/* ------------------------------------------------------------------- lprm - remove job from line printer queue lprm removes a job or jobs from a print spooling queue managed by an LPD daemon running on a remote machine. Built on top of the NCSA TCP/IP package (version 2.2tn for MS-DOS). Paul Hilchey May 1989 Copyright (C) 1989 The University of British Columbia All rights reserved. history ------- 1/6/89 Microsoft C port by Heeren Pathak (NCSA) ------------------------------------------------------------------- */ #include #include #include #include #include #include #ifdef MSC #include #include #endif #define WINMASTER #ifdef MEMORY_DEBUG #include "memdebug.h" #endif #include "whatami.h" #include "hostform.h" #include "windat.h" #include "lp.h" #include "externs.h" int debug = 0; /* 1 = print debugging info; set with -D option */ int ftppassword, /* not used; just to avoid unresolved external */ bypass_passwd=0; /* whether to bypass the password check */ unsigned char path_name[_MAX_DRIVE+_MAX_DIR], /* character storage for the path name */ temp_str[20],s[_MAX_DIR],temp_data[30]; #define JOB_AND_USER_BUFF_SIZE 150 /* size of buffer for job numbers and user name specified on the command line */ /* Function Protoypes */ void main(int argc,char *argv[]); static void randomize(void ); /**************************************************************** * Main program. * * lprm [ -Pprinter ] [ -Sserver ] [ - ] [job# ...] * ****************************************************************/ void main(int argc,char *argv[]) { int i; char *ptr; int len; char username[9]; /* name of user (max 8 chars) */ struct config *cp; /* configuration information */ static char buff[JOB_AND_USER_BUFF_SIZE] = ""; /* string of jobs to be removed */ int something = 0; /* 1 = we got something back from the server */ struct machinfo *server_info_record; int server_connection_id; char *remote_name, /* printer name on remote system */ *remote_host; /* address of remote host */ _splitpath(argv[0],path_name,s,temp_str,temp_data); /* split the full path name of telbin.exe into it's components */ strcat(path_name,s); /* append the real path name to the drive specifier */ #ifdef MSC signal(SIGINT,breakstop); /* Microsoft intercept of break */ #else ctrlbrk(breakstop); /* set up ctrl-c handler */ #endif /* Do session initialization. Snetinit reads config file. */ ptr = getenv("CONFIG.TEL"); if (ptr != NULL) Shostfile(ptr); if(i=Snetinit()) { if(i==-2) /* check for BOOTP server not responding */ netshut(); /* release network */ crash("network initialization failed.\n"); } /* end if */ /* select default printer and server */ remote_name = getenv("PRINTER"); if (remote_name == NULL) remote_name = DEFAULT_PRINTER; remote_host = getenv("SERVER"); /* get info from the configuration file */ cp = (struct config *)malloc(sizeof(struct config)); Sgetconfig(cp); /* check that the machine name was set in the configuration file */ if (0 == strlen(cp->me)) crash("`myname' not set in config file."); /* set user name. use first part of machine name if nothing else */ ptr = getenv("USER"); if (NULL != ptr) { strncpy(username,ptr,8); username[8]='\0'; } else { i = min(strcspn(cp->me,"."),sizeof(username)-1); strncpy(username,cp->me,i); username[i]='\0'; } /* Loop through command line arguments */ for (i=1; i