home *** CD-ROM | disk | FTP | other *** search
- /* (C) Tim Graves 20th April 1994
- This code is supplied AS IS. no warrantee either expressed or implied
- is provided. This code may be freeley modified and modified as long as my
- origional authorship is acknowledged.
-
- Tim Graves
- Sun Microsystems
-
- */
- /* a set of routines for transfering data between the Psion and the Sun machines
- where possible I have provided a sensible wrapper for the low level function
- This program should be started BEFORE the suncom program on the psion */
- #include <stdio.h>
- #include <ctype.h>
- #include <sys/termios.h>
- #include <fcntl.h>
- #include <string.h>
- #include "psion.h"
- #define MAXSEND 200
- #define DEFVSNSTR "2.3"
-
- static char vsn[]= "@(#) pslib.c 3.17@(#)" ;
- char pspath[255] = "";
- char pspart[10] = "" ;
- char psdir [255] = "";
- char psfname[30] = "";
- int pspathset ;
- int tmode ;
- int transct ;
- int debuglink = FALSE ;
- extern int debugcall ;
- extern int logfile ;
- extern int dovsnchk ;
- char version[100] ="X" ;
- /* the following are for counting good and bad blocks on
- transmision and recieve*/
- int transgood = 0;
- int transbad = 0 ;
- int recgood = 0 ;
- int recbad = 0;
- /* the following are for counting good and bad blocks on
- transmision and recieve*/
- int ftransgood = 0;
- int ftransbad = 0 ;
- int frecgood = 0 ;
- int frecbad = 0;
- /* used to indicate file transfers with checksums */
- int filechksum = FALSE ;
- int devid;
- struct termios initial, modified ;
- #ifndef SVR4
- char dehex() ;
- int idehex() ;
- #else
- char dehex(char *) ;
- int idehex(char *) ;
- #endif
-
- psisset(qn)
- int qn ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psisset (qn = %d)\n", qn) ;
- fflush(stderr) ;
- }
- if (qn == PATH)
- return(pspathset) ;
- else
- return (BADPARAM) ;
- }
-
- pstrans()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pstrans()\n") ;
- fflush(stderr) ;
- }
- return(transct) ;
- }
-
- psinit(restart, devname)
- int restart ;
- char * devname ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psinit (restart = %d, devname = %s)\n", restart, devname) ;
- fflush(stderr) ;
- }
- devid = 0 ;
- tmode = BINARY ;
- psinitlink(devname) ;
- /* is we are doing a restart we send the online cmd by hand
- WITHOUT waiting for any fancy XCMD> prompts to come back
- to us */
- if (restart)
- psrestart() ;
- else
- psreply("XONLINE") ;
- psbinary() ;
- }
-
- psrestart()
- {
- char length[5] ;
-
- if (debugcall >= 1 )
- {
- fprintf(stderr, "CALL: psrestart()\n") ;
- fflush(stderr) ;
- }
- /* cheat the system for the restart mode only. to have got here
- we know that the link opened correctley */
- /* we are not looking for the sync char so call putline1 directly and
- tell it not to sync up (the > will have been losk somewhere in
- the previous psion process */
- psputline1("ol",FALSE) ;
- psreply("XONLINE") ;
- pspath[0] = '\0' ;
- pssp("m:") ;
-
- }
-
- psinitlink(devstr)
- char * devstr ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psinitlink (devstr = %s)\n", devstr) ;
- fflush(stderr) ;
- }
- if (strlen(devstr) == 0)
- {
- if ((devid = open(DEVFILE, O_RDWR , 0)) == -1)
- pserror ("Error in opening device\n") ;
- }
- else
- {
- if ((devid = open(devstr, O_RDWR, 0)) == -1)
- pserror ("Error in openint device\n") ;
- }
-
- /* we need to remove the echo as it confuses the psion (tremendously!) */
- /* first get the current structure for storage and modification*/
- ioctl(devid, TCGETS, &initial);
- ioctl(devid, TCGETS, &modified);
- /* remove the echo line */
- modified.c_lflag = modified.c_lflag & ~ECHO ;
- /* stop it from doing any flay input processing */
- modified.c_lflag = modified.c_lflag & ~IEXTEN ;
- /* setup the input and output speeds */
- modified.c_cflag = B9600 | CS8 | CREAD | ( B9600 << IBSHIFT ) ;
- /* remove incomming parity checks */
- modified.c_iflag = modified.c_iflag & ~INPCK ;
- /* remove CR on input, make life a bit easier on the input routing coding ! */
- modified.c_iflag = modified.c_iflag | IGNCR ;
- /* strip down to 7 characters */
- modified.c_iflag = modified.c_iflag | ISTRIP ;
- /* Install xon/xoff flow control */
- /*modified.c_iflag = modified.c_iflag | IXON | IXOFF ;*/
- /* remove flow control */
- modified.c_iflag = modified.c_iflag & ~IXON ;
- modified.c_iflag = modified.c_iflag & ~IXOFF ;
- modified.c_cflag = modified.c_cflag & ~CRTSCTS ;
- /* remove cannonical processing, this is more cpu / interupt
- intensive but does enable the new checksumming protocol
- to work */
- /* modified.c_lflag = modified.c_lflag & ~ICANON ; */
- /* ensure that on output we only send newline, not CRNL */
- modified.c_oflag = modified.c_oflag | ONLRET ;
- /* and just to make sure remove the output processing facility */
- modified.c_oflag = modified.c_oflag & ~OPOST ;
- /* set the new params */
- ioctl(devid, TCSETS, &modified) ;
-
- }
-
- /* reset the terminal device and close the link down */
- psshutdown(ret)
- int ret ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL psshutdown (ret = %d)\n", ret) ;
- fflush(stderr) ;
- }
- /* we need to reset the terminal flags to their initial state ! */
- ioctl (devid, TCSETS, &initial) ;
-
- if (devid != -1)
- close (devid) ;
-
-
-
- exit(ret) ;
- }
-
- /* send a command to the psion */
- pscommand (msg)
- char * msg ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pscommand (msg = %s)\n", msg) ;
- fflush(stderr) ;
- }
- psputline(msg) ;
- }
- psputline(str)
- char * str ;
- {
- if (debugcall >= 4)
- {
- fprintf(stderr, "CALL: psputline (str = :%s:)\n", str) ;
- fflush(stderr) ;
- }
- psputline1(str, TRUE) ;
- }
- psputline1(str, getgt)
- char * str;
- int getgt ;
- {
- int len, chksum ;
- char msg [1000] ;
- char tmp [10] ;
- char resp[10] ;
- if (debugcall >= 4)
- {
- fprintf(stderr, "CALL: psputline1 (str = :%s:)\n", str) ;
- fflush(stderr) ;
- }
- /* if getgt then hunt for the > otherwise skip this bit */
- if (getgt == TRUE)
- {
- /* wait for the psion to send > to indicate it's ready */
- tmp[0] = ' ' ;
- while (tmp[0] != '>')
- {
- psreadstr(tmp, 10) ;
- if (debuglink)
- printf("putline: got %c as sync char\n", tmp[0]) ;
- if (logfile)
- {
- fprintf(stderr, "putline: got %c as sync char\n", tmp[0]) ;
- fflush(stderr) ;
- }
- }
- }
- /* get the length */
- len = strlen(str) ;
- /* calculate the checksum */
- chksum = 0 ;
- dochksum(&chksum, str, len) ;
- /* compose the output line */
- sprintf(msg, "$%2.2X%s$%2.2X", len, str, chksum) ;
- /* send the line across */
- write (devid, msg, strlen(msg)) ;
- /* do the debugging stuff */
- if (debuglink)
- printf("Sent :%s:\n", msg) ;
- if (logfile)
- fprintf(stderr, "> %s\n", msg) ;
- /* wait for the response */
- resp[0] = 'R' ;
- while (resp[0] != 'O')
- {
- /* get the response */
- psreadstr(resp,10) ;
- if (resp[0] != 'O')
- {
- /* we need to resend here */
- write(devid, msg, strlen(msg)) ;
- if (debuglink)
- printf("putline: Resent last block (%s)\n", msg) ;
- if (logfile)
- {
- fprintf(stderr, "putline: Resent last block (%s)\n", msg) ;
- fflush(stderr) ;
- }
- transbad ++ ;
- }
- }
- transgood ++ ;
- if (debuglink)
- printf("OK transmited (%s)\n", msg) ;
- if (logfile)
- {
- fprintf(stderr, "OK transmited (%s)\n", msg) ;
- fflush(stderr) ;
- }
- }
-
-
- /* get a line of text from the psion, remove any newlines etc */
- psreadstr(string, count)
- char * string ;
- int count ;
- {
- int ctr ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psreadstr (string OMITED, count = %d)\n", count) ;
- fflush(stderr) ;
- }
- ctr = 0 ;
- ctr = read(devid, string, count) ;
- string[ctr -1] = '\0' ;
- if (string[ctr - 1] == '\n') ;
- string[ctr - 1] == '\0' ;
- }
-
- psresponse(str)
- char * str ;
- {
- int len, chksum, pchksum ;
- char msg[1000] ;
- char tmp[1000] ;
- char lenstr[4] ;
- char chkstr[4] ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL psresponse (OMITED)\n") ;
- fflush (stderr) ;
- }
- /* init the checksums to be different */
- chksum = 1 ;
- pchksum = 0 ;
- /* repeat untill the checksums are the same */
- while (pchksum != chksum)
- {
- /* get the string */
- psreadstr(tmp, 1000) ;
-
- /* get the first 3 bytes, these are the length of the data */
- strncpy(lenstr, tmp, 3) ;
- /* as strncpy may not terminate the string */
- lenstr[3] = '\0' ;
- /* convert the length data. NOTE the psion does not zero pad
- so we have to do this our selves */
- if (lenstr[1] == ' ')
- lenstr[1] = '0' ;
- if (lenstr[2] == ' ')
- lenstr[2] == '0' ;
- len = idehex(lenstr+1) ;
- /* read the main data */
- strncpy(msg, tmp+3, len) ;
- /* as strncpy may not terminate the string */
- msg[len] = '\0' ;
- /* read the 3 bytes of chksum data */
- strncpy(chkstr, tmp+3+len, 3) ;
- /* as strncpy may not terminate the string */
- chkstr[3] = '\0' ;
- /* convert the checksum again note the zero padding problem*/
- if (chkstr[1] == ' ')
- chkstr[1] = '0' ;
- if (chkstr[2] == ' ')
- chkstr[2] = '0' ;
- pchksum = idehex(chkstr+1) ;
- /* calculate the real chksum */
- chksum = 0 ;
- dochksum(&chksum, msg, len) ;
- /* if the chksums are the same send 'O' otherwise send R */
- if (chksum == pchksum)
- {
- write(devid, "O", 1) ;
- if (debuglink)
- printf("Recieved datablock OK (lenstr = %s, msg = :%s: chkstr = %s)\n", lenstr, msg, chkstr) ;
- if (logfile)
- {
- fprintf(stderr, "Recieved datablock OK (lenstr = %s, msg = :%s:, chkstr = %s)\n", lenstr, msg, chkstr) ;
- fflush(stderr) ;
- }
- }
- else
- {
- recbad ++ ;
- write(devid, "R", 1) ;
- if (debuglink)
- printf("Error on recieving data block (lenstr = %s, msg = :%s: chkstr = %s)\n", lenstr, msg, chkstr) ;
- if (logfile)
- {
- fprintf(stderr, "Error on recieving data block (lenstr = %s, msg = :%s: chkstr = %s)\n", lenstr, msg, chkstr) ;
- fflush(stderr) ;
- }
- }
- }
- recgood ++ ;
- /* copy the string */
- strcpy(str, msg) ;
- if (debuglink)
- printf("Len %d, Got:%s:\n", strlen(str), str) ;
- if (logfile)
- {
- fprintf(stderr, "< %s\n", str) ;
- fflush (stderr) ;
- }
- }
-
- /* send a file to the psion, remove the file if it exists. if we have been
- passed a null string use the file name we are sending as the local files name
- */
- pssendfile(fname)
- char * fname ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pssendfile (fname = %s)\n", fname) ;
- fflush(stderr) ;
- }
- /* then parse pspath to extract the filename component */
- psgetfname() ;
- /* first remove the target file if required */
- psclearfile() ;
- if ( strlen(fname) == 0)
- {
- return(psgf(psfname)) ;
- }
- else
- return(psgf(fname)) ;
- /* the above command is misnamed as if refers to getting a file on the psion ! */
- }
-
-
- /* we have an error, print the message ans shutdown */
- pserror(str)
- char * str ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pserror (str = %s)\n", str) ;
- fflush(stderr) ;
- }
- fprintf(stderr, "%s\n", str) ;
- psshutdown(6) ;
- }
-
- psgf(fname)
- char * fname ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psgf (fname = %s)\n", fname) ;
- fflush(stderr) ;
- }
- if (tmode == ASCII)
- {
- printf("ASCII mode is nolonger supported\n");
- return(BAD) ;
- }
- else if (tmode == XMDM)
- return(psgfx(fname)) ;
- else
- return(psgfb(fname)) ;
- }
-
- /* send the file named in the parameter to the psion. this assumes that the
- file does not exist on the psion and that the remote path is correct
- then send a hex file */
-
- int psgfb(fname)
- char * fname ;
- {
- FILE *fd ;
- char sendstr [255], tmpstr [10], binbuff[255], tmpbuff[255];
- char ch ;
- int ctr ;
- int binctr ;
- int binsum ;
- int ln ;
- int fileid ;
- int i ;
-
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psgfb(fname = %s)\n", fname) ;
- fflush(stderr) ;
- }
- transct = 0 ;
-
- if ((fileid = open(fname, O_RDONLY , 0)) == -1)
- {
- printf("Error in puting %s, not found on local machine\n", fname) ;
- return(BAD) ;
- }
-
- pscommand("gf") ;
-
- psreply("XSTARTGET") ;
- if (psquery("XBADOPEN") == TRUE)
- {
- if (findvar(VAR_HELPFULL) != NULL)
- {
- printf("HELP: Error in getting file from the psion, cannot open it.\n") ;
- printf("HELP: Either the disk is full, there are to many files or the directory\n") ;
- printf("HELP: does not exist\n") ;
- }
- return (BAD);
- }
-
- ctr = 0 ;
- ln = 0 ;
-
- while ((ln = read(fileid, binbuff, MAXSEND / 2)) > 0)
- {
- tmpbuff[0] = '\0' ; /* init the output string */
- for (i = 0 ; i < ln ; i ++ )
- {
- pstoas(binbuff[i], tmpstr) ; /* convert the byte and add it to the string */
- strcat(tmpbuff, tmpstr) ;
- }
- /* are we working with file transfer level binary
- checksumming turned on ? if so do stuff */
- if (filechksum == TRUE)
- {
- binsum = 0 ;
- dochksum(&binsum, binbuff, ln) ;
- /* insert the checksum into the data string */
- sprintf(sendstr, "%2.2X%s", binsum,tmpbuff) ;
- }
- else
- {
- /* no checksumming but we need to copy the string over */
- sprintf(sendstr,"%s", tmpbuff) ;
- }
- /* we now have the output stream, lets send it */
- psputline(sendstr) ;
- /* if we are using file transfer level binary checksumming lets make sure it all worked OK */
- if (filechksum == TRUE)
- {
- /* init the response buffer */
- strcpy(tmpbuff, "XB") ;
- while (strcmp(tmpbuff, "XG") != 0)
- {
- /* get the response */
- psresponse(tmpbuff) ;
- if (strcmp(tmpbuff, "XG") != 0)
- {
- /* we need to resend */
- psputline(sendstr) ;
- if (debuglink)
- printf("putfile: Resent last block (%s)\n", sendstr) ;
- if (logfile)
- {
- fprintf(stderr, "putfile: Resent last block (%s)\n", sendstr) ;
- fflush(stderr) ;
- }
- /* increment the bad count */
- ftransbad ++ ;
- }
- }
- /* good block transfer, increment the count */
- ftransgood ++ ;
- }
- ctr = 0 ;
- transct += ln ; /* increment the number of bytes sent */
- }
-
- psputline("XE") ;
- psreply("XENDGET") ;
- close(fileid) ;
- return(OK) ;
- }
-
- pstoas(ch, str)
- char ch ;
- char * str ;
- {
- int msn, lsn ;
- int tmp ;
- if (debugcall >= 6)
- {
- fprintf(stderr, "CALL: pstoas (OMITED)\n") ;
- fflush(stderr) ;
- }
- tmp = ch & 0xFF ;
- msn = ((int) tmp) / 16 ;
- lsn = (int) tmp - (msn * 16) ;
- str[0] = 'A' + msn ;
- str[1] = 'A' + lsn ;
- str[2] = '\0' ;
- }
-
- psrecfile(fname)
- char * fname ;
- {
- /* parse the name to get the filename component */
- /* if the file exists remotley */
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psrecfile (fname = %s)\n", fname) ;
- fflush(stderr) ;
- }
- if (psep())
- {
- if (strlen(fname) == 0)
- {
- psgetfname() ;
- return(pspf(psfname)) ;
- }
- else
- return(pspf(fname)) ;
- }
- }
-
- /* call the appropriate transfer method */
- int pspf(fname)
- char * fname ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pspf (fname = %s)\n", fname) ;
- fflush(stderr) ;
- }
- if (tmode == ASCII)
- {
- printf("ASCII mode is nolonger supported\n") ;
- return(BAD) ;
- }
- else if (tmode == XMDM)
- return(pspfx(fname)) ;
- else
- return(pspfb(fname)) ;
- }
-
- int pspfb(fname)
- char * fname ;
- {
- FILE *fd ;
- char recstr [255], tmpstr [10], binbuff[255] ;
- char ch, dehex() ;
- int fileid, ctr, len, binctr ;
- int pcs, scs ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pspfb (fname = %s)\n", fname) ;
- fflush(stderr) ;
- }
-
- transct = 0 ;
-
- if ((fileid = open(fname, O_WRONLY |O_CREAT, 420)) == -1)
- {
- printf("ERROR: Cant open file (%s) to recieve the data\n", fname) ;
- return (BAD);
- }
-
- pscommand("pf") ;
-
- psreply("XSTARTPUT") ;
- if (psquery("XBADOPEN"))
- {
- if (findvar(VAR_HELPFULL) != NULL)
- printf("Error in put, cannot open the file on the psion\n") ;
- return (BAD) ;
- }
-
- psresponse(recstr) ;
- while (strcmp(recstr, "XE") != 0)
- {
- /* if we are file level checksumming the flow control is somewhat different */
- if (filechksum == TRUE)
- {
- pcs = 0 ;
- scs = 1 ;
- while (pcs != scs)
- {
- ctr = 0 ;
- /* extract the chksum */
- /* note, the psion does not pad the first space if it is zero so */
- if (recstr[ctr] == ' ')
- recstr[ctr] = '0' ;
- pcs = idehex(recstr) ;
- ctr += 2 ; /* skip over the checksum and un munge the line as normal */
- binctr = 0 ;
- len = strlen(recstr) ;
- while ( ctr <= (len - 2))
- {
- binbuff[binctr] = dehex(recstr + ctr) ; /* get the char */
- ctr += 2 ; /* increment the hex counter */
- binctr ++ ; /* inc the binary counter */
- }
- /* now calculate the chksum on the decoded binary string */
- scs = 0 ;
- dochksum(&scs,binbuff,binctr) ;
- /* if they agree just acknowledge, write the log entries and carry on */
- if (pcs == scs)
- {
- psputline("G") ;
- if (debuglink)
- printf("Recieved file datablock OK (len = %d, msg = :%s: chk = %2.2X)\n", len, recstr +2 , pcs) ;
- if (logfile)
- {
- fprintf(stderr,"Recieved file datablock OK (len = %d, msg = :%s: chk = %2.2X)\n", len, recstr +2 , pcs) ;
- fflush(stderr) ;
- }
- }
- else
- {
- /* increment the bad counter */
- frecbad ++ ;
- /* request a resend */
- psputline("B") ;
- /* do the log file stuff */
- if (debuglink)
- printf("Error Recieving file datablock (len = %d, msg = :%s: chk = %2.2X)\n", len, recstr +2 , pcs) ;
- if (logfile)
- {
- fprintf(stderr,"Error Recieving file datablock (len = %d, msg = :%s: chk = %2.2X)\n", len, recstr +2 , pcs) ;
- fflush(stderr) ;
- }
- /* get the resent line */
- psresponse(recstr) ;
- }
- }
- write(fileid, binbuff, binctr) ;
- transct += binctr; /* increment the transfered counter by the number of bytes written */
- /* increment the good block count */
- frecgood ++ ;
- }
- else /* no file level check summing */
- {
- ctr = 0 ;
- binctr = 0 ;
- len = strlen(recstr) ;
- while ( ctr <= (len - 2))
- {
- binbuff[binctr] = dehex(recstr + ctr) ; /* get the char */
- ctr += 2 ; /* increment the hex counter */
- binctr ++ ; /* inc the binary counter */
- }
- write(fileid, binbuff, binctr) ;
- transct += binctr; /* increment the transfered counter by the number of bytes written */
- }
- /* get the next block */
- psresponse(recstr) ;
- }
-
- psquery("XENDPUT") ;
- close(fileid) ;
- return(OK) ;
-
- }
-
- int idehex (str)
- char * str ;
- {
- char ch ;
- int tmp ;
- char tmpstr[6] ;
-
- if (debugcall >= 6)
- {
- fprintf(stderr, "CALL: idehex (OMITED)\n") ;
- fflush(stderr) ;
- }
- tmpstr[0] = '0' ;
- tmpstr[1] = 'x' ;
- tmpstr[2] = str[0] ;
- tmpstr[3] = str[1] ;
- tmpstr[4] = '\0' ;
-
- sscanf(tmpstr, "%i", &tmp) ;
- return (tmp) ;
- }
-
- char dehex (str)
- char * str ;
- {
- char ch ;
- int tmp ;
- char tmpstr[6] ;
-
- if (debugcall >= 6)
- {
- fprintf(stderr, "CALL: dehex (OMITED)\n") ;
- fflush(stderr) ;
- }
- tmpstr[0] = '0' ;
- tmpstr[1] = 'x' ;
- tmpstr[2] = str[0] ;
- tmpstr[3] = str[1] ;
- tmpstr[4] = '\0' ;
-
- sscanf(tmpstr, "%i", &tmp) ;
-
- ch = (char) tmp ;
- return (ch) ;
- }
-
- psscreenoff()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psscreenoff ()\n") ;
- fflush(stderr) ;
- }
- pscommand("is") ;
- if (psquery ("XYES") == 1)
- pssc() ;
-
- }
-
- psscreenon()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psscreenon ()\n") ;
- fflush(stderr) ;
- }
- pscommand("is") ;
- if (psquery ("XNO") == 1)
- pssc() ;
-
- }
-
- pssc()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pssc()\n") ;
- fflush(stderr) ;
- }
- pscommand("sc") ;
- psreply("XOK") ;
- }
-
- psverboseoff()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psverboseoff()\n") ;
- fflush(stderr) ;
- }
- pscommand("iv") ;
- if (psquery ("XYES") == 1)
- psvb() ;
-
- }
-
- psverboseon()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psverboseon()\n") ;
- fflush(stderr) ;
- }
- pscommand("iv") ;
- if (psquery ("XNO") == 1)
- psvb() ;
-
- }
-
- char * psversion()
- {
- char vsnstr[100] ;
-
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psversion()\n") ;
- fflush(stderr) ;
- }
- /* if the first char of version is X we have not got the version
- yet so get it and store it, otherwise just return the pointer
- to the version string */
- if (version[0] == 'X')
- {
- psvn(vsnstr) ;
- /* copy from the second char as the first will be X */
- strcpy(version, &vsnstr[1]) ;
- /* if the first char is B (the psion will return XBADCMD
- if it doesnot support version checking yet) run pssetdefvsn */
- if (version[0] == 'B')
- pssetdefvsn() ;
- }
- return (version) ;
- }
-
- /* compare psion vsn string to sun vsn string, if the psion one is later return
- GREATERTHAN, if they are the same EQUAL otherwise LESSTHAN */
- psvsncmp(vsstr)
- char * vsstr ;
- {
- char * psvnstr ;
- char * ps1, *ps2, *ps3, *ps4 ;
- char * ss1, *ss2, *ss3, *ss4 ;
- char nstr[1] ;
- int pint, vint ;
-
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psvsncmp(vsstr = %s)\n", vsstr) ;
- fflush(stderr) ;
- }
- /* first ensure that we have the correct version */
- psvnstr = psversion() ;
-
- /* initialise the nstr */
- nstr[0] = '\0' ;
-
- /* now extract the strings */
- ps1 = psvnstr ;
- ss1 = vsstr ;
-
- /* locate the next . */
- psvnstr = strchr(psvnstr, '.') ;
- vsstr = strchr(vsstr, '.') ;
- if (psvnstr == NULL)
- psvnstr = nstr ;
- else
- psvnstr ++;/* skip over the . */
- if (vsstr == NULL)
- vsstr = nstr ;
- else
- vsstr ++ ; /* see above */
-
- ps2 = psvnstr;
- ss2 = vsstr ;
- /* and the next */
- psvnstr = strchr(psvnstr, '.') ;
- vsstr = strchr(vsstr, '.') ;
- if (psvnstr == NULL)
- psvnstr = nstr ;
- else
- psvnstr ++;/* skip over the . */
- if (vsstr == NULL)
- vsstr = nstr ;
- else
- vsstr ++ ; /* see above */
-
- ps3 = psvnstr ;
- ss3 = vsstr ;
- /* and the last */
- psvnstr = strchr(psvnstr, '.') ;
- vsstr = strchr(vsstr, '.') ;
- if (psvnstr == NULL)
- psvnstr = nstr ;
- else
- psvnstr ++;/* skip over the . */
- if (vsstr == NULL)
- vsstr = nstr ;
- else
- vsstr ++ ; /* see above */
-
- ps4 = psvnstr ;
- ss4 = vsstr ;
-
- /* do the first test */
- pint = atoi(ps1) ;
- vint = atoi(ss1) ;
-
- if (pint > vint)
- return (GREATERTHAN) ;
- else if (pint < vint)
- return (LESSTHAN) ;
- pint = atoi(ps2) ;
- vint = atoi(ss2) ;
-
- if (pint > vint)
- return (GREATERTHAN) ;
- else if (pint < vint)
- return (LESSTHAN) ;
- pint = atoi(ps3) ;
- vint = atoi(ss3) ;
-
- if (pint > vint)
- return (GREATERTHAN) ;
- else if (pint < vint)
- return (LESSTHAN) ;
- pint = atoi(ps4) ;
- vint = atoi(ss4) ;
-
- if (pint > vint)
- return (GREATERTHAN) ;
- else if (pint < vint)
- return (LESSTHAN) ;
-
- /* they would appear to be the same */
- return (EQUAL) ;
- }
-
-
- psvsngt(vsn)
- char * vsn ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psvsngt(vsn = %s)\n",vsn) ;
- fflush(stderr) ;
- }
- /* if dovsnchk is FALSE i.e. just dont do version checking
- just return FALSE */
- if (dovsnchk == FALSE)
- return (FALSE) ;
- if (psvsncmp(vsn) == GREATERTHAN)
- return (TRUE) ;
- else
- return(FALSE) ;
- }
-
- psvsnlt(vsn)
- char * vsn ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psvsnlt(vsn = %s)\n",vsn) ;
- fflush(stderr) ;
- }
- /* if dovsnchk is FALSE i.e. just dont do version checking
- just return FALSE */
- if (dovsnchk == FALSE)
- return (FALSE) ;
- if (psvsncmp(vsn) == LESSTHAN)
- return(TRUE) ;
- else
- return(FALSE) ;
- }
-
- psvsneq(vsn)
- char * vsn ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psvsneq(vsn = %s)\n",vsn) ;
- fflush(stderr) ;
- }
- /* if dovsnchk is FALSE i.e. just dont do version checking
- just return FALSE */
- if (dovsnchk == FALSE)
- return (FALSE) ;
- if (psvsncmp(vsn) == EQUAL)
- return(TRUE) ;
- else
- return(FALSE) ;
- }
- pssetdefvsn()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pssetdefvsn()\n") ;
- fflush(stderr) ;
- }
- /* set the default version string */
- strcpy(version, DEFVSNSTR) ;
- }
-
- psvn(vsnstr)
- char * vsnstr ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psvn(OMITED)\n") ;
- fflush(stderr) ;
- }
- pscommand("vn") ;
- psresponse(vsnstr) ;
- }
-
- psvb()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psvb()\n") ;
- fflush(stderr) ;
- }
- pscommand("vb") ;
- psreply("XOK") ;
- }
-
- psds()
- {
- char path[255] ;
-
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psds()\n") ;
- fflush(stderr) ;
- }
- pscommand("ds") ;
- psreply("XSTART") ;
- psresponse(path) ;
- psreply("XEND") ;
- }
- psgetpwd(path)
- char * path ;
- {
- char tmp[1024] ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psgetpwd()\n") ;
- fflush(stderr) ;
- }
- pscommand("pp") ;
- psresponse(tmp) ;
- /* remove the X at the start of the line */
- strcpy (path, &tmp[1]) ;
- }
-
- psbinary()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psbinary()\n") ;
- fflush(stderr) ;
- }
- pscommand("ia") ;
- if (psquery("XYES") == 1)
- {
- pstm() ;
- tmode = BINARY ;
- }
-
- }
- psxmodem()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psxmodem()\n") ;
- fflush(stderr) ;
- }
- pscommand("ix") ;
- if (psquery("XNO") == 1)
- {
- pstx() ;
- tmode = XMDM ;
- }
- }
-
- pstm()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pstm()\n") ;
- fflush(stderr) ;
- }
- pscommand("tm") ;
- psreply("XOK") ;
- }
-
- pstx()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pstm()\n") ;
- fflush(stderr) ;
- }
- pscommand("tx") ;
- psreply("XOK") ;
- }
-
- int psquery(str)
- char * str ;
- {
- char tmp[100] ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psquery(str = %s)\n",str) ;
- fflush(stderr) ;
- }
- psresponse(tmp) ;
- if (strcmp(tmp, str) == 0)
- return(TRUE) ;
- else
- return (FALSE) ;
- }
-
- psclearfile()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psclearfile()\n") ;
- fflush(stderr) ;
- }
- if (psep() == TRUE)
- psrp() ;
- }
-
- psep()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psep()\n") ;
- fflush(stderr) ;
- }
- pscommand("ep") ;
- return(psquery("XYES") == 1);
- }
-
- psrp()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psrp()\n") ;
- fflush(stderr) ;
- }
- pscommand("rp") ;
- if (!psquery("XOK"))
- printf("ERROR: Cant remove the file on the psion\n") ;
- }
-
- psmd()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psmd()\n") ;
- fflush(stderr) ;
- }
- pscommand("md");
- psquery("XOK") ;
- }
-
- psrl()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psrl()\n") ;
- fflush(stderr) ;
- }
- pscommand("rl") ;
- psreply("XOK") ;
- }
-
-
- pslp(fd)
- FILE *fd ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pslp(OMITED FD)\n") ;
- fflush(stderr) ;
- }
- pscommand("lp") ;
- psldir(fd) ;
- }
- psldir(fd)
- FILE *fd ;
- {
- char txt[255] ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psldir(OMITED FD)\n") ;
- fflush(stderr) ;
- }
- if (psquery("XSTARTLIST"))
- while(1)
- {
- psresponse(txt) ;
- if (strcmp (txt, "XENDLIST") == 0)
- break ;
- else if (strcmp(txt,"XBADPATH") == 0)
- {
- if (findvar(VAR_HELPFULL) != NULL)
- printf("HELP: Error in listing files, bad path specified\n") ;
- break ;
- }
- if (fd == NULL)
- printf("File :%s\n", txt) ;
- else
- fprintf(fd, "%s\n", txt) ;
- }
- }
-
- psdc()
- {
- if (debugcall >= 3)
- fprintf(stderr, "CALL: psdc()\n") ;
- pscommand("dc") ;
- psreply("XDISCONNECTED") ;
- psshutdown(0) ;
- }
-
- psreply (expected)
- char * expected ;
- {
- char tmp[1000] ;
-
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psreply(expected = %s)\n",expected) ;
- fflush(stderr) ;
- }
- psresponse(tmp) ;
-
- if (strcmp(tmp, expected) == 0)
- return;
- printf("ERROR, Protocol violation, expected (%s), got (%s), exiting\n",expected, tmp) ;
- psshutdown(1);
- }
-
- psdt (txt)
- char * txt ;
- {
- char tmp [1000] ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psdt(txt = %s)\n",txt) ;
- fflush(stderr) ;
- }
- strcpy (tmp, "dt ") ;
- strcat (tmp, txt) ;
- pscommand (tmp) ;
- psreply("XOK") ;
- }
-
- pssetpath(path)
- char * path ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pssetpath(path = %s)\n",path) ;
- fflush(stderr) ;
- }
- if (strcmp(path, pspath) == 0)
- return ;
- pssp(path) ;
-
- }
-
- pssp(path)
- char *path ;
- {
- char tmp[100] ;
-
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pssp(path = %s)\n",path) ;
- fflush(stderr) ;
- }
- /* if the stored name is the same as the current name save on
- transmitting information */
- strcpy(pspath, path) ;
- strcpy(tmp, "sp ") ;
- strcat(tmp, pspath) ;
-
- pscommand(tmp) ;
- psreply ("XOK") ;
- }
-
- ispathset()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: ispathset()\n") ;
- fflush(stderr) ;
- }
- return(strlen(pspath)) ;
- }
-
- psgetfname()
- {
- char * tmp ;
-
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psgetfname()\n") ;
- fflush(stderr) ;
- }
- /* find the last \ in the remaining name, this will be the
- end of the directory component */
- tmp = strrchr(pspath, '\\') ;
- /* if tmp is NULL there is no \ i.e. we are dealing with a local
- pathname not an absolute pathname */
- if (tmp == NULL)
- {
- strcpy (psfname, pspath) ;
- }
- else
- {
- /* tmp will point to the \ so increment by one */
- tmp ++ ;
- /* extract the filename from pspath using tmp */
- strcpy (psfname, tmp) ;
- }
- }
-
- psgetfsize()
- {
- char tmp[100] ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psgetfsize()\n") ;
- fflush(stderr) ;
- }
-
- pscommand("sz") ;
- psresponse(tmp) ;
- if (strcmp(tmp, "XBADPATH") == 0)
- return(0) ;
- return (atoi(tmp+1)) ;
- }
-
- psgetrw()
- {
- char tmp[100] ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psgetrw()\n") ;
- fflush(stderr) ;
- }
- pscommand("rw") ;
- psresponse(tmp) ;
- if (strcmp(tmp, "XBADPATH") == 0)
- return(PSBADPATH) ;
- else if (strcmp(tmp, "XRW") == 0)
- return(PSFILERW) ;
- else
- return(PSFILERO) ;
- }
- int pscs()
- {
- char tmp[100] ;
- int ret ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pscs ()\n");
- fflush(stderr) ;
- }
- pscommand("cs") ;
- psresponse(tmp) ; /* get the STARTSUM out of the way */
- psresponse(tmp) ; /* good or bad open ? */
- if (strcmp(tmp, "XBADOPEN") == 0)
- return(PSBADPATH) ;
- psresponse(tmp) ;
- if (strcmp(tmp, "XBADSUM") == 0)
- return(PSBADPATH) ;
- sscanf(tmp+1 /* skip over the X */, "%d", &ret) ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "INLINE: pscs return string is :%s:\n", tmp) ;
- fprintf(stderr, "INLINE: pscs return value is %d\n", ret);
- fflush(stderr) ;
- }
- psresponse(tmp) ;/* get the ENDSUM line */
- return (ret) ;
- }
-
- psgetatts()
- {
- char tmp [100] ;
- int atts ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psgetatts()\n") ;
- fflush(stderr) ;
- }
- pscommand("ft") ;
- psresponse(tmp) ;
- atts = 0 ;
- if (strcmp(tmp, "XBADPATH") == 0)
- return(PSBADPATH) ;
- else if (strstr(tmp,"DIR") != NULL)
- atts = atts | PSFILEDIR ;
- else if (strstr(tmp,"TEXT") != NULL)
- atts = atts | PSFILETEXT ;
- else if (strstr(tmp,"HIDDEN") != NULL)
- atts = atts | PSFILEHIDDEN ;
- else if (strstr(tmp, "SYSTEM") != NULL)
- atts = atts | PSFILESYSTEM ;
- else if (strstr(tmp, "VOLUME") != NULL)
- atts = atts | PSFILEVOLUME ;
- /* if the atts do not say this is a directory, its a file but not a text file */
- if (strstr(tmp, "DIR") == NULL)
- atts = atts | PSFILEFILE ;
- return (atts) ;
- }
- psrcd()
- {
- char tmp [1024] ;
- char ch ;
- if (debugcall >= 3)
- fprintf(stderr, "CALL: psrcd()\n") ;
- /* Are we dealing with a partition ? */
- if ((strlen(pspath) == 2) && (pspath[1] == ':'))
- {
- /* this is a partition. Check that it's valid and then
- just cd straight there */
- ch = isupper(pspath[0]) ? tolower(pspath[0]) : pspath[0] ;
- if ((ch == 'a') || (ch == 'b') || (ch == 'c') || (ch == 'm'))
- {
- /* set the path to be terminated with a \ */
- strcpy (tmp,pspath) ;
- strcat (tmp, "\\") ;
- pssetpath(tmp) ;
- pscommand("cd") ;
- if (!psquery("XOK"))
- {
- return(BAD) ;
- }
- return(OK) ;
- }
- printf("ERROR: Invalid devicename %s\n", pspath) ;
- return (BAD) ;
- }
- /* check that the already downloaded path exists and is a directory
- BEFORE we try to change to it */
- if (! psep())
- return (BAD) ;
- /* check that it's a directory */
- if (!(psgetatts () & PSFILEDIR))
- return (BAD) ;
- /* we need to append a \ to the end of the path */
- strcpy (tmp, pspath) ;
- strcat (tmp, "\\") ;
- pssetpath (tmp) ;
- pscommand("cd") ;
- if (!psquery("XOK"))
- {
- printf ("ERROR: remote command failed to set remote directory\n") ;
- return (BAD) ;
- }
- return (OK) ;
- }
- /* start debugging on the psion, assume tha path has been set and the file does not exist */
- pssd()
- {
- char resp[100] ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pssd ()\n");
- fflush(stderr) ;
- }
- pscommand("sd") ; /* send the command */
- psresponse(resp) ; /* get the responnse */
- if (strcmp (resp, "XGOODOPEN") == 0)
- {
- return (OK) ;
- }
- else if (strcmp(resp, "XBADCMD") == 0)
- {
- return (BADCMD) ;
- }
- else
- return (BAD) ;
- }
-
- psstartdebug(pth)
- char * pth ;
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psstartdebug ()\n");
- fflush(stderr) ;
- }
- pssetpath(pth) ;
- /* if it exist, remove it */
- psclearfile() ;
- /* start the debugging */
- return(pssd()) ;
- }
- psenddebug()
- {
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psenddebug ()\n");
- fflush(stderr) ;
- }
- return (psed()) ;
- }
- /* end debugging on the psion */
- psed()
- {
- char resp [100] ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psed ()\n");
- fflush(stderr) ;
- }
- pscommand("ed") ;
- psresponse (resp) ;
- if (strcmp(resp, "XGOODCLOSE") == EQUAL)
- {
- return(OK) ;
- }
- else if (strcmp(resp, "XBADCMD") == EQUAL)
- {
- return(BADCMD) ;
- }
- else
- return(BAD) ;
- }
- long psgetmodtime()
- {
- long pstime ;
- char tmp[100] ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psgetatts()\n") ;
- fflush(stderr) ;
- }
- pscommand ("ti") ;
- psresponse(tmp) ;
-
- if (strcmp("XBADPATH", tmp) == 0)
- return(-1) ;
- return(atoi(tmp+1)) ;
- }
-
- pssetro()
- {
- char tmp[100] ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL:pssetro()\n") ;
- fflush(stderr) ;
- }
- pscommand("wn") ;
- psresponse(tmp) ;
- }
- pssetrw()
- {
- char tmp[100] ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL:pssetrw()\n") ;
- fflush(stderr) ;
- }
- pscommand("wy") ;
- psresponse(tmp) ;
- }
-
- pstf(trunc_size)
- int trunc_size ;
- {
- char tmp [100] ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL:pstf(trunc_size = %d)\n", trunc_size) ;
- fflush(stderr) ;
- }
- sprintf(tmp, "tf %d") ;
- pscommand(tmp) ;
- psresponse(tmp) ;
- }
-
- psfc(mode)
- int mode ;
- {
- /* tell the psion to start talking (or not) with file level checksumming */
- char tmp[100] ;
- if (debugcall >=3)
- {
- fprintf(stderr, "CALL:psfc(mode = %d)\n", mode) ;
- fflush(stderr) ;
- }
- if (mode == TRUE)
- {
- sprintf(tmp,"fc 1") ;
- filechksum = TRUE ;
- }
- else
- {
- sprintf(tmp,"fc 0") ;
- filechksum = FALSE ;
- }
- pscommand(tmp) ;
- if (!psquery("XOK"))
- printf("Error in command psfc\n") ;
- }
-
- /* process control functions. these are dangerous if misused */
- pspo(mode)
- int mode ;
- {
- /* tell the psion to disallow or allow override of process checking */
- char tmp[100] ;
- if (debugcall >=3)
- {
- fprintf(stderr, "CALL:pspo(mode = %d)\n", mode) ;
- fflush(stderr) ;
- }
- if (mode == TRUE)
- {
- sprintf(tmp,"po 1") ;
- pscommand(tmp) ;
- psreply("XON") ;
- }
- else
- {
- sprintf(tmp,"po 0") ;
- pscommand(tmp) ;
- psreply("XOFF") ;
- }
- return(OK) ;
- }
-
- pspl(fd, pattern)
- FILE *fd ;
- char * pattern ;
- {
- /* list the processes according to the pattern */
- char txt[255] ;
- char tmp[20] ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pspl(OMITED FD, pattern = %s)\n", pattern) ;
- fflush(stderr) ;
- }
- /* assemble the command */
- sprintf(tmp, "pl %s", pattern) ;
- pscommand(tmp) ;
- if (psquery("XBADPARAM"))
- {
- if (findvar(VAR_HELPFULL) != NULL)
- {
- printf("HELP: Error in listing processes using pattern %s, posibly the pattern is to long\n", pattern) ;
- }
- return(OK) ;
- }
- while(1)
- {
- psresponse(txt) ;
- if (strcmp (txt, "XENDLIST") == 0)
- break ;
- if (fd == NULL)
- printf("Process :%s\n", txt) ;
- else
- fprintf(fd, "%s\n", txt) ;
- }
- }
- pspk(pattern)
- char * pattern ;
- {
- /* kill processes according to the pattern */
- char txt[255] ;
- char tmp[20] ;
- int count ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: pspk( pattern = %s)\n", pattern) ;
- fflush(stderr) ;
- }
- /* assemble the command */
- sprintf(tmp, "pk %s", pattern) ;
- pscommand(tmp) ;
- psresponse(tmp);
- if (strcmp(tmp, "XBADPARAM") == 0)
- {
- if (findvar(VAR_HELPFULL) != NULL)
- {
- printf("HELP: Error in killing processes using pattern %s, posibly the pattern is to long or was not supplied\n", pattern) ;
- }
- return(OK) ;
- }
- if (strcmp(tmp, "KILLNOPROC") == 0)
- {
- if (findvar(VAR_HELPFULL) != NULL)
- {
- printf("HELP: Error in killing processes, no processes found matching patterm %s\n", pattern) ;
- }
- return(OK) ;
- }
- if (strcmp(tmp, "KILLERRPROC") == 0)
- {
- if (findvar(VAR_HELPFULL) != NULL)
- {
- printf("HELP: Error in killing processes, suncom error\n") ;
- }
- return(OK) ;
- }
- count = atoi(tmp+1) ;
- if (findvar(VAR_VERBOSE) != NULL)
- printf("%d processes killed matching pattern %s\n", count, pattern) ;
- return(OK) ;
- }
- psps(pattern)
- char * pattern ;
- {
- /* shutdown processes according to the pattern */
- char txt[255] ;
- char tmp[20] ;
- int count ;
- if (debugcall >= 3)
- {
- fprintf(stderr, "CALL: psps( pattern = %s)\n", pattern) ;
- fflush(stderr) ;
- }
- /* assemble the command */
- sprintf(tmp, "ps %s", pattern) ;
- pscommand(tmp) ;
- psresponse(tmp);
- if (strcmp(tmp, "XBADPARAM") == 0)
- {
- if (findvar(VAR_HELPFULL) != NULL)
- {
- printf("HELP: Error in shutting down processes using pattern %s, posibly the pattern is to long or was not supplied\n", pattern) ;
- }
- return(OK) ;
- }
- if (strcmp(tmp, "SDNOPROC") == 0)
- {
- if (findvar(VAR_HELPFULL) != NULL)
- {
- printf("HELP: Error in shutting down processes, no processes found matching patterm %s\n", pattern) ;
- }
- return(OK) ;
- }
- if (strcmp(tmp, "SDERRPROC") == 0)
- {
- if (findvar(VAR_HELPFULL) != NULL)
- {
- printf("HELP: Error in shutting down processes, suncom error\n") ;
- }
- return(OK) ;
- }
- count = atoi(tmp+1) ;
- if (findvar(VAR_VERBOSE) != NULL)
- printf("%d processes shutdown matching pattern %s\n", count, pattern) ;
- return(OK) ;
- }
-