From 28ed9cda2a47c17130ee5b97588695ed3acb4e45 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Wed, 29 Sep 2010 21:45:56 +0000 Subject: Rename nstring.h functions with pm_ prefix git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1320 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/ppm/picttoppm.c | 8 ++-- converter/ppm/ppmtogif.c | 38 +++++++++---------- converter/ppm/ppmtompeg/combine.c | 10 ++--- converter/ppm/ppmtompeg/input.c | 14 +++---- converter/ppm/ppmtompeg/mpeg.c | 16 ++++---- converter/ppm/ppmtompeg/parallel.c | 74 ++++++++++++++++++------------------- converter/ppm/ppmtompeg/param.c | 2 +- converter/ppm/ppmtompeg/ppmtompeg.c | 16 ++++---- converter/ppm/ppmtompeg/psocket.c | 44 +++++++++++----------- converter/ppm/ppmtompeg/rate.c | 4 +- converter/ppm/ppmtompeg/readframe.c | 52 +++++++++++++------------- converter/ppm/ppmtowinicon.c | 14 +++---- converter/ppm/ppmtoxpm.c | 16 ++++---- converter/ppm/winicontoppm.c | 27 +++++++------- converter/ppm/yuvsplittoppm.c | 12 +++--- 15 files changed, 174 insertions(+), 173 deletions(-) (limited to 'converter/ppm') diff --git a/converter/ppm/picttoppm.c b/converter/ppm/picttoppm.c index 9a7d8e7c..d91e23e2 100644 --- a/converter/ppm/picttoppm.c +++ b/converter/ppm/picttoppm.c @@ -1217,8 +1217,8 @@ doDiffSize(struct Rect const clipsrc, pm_close(tempFileP); - asprintfN(&command, "pnmscale -xsize %d -ysize %d > %s", - rectwidth(&clipdst), rectheight(&clipdst), tempFilename); + pm_asprintf(&command, "pnmscale -xsize %d -ysize %d > %s", + rectwidth(&clipdst), rectheight(&clipdst), tempFilename); pm_message("running command '%s'", command); @@ -1227,7 +1227,7 @@ doDiffSize(struct Rect const clipsrc, pm_error("cannot execute command '%s' popen() errno = %s (%d)", command, strerror(errno), errno); - strfree(command); + pm_strfree(command); fprintf(pnmscalePipeP, "P6\n%d %d\n%d\n", rectwidth(&clipsrc), rectheight(&clipsrc), PPM_MAXMAXVAL); @@ -1331,7 +1331,7 @@ doDiffSize(struct Rect const clipsrc, pm_close(scaled); ppm_freerow(row); - strfree(tempFilename); + pm_strfree(tempFilename); unlink(tempFilename); } diff --git a/converter/ppm/ppmtogif.c b/converter/ppm/ppmtogif.c index 3123d1f0..753782fb 100644 --- a/converter/ppm/ppmtogif.c +++ b/converter/ppm/ppmtogif.c @@ -183,8 +183,8 @@ openPnmremapStream(const char * const inputFileName, assert(inputFileName != NULL); assert(mapFileName != NULL); - asprintfN(&pnmremapCommand, "pnmremap -mapfile='%s' %s", - mapFileName, inputFileName); + pm_asprintf(&pnmremapCommand, "pnmremap -mapfile='%s' %s", + mapFileName, inputFileName); if (verbose) pm_message("Preprocessing Pamtogif input with shell command '%s'", @@ -198,7 +198,7 @@ openPnmremapStream(const char * const inputFileName, else *pnmremapPipeP = pnmremapPipe; - strfree(pnmremapCommand); + pm_strfree(pnmremapCommand); } @@ -221,39 +221,39 @@ pamtogifCommand(const char * const arg0, struct stat statbuf; - asprintfN(&progName, "%s/%s", arg0DirName, pamtogifName); + pm_asprintf(&progName, "%s/%s", arg0DirName, pamtogifName); if (stat(progName, &statbuf) == 0) commandVerb = progName; else commandVerb = strdup(pamtogifName); - strfree(arg0DirName); + pm_strfree(arg0DirName); } else commandVerb = strdup(pamtogifName); if (cmdline.transparent) - asprintfN(&transparentOpt, "-transparent=%s", cmdline.transparent); + pm_asprintf(&transparentOpt, "-transparent=%s", cmdline.transparent); else transparentOpt = strdup(""); if (cmdline.comment) - asprintfN(&commentOpt, "-comment=%s", cmdline.comment); + pm_asprintf(&commentOpt, "-comment=%s", cmdline.comment); else commentOpt = strdup(""); - asprintfN(&retval, "%s - -alphacolor=%s %s %s %s %s %s %s", - commandVerb, - cmdline.alphacolor, - cmdline.interlace ? "-interlace" : "", - cmdline.sort ? "-sort" : "", - transparentOpt, - commentOpt, - cmdline.nolzw ? "-nolzw" : "", - cmdline.verbose ? "-verbose" : ""); + pm_asprintf(&retval, "%s - -alphacolor=%s %s %s %s %s %s %s", + commandVerb, + cmdline.alphacolor, + cmdline.interlace ? "-interlace" : "", + cmdline.sort ? "-sort" : "", + transparentOpt, + commentOpt, + cmdline.nolzw ? "-nolzw" : "", + cmdline.verbose ? "-verbose" : ""); - strfree(transparentOpt); - strfree(commentOpt); + pm_strfree(transparentOpt); + pm_strfree(commentOpt); return retval; } @@ -413,7 +413,7 @@ main(int argc, if (rc != 0) pm_error("Pamtogif process failed. pclose() failed."); - strfree(command); + pm_strfree(command); pm_close(ifP); pm_close(stdout); diff --git a/converter/ppm/ppmtompeg/combine.c b/converter/ppm/ppmtompeg/combine.c index 8e0d3281..c00f9c71 100644 --- a/converter/ppm/ppmtompeg/combine.c +++ b/converter/ppm/ppmtompeg/combine.c @@ -104,7 +104,7 @@ appendSpecifiedGopFiles(struct inputSource * const inputSourceP, FILE * ifP; GetNthInputFileName(inputSourceP, fileSeq, &inputFileName); - asprintfN(&fileName, "%s/%s", currentGOPPath, inputFileName); + pm_asprintf(&fileName, "%s/%s", currentGOPPath, inputFileName); for (nAttempts = 0, ifP = NULL; nAttempts < READ_ATTEMPTS && !ifP; @@ -122,8 +122,8 @@ appendSpecifiedGopFiles(struct inputSource * const inputSourceP, } else pm_error("Unable to read file '%s' after %u attempts.", fileName, READ_ATTEMPTS); - strfree(fileName); - strfree(inputFileName); + pm_strfree(fileName); + pm_strfree(inputFileName); } } @@ -140,7 +140,7 @@ appendDefaultGopFiles(const char * const outputFileName, const char * fileName; FILE * ifP; - asprintfN(&fileName, "%s.gop.%u", outputFileName, fileSeq); + pm_asprintf(&fileName, "%s.gop.%u", outputFileName, fileSeq); ifP = fopen(fileName, "rb"); if (ifP == NULL) @@ -151,7 +151,7 @@ appendDefaultGopFiles(const char * const outputFileName, AppendFile(ofP, ifP); } - strfree(fileName); + pm_strfree(fileName); } } diff --git a/converter/ppm/ppmtompeg/input.c b/converter/ppm/ppmtompeg/input.c index 2b87afa7..4266d39b 100644 --- a/converter/ppm/ppmtompeg/input.c +++ b/converter/ppm/ppmtompeg/input.c @@ -104,17 +104,17 @@ GetNthInputFileName(struct inputSource * const inputSourceP, } if (mapNEntryP->repeat != TRUE) - asprintfN(fileNameP, "%s%s%s", - mapNEntryP->left, &numBuffer[32-numPadding], - mapNEntryP->right); + pm_asprintf(fileNameP, "%s%s%s", + mapNEntryP->left, &numBuffer[32-numPadding], + mapNEntryP->right); else - asprintfN(fileNameP, "%s", mapNEntryP->left); + pm_asprintf(fileNameP, "%s", mapNEntryP->left); } else { if (mapNEntryP->repeat != TRUE) - asprintfN(fileNameP, "%s%d%s", - mapNEntryP->left, index, mapNEntryP->right); + pm_asprintf(fileNameP, "%s%d%s", + mapNEntryP->left, index, mapNEntryP->right); else - asprintfN(fileNameP, "%s", mapNEntryP->left); + pm_asprintf(fileNameP, "%s", mapNEntryP->left); } lastN = n; diff --git a/converter/ppm/ppmtompeg/mpeg.c b/converter/ppm/ppmtompeg/mpeg.c index 6557f377..a00a1bb6 100644 --- a/converter/ppm/ppmtompeg/mpeg.c +++ b/converter/ppm/ppmtompeg/mpeg.c @@ -413,11 +413,11 @@ bitioNew(const char * const outputFileName, else { const char * fileName; - asprintfN(&fileName, "%s.frame.%d", outputFileName, frameNumber); + pm_asprintf(&fileName, "%s.frame.%d", outputFileName, frameNumber); bbP = Bitio_New_Filename(fileName); - strfree(fileName); + pm_strfree(fileName); } return bbP; } @@ -771,12 +771,12 @@ doFirstFrameStuff(enum frameContext const context, time_t now; time(&now); - asprintfN(&userDataString,"MPEG stream encoded by UCB Encoder " - "(mpeg_encode) v%s on %s.", - VERSION, ctime(&now)); + pm_asprintf(&userDataString,"MPEG stream encoded by UCB Encoder " + "(mpeg_encode) v%s on %s.", + VERSION, ctime(&now)); userData = strdup(userDataString); userDataSize = strlen(userData); - strfree(userDataString); + pm_strfree(userDataString); } Mhead_GenSequenceHeader(bbP, Fsize_x, Fsize_y, /* pratio */ aspectRatio, @@ -1322,12 +1322,12 @@ PrintStartStats(time_t const startTime, GetNthInputFileName(inputSourceP, 0, &inputFileName); fprintf(fpointer, "FIRST FILE: %s/%s\n", currentPath, inputFileName); - strfree(inputFileName); + pm_strfree(inputFileName); GetNthInputFileName(inputSourceP, inputSourceP->numInputFiles-1, &inputFileName); fprintf(fpointer, "LAST FILE: %s/%s\n", currentPath, inputFileName); - strfree(inputFileName); + pm_strfree(inputFileName); } fprintf(fpointer, "OUTPUT: %s\n", outputFileName); diff --git a/converter/ppm/ppmtompeg/parallel.c b/converter/ppm/ppmtompeg/parallel.c index 97cb9f84..9bc695a6 100644 --- a/converter/ppm/ppmtompeg/parallel.c +++ b/converter/ppm/ppmtompeg/parallel.c @@ -156,7 +156,7 @@ machineDebug(const char format[], ...) { if (debugMachines) { const char * const hostname = GetHostName(); fprintf(stderr, "%s: ---", hostname); - strfree(hostname); + pm_strfree(hostname); vfprintf(stderr, format, args); fputc('\n', stderr); } @@ -175,7 +175,7 @@ errorExit(const char format[], ...) { va_start(args, format); fprintf(stderr, "%s: FATAL ERROR. ", hostname); - strfree(hostname); + pm_strfree(hostname); vfprintf(stderr, format, args); fputc('\n', stderr); @@ -767,13 +767,13 @@ routeFromSocketToDisk(int const otherSock, ReadBytes(otherSock, bigBuffer, numBytes); /* open file to output this stuff to */ - asprintfN(&fileName, "%s.frame.%d", outputFileName, frameNumber); + pm_asprintf(&fileName, "%s.frame.%d", outputFileName, frameNumber); filePtr = fopen(fileName, "wb"); if (filePtr == NULL) errorExit("I/O SERVER: Could not open output file(3): %s", fileName); - strfree(fileName); + pm_strfree(fileName); /* now write the bytes here */ fwrite(bigBuffer, sizeof(char), numBytes, filePtr); @@ -1246,11 +1246,11 @@ waitForOutputFile(void * const inputHandle, } machineDebug("COMBINE SERVER: Wait for frame %u over", frameNumber); - asprintfN(&fileName, "%s.frame.%u", outputFileName, frameNumber); + pm_asprintf(&fileName, "%s.frame.%u", outputFileName, frameNumber); openInputFile(fileName, ifPP); - strfree(fileName); + pm_strfree(fileName); } } @@ -1263,11 +1263,11 @@ unlinkFile(void * const inputHandle, if (!keepTempFiles) { const char * fileName; - asprintfN(&fileName, "%s.frame.%u", outputFileName, frameNumber); + pm_asprintf(&fileName, "%s.frame.%u", outputFileName, frameNumber); unlink(fileName); - strfree(fileName); + pm_strfree(fileName); } } @@ -1340,13 +1340,13 @@ startCombineServer(const char * const encoderName, int otherSock; const char * error; - snprintfN(command, sizeof(command), - "%s %s -max_machines %d -output_server %s %d %d %s", - encoderName, - debugMachines ? "-debug_machines" : "", - numMachines, masterHostName, masterPortNum, - numInputFiles, paramFileName); - + pm_snprintf(command, sizeof(command), + "%s %s -max_machines %d -output_server %s %d %d %s", + encoderName, + debugMachines ? "-debug_machines" : "", + numMachines, masterHostName, masterPortNum, + numInputFiles, paramFileName); + machineDebug("MASTER: Starting combine server with shell command '%s'", command); @@ -1382,12 +1382,12 @@ startDecodeServer(const char * const encoderName, int otherSock; const char * error; - snprintfN(command, sizeof(command), - "%s %s -max_machines %d -decode_server %s %d %d %s", - encoder_name, - debugMachines ? "-debug_machines" : "", - numMachines, masterHostName, masterPortNum, - numInputFiles, paramFileName); + pm_snprintf(command, sizeof(command), + "%s %s -max_machines %d -decode_server %s %d %d %s", + encoder_name, + debugMachines ? "-debug_machines" : "", + numMachines, masterHostName, masterPortNum, + numInputFiles, paramFileName); machineDebug("MASTER: Starting decode server with shell command '%s'", command); @@ -1680,21 +1680,21 @@ startChildren(struct scheduler * const schedulerP, } --childrenLeftCurrentIoServer; } - snprintfN(command, sizeof(command), - "%s %s -l %s %s " - "%s %s -child %s %d %d %d %d %d %d " - "-frames %d %d %s", - rsh, - machineName[childNum], userName[childNum], - beNice ? "nice" : "", - executable[childNum], - debugMachines ? "-debug_machines" : "", - masterHostName, masterPortNum, - remote[childNum] ? ioPortNum[numIoServers-1] : 0, - combinePortNum, decodePortNum, childNum, - remote[childNum] ? 1 : 0, - startFrame, startFrame + nFrames - 1, - remote[childNum] ? + pm_snprintf(command, sizeof(command), + "%s %s -l %s %s " + "%s %s -child %s %d %d %d %d %d %d " + "-frames %d %d %s", + rsh, + machineName[childNum], userName[childNum], + beNice ? "nice" : "", + executable[childNum], + debugMachines ? "-debug_machines" : "", + masterHostName, masterPortNum, + remote[childNum] ? ioPortNum[numIoServers-1] : 0, + combinePortNum, decodePortNum, childNum, + remote[childNum] ? 1 : 0, + startFrame, startFrame + nFrames - 1, + remote[childNum] ? remoteParamFile[childNum] : paramFileName ); @@ -2070,7 +2070,7 @@ MasterServer(struct inputSource * const inputSourceP, fclose(statFile); free(childState); - strfree(hostName); + pm_strfree(hostName); } diff --git a/converter/ppm/ppmtompeg/param.c b/converter/ppm/ppmtompeg/param.c index a145d33c..15f13473 100644 --- a/converter/ppm/ppmtompeg/param.c +++ b/converter/ppm/ppmtompeg/param.c @@ -988,7 +988,7 @@ ReadParamFile(const char * const fileName, paramP); /* May read additional lines from file */ - strfree(input); + pm_strfree(input); } fclose(fpointer); diff --git a/converter/ppm/ppmtompeg/ppmtompeg.c b/converter/ppm/ppmtompeg/ppmtompeg.c index f53ffea9..1440d88c 100644 --- a/converter/ppm/ppmtompeg/ppmtompeg.c +++ b/converter/ppm/ppmtompeg/ppmtompeg.c @@ -335,9 +335,9 @@ announceJob(enum frameContext const context, const char * combineDest; if (context == CONTEXT_JUSTFRAMES) - asprintfN(&outputDest, "to individual frame files"); + pm_asprintf(&outputDest, "to individual frame files"); else - asprintfN(&outputDest, "to file '%s'", outputFileName); + pm_asprintf(&outputDest, "to file '%s'", outputFileName); if (childProcess) combineDest = strdup("for delivery to combine server"); @@ -347,8 +347,8 @@ announceJob(enum frameContext const context, pm_message("%s: ENCODING FRAMES %u-%u to %s %s", hostname, frameStart, frameEnd, outputDest, combineDest); - strfree(combineDest); - strfree(outputDest); + pm_strfree(combineDest); + pm_strfree(outputDest); } } @@ -540,15 +540,15 @@ getUserFrameFile(void * const handle, GetNthInputFileName(inputSourceP, frameNumber, &inputFileName); - asprintfN(&fileName, "%s/%s", currentFramePath, inputFileName); + pm_asprintf(&fileName, "%s/%s", currentFramePath, inputFileName); *ifPP = fopen(fileName, "rb"); if (*ifPP == NULL) pm_error("Unable to open file '%s'. Errno = %d (%s)", fileName, errno, strerror(errno)); - strfree(inputFileName); - strfree(fileName); + pm_strfree(inputFileName); + pm_strfree(fileName); } } @@ -702,7 +702,7 @@ main(int argc, char **argv) { } Frame_Exit(); - strfree(hostname); + pm_strfree(hostname); return 0; } diff --git a/converter/ppm/ppmtompeg/psocket.c b/converter/ppm/ppmtompeg/psocket.c index 707f1d84..6a50dc27 100644 --- a/converter/ppm/ppmtompeg/psocket.c +++ b/converter/ppm/ppmtompeg/psocket.c @@ -91,7 +91,7 @@ errorExit(const char format[], ...) { va_start(args, format); fprintf(stderr, "%s: FATAL ERROR. ", hostname); - strfree(hostname); + pm_strfree(hostname); vfprintf(stderr, format, args); fputc('\n', stderr); @@ -272,13 +272,13 @@ ConnectToSocket(const char * const machineName, if ((*hostEnt) == NULL) { (*hostEnt) = gethostbyname(machineName); if ((*hostEnt) == NULL) - asprintfN(errorP, "Couldn't get host by name (%s)", machineName); + pm_asprintf(errorP, "Couldn't get host by name (%s)", machineName); } if (!*errorP) { rc = socket(AF_INET, SOCK_STREAM, 0); if (rc < 0) - asprintfN(errorP, "socket() failed with errno %d (%s)", - errno, strerror(errno)); + pm_asprintf(errorP, "socket() failed with errno %d (%s)", + errno, strerror(errno)); else { int const socketFd = rc; @@ -298,10 +298,10 @@ ConnectToSocket(const char * const machineName, sizeof(struct sockaddr)); if (rc != 0) - asprintfN(errorP, - "connect() to host '%s', port %d failed with " - "errno %d (%s)", - machineName, portNum, errno, strerror(errno)); + pm_asprintf(errorP, + "connect() to host '%s', port %d failed with " + "errno %d (%s)", + machineName, portNum, errno, strerror(errno)); else { *errorP = NULL; *socketFdP = socketFd; @@ -364,14 +364,14 @@ bindToUnusedPort(int const socketFd, foundPort = TRUE; *portNumP = trialPortNum; } else if (!portInUseErrno(errno)) - asprintfN(errorP, "bind() of TCP port number %hu failed " - "with errno %d (%s)", - trialPortNum, errno, strerror(errno)); + pm_asprintf(errorP, "bind() of TCP port number %hu failed " + "with errno %d (%s)", + trialPortNum, errno, strerror(errno)); } if (!*errorP && !foundPort) - asprintfN(errorP, "Unable to find a free port. Every TCP port " - "in the range 2048-16383 is in use"); + pm_asprintf(errorP, "Unable to find a free port. Every TCP port " + "in the range 2048-16383 is in use"); } @@ -392,10 +392,10 @@ CreateListeningSocket(int * const socketP, rc = socket(AF_INET, SOCK_STREAM, 0); if (rc < 0) - asprintfN(errorP, - "Unable to create socket. " - "socket() failed with errno %d (%s)", - errno, strerror(errno)); + pm_asprintf(errorP, + "Unable to create socket. " + "socket() failed with errno %d (%s)", + errno, strerror(errno)); else { int const socketFd = rc; @@ -414,9 +414,9 @@ CreateListeningSocket(int * const socketP, */ rc = listen(socketFd, SOMAXCONN); if (rc != 0) - asprintfN(errorP, "Unable to listen on TCP socket. " - "listen() fails with errno %d (%s)", - errno, strerror(errno)); + pm_asprintf(errorP, "Unable to listen on TCP socket. " + "listen() fails with errno %d (%s)", + errno, strerror(errno)); } if (*errorP) close(socketFd); @@ -443,8 +443,8 @@ AcceptConnection(int const listenSocketFd, rc = accept(listenSocketFd, &otherSocket, &otherSize); if (rc < 0) - asprintfN(errorP, "accept() failed with errno %d (%s). ", - errno, strerror(errno)); + pm_asprintf(errorP, "accept() failed with errno %d (%s). ", + errno, strerror(errno)); else { *connectSocketFdP = rc; *errorP = NULL; diff --git a/converter/ppm/ppmtompeg/rate.c b/converter/ppm/ppmtompeg/rate.c index 1a44cb95..0f1bcac1 100644 --- a/converter/ppm/ppmtompeg/rate.c +++ b/converter/ppm/ppmtompeg/rate.c @@ -236,7 +236,7 @@ analyzePattern(const char * const framePattern, case 'p': ++*gop_pP; break; case 'b': ++*gop_bP; break; default: - asprintfN(errorP, "Bad pattern - not composed of i, p, and b"); + pm_asprintf(errorP, "Bad pattern - not composed of i, p, and b"); } } assert(*gop_xP == *gop_iP + *gop_pP + *gop_bP); @@ -285,7 +285,7 @@ initRateControl(bool const wantUnderflowWarning, if (error) { pm_message("Unable to set up rate control. Switching to variable. " "%s", error); - strfree(error); + pm_strfree(error); RateControlMode = VARIABLE_RATE; return -1; } diff --git a/converter/ppm/ppmtompeg/readframe.c b/converter/ppm/ppmtompeg/readframe.c index d1423c1f..112ebdf0 100644 --- a/converter/ppm/ppmtompeg/readframe.c +++ b/converter/ppm/ppmtompeg/readframe.c @@ -155,7 +155,7 @@ openFile(struct inputSource * const inputSourceP, GetNthInputFileName(inputSourceP, frameNumber, &fileName); - asprintfN(&fullFileName, "%s/%s", currentPath, fileName); + pm_asprintf(&fullFileName, "%s/%s", currentPath, fileName); CurrFile = fullFileName; @@ -207,8 +207,8 @@ openFile(struct inputSource * const inputSourceP, if (baseFormat == JMOVIE_FILE_TYPE) unlink(fullFileName); } - strfree(fullFileName); - strfree(fileName); + pm_strfree(fullFileName); + pm_strfree(fileName); } } @@ -377,10 +377,10 @@ ReadFrame(MpegFrame * const frameP, void SetFileType(const char * const conversion) { - if ( strcmp(conversion, "*") == 0 ) { - fileType = BASE_FILE_TYPE; + if (streq(conversion, "*")) { + fileType = BASE_FILE_TYPE; } else { - fileType = ANY_FILE_TYPE; + fileType = ANY_FILE_TYPE; } } @@ -399,23 +399,23 @@ SetFileType(const char * const conversion) void SetFileFormat(const char * const format) { - if ( strcmp(format, "PPM") == 0 ) { - baseFormat = PNM_FILE_TYPE; - } else if ( strcmp(format, "YUV") == 0 ) { - baseFormat = YUV_FILE_TYPE; - } else if ( strcmp(format, "Y") == 0 ) { - baseFormat = Y_FILE_TYPE; - } else if ( strcmp(format, "PNM") == 0 ) { - baseFormat = PNM_FILE_TYPE; - } else if (( strcmp(format, "JPEG") == 0 ) || ( strcmp(format, "JPG") == 0 )) { - baseFormat = JPEG_FILE_TYPE; - } else if ( strcmp(format, "JMOVIE") == 0 ) { - baseFormat = JMOVIE_FILE_TYPE; - } else if ( strcmp(format, "SUB4") == 0 ) { - baseFormat = SUB4_FILE_TYPE; + if (streq(format, "PPM")) { + baseFormat = PNM_FILE_TYPE; + } else if (streq(format, "YUV")) { + baseFormat = YUV_FILE_TYPE; + } else if (streq(format, "Y")) { + baseFormat = Y_FILE_TYPE; + } else if (streq(format, "PNM")) { + baseFormat = PNM_FILE_TYPE; + } else if (streq(format, "JPEG") || streq(format, "JPG")) { + baseFormat = JPEG_FILE_TYPE; + } else if (streq(format, "JMOVIE")) { + baseFormat = JMOVIE_FILE_TYPE; + } else if (streq(format, "SUB4")) { + baseFormat = SUB4_FILE_TYPE; } else { - fprintf(stderr, "ERROR: Invalid file format: %s\n", format); - exit(1); + fprintf(stderr, "ERROR: Invalid file format: %s\n", format); + exit(1); } } @@ -435,9 +435,9 @@ ReadIOConvert(struct inputSource * const inputSourceP, GetNthInputFileName(inputSourceP, frameNumber, &fileName); - asprintfN(&fullFileName, "%s/%s", currentPath, fileName); + pm_asprintf(&fullFileName, "%s/%s", currentPath, fileName); - if ( strcmp(ioConversion, "*") == 0 ) { + if (streq(ioConversion, "*")) { char buff[1024]; ifp = fopen(fullFileName, "rb"); sprintf(buff,"fopen \"%s\"",fullFileName); @@ -483,8 +483,8 @@ ReadIOConvert(struct inputSource * const inputSourceP, exit(1); } - strfree(fullFileName); - strfree(fileName); + pm_strfree(fullFileName); + pm_strfree(fileName); return ifp; } diff --git a/converter/ppm/ppmtowinicon.c b/converter/ppm/ppmtowinicon.c index be07fcc8..faa6a5ac 100644 --- a/converter/ppm/ppmtowinicon.c +++ b/converter/ppm/ppmtowinicon.c @@ -529,9 +529,9 @@ makePalette(pixel ** const xorPPMarray, xorChv = ppm_computecolorhist(xorPPMarray, xorCols, xorRows, MAXCOLORS, &colors); if (xorChv == NULL) - asprintfN(errorP, - "image has too many colors - try doing a 'pnmquant %d'", - MAXCOLORS); + pm_asprintf(errorP, + "image has too many colors - try doing a 'pnmquant %d'", + MAXCOLORS); else { *errorP = NULL; @@ -589,10 +589,10 @@ getOrFakeAndMap(const char * const andPgmFname, pm_close(andfile); if ((andCols != xorCols) || (andRows != xorRows)) { - asprintfN(errorP, - "And mask and image have different dimensions " - "(%d x %d vs %d x %d). Aborting.", - andCols, xorCols, andRows, xorRows); + pm_asprintf(errorP, + "And mask and image have different dimensions " + "(%d x %d vs %d x %d). Aborting.", + andCols, xorCols, andRows, xorRows); } else *errorP = NULL; } diff --git a/converter/ppm/ppmtoxpm.c b/converter/ppm/ppmtoxpm.c index 0b6aea84..ff47359b 100644 --- a/converter/ppm/ppmtoxpm.c +++ b/converter/ppm/ppmtoxpm.c @@ -363,13 +363,13 @@ genCmap(colorhist_vector const chv, PPM_DEPTH(scaledColor, color, maxval, xpmMaxval); - asprintfN(&hexString, xpmMaxval == 0x000F ? "#%X%X%X" : - xpmMaxval == 0x00FF ? "#%02X%02X%02X" : - xpmMaxval == 0x0FFF ? "#%03X%03X%03X" : - "#%04X%04X%04X", - PPM_GETR(scaledColor), - PPM_GETG(scaledColor), - PPM_GETB(scaledColor) + pm_asprintf(&hexString, xpmMaxval == 0x000F ? "#%X%X%X" : + xpmMaxval == 0x00FF ? "#%02X%02X%02X" : + xpmMaxval == 0x0FFF ? "#%03X%03X%03X" : + "#%04X%04X%04X", + PPM_GETR(scaledColor), + PPM_GETG(scaledColor), + PPM_GETB(scaledColor) ); if (hexString == NULL) @@ -399,7 +399,7 @@ destroyCmap(cixel_map * const cmap, int i; /* Free the real color entries */ for (i = 0; i < cmapSize; i++) { - strfree(cmap[i].rgbname); + pm_strfree(cmap[i].rgbname); free(cmap[i].cixel); } free(cmap); diff --git a/converter/ppm/winicontoppm.c b/converter/ppm/winicontoppm.c index 98fe0934..014eab40 100644 --- a/converter/ppm/winicontoppm.c +++ b/converter/ppm/winicontoppm.c @@ -639,11 +639,11 @@ writeXors(FILE * const multiOutF, } else { if (outputFileBase) { if (multiple) { - asprintfN(&outputFile, "%s%s_%d.ppm", - outputFileBase,(xor ? "_xor" : ""), entryNum); + pm_asprintf(&outputFile, "%s%s_%d.ppm", + outputFileBase,(xor ? "_xor" : ""), entryNum); } else { - asprintfN(&outputFile, "%s%s.ppm", - outputFileBase,(xor ? "_xor" : "")); + pm_asprintf(&outputFile, "%s%s.ppm", + outputFileBase,(xor ? "_xor" : "")); } } else outputFile = strdup("-"); @@ -690,7 +690,7 @@ writeXors(FILE * const multiOutF, (pixval) maxval, forcetext); ppm_freearray(ppm_array,entry->height); - strfree(outputFile); + pm_strfree(outputFile); if (!multiOutF) pm_close(outF); @@ -727,11 +727,12 @@ writeAnds(FILE * const multiOutF, assert(outputFileBase); if (multiple) - asprintfN(&outputFile, "%s_and_%d.pbm", outputFileBase, entryNum); + pm_asprintf(&outputFile, "%s_and_%d.pbm", + outputFileBase, entryNum); else - asprintfN(&outputFile, "%s_and.pbm", outputFileBase); + pm_asprintf(&outputFile, "%s_and.pbm", outputFileBase); outF = pm_openw(outputFile); - strfree(outputFile); + pm_strfree(outputFile); } pbm_array = pbm_allocarray(entry->width, entry->height); for (row=0; row < entry->height; row++) { @@ -760,8 +761,8 @@ openMultiXor(char outputFileBase[], const char *outputFile; if (outputFileBase) { - asprintfN(&outputFile, "%s%s.ppm", - outputFileBase, (writeands ? "_xor" : "")); + pm_asprintf(&outputFile, "%s%s.ppm", + outputFileBase, (writeands ? "_xor" : "")); } else outputFile = strdup("-"); @@ -770,7 +771,7 @@ openMultiXor(char outputFileBase[], */ *multiOutFP = pm_openw(outputFile); - strfree(outputFile); + pm_strfree(outputFile); } @@ -782,11 +783,11 @@ openMultiAnd(char outputFileBase[], FILE ** const multiAndOutFP) { assert(outputFileBase); - asprintfN(&outputFile, "%s_and.pbm", outputFileBase); + pm_asprintf(&outputFile, "%s_and.pbm", outputFileBase); *multiAndOutFP = pm_openw(outputFile); - strfree(outputFile); + pm_strfree(outputFile); } static void free_iconentry(IC_Entry entry) { diff --git a/converter/ppm/yuvsplittoppm.c b/converter/ppm/yuvsplittoppm.c index 029cec00..5343a21e 100644 --- a/converter/ppm/yuvsplittoppm.c +++ b/converter/ppm/yuvsplittoppm.c @@ -196,9 +196,9 @@ main(int argc, char **argv) { parseCommandLine(argc, argv, &cmdline); - asprintfN(&ufname, "%s.U", cmdline.filenameBase); - asprintfN(&vfname, "%s.V", cmdline.filenameBase); - asprintfN(&yfname, "%s.Y", cmdline.filenameBase); + pm_asprintf(&ufname, "%s.U", cmdline.filenameBase); + pm_asprintf(&vfname, "%s.V", cmdline.filenameBase); + pm_asprintf(&yfname, "%s.Y", cmdline.filenameBase); uf = pm_openr(ufname); vf = pm_openr(vfname); @@ -241,9 +241,9 @@ main(int argc, char **argv) { } pm_close(stdout); - strfree(yfname); - strfree(vfname); - strfree(ufname); + pm_strfree(yfname); + pm_strfree(vfname); + pm_strfree(ufname); pm_close(yf); pm_close(uf); -- cgit 1.4.1