#include // for exit #include // for getopt #include // for printf, fprintf, fflush #include // for strtok, memset, memcpy #include // for isdigit // // Purpose: Homework 1, Problem 3 // Usage: hw1-3 < Command // Comment: // o This is a minimalistic solution based on hw1-3.c which is a pedagogic // version. // History: // 14 sep 2006 kenw, creation // // --| constants |-- const int MAX_LINE = 50; const int BUFSZ = 100; const char *WHITE = " \t\n"; // white space characters // --| prototypes |-- int getTokens( char *cmnd, char *word[], const char *delim ); void pkbuf0( u_long code, int nwords, char *word[] ); u_long get_code( char *keyword ); // --| globals |-- // --| defines |-- #define DEBUG(arglst) fprintf arglst; int main ( int argc, char *argv[] ) { char cmnd[MAX_LINE]; // command-line char *word[BUFSZ]; // word[k] points to kth word int nwords; // #words in command line int i; int code; while( fgets(cmnd, MAX_LINE, stdin) != NULL ) { if( cmnd[strlen(cmnd)-1] != '\n' ) { fprintf(stderr, "*** Ooops, line too long\n"); exit( 1 ); } // for ( i=0; (i