? programs-Xserver-Xprint-strlen-various.patch Index: AttrValid.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/AttrValid.c,v retrieving revision 1.2 diff -u -3 -p -d -w -r1.2 AttrValid.c --- AttrValid.c 23 Apr 2004 18:57:32 -0000 1.2 +++ AttrValid.c 18 Feb 2005 02:04:42 -0000 @@ -130,7 +130,7 @@ XpPutCardAttr(XpContextPtr pContext, if(value_card > 0) { char value_out[16]; - sprintf(value_out, "%lu", value_card); + snprintf(value_out, sizeof(value_out), "%lu", value_card); XpPutStringAttr(pContext, pool, oid, value_out); } else Index: AttrValid.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/AttrValid.h,v retrieving revision 1.2 diff -u -3 -p -d -w -r1.2 AttrValid.h --- AttrValid.h 23 Apr 2004 18:57:32 -0000 1.2 +++ AttrValid.h 18 Feb 2005 02:04:42 -0000 @@ -178,7 +178,7 @@ void XpPutMediumSSAttr(XpContextPtr pCon XPAttributes pool, XpOid oid, const XpOidMediumSS* msss); -const XpOidMediumSS* XpGetDefaultMediumSS(); +const XpOidMediumSS* XpGetDefaultMediumSS(void); /* * XpOidTrayMediumList-valued attribute access Index: Init.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/Init.c,v retrieving revision 1.9 diff -u -3 -p -d -w -r1.9 Init.c --- Init.c 4 Dec 2004 00:42:50 -0000 1.9 +++ Init.c 18 Feb 2005 02:04:42 -0000 @@ -364,7 +364,6 @@ XprintOptions( char **argv, int i) { - extern void ddxUseMsg(); if(strcmp(argv[i], "-XpFile") == 0) { if ((i + 1) >= argc) { @@ -503,14 +502,14 @@ static int AugmentPrinterDb(const char *command) { FILE *fp; + /* XXX is a 256 character limit overly restrictive for printer names? */ char name[256]; int num_printers = 0; /* Number of printers we found */ size_t namelen; char *desc = NULL; fp = popen(command, "r"); - /* XXX is a 256 character limit overly restrictive for printer names? */ - while(fgets(name, 256, fp) != (char *)NULL && (namelen=strlen(name))) + while(fgets(name, sizeof(name), fp) != (char *)NULL && (namelen=strlen(name))) { char *option = name; @@ -654,11 +653,10 @@ StoreDriverNames(void) { pEntry->driverName = (char*)XpGetPrinterAttribute(pEntry->name, "xp-ddx-identifier"); - if(pEntry->driverName == (char *)NULL || - strlen(pEntry->driverName) == 0 || + if(pEntry->driverName == (char *)NULL || *pEntry->driverName == '\0' || GetInitFunc(pEntry->driverName) == (Bool(*)())NULL) { - if (pEntry->driverName && (strlen(pEntry->driverName) != 0)) { + if (pEntry->driverName && (*pEntry->driverName != 0)) { ErrorF("Xp Extension: Can't load driver %s\n", pEntry->driverName); ErrorF(" init function missing\n"); @@ -790,6 +788,7 @@ BuildPrinterDb(void) { char *printerList, *augmentCmd = (char *)NULL; Bool defaultAugment = TRUE, freeConfigFileName; + FILE *fp; if(configFileName && access(configFileName, R_OK) != 0) { @@ -800,12 +799,11 @@ BuildPrinterDb(void) else freeConfigFileName = FALSE; - if(configFileName != (char *)NULL && access(configFileName, R_OK) == 0) + if(configFileName != (char *)NULL && (fp = fopen(configFileName, "r"))) { char line[256]; - FILE *fp = fopen(configFileName, "r"); - while(fgets(line, 256, fp) != (char *)NULL) + while(fgets(line, sizeof(line), fp) != (char *)NULL) { char *tok, *ptr; if((tok = strtok(line, " \t\012")) != (char *)NULL) @@ -875,7 +873,7 @@ BuildPrinterDb(void) } if(curr_spooler_type->list_queues_command == NULL || - strlen(curr_spooler_type->list_queues_command) == 0) + *(curr_spooler_type->list_queues_command) == '\0') { continue; } @@ -1072,7 +1070,7 @@ FindFontDir( { char *configDir, *fontDir; - if(!modelName || !strlen(modelName)) + if(!modelName || *modelName == '\0') return (char *)NULL; configDir = XpGetConfigDir(TRUE); @@ -1163,7 +1161,7 @@ AugmentFontPath(void) (char*)XpGetPrinterAttribute(pDbEntry->name, "xp-model-identifier"); - if(modelID && strlen(modelID) != 0) + if(modelID && *modelID != '\0') { /* look for current model in the list of allIDs */ for(i = 0; i < numModels; i++) @@ -1180,7 +1178,7 @@ AugmentFontPath(void) * If this printer's model-identifier isn't in the allIDs list, * then add it to allIDs. */ - if(modelID && strlen(modelID) != 0) + if(modelID && *modelID != '\0') { allIDs = (char **)xrealloc(allIDs, (numModels+2) * sizeof(char *)); if(allIDs == (char **)NULL) @@ -1240,10 +1238,10 @@ XpClientIsBitmapClient( * check the document attributes. */ mode = XpGetOneAttribute(pContext, XPPageAttr, "xp-listfonts-modes"); - if(!mode || !strlen(mode)) + if(! (mode && *mode)) { mode = XpGetOneAttribute(pContext, XPDocAttr, "xp-listfonts-modes"); - if(!mode || !strlen(mode)) + if(! (mode && *mode)) return TRUE; } @@ -1285,12 +1283,13 @@ XpClientIsPrintClient( * check the document attributes. */ mode = XpGetOneAttribute(pContext, XPPageAttr, "xp-listfonts-modes"); - if(!mode || !strlen(mode)) + + if(!mode || *mode == '\0') { mode = XpGetOneAttribute(pContext, XPDocAttr, "xp-listfonts-modes"); } - if(mode && strlen(mode)) + if(mode && *mode != '\0') { if(!strstr(mode, "xp-list-internal-printer-fonts")) return FALSE; @@ -1300,7 +1299,7 @@ XpClientIsPrintClient( return TRUE; modelID = XpGetOneAttribute(pContext, XPPrinterAttr, "xp-model-identifier"); - if(!modelID || !strlen(modelID)) + if(!modelID || *modelID == '\0') return FALSE; if(!(fontDir = FindFontDir(modelID))) Index: Oid.h =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/Oid.h,v retrieving revision 1.2 diff -u -3 -p -d -w -r1.2 Oid.h --- Oid.h 23 Apr 2004 18:57:32 -0000 1.2 +++ Oid.h 18 Feb 2005 02:04:42 -0000 @@ -205,7 +205,7 @@ char* XpOidListString(const XpOidList*); /* * XpOidLinkedList public methods */ -XpOidLinkedList* XpOidLinkedListNew(); +XpOidLinkedList* XpOidLinkedListNew(void); void XpOidLinkedListDelete(XpOidLinkedList*); #define XpOidLinkedListCount(l) ((l) ? (l)->count : 0) XpOid XpOidLinkedListGetOid(XpOidLinkedList* list, int i); Index: attributes.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/attributes.c,v retrieving revision 1.8 diff -u -3 -p -d -w -r1.8 attributes.c --- attributes.c 10 Jan 2005 18:47:55 -0000 1.8 +++ attributes.c 18 Feb 2005 02:04:43 -0000 @@ -1043,7 +1043,7 @@ XpGetPrinterAttribute(const char *printe break; } } - if(value.addr != (XPointer)NULL && strlen(value.addr) != 0) + if(value.addr != (XPointer)NULL && *value.addr != '\0') return value.addr; else return ""; @@ -1070,7 +1070,7 @@ XpSpoolerGetServerAttributes(void) XrmDatabase db; localeName = setlocale(LC_CTYPE, (char *)NULL); - if(!localeName || strlen(localeName) == 0) + if(!localeName || *localeName == '\0') localeName = "C"; if((totalAttrs = (char *)xalloc(strlen(serverAttrStr) + strlen(localeName) @@ -1203,33 +1203,33 @@ ReplaceAllKeywords( cmdOpt = XpGetOneAttribute(pContext, XPPrinterAttr, "xp-spooler-printer-name"); - if(cmdOpt != (char *)NULL && strlen(cmdOpt) != 0) + if(cmdOpt != (char *)NULL && *cmdOpt != '\0') command = ReplaceAnyString(command, "%printer-name%", cmdOpt); else command = ReplaceAnyString(command, "%printer-name%", pContext->printerName); cmdOpt = XpGetOneAttribute(pContext, XPDocAttr, "copy-count"); - if(cmdOpt != (char *)NULL && strlen(cmdOpt) != 0) + if(cmdOpt != (char *)NULL && *cmdOpt != '\0') command = ReplaceAnyString(command, "%copy-count%", cmdOpt); else command = ReplaceAnyString(command, "%copy-count%", "1"); cmdOpt = XpGetOneAttribute(pContext, XPJobAttr, "job-name"); - if(cmdOpt != (char *)NULL && strlen(cmdOpt) != 0) + if(cmdOpt != (char *)NULL && *cmdOpt != '\0') command = ReplaceAnyString(command, "%job-name%", cmdOpt); else command = ReplaceAnyString(command, "%job-name%", ""); cmdOpt = XpGetOneAttribute(pContext, XPJobAttr, "job-owner"); - if(cmdOpt != (char *)NULL && strlen(cmdOpt) != 0) + if(cmdOpt != (char *)NULL && *cmdOpt != '\0') command = ReplaceAnyString(command, "%job-owner%", cmdOpt); else command = ReplaceAnyString(command, "%job-owner%", ""); cmdOpt = XpGetOneAttribute(pContext, XPJobAttr, "xp-spooler-command-options"); - if(cmdOpt != (char *)NULL && strlen(cmdOpt) != 0) + if(cmdOpt != (char *)NULL && *cmdOpt != '\0') command = ReplaceAnyString(command, "%options%", cmdOpt); else command = ReplaceAnyString(command, "%options%", ""); @@ -1439,7 +1439,7 @@ XpSubmitJob(fileName, pContext) int i; command = XpGetOneAttribute(pContext, XPPrinterAttr, "xp-spooler-command"); - if(command == (char *)NULL || strlen(command) == 0) + if(command == (char *)NULL || *command == '\0') { if( spooler_type ) { @@ -1480,7 +1480,7 @@ XpSubmitJob(fileName, pContext) } userName = XpGetOneAttribute(pContext, XPJobAttr, "job-owner"); - if(userName != (char *)NULL && strlen(userName) == 0) + if(userName != (char *)NULL && *userName == '\0') userName = (char *)NULL; SendFileToCommand(fileName, cmdNam, vector, userName); Index: ddxInit.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/Xprint/ddxInit.c,v retrieving revision 1.4 diff -u -3 -p -d -w -r1.4 ddxInit.c --- ddxInit.c 27 Jul 2004 20:26:47 -0000 1.4 +++ ddxInit.c 18 Feb 2005 02:04:43 -0000 @@ -72,8 +72,6 @@ InitOutput( char **argv) { - int i; - pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER; pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;