/* ** Name: DropExistingTags ** ** Description: ** Removes the tags between the begin and end tags inclusive. ** ** Inputs: ** Start if the tags. ** ** Outputs: ** Updated start of the tags. ** ** Returns: ** OK there is no error return. */ STATUS DropExistingTags( PRL* begin ) { STATUS retval = OK; PRL begintag; PRL endtag; if (((begintag = CFScanConf( stag, *begin, FALSE )) != NULL) && ((endtag = CFScanConf( etag, *begin, FALSE )) != NULL)) { if (begintag != NULL) { if (begintag == *begin) { *begin = endtag->next; } else { begintag->prev->next = endtag->next; } endtag->next = NULL; } for (endtag = begintag; endtag != NULL; endtag = begintag) { begintag = begintag->next; HFREE( endtag->text ); HFREE( (PTR)endtag ); } } return (retval); }
static void Pak_Destroy(Pak **p) { if(!p || !*p) return; Pak_Cleanup(*p); HFREE(p); }
/* ** Name: CFFreeConf ** ** Description: ** Free all the memory used to update the configuration. ** ** Inputs: ** begin Starting line of the configuration ** ** Outputs: ** none ** ** Returns: ** OK success ** FAIL failure ** ** History: ** 11-Feb-2000 (fanra01) ** Created. */ STATUS CFFreeConf( PRL begin ) { STATUS status = FAIL; PRL entry; while (begin != NULL) { entry = begin; begin = entry->next; if ((status = HFREE( entry->text )) == OK) { status = HFREE( (PTR)entry ); } } return (status); }
static void NetLink_Destroy(NetLink **hl) { NetLink *l; if(!hl || !*hl) return; l = *hl; apak_destroy(&l->recvs,Pak_Destroy); apak_destroy(&l->sends,Pak_Destroy); achr_destroy(&l->recv_frame); Pak_Destroy(&l->recv_pak); HFREE(hl); }
/*-------------------------------------------------------------------*/ static int printer_init_handler (DEVBLK *dev, int argc, char *argv[]) { int iarg,i,j; /* some Array subscripts */ char *ptr; char *nxt; int sockdev = 0; /* 1 == is socket device */ char pathname[PATH_MAX+1]; dev->excps = 0; /* Forcibly disconnect anyone already currently connected */ if (dev->bs && !unbind_device_ex(dev,1)) return -1; // (error msg already issued) /* The first argument is the file name */ if (argc == 0 || strlen(argv[0]) >= sizeof(pathname) ) { WRMSG (HHC01101, "E", SSID_TO_LCSS(dev->ssid), dev->devnum); return -1; } /* Save the file name in the device block */ hostpath(pathname, argv[0], sizeof(pathname) ); HFREE( dev->filename ); dev->filename = strdup(pathname); if ( dev->filename == NULL ) { WRMSG (HHC01460, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, "strdup(filename)", strerror(errno)); return -1; } if(!sscanf(dev->typname,"%hx",&(dev->devtype))) dev->devtype = 0x3211; /* Initialize device dependent fields */ dev->fd = -1; dev->devunique.cprt_dev.diaggate = 0; dev->devunique.cprt_dev.fold = 0; dev->devunique.cprt_dev.crlf = 0; dev->devunique.cprt_dev.stopdev = FALSE; dev->devunique.cprt_dev.notrunc = 0; dev->devunique.cprt_dev.ispiped = (dev->filename[0] == '|'); /* initialize the new fields for FCB+ support */ dev->devunique.cprt_dev.fcbsupp = 1; dev->devunique.cprt_dev.rawcc = 0; dev->devunique.cprt_dev.nofcbcheck = 0; dev->devunique.cprt_dev.ccpend = 0; dev->devunique.cprt_dev.prevline = 1; dev->devunique.cprt_dev.currline = 1; dev->devunique.cprt_dev.destline = 1; dev->devunique.cprt_dev.optbrowse = 1; dev->devunique.cprt_dev.lpi = 6; dev->devunique.cprt_dev.index = 0; dev->devunique.cprt_dev.ffchan = 1; for (i = 0; i < FCBSIZE; i++) dev->devunique.cprt_dev.fcb[i] = 0; for (i = 1; i <= 12; i++ ) { if ( FCBMASK[i] != 0 ) dev->devunique.cprt_dev.fcb[FCBMASK[i]] = i; } dev->devunique.cprt_dev.lpp = FCBMASK[0] ; dev->devunique.cprt_dev.fcbisdef = 0 ; /* Process the driver arguments */ for (iarg = 1; iarg < argc; iarg++) { if (strcasecmp(argv[iarg], "crlf") == 0) { dev->devunique.cprt_dev.crlf = 1; continue; } /* sockdev means the device file is actually a connected socket instead of a disk file. The file name is the socket_spec (host:port) to listen for connections on. */ if (!dev->devunique.cprt_dev.ispiped && strcasecmp(argv[iarg], "sockdev") == 0) { sockdev = 1; continue; } if (strcasecmp(argv[iarg], "noclear") == 0) { dev->devunique.cprt_dev.notrunc = 1; continue; } if (strcasecmp(argv[iarg], "rawcc") == 0) { dev->devunique.cprt_dev.rawcc = 1; dev->devunique.cprt_dev.optbrowse = 0; continue; } if (strcasecmp(argv[iarg], "nofcbcheck") == 0) { dev->devunique.cprt_dev.nofcbcheck = 1; continue; } if (strcasecmp(argv[iarg], "fcbcheck") == 0) { dev->devunique.cprt_dev.nofcbcheck = 0; continue; } if (strcasecmp(argv[iarg], "optbrowse") == 0) { dev->devunique.cprt_dev.optbrowse = 1; continue; } if (strcasecmp(argv[iarg], "optprint") == 0) { dev->devunique.cprt_dev.optbrowse = 0; continue; } if (strncasecmp("lpi=", argv[iarg], 4) == 0) { ptr = argv[iarg]+4; errno = 0; dev->devunique.cprt_dev.lpi = (int) strtoul(ptr,&nxt,10) ; if (errno != 0 || nxt == ptr || *nxt != 0 || ( dev->devunique.cprt_dev.lpi != 6 && dev->devunique.cprt_dev.lpi != 8 ) ) { j = ptr - argv[iarg] ; WRMSG (HHC01103, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, argv[iarg], iarg + 1, j); return -1; } continue; } if (strncasecmp("index=", argv[iarg], 6) == 0) { if (dev->devtype != 0x3211 ) { WRMSG (HHC01103, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, argv[iarg], iarg + 1, 1); return -1; } ptr = argv[iarg]+6; errno = 0; dev->devunique.cprt_dev.index = (int) strtoul(ptr,&nxt,10) ; if (errno != 0 || nxt == ptr || *nxt != 0 || ( dev->devunique.cprt_dev.index < 0 || dev->devunique.cprt_dev.index > 15) ) { j = ptr - argv[iarg] ; WRMSG (HHC01103, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, argv[iarg], iarg + 1, j); return -1; } continue; } if (strncasecmp("lpp=", argv[iarg], 4) == 0) { ptr = argv[iarg]+4; errno = 0; dev->devunique.cprt_dev.lpp = (int) strtoul(ptr,&nxt,10) ; if (errno != 0 || nxt == ptr || *nxt != 0 ||dev->devunique.cprt_dev.lpp > FCBSIZE) { j = ptr - argv[iarg] ; WRMSG (HHC01103, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, argv[iarg], iarg + 1, j); return -1; } continue; } #if 0 if (strncasecmp("ffchan=", argv[iarg], 7) == 0) { ptr = argv[iarg]+7; errno = 0; dev->ffchan = (int) strtoul(ptr,&nxt,10) ; if (errno != 0 || nxt == ptr || *nxt != 0 || dev->ffchan < 1 || dev->ffchan > 12) { j = ptr - argv[iarg] ; WRMSG (HHC01103, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, argv[iarg], iarg + 1, j); return -1; } continue ; } #endif if (strncasecmp("fcb=", argv[iarg], 4) == 0) { for (line = 0 ; line <= FCBSIZE; line++) dev->devunique.cprt_dev.fcb[line] = 0; /* check for simple mode */ if ( strstr(argv[iarg],":") ) { /* ':" found ==> new mode */ ptr = argv[iarg]+4; while (*ptr) { errno = 0; line = (int) strtoul(ptr,&nxt,10) ; if (errno != 0 || *nxt != ':' || nxt == ptr || line > dev->devunique.cprt_dev.lpp || dev->devunique.cprt_dev.fcb[line] != 0 ) { j = ptr - argv[iarg] ; WRMSG (HHC01103, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, argv[iarg], iarg + 1, j); return -1; } ptr = nxt + 1 ; errno = 0; chan = (int) strtoul(ptr,&nxt,10) ; if (errno != 0 || (*nxt != ',' && *nxt != 0) || nxt == ptr || chan < 1 || chan > 12 ) { j = ptr - argv[iarg] ; WRMSG (HHC01103, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, argv[iarg], iarg + 1, j); return -1; } dev->devunique.cprt_dev.fcb[line] = chan; if ( nxt == 0 ) break ; ptr = nxt + 1; } } else { /* ':" NOT found ==> old mode */ ptr = argv[iarg]+4; chan = 0; while (*ptr) { errno = 0; line = (int) strtoul(ptr,&nxt,10) ; if (errno != 0 || (*nxt != ',' && *nxt != 0) || nxt == ptr || line > dev->devunique.cprt_dev.lpp || dev->devunique.cprt_dev.fcb[line] != 0 ) { j = ptr - argv[iarg] ; WRMSG (HHC01103, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, argv[iarg], iarg + 1, j); return -1; } chan += 1; if ( chan > 12 ) { j = ptr - argv[iarg] ; WRMSG (HHC01103, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, argv[iarg], iarg + 1, j); return -1; } dev->devunique.cprt_dev.fcb[line] = chan; if ( nxt == 0 ) break ; ptr = nxt + 1; } if ( chan != 12 ) { j = 5 ; WRMSG (HHC01103, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, argv[iarg], iarg + 1, j); return -1; } } continue; } WRMSG (HHC01102, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, argv[iarg], iarg + 1); return -1; } /* Check for incompatible options */ if (dev->devunique.cprt_dev.rawcc && dev->devunique.cprt_dev.optbrowse) { WRMSG (HHC01104, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, "rawcc/optbrowse"); return -1; } if (sockdev && dev->devunique.cprt_dev.crlf) { WRMSG (HHC01104, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, "sockdev/crlf"); return -1; } if (sockdev && dev->devunique.cprt_dev.notrunc) { WRMSG (HHC01104, "E", SSID_TO_LCSS(dev->ssid), dev->devnum, "sockdev/noclear"); return -1; } /* If socket device, create a listening socket to accept connections on. */ if (sockdev && !bind_device_ex( dev, dev->filename, onconnect_callback, dev )) { return -1; // (error msg already issued) } /* Set length of print buffer */ // dev->bufsize = LINE_LENGTH + 8; dev->bufsize = BUFF_SIZE + BUFF_OVFL; dev->bufres = BUFF_SIZE; dev->bufoff = 0; /* Set number of sense bytes */ dev->numsense = 1; /* Initialize the device identifier bytes */ dev->devid[0] = 0xFF; dev->devid[1] = 0x28; /* Control unit type is 2821-1 */ dev->devid[2] = 0x21; dev->devid[3] = 0x01; dev->devid[4] = dev->devtype >> 8; dev->devid[5] = dev->devtype & 0xFF; dev->devid[6] = 0x01; dev->numdevid = 7; /* Activate I/O tracing */ // dev->ccwtrace = 1; return 0; } /* end function printer_init_handler */