summaryrefslogtreecommitdiff
path: root/user/progW.c
diff options
context:
space:
mode:
Diffstat (limited to 'user/progW.c')
-rw-r--r--user/progW.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/user/progW.c b/user/progW.c
index 5903663..b71ec23 100644
--- a/user/progW.c
+++ b/user/progW.c
@@ -12,46 +12,50 @@
** s is the sleep time (defaults to 3 seconds)
*/
-USERMAIN( main ) {
- int count = 20; // default iteration count
- char ch = 'w'; // default character to print
- int nap = 3; // nap length
+USERMAIN(main)
+{
+ int count = 20; // default iteration count
+ char ch = 'w'; // default character to print
+ int nap = 3; // nap length
char buf[128];
// process the command-line arguments
- switch( argc ) {
- case 4: nap = str2int( argv[3], 10 );
- // FALL THROUGH
- case 3: count = str2int( argv[2], 10 );
- // FALL THROUGH
- case 2: ch = argv[1][0];
- break;
+ switch (argc) {
+ case 4:
+ nap = str2int(argv[3], 10);
+ // FALL THROUGH
+ case 3:
+ count = str2int(argv[2], 10);
+ // FALL THROUGH
+ case 2:
+ ch = argv[1][0];
+ break;
default:
- sprint( buf, "userW: argc %d, args: ", argc );
- cwrites( buf );
- for( int i = 0; i <= argc; ++i ) {
- sprint( buf, " %s", argv[argc] ? argv[argc] : "(null)" );
- cwrites( buf );
- }
- cwrites( "\n" );
+ sprint(buf, "userW: argc %d, args: ", argc);
+ cwrites(buf);
+ for (int i = 0; i <= argc; ++i) {
+ sprint(buf, " %s", argv[argc] ? argv[argc] : "(null)");
+ cwrites(buf);
+ }
+ cwrites("\n");
}
// announce our presence
int pid = getpid();
uint32_t now = gettime();
- sprint( buf, " %c[%d,%u]", ch, pid, now );
- swrites( buf );
+ sprint(buf, " %c[%d,%u]", ch, pid, now);
+ swrites(buf);
- write( CHAN_SIO, &ch, 1 );
+ write(CHAN_SIO, &ch, 1);
- for( int i = 0; i < count ; ++i ) {
+ for (int i = 0; i < count; ++i) {
now = gettime();
- sprint( buf, " %c[%d,%u] ", ch, pid, now );
- swrites( buf );
- sleep( SEC_TO_MS(nap) );
+ sprint(buf, " %c[%d,%u] ", ch, pid, now);
+ swrites(buf);
+ sleep(SEC_TO_MS(nap));
}
- exit( 0 );
+ exit(0);
- return( 42 ); // shut the compiler up!
+ return (42); // shut the compiler up!
}