about summary refs log tree commit diff
path: root/converter/pbm
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-12-30 03:44:25 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2010-12-30 03:44:25 +0000
commitb467d3b440793b3e7876bdff3d2288caf25b179b (patch)
tree8d9398127b697a7e95e86e7ad89d5acf90bbe305 /converter/pbm
parent6aa47353c078efc71453aa24aeda722890b62b4f (diff)
parenteab9577b9f050e694c3420e42c6a12417a55968b (diff)
downloadnetpbm-mirror-b467d3b440793b3e7876bdff3d2288caf25b179b.tar.gz
netpbm-mirror-b467d3b440793b3e7876bdff3d2288caf25b179b.tar.xz
netpbm-mirror-b467d3b440793b3e7876bdff3d2288caf25b179b.zip
Rebase to trunk as Release 10.53
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@1382 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/pbm')
-rw-r--r--converter/pbm/Makefile10
-rw-r--r--converter/pbm/g3topbm.c52
-rw-r--r--converter/pbm/icontopbm.c159
-rw-r--r--converter/pbm/pbmtoepsi.c2
-rw-r--r--converter/pbm/pbmtoepson.c4
-rw-r--r--converter/pbm/pbmtoescp2.c2
-rw-r--r--converter/pbm/pbmtog3.c2
-rw-r--r--converter/pbm/pbmtoibm23xx.c2
-rw-r--r--converter/pbm/pbmtolj.c2
-rw-r--r--converter/pbm/pbmtonokia.c8
-rw-r--r--converter/pbm/pbmtopsg3.c2
-rw-r--r--converter/pbm/pbmtoxbm.c6
-rw-r--r--converter/pbm/thinkjettopbm.l4
13 files changed, 52 insertions, 203 deletions
diff --git a/converter/pbm/Makefile b/converter/pbm/Makefile
index 0461eedc..07b768c0 100644
--- a/converter/pbm/Makefile
+++ b/converter/pbm/Makefile
@@ -9,7 +9,7 @@ include $(BUILDDIR)/config.mk
 
 PORTBINARIES =	atktopbm brushtopbm cistopbm cmuwmtopbm \
 		ddbugtopbm g3topbm escp2topbm \
-		icontopbm macptopbm mdatopbm mgrtopbm mrftopbm \
+		macptopbm mdatopbm mgrtopbm mrftopbm \
 		pbmto10x pbmto4425 pbmtoascii pbmtoatk \
 		pbmtobbnbg pbmtocis pbmtocmuwm pbmtodjvurle \
 		pbmtoepsi pbmtoepson pbmtoescp2 \
@@ -73,6 +73,14 @@ thinkjettopbm.c:%.c:%.c1 $(SRCDIR)/lib/util/lexheader
 	  grep -v "^[[:space:]]*int yywrap(void);" \
 	  >$@
 
+install.bin: install.bin.local
+.PHONY: install.bin.local
+install.bin.local: $(PKGDIR)/bin
+# Remember that $(SYMLINK) might just be a copy command.
+# In December 2010, sunicontopnm replaced icontopbm
+	cd $(PKGDIR)/bin ; \
+	$(SYMLINK) sunicontopnm icontopbm
+
 thisdirclean: localclean
 .PHONY: localclean
 localclean:
diff --git a/converter/pbm/g3topbm.c b/converter/pbm/g3topbm.c
index 66cd9f9e..908008a9 100644
--- a/converter/pbm/g3topbm.c
+++ b/converter/pbm/g3topbm.c
@@ -97,7 +97,7 @@ parseCommandLine(int argc, char ** const argv,
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;  /* We may have parms that are negative numbers */
 
-    optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
     if (widthSpec && paper_sizeSpec)
@@ -169,7 +169,7 @@ readBit(struct bitStream * const bitStreamP,
     if ((bitStreamP->shbit & 0xff) == 0) {
         bitStreamP->shdata = getc(bitStreamP->fileP);
         if (bitStreamP->shdata == EOF)
-            asprintfN(errorP, "EOF or error reading file");
+            pm_asprintf(errorP, "EOF or error reading file");
         else {
             bitStreamP->shbit = 0x80;
             if ( bitStreamP->reversebits )
@@ -428,12 +428,12 @@ formatBadCodeException(const char ** const exceptionP,
                        unsigned int  const curlen,
                        unsigned int  const curcode) {
 
-    asprintfN(exceptionP,
-        "bad code word at Column %u.  "
-        "No prefix of the %u bits 0x%x matches any recognized "
-        "code word and no code words longer than 12 bits are "
-        "defined.  ",
-        col, curlen, curcode);
+    pm_asprintf(exceptionP,
+                "bad code word at Column %u.  "
+                "No prefix of the %u bits 0x%x matches any recognized "
+                "code word and no code words longer than 12 bits are "
+                "defined.  ",
+                col, curlen, curcode);
 }
 
 
@@ -485,8 +485,8 @@ readFaxRow(struct bitStream * const bitStreamP,
 
     while (!done) {
         if (col >= MAXCOLS) {
-            asprintfN(exceptionP, "Line is too long for this program to "
-                      "handle -- longer than %u columns", MAXCOLS);
+            pm_asprintf(exceptionP, "Line is too long for this program to "
+                        "handle -- longer than %u columns", MAXCOLS);
             done = TRUE;
         } else {
             unsigned int bit;
@@ -570,7 +570,7 @@ handleRowException(const char * const exception,
                        row, exception);
         else
             pm_error("Problem reading Row %u.  Aborting.  %s", row, exception);
-        strfree(exception);
+        pm_strfree(exception);
     }
 
     if (error) {
@@ -579,7 +579,7 @@ handleRowException(const char * const exception,
                        row, error);
         else
             pm_error("Unable to read Row %u.  Aborting.  %s", row, error);
-        strfree(error);
+        pm_strfree(error);
     }
 }
 
@@ -626,16 +626,16 @@ analyzeLineSize(lineSizeAnalyzer * const analyzerP,
 
     if (analyzerP->expectedLineSize &&
         thisLineSize != analyzerP->expectedLineSize)
-        asprintfN(&error, "Image contains a line of %u pixels.  "
-                  "You specified lines should be %u pixels.",
-                  thisLineSize, analyzerP->expectedLineSize);
+        pm_asprintf(&error, "Image contains a line of %u pixels.  "
+                    "You specified lines should be %u pixels.",
+                    thisLineSize, analyzerP->expectedLineSize);
     else {
         if (analyzerP->maxLineSize && thisLineSize != analyzerP->maxLineSize)
-            asprintfN(&error, "There are at least two different "
-                      "line lengths in this image, "
-                      "%u pixels and %u pixels.  "
-                      "This is a violation of the G3 standard.  ",
-                      thisLineSize, analyzerP->maxLineSize);
+            pm_asprintf(&error, "There are at least two different "
+                        "line lengths in this image, "
+                        "%u pixels and %u pixels.  "
+                        "This is a violation of the G3 standard.  ",
+                        thisLineSize, analyzerP->maxLineSize);
         else
             error = NULL;
     }
@@ -649,7 +649,7 @@ analyzeLineSize(lineSizeAnalyzer * const analyzerP,
         } else
             pm_error("%s", error);
 
-        strfree(error);
+        pm_strfree(error);
     }
     analyzerP->maxLineSize = MAX(thisLineSize, analyzerP->maxLineSize);
 }
@@ -693,8 +693,8 @@ readFax(struct bitStream * const bitStreamP,
         unsigned int lineSize;
 
         if (row >= MAXROWS)
-            asprintfN(&error, "Image is too tall.  This program can "
-                      "handle at most %u rows", MAXROWS);
+            pm_asprintf(&error, "Image is too tall.  This program can "
+                        "handle at most %u rows", MAXROWS);
         else {
             const char * exception;
 
@@ -714,9 +714,9 @@ readFax(struct bitStream * const bitStreamP,
                     if (stretch) {
                         ++row;
                         if (row >= MAXROWS)
-                            asprintfN(&error, "Image is too tall.  This "
-                                      "program can handle at most %u rows "
-                                      "after stretching", MAXROWS);
+                            pm_asprintf(&error, "Image is too tall.  This "
+                                        "program can handle at most %u rows "
+                                        "after stretching", MAXROWS);
                         else
                             packedBits[row] = packedBits[row-1];
                     }
diff --git a/converter/pbm/icontopbm.c b/converter/pbm/icontopbm.c
deleted file mode 100644
index a0d1bd2b..00000000
--- a/converter/pbm/icontopbm.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/* icontopbm.c - read a Sun icon file and produce a portable bitmap
-**
-** Copyright (C) 1988 by Jef Poskanzer.
-**
-** Permission to use, copy, modify, and distribute this software and its
-** documentation for any purpose and without fee is hereby granted, provided
-** that the above copyright notice appear in all copies and that both that
-** copyright notice and this permission notice appear in supporting
-** documentation.  This software is provided "as is" without express or
-** implied warranty.
-*/
-
-#include <string.h>
-
-#include "nstring.h"
-#include "pbm.h"
-
-/* size in bytes of a bitmap */
-#define BitmapSize(width, height) (((((width) + 15) >> 3) &~ 1) * (height))
-
-static void
-ReadIconFile(FILE *                const file, 
-             int *                 const widthP, 
-             int *                 const heightP, 
-             short unsigned int ** const dataP) {
-
-    char variable[80+1];
-    int ch;
-    int status, value, i, data_length, gotsome;
-
-    gotsome = 0;
-    *widthP = *heightP = -1;
-    for ( ; ; )
-    {
-        while ( ( ch = getc( file ) ) == ',' || ch == '\n' || ch == '\t' ||
-                ch == ' ' )
-            ;
-        for ( i = 0;
-              ch != '=' && ch != ',' && ch != '\n' && ch != '\t' && 
-                  ch != ' ' && (i < (sizeof(variable) - 1));
-              i++ )
-        {
-            variable[i] = ch;
-            if ((ch = getc( file )) == EOF)
-                pm_error( "invalid input file -- premature EOF" );
-        }
-        variable[i] = '\0';
-
-        if ( streq( variable, "*/" )&& gotsome )
-            break;
-
-        if ( fscanf( file, "%d", &value ) != 1 )
-            continue;
-
-        if ( streq( variable, "Width" ) )
-        {
-            *widthP = value;
-            gotsome = 1;
-        }
-        else if ( streq( variable, "Height" ) )
-        {
-            *heightP = value;
-            gotsome = 1;
-        }
-        else if ( streq( variable, "Depth" )  )
-        {
-            if ( value != 1 )
-                pm_error( "invalid depth" );
-            gotsome = 1;
-        }
-        else if ( streq( variable, "Format_version" ) )
-        {
-            if ( value != 1 )
-                pm_error( "invalid Format_version" );
-            gotsome = 1;
-        }
-        else if ( streq( variable, "Valid_bits_per_item" ) )
-        {
-            if ( value != 16 )
-                pm_error( "invalid Valid_bits_per_item" );
-            gotsome = 1;
-        }
-    }
-
-    if ( *widthP <= 0 )
-        pm_error( "invalid width (must be positive): %d", *widthP );
-    if ( *heightP <= 0 )
-        pm_error( "invalid height (must be positive): %d", *heightP );
-
-    data_length = BitmapSize( *widthP, *heightP );
-    *dataP = (short unsigned int *) malloc( data_length );
-    if ( *dataP == NULL )
-        pm_error( "out of memory" );
-    data_length /= sizeof( short );
-    
-    for ( i = 0 ; i < data_length; i++ )
-    {
-        if ( i == 0 )
-            status = fscanf( file, " 0x%4hx", *dataP );
-        else
-            status = fscanf( file, ", 0x%4hx", *dataP + i );
-        if ( status != 1 )
-            pm_error( "error 4 scanning bits item" );
-    }
-}
-
-
-
-int
-main(int  argc, char ** argv) {
-
-    FILE* ifp;
-    bit* bitrow;
-    register bit* bP;
-    int rows, cols, row, col, shortcount, mask;
-    short unsigned int * data;
-
-
-    pbm_init( &argc, argv );
-
-    if ( argc > 2 )
-        pm_usage( "[iconfile]" );
-
-    if ( argc == 2 )
-        ifp = pm_openr( argv[1] );
-    else
-        ifp = stdin;
-
-    ReadIconFile( ifp, &cols, &rows, &data );
-
-    pm_close( ifp );
-
-    pbm_writepbminit( stdout, cols, rows, 0 );
-    bitrow = pbm_allocrow( cols );
-
-    for ( row = 0; row < rows; row++ )
-    {
-        shortcount = 0;
-        mask = 0x8000;
-        for ( col = 0, bP = bitrow; col < cols; col++, bP++ )
-        {
-            if ( shortcount >= 16 )
-            {
-                data++;
-                shortcount = 0;
-                mask = 0x8000;
-            }
-            *bP = ( *data & mask ) ? PBM_BLACK : PBM_WHITE;
-            shortcount++;
-            mask = mask >> 1;
-        }
-        data++;
-        pbm_writepbmrow( stdout, bitrow, cols, 0 );
-    }
-
-    pm_close( stdout );
-    exit( 0 );
-}
-
diff --git a/converter/pbm/pbmtoepsi.c b/converter/pbm/pbmtoepsi.c
index b770a7c4..fce7b6ea 100644
--- a/converter/pbm/pbmtoepsi.c
+++ b/converter/pbm/pbmtoepsi.c
@@ -97,7 +97,7 @@ parseCommandLine(int argc, char ** const argv,
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;  /* We have no parms that are negative numbers */
 
-    optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
     
 
diff --git a/converter/pbm/pbmtoepson.c b/converter/pbm/pbmtoepson.c
index b485d888..762c6858 100644
--- a/converter/pbm/pbmtoepson.c
+++ b/converter/pbm/pbmtoepson.c
@@ -56,7 +56,7 @@ parseCommandLine(int                 argc,
    was passed to us as the argv array.  We also trash *argv.
 -----------------------------------------------------------------------------*/
     optEntry *option_def;
-        /* Instructions to optParseOptions3 on how to parse our options.
+        /* Instructions to pm_optParseOptions3 on how to parse our options.
          */
     optStruct3 opt;
 
@@ -82,7 +82,7 @@ parseCommandLine(int                 argc,
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;  /* We have no parms that are negative numbers */
 
-    optParseOptions3( &argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3( &argc, argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
 
diff --git a/converter/pbm/pbmtoescp2.c b/converter/pbm/pbmtoescp2.c
index 973c8781..8585614a 100644
--- a/converter/pbm/pbmtoescp2.c
+++ b/converter/pbm/pbmtoescp2.c
@@ -48,7 +48,7 @@ parseCommandLine(int argc, char ** argv,
     OPTENT3(0, "resolution",   OPT_UINT,    &cmdlineP->resolution,  
             &resolutionSpec, 0);
     
-    optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
     
     if (argc-1 > 1)
         pm_error("Too many arguments: %d.  "
diff --git a/converter/pbm/pbmtog3.c b/converter/pbm/pbmtog3.c
index f53bfaa0..04ea651f 100644
--- a/converter/pbm/pbmtog3.c
+++ b/converter/pbm/pbmtog3.c
@@ -108,7 +108,7 @@ parseCommandLine(int argc, char ** const argv,
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = TRUE;  /* We may have parms that are negative numbers */
 
-    optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
     free(option_def);
diff --git a/converter/pbm/pbmtoibm23xx.c b/converter/pbm/pbmtoibm23xx.c
index a83e260d..9f530b48 100644
--- a/converter/pbm/pbmtoibm23xx.c
+++ b/converter/pbm/pbmtoibm23xx.c
@@ -84,7 +84,7 @@ parseCommandLine(int argc, char ** const argv,
     opt.short_allowed = 0;
     opt.allowNegNum = 0;
 
-    optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
     if (!xresSpec)
diff --git a/converter/pbm/pbmtolj.c b/converter/pbm/pbmtolj.c
index be28f635..4afa4c6d 100644
--- a/converter/pbm/pbmtolj.c
+++ b/converter/pbm/pbmtolj.c
@@ -94,7 +94,7 @@ parseCommandLine(int argc, char ** argv,
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;  /* We may have parms that are negative numbers */
 
-    optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
     if (argc-1 == 0) 
diff --git a/converter/pbm/pbmtonokia.c b/converter/pbm/pbmtonokia.c
index dd64fc20..839e6cc1 100644
--- a/converter/pbm/pbmtonokia.c
+++ b/converter/pbm/pbmtonokia.c
@@ -69,7 +69,7 @@ parseCommandLine(int argc, char ** argv,
    was passed to us as the argv array.
 -----------------------------------------------------------------------------*/
     optEntry * option_def;
-        /* Instructions to optParseOptions3 on how to parse our options.
+        /* Instructions to pm_optParseOptions3 on how to parse our options.
          */
     optStruct3 opt;
 
@@ -92,7 +92,7 @@ parseCommandLine(int argc, char ** argv,
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;  /* We have no parms that are negative numbers */
 
-    optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
     if (fmtSpec) {
@@ -118,7 +118,7 @@ parseCommandLine(int argc, char ** argv,
         if (strlen(netOpt) != 6)
             pm_error("-net option must be 6 hex digits long.  "
                      "You specified %u characters", (unsigned)strlen(netOpt));
-        else if (!strishex(netOpt))
+        else if (!pm_strishex(netOpt))
             pm_error("-net option must be hexadecimal.  You specified '%s'",
                      netOpt);
         else
@@ -147,7 +147,7 @@ parseCommandLine(int argc, char ** argv,
 static void
 freeCmdline(struct cmdlineInfo const cmdline) {
 
-    strfree(cmdline.networkCode);
+    pm_strfree(cmdline.networkCode);
 }
 
 
diff --git a/converter/pbm/pbmtopsg3.c b/converter/pbm/pbmtopsg3.c
index 54d0a0a0..2878686b 100644
--- a/converter/pbm/pbmtopsg3.c
+++ b/converter/pbm/pbmtopsg3.c
@@ -60,7 +60,7 @@ parseCommandLine(int argc, char ** argv,
     opt.short_allowed = FALSE;
     opt.allowNegNum = FALSE;
 
-    optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
 
     if (argc-1 == 0)
         cmdlineP->inputFilespec = "-";
diff --git a/converter/pbm/pbmtoxbm.c b/converter/pbm/pbmtoxbm.c
index dd3dcc3b..2b59a17c 100644
--- a/converter/pbm/pbmtoxbm.c
+++ b/converter/pbm/pbmtoxbm.c
@@ -59,7 +59,7 @@ parseCommandLine(int                 argc,
    was passed to us as the argv array.  We also trash *argv.
 -----------------------------------------------------------------------------*/
     optEntry *option_def;
-    /* Instructions to optParseOptions3 on how to parse our options. */
+    /* Instructions to pm_optParseOptions3 on how to parse our options. */
 
     optStruct3 opt;
     unsigned int option_def_index;
@@ -76,7 +76,7 @@ parseCommandLine(int                 argc,
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;  /* We have no parms that are negative numbers */
 
-    optParseOptions3( &argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3( &argc, argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
     if (!nameSpec)
@@ -390,7 +390,7 @@ main(int    argc,
 
     convertRaster(ifP, cols, rows, format, stdout, cmdline.xbmVersion);
 
-    strfree(name);
+    pm_strfree(name);
     pm_close(ifP);
 
     return 0;
diff --git a/converter/pbm/thinkjettopbm.l b/converter/pbm/thinkjettopbm.l
index c7f1b373..5de4f2bb 100644
--- a/converter/pbm/thinkjettopbm.l
+++ b/converter/pbm/thinkjettopbm.l
@@ -158,7 +158,7 @@ parseCommandLine(int argc, char ** const argv,
    was passed to us as the argv array.
 -----------------------------------------------------------------------------*/
     optEntry *option_def = malloc(100*sizeof(optEntry));
-        /* Instructions to OptParseOptions3 on how to parse our options.
+        /* Instructions to pm_OptParseOptions3 on how to parse our options.
          */
     optStruct3 opt;
 
@@ -171,7 +171,7 @@ parseCommandLine(int argc, char ** const argv,
     opt.short_allowed = FALSE;  /* We have no short (old-fashioned) options */
     opt.allowNegNum = FALSE;  /* We have no parms that are negative numbers */
 
-    optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
+    pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */