================================================================== ================================================================== /* tab2space.c : convert tabs to spaces */ /* To build : */ /* $ CC TAB2SPACE.C */ /* $ LINK/NOTRACE TAB2SPACE.OBJ */ /* To run use a foreign command symbol like $ TAB2SPACE:=="$TAB2SOACE.EXE or use a CLD file */ /* VMS Version (C) 1995 S Sanyal */ #include #include #include main(argc,argv) int argc ; char *argv[] ; { FILE *ifp, *ofp ; int c, i, numSpaces ; int charCount, tabCount ; if(argc!=4) fprintf(stderr,"Usage : %s .%c\n", argv[0], 0x07), exit(1) ; ifp=fopen(argv[1],"r") ; if(ifp==(FILE *)NULL) perror(argv[1]), exit(1) ; ofp=fopen(argv[2],"w") ; if(ofp==(FILE *)NULL) perror(argv[2]), exit(1) ; if(!isdigit(argv[3][0])) { fprintf(stderr,"[%s] is not a valid number of spaces to be put for each tab. Valid range is 1 .. 9.%c\n", argv[3],0x07) ; fprintf(stderr,"Usage : %s .%c\n", argv[0], 0x07) ; exit(1) ; } numSpaces = atoi(argv[3]) ; if(numSpaces < 1 || numSpaces > 9) { fprintf(stderr,"[%s] is not a valid number of spaces to be put for each tab. Valid range is 1 .. 9.%c\n", argv[3],0x07) ; fprintf(stderr,"Usage : %s .%c\n", argv[0], 0x07) ; exit(1) ; } tabCount = charCount = 0 ; while( (c=getc(ifp))!=EOF) { charCount++ ; if (c=='\t') { for(i=0; i #include int main(argc,argv,envp) int argc ; char *argv[] ; char *envp[] ; { FILE *fp ; int c = 0 ; if (argc > 2) { fprintf(stderr,"%s : Filters out ^M characters from either stdin or specified filename.\n",argv[0]) ; exit(1) ; } if(argc==2) { if ( (fp=fopen(argv[1],"r")) == (FILE *)NULL) perror(argv[1]), exit(1) ; } else fp=stdin ; while( (c=getc(fp))!=EOF) if (c!=0x0D) putchar(c) ; fclose(fp); exit(0) ; } /*main() */ ================================================================== ================================================================== /* Filter out ^M characters from files specified on command line. Since UNIX shell expands wildcards, wildcards are supported. (C) Supratim Sanyal 1997. */ #include #include #include #include int main(argc,argv,envp) int argc ; char *argv[] ; char *envp[] ; { FILE *fp=NULL, *ofp=NULL ; int c = 0 ; int i = 0 ; char tempfname[L_tmpnam+1] ; char bakfname[MAXPATHLEN+1] ; int numinchars=0, numoutchars=0 ; if (argc < 2) { fprintf(stderr,"%s : Filters out ^M characters from specified filenames.\n",argv[0]) ; exit(1) ; } i=1; while(i #include main(argc, argv) int argc ; char *argv[] ; { int i,j,c ; char ofn[100] ; FILE *ifp, *ofp ; int numbytes=0 ; if(argc==1) { printf("%s : convert filenames to lower case\n", argv[0]) ; exit(1) ; } for(i=1; i skipped : no change in filename\n", argv[i]) ; fclose(ifp) ; continue ; } #ifdef DEBUG printf("Opening [%s] for write binary \n", ofn) ; #endif if ( (ofp=fopen(ofn,"wb"))==NULL) perror(ofn),exit(1) ; #ifdef DEBUG printf("Opened [%s] \n", ofn) ; #endif numbytes=0 ; while( (c=getc(ifp))!=EOF) { putc(c, ofp) ; numbytes++ ; } printf("%s -> %s (%d bytes)\n", argv[i], ofn,numbytes) ; fclose(ifp) ; fclose(ofp) ; #ifdef DEBUG printf("Closed files.\n" ) ; #endif } } ================================================================== ================================================================== /* ------------------------------------------------------------ */ /* httpget.c */ /* Gets a file over HTTP for a URL entered */ /* (c) 1997 Supratim Sanyal */ /* Unix version */ /* To build: gcc -o httpget httpget.c */ /* Usage: httpget (e.g. httpget www.yahoo.com */ /* ------------------------------------------------------------ */ #include #include #include #include #include #include #include #include #include #include #define PORTNUM 80 /* HTTP default port number */ #define MAXHOSTNAME BUFSIZ /* Maximum length of host name string */ /* create a socket */ int establish(char *hostname, unsigned short portnum) { struct sockaddr_in sa ; struct hostent *hp ; int s ; if ( (hp=gethostbyname(hostname)) == NULL ) /* get the host's address */ { fprintf(stderr,"%s : Host not found.\n", hostname) ; return(-1) ; } memset(&sa,0,sizeof(sa)) ; memcpy((char*)&sa.sin_addr, hp->h_addr, hp->h_length) ; /*set address*/ sa.sin_family=hp->h_addrtype ; sa.sin_port=htons((u_short)portnum) ; if ((s=socket(hp->h_addrtype,SOCK_STREAM,0))<0) /*get socket*/ { perror(hostname) ; return(-1) ; } if (connect(s,&sa,sizeof sa) < 0) /* connect */ { perror(hostname) ; close(s) ; return(-1) ; } return(s) ; /* return the socket id */ } /* establish() */ int write_data (int s, char *buf, int n) { return(write(s,buf,n)) ; } /* write_data() */ int read_data(int s, char *buf, int nchars) { if (nchars > BUFSIZ) nchars=BUFSIZ ; return(read(s,buf,nchars)) ; } /* read_data() */ int main(int argc, char **argv) { int s, bytesread, i ; char c, buf[BUFSIZ]; char uri[BUFSIZ] ; char hostname[MAXHOSTNAME] ; char resource[BUFSIZ] ; if(argc==2) { strcpy(uri,argv[1]) ; } else if(argc > 2) { fprintf(stderr,"usage: %s \n", argv[0]) ; exit(1) ; } else { fflush(NULL) ; printf("Enter URI (e.g www.cnn.com/index.html) : http://") ; scanf("%s", uri) ; fflush(NULL) ; } /* Get the hostname and resource into separate variables */ strcpy(hostname,uri) ; strcpy(resource,"\0") ; for(i=0; hostname[i]!='\0';i++) { if(hostname[i] == '/') { strcpy(resource, &hostname[i]) ; hostname[i]='\0' ; break ; } } if(strlen(resource)==0) strcpy(resource,"/") ; printf("Resource:[%s], host:[%s]\n",resource,hostname) ; if( (s=establish(hostname, PORTNUM)) <= 0) fprintf(stderr,"Cannot establish connection.\n"),exit(1) ; /* Send HTTP Request */ /*sprintf(buf,"GET /index.html HTTP/1.1\n") ;*/ sprintf(buf,"GET %s HTTP/1.0\n", resource) ; write_data(s, buf, strlen(buf)) ; sprintf(buf,"Accept: www/source\n") ; write_data(s, buf, strlen(buf)) ; sprintf(buf,"Accept: text/html\n") ; write_data(s, buf, strlen(buf)) ; sprintf(buf,"User-Agent: TukluBrowser 1.0\n") ; write_data(s, buf, strlen(buf)) ; sprintf(buf,"Referer: http://supratim.cjb.net") ; write_data(s, buf, strlen(buf)) ; /* +++ sprintf(buf,"Host: jean-luc-picard@tuklus.apartment\n") ; write_data(s, buf, strlen(buf)) ; --- */ sprintf(buf,"From: ssanyal@cyberdude.com\n\n") ; write_data(s, buf, strlen(buf)) ; /* Get Response Header */ i=0 ; c=0 ; while ( (bytesread=read_data(s,&c,1)) == 1) { if(c=='\n') { buf[i]='\0' ; break; } buf[i]=c; i++; } if (!checkheader(buf)) fprintf(stderr,"Error in HTTP Response header.\n"),exit(1) ; do { bytesread=read_data(s,buf,BUFSIZ) ; for(i=0;i 0) ; close(s) ; exit(0) ; } /* main() */ int checkheader(char *header) { char httpversion[20] ; int httpstatus, i, j, len; char httpreason[BUFSIZ] ; /* Parse the response Header. The response header is of the form : */ len=strlen(header) ; for(i=0; i= 300) { fprintf(stderr,"ERROR %d IN HTTP RESPONSE\n",httpstatus) ; /* return(0) ; */ } printf("*** Press Return to continue ... ") ; fflush(NULL) ; getchar() ; fflush(NULL) ; return 1 ; } /* main() */ ================================================================== ================================================================== #include #include #include #include int main(argc,argv,envp) int argc ; char *argv[] ; char *envp[] ; { FILE *fp=NULL, *ofp=NULL ; int c = 0 ; int i = 0 ; char tempfname[L_tmpnam+1] ; char bakfname[MAXPATHLEN+1] ; int numinchars=0, numoutchars=0 ; if (argc < 2) { fprintf(stderr,"%s : Inserts DOCTYPE into specified file(s).\n",argv[0]) ; exit(1) ; } i=1; while(i\n") ; while( (c=getc(fp))!=EOF) { numinchars++ ; putc(c,ofp) ; numoutchars++ ; } /* while */ fclose(fp); fclose(ofp) ; strcpy(bakfname,argv[i]) ; strcat(bakfname,".bak") ; if ( rename ( argv[i], bakfname ) != 0 ) fprintf(stderr,"Cannot rename %s to %s\n", argv[i],bakfname), perror(bakfname), exit(1) ; if ( (fp=fopen(tempfname,"r")) == (FILE *)NULL) fprintf(stderr,"Cannot open temporary file for read\n"), perror(tempfname), exit(1) ; if ( (ofp=fopen(argv[i],"w"))==(FILE *)NULL) fprintf(stderr,"Cannot open %s file for write\n", argv[i]), perror(argv[i]),exit(1) ; while( (c=getc(fp))!=EOF) putc(c,ofp) ; /* copy tempfname to argv[i] */ fclose(fp) ; fclose(ofp) ; if ( unlink ( tempfname ) != 0 ) fprintf(stderr,"Cannot delete temporary file %s\n", tempfname), perror(argv[i]), exit(1) ; printf("%5.2f%%\n", (numinchars==0) ? 0.0 : (float)numoutchars/(float)numinchars*100.00 ) ; fflush (NULL) ; i++ ; } /* while */ exit(0) ; } /*main() */ ================================================================== ================================================================== /* insert.c : inserts specified line after line containing specified string in specified file(s), to be specific :) (c) 1997 S Sanyal */ /* #define DEBUG */ #include #include char OUT_DIR[BUFSIZ] ; char CHECKSTR[BUFSIZ] ; char INSERTSTR[BUFSIZ] ; main(argc, argv) int argc ; char *argv[] ; { int argi, stat ; FILE *inf, *ouf ; char ofname[BUFSIZ] ; char line[BUFSIZ] ; if (argc==1) { fprintf(stderr,"usage : %s filename(s)\n", argv[0]) ; fprintf(stderr,"inserts specified line after line containing\n") ; fprintf(stderr,"specified string in specified file(s), to be specific :)\n") ; fprintf(stderr,"String to be inserted and string to be searched for will be asked\nto be input.\n") ; fprintf(stderr,"String matching is case-insensitive\n") ; exit(0) ; } getparams() ; printf("%s : using output directory %s\n", argv[0], OUT_DIR) ; for(argi=1 ; argi < argc; argi++) { inf = fopen ( argv[argi], "r") ; if ( inf == NULL ) perror(argv[argi]), exit(1) ; strcpy(ofname,OUT_DIR) ; strcat(ofname,argv[argi]) ; ouf = fopen ( ofname, "w" ) ; if ( ouf == NULL ) perror(ofname), exit(1) ; printf("%s -> %s ...", argv[argi], ofname) ; fflush(NULL) ; do { stat = readline ( inf, line ) ; #ifdef DEBUG printf("Read:%s:%d chars : %s\n", argv[argi],stat, line) ; fflush(NULL) ; #endif writeline( ouf, line ) ; if (checkforinsert(line)) insertstuff (ouf) ; } while (stat != EOF) ; fclose(inf) ; fclose(ouf) ; printf (" done\n") ; fflush(NULL) ; } } /* main() */ int readline(fp, line) FILE *fp ; char *line ; { int c,i=0 ; while( (c=getc(fp)) != '\n') { if ( c==EOF ) { line[i]='\0' ; return EOF ; } line[i]=c ; i++ ; } line[i]='\0' ; return i; /* return the line length */ } /* readline() */ int writeline ( fp, line ) FILE *fp ; char *line ; { fprintf(fp,"%s\n", line) ; } /* writeline() */ int checkforinsert(line) char *line; { char buf[BUFSIZ] ; char checkstr[BUFSIZ] ; int i ; for(i=0; line[i] != '\0'; i++) buf[i] = tolower(line[i]) ; buf[i]='\0' ; for(i=0; CHECKSTR[i]!= '\0'; i++) checkstr[i]=tolower(CHECKSTR[i]) ; checkstr[i]='\0' ; if ( strstr(buf, checkstr) != NULL) return(1) ; return 0 ; } /* checkforinsert() */ int insertstuff(fp) FILE *fp ; { fprintf(fp,"%s\n",INSERTSTR) ; } /* insertstuff() */ int getparams() { int i ; char c; c='N' ; while(c=='N') { fflush(stdin) ; printf("Output directory (must exist!) : ") ; scanf("%s",OUT_DIR) ; i=strlen(OUT_DIR) ; if(OUT_DIR[i-1]!='/') strcat(OUT_DIR,"/") ; fflush(stdin) ; printf("String to check for : ") ; gets(CHECKSTR) ; fflush(stdin) ; printf("Line to insert : ") ; gets(INSERTSTR) ; printf("\n\n") ; printf("Output directory is : %s\n", OUT_DIR) ; printf("Insert the line:\n%s\nafter line(s) containing\n%s\n irrespective of case\n", INSERTSTR, CHECKSTR) ; printf("\n\nIs this correct [YNQ] ?") ; c=getchar() ; c=toupper(c) ; if(c=='Y') return ; if(c=='Q') exit(0) ; if(c!='N') printf("\nInvalid response!\n"), c='N' ; } /* while */ } /* getparams() */ ================================================================== ================================================================== /* myhttpd.c (c) 1997 S Sanyal */ #include #include #include #include #include #include #include #define ERR_EXIT 1 #define NORMAL_EXIT 0 #define TRUE 1 #define FALSE 0 #define SUCCESS TRUE #define FAIL FALSE #define DEFAULT_PORT 80 #define IO_TIMEOUT 5 /* Timeout for socket I/O in seconds */ #define BUFFERSIZE BUFSIZ #define SERVER_ROOT "/user/ssanyal/public_html" /* Directory for web files */ int mySocket = 0 ; /* Master socket to listen to */ int clientSocket = 0 ; /* Connection specific socket returned by accept() */ /* We make these global because signal handlers need */ /* to close this. */ void interrupt_handler(int sig) /* Ctrl-C Signal Handler */ { printf("\n\nCtrl-C detected ... Abort\n") ; fflush(NULL) ; if(clientSocket != 0) close(clientSocket) ; if(mySocket != 0) close(mySocket) ; exit(ERR_EXIT) ; } /* interrupt_handler() */ void timeout_handler(int sig) /* Communication Timeout signal handler */ { printf("\n\nClient Socket %d I/O Timeout ... Abort\n", clientSocket) ; fflush(NULL) ; if(clientSocket != 0) close(clientSocket) ; if(mySocket != 0) close(mySocket) ; exit(ERR_EXIT) ; } /* timeout_handler() */ void child_exit_handler(int sig) /* Child exited - reestablish handler */ { printf("\n\nParent: A forked child exited.\n" ) ; fflush(NULL) ; /* Ignore SIGCLD ... don't do signal(SIGCLD, child_exit_handler) ; */ signal(SIGCLD, SIG_IGN) ; } /* child_exit_handler */ void unexpected_signal_handler(int sig) /* Catch all uncaught signals & exit */ { printf("\n\nCaught Signal %d ... Abort\n") ; fflush(NULL) ; if(clientSocket != 0) close(clientSocket) ; if(mySocket != 0) close(mySocket) ; exit(ERR_EXIT) ; } /* unexpected_signal_handler() */ int bindPort ( int portNumber ) { struct sockaddr_in address; address.sin_family = AF_INET ; address.sin_port = htons((ushort)(portNumber & 0xffff)) ; address.sin_addr.s_addr = htonl(INADDR_ANY) ; if (bind(mySocket, (struct sockaddr *)&address, sizeof address) == -1) { return FAIL ; } return SUCCESS ; } /* bindPort() */ int processSocket() { char *funcName="processSocket"; unsigned char writeBuf[BUFFERSIZE], byte ; int i, bytesWritten, bytesRead ; int status = SUCCESS ; int enable = 1 ; /* Catch all signals unless overriden later */ for(i=0; i<256; i++) signal (i, unexpected_signal_handler) ; /* Establish interrupt signal handler */ signal(SIGINT, interrupt_handler) ; /* set the keep-alive socket option */ if ( setsockopt( clientSocket, SOL_SOCKET, SO_KEEPALIVE, &enable, sizeof(enable)) < 0) { perror("setsockopt()") ; status = FAIL ; return status ; } /* set the no-delay option */ if ( fcntl( clientSocket, F_SETFL, FNDELAY) < 0) { perror("fcntl()") ; status = FAIL ; return status ; } /* Establish timer signal handler */ signal(SIGALRM, timeout_handler) ; alarm(IO_TIMEOUT) ; /* Set timer */ bytesRead = send(clientSocket, writeBuf, BUFFERSIZE, 0) ; alarm(0) ; /* Cancel timer */ alarm(IO_TIMEOUT) ; /* Set timer */ bytesWritten = send(clientSocket, writeBuf, BUFFERSIZE, 0) ; alarm(0) ; /* Cancel timer */ /* Clear timer signal handler */ signal(SIGALRM, SIG_DFL) ; if (bytesWritten != BUFFERSIZE) { perror("send()") ; status = FAIL ; break ; } else { printf("... Written.\n") ; fflush (NULL) ; } /* Right Rotate the message */ byte = writeBuf[BUFFERSIZE-1] ; for(i=BUFFERSIZE-1; i>0; i--) writeBuf[i] = writeBuf[i-1] ; writeBuf[0] = byte ; sleep(4) ; /* sleep for 4 seconds */ close (clientSocket) ; /* Control never comes here! */ return status ; } /* processSocket() */ int acceptConnection() { char *funcName="acceptConnection" ; struct sockaddr_in clientAddr ; int clientAddrLen ; int status = SUCCESS ; /* Accept the connection */ clientAddrLen = sizeof clientAddr; if ( (clientSocket = accept(mySocket, (struct sockaddr *)&clientAddr, &clientAddrLen)) < 0 ) { perror("accept()"); status = FAIL ; } else { printf("%s: client %s assigned client socket %d\n", funcName, inet_ntoa(clientAddr.sin_addr), clientSocket) ; } return status ; } /* acceptConnection() */ int main (int argc, char **argv) { int portNumber = 0 ; int i = 0,status = SUCCESS ; int childPID ; if (argc==1) { portNumber = DEFAULT_PORT ; } else if (argc==2) { portNumber = atoi(argv[1]) ; } else { status = FAIL ; printf("%s: usage: %s [port]\n", argv[0], argv[0]) ; printf(" Default port is %d\n", DEFAULT_PORT") ; fflush(NULL) ; } if (status == SUCCESS) { printf("%s: using port %d\n", argv[0], portNumber) ; fflush(NULL) ; } /* Create a TCP/IP STREAM socket */ if (status == SUCCESS) { mySocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) ; if (mySocket == -1) { perror("socket()"); status = FAIL ; } else { } } /* Bind to port */ if (status == SUCCESS) { status = bindPort ( portNumber ) ; if (status == FAIL) { perror("bind()") ; close(mySocket) ; } else { } } /* listen for connections on a (now passive) socket */ if (status == SUCCESS) { printf ("%s: Listening for connection\n", argv[0]) ; fflush(NULL) ; if (listen(mySocket, SOMAXCONN) == -1) { perror("listen()"); close(mySocket); status = FAIL ; } else { } } /* Establish handler for SIGCLD in parent process */ /* to avoid zombies. This will be overriden by */ /* child processes ... */ /* Oops - doesn't work ... */ /* Ignore SIGCLD ... don't do signal(SIGCLD, child_exit_handler) ; */ signal(SIGCLD, SIG_IGN) ; if (status == SUCCESS) for (;;) /* As long as we are alive ... */ { status = acceptConnection() ; if (status == FAIL) { close(mySocket) ; close(clientSocket) ; break; } else { } /* Now fork a child process to serve the client */ childPID = fork() ; if (childPID != 0) /* Parent process */ { close(clientSocket) ; printf ("%s: forked child PID %d\n", argv[0], childPID) ; fflush(NULL) ; } else /* Child process - serve the client */ { fflush(NULL) ; close(mySocket) ; status = processSocket() ; close(clientSocket) ; if (status == SUCCESS) { exit (NORMAL_EXIT) ; } else { printf ("%s: Child: Error serving client\n", argv[0]) ; fflush(NULL) ; exit(ERR_EXIT) ; } } } /* for(;;) */ /* Control comes here if something goes wrong ... Clean up and exit */ close( mySocket ) ; close(clientSocket) ; if (status == SUCCESS) { printf ("\n%s: Normal Exit\n", argv[0]) ; fflush(NULL) ; return NORMAL_EXIT ; } else { printf ("\n%s: Abnormal Exit\n", argv[0]) ; fflush(NULL) ; return ERR_EXIT ; } } /* main() */ ================================================================== ================================================================== /* replaceline.c : replaces specified line with specified line in specified file(s), to be specific :) (c) 1997 s sanyal */ #include #include char OUT_DIR[BUFSIZ] ; char CHECKSTR[BUFSIZ] ; char INSERTSTR[BUFSIZ] ; main(argc, argv) int argc ; char *argv[] ; { int argi, stat ; FILE *inf, *ouf ; char ofname[BUFSIZ] ; char line[BUFSIZ] ; if (argc==1) { fprintf(stderr,"usage : %s filename(s)\n", argv[0]) ; fprintf(stderr,"replaces specified line with specified line in specified file(s)\n") ; fprintf(stderr,"String to be replaced and string to be searched for will be asked\nto be input.\n") ; exit(0) ; } getparams() ; printf("%s : using output directory %s\n", argv[0], OUT_DIR) ; for(argi=1 ; argi < argc; argi++) { inf = fopen ( argv[argi], "r") ; if ( inf == NULL ) perror(argv[argi]), exit(1) ; strcpy(ofname,OUT_DIR) ; strcat(ofname,argv[argi]) ; ouf = fopen ( ofname, "w" ) ; if ( ouf == NULL ) perror(ofname), exit(1) ; printf("%s -> %s ...", argv[argi], ofname) ; fflush(NULL) ; do { stat = readline ( inf, line ) ; if (checkforreplace(line)) insertstuff (ouf) ; else writeline( ouf, line ) ; } while (stat != EOF) ; fclose(inf) ; fclose(ouf) ; printf (" done\n") ; fflush(NULL) ; } } /* main() */ int readline(fp, line) FILE *fp ; char *line ; { int c,i=0 ; while( (c=getc(fp)) != '\n') { if ( c==EOF ) { line[i]='\0' ; return EOF ; } line[i]=c ; i++ ; } line[i]='\0' ; return i; /* return the line length */ } /* readline() */ int writeline ( fp, line ) FILE *fp ; char *line ; { fprintf(fp,"%s\n", line) ; } /* writeline() */ int checkforreplace(line) char *line; { char buf[BUFSIZ] ; char checkstr[BUFSIZ] ; int i ; for(i=0; line[i] != '\0'; i++) buf[i] = line[i] ; buf[i]='\0' ; for(i=0; CHECKSTR[i]!= '\0'; i++) checkstr[i]=CHECKSTR[i] ; checkstr[i]='\0' ; if ( strstr(buf, checkstr) != NULL) return(1) ; return 0 ; } /* checkforreplace() */ int insertstuff(fp) FILE *fp ; { fprintf(fp,"%s\n",INSERTSTR) ; } /* insertstuff() */ int getparams() { int i ; char c; c='N' ; while(c=='N') { fflush(stdin) ; printf("Output directory (must exist!) : ") ; scanf("%s",OUT_DIR) ; i=strlen(OUT_DIR) ; if(OUT_DIR[i-1]!='/') strcat(OUT_DIR,"/") ; fflush(stdin) ; printf("Line to check for : ") ; gets(CHECKSTR) ; fflush(stdin) ; printf("Line to replace above line with : ") ; gets(INSERTSTR) ; printf("\n\n") ; printf("Output directory is : %s\n", OUT_DIR) ; printf("Replace the line:\n%s\nwith\n%s\n", CHECKSTR, INSERTSTR) ; printf("\n\nIs this correct [YNQ] ?") ; c=getchar() ; c=toupper(c) ; if(c=='Y') return ; if(c=='Q') exit(0) ; if(c!='N') printf("\nInvalid response!\n"), c='N' ; } /* while */ } /* getparams() */ ================================================================== ================================================================== /* sink.c : just reads a file and does nothing. Useful for external application for netscape so that netscape does not prompt the user. (c) S Sanyal 1997 */ #include main (argc,argv,envp) int argc ; char *argv[] ; char *envp[] ; { FILE *fp = NULL ; int c = 0 ; if (argc==2) { if ( (fp=fopen(argv[1],"rb"))==NULL) perror(argv[1]),exit(1) ; } else fp=stdin ; while( (c=getc(fp)) != EOF ) ; fclose(fp) ; exit(0) ; } ================================================================== ==================================================================