]> arthur.barton.de Git - netatalk.git/blobdiff - bin/psorder/psorder.c
massive commenting/autoconf changes
[netatalk.git] / bin / psorder / psorder.c
index 34248512b409866092b36aa6c249ac8a58bea285..7ba4332f9eedfe3e4258189f68428cb562806cc2 100644 (file)
@@ -1,4 +1,6 @@
 /*
+ * $Id: psorder.c,v 1.5 2001-06-29 14:14:46 rufustfirefly Exp $
+ *
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
  *
  *     netatalk@itd.umich.edu
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/uio.h>
 #include <sys/file.h>
 #include <ctype.h>
+#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
+#endif /* HAVE_FCNTL_H */
 #include <stdio.h>
 #include <string.h>
 #include <dirent.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif /* HAVE_UNISTD_H */
 #include "pa.h"
 #include "psorder.h"
 
 #include <atalk/paths.h>
 
-#define        DEBUG           0
-
 /*
  *                     Global Variables
  */
@@ -49,7 +57,7 @@ u_char                        psbuf[ 8192 ];
 struct psinfo_st       psinfo;
 int                    orderflag, forceflag;
 
-main( argc, argv )
+int main( argc, argv )
     int                argc;
     char       **argv;
 {
@@ -137,7 +145,7 @@ filesetup( inputfile, infd, tfile, tfd )
 #if DEBUG
     fprintf( stderr, "Input file or stdin and stdout opened.\n" );
     fprintf( stderr, "Input file descriptor is %d .\n", *infd );
-#endif
+#endif /* DEBUG */
 
 /*
        make temporary file
@@ -152,7 +160,7 @@ filesetup( inputfile, infd, tfile, tfd )
 #if DEBUG
     fprintf( stderr, "Temporary file %s created and opened.\n", tfile );
     fprintf( stderr, "Temporary file descriptor is %d .\n", *tfd );
-#endif
+#endif /* DEBUG */
 
     psinfo.firstpage = NULL;
     psinfo.lastpage = NULL;
@@ -203,7 +211,7 @@ readps( inputfd, tempfd, tempfile )
     }
 #if DEBUG
     fprintf( stderr, "%s\n", curtok );
-#endif
+#endif /* DEBUG */
 
 /*
  * not postscript
@@ -211,7 +219,7 @@ readps( inputfd, tempfd, tempfile )
     if ( strcmp( curtok, PPSADOBE ) != 0 ) {
 #if DEBUG
     fprintf( stderr, "in the not postscript section of readps\n" );
-#endif
+#endif /* DEBUG */
        while (( c = pa_getchar( pb )) != 0 ) {
            ccread++;
            (void)putc( c, tempstream );
@@ -228,7 +236,7 @@ readps( inputfd, tempfd, tempfile )
  */
 #if DEBUG
     fprintf( stderr, "in the postscript section of readps\n" );
-#endif
+#endif /* DEBUG */
     while (( c = pa_getchar( pb )) != 0 ) {
        ccread++;
        (void)putc( c, tempstream );
@@ -237,10 +245,10 @@ readps( inputfd, tempfd, tempfile )
        if ((( pc == '\r' ) || ( pc == '\n' )) && ( cc == '%' )) {
 #if DEBUG
            fprintf( stderr, "supposed start of match, cc = %c\n", cc );
-#endif
+#endif /* DEBUG */
            pa_match( pb );
            ccmatch = ccread - 1;
-           while ( c = pa_getchar( pb )) {
+           while ( ( c = pa_getchar( pb ) ) ) {
                if ( c != 0 ) {
                    ccread++;
                    (void)putc( c, tempstream );
@@ -251,7 +259,7 @@ readps( inputfd, tempfd, tempfile )
                    curtok = pa_gettok( pb );
 #if DEBUG
                    fprintf( stderr, "%s\n", curtok );
-#endif
+#endif /* DEBUG */
                    if ( handletok( ccmatch, curtok ) < 0 ) {
                        perror( "malloc died" );
                        filecleanup( -1, tempfd, tempfile );
@@ -281,19 +289,19 @@ handletok( count, token )
        incdoc--;
 #if DEBUG
        fprintf( stderr, "found an EndDoc\n" );
-#endif
+#endif /* DEBUG */
 
     } else if ( strncmp( PBEGINDOC, token, strlen( PBEGINDOC )) == 0 ) {
        incdoc++;
 #if DEBUG
        fprintf( stderr, "found a BeginDoc\n" );
-#endif
+#endif /* DEBUG */
 
     } else if ( !incdoc && 
            ( strncmp( PPAGE, token, strlen( PPAGE )) == 0 )) {
 #if DEBUG
        fprintf( stderr, "found a Page\n" );
-#endif
+#endif /* DEBUG */
        if (( newpage = getpspage( count )) == NULL ) {
            return( -1 );
        }
@@ -315,13 +323,13 @@ handletok( count, token )
 #if DEBUG
        fprintf( stderr, "page lable %s, page ord %s\n", newpage->lable,
                newpage->ord );
-#endif
+#endif /* DEBUG */
 
     } else if ( !incdoc && 
            ( strncmp( PPAGES, token, strlen( PPAGES )) == 0 )) {
 #if DEBUG
        fprintf( stderr, "found a Pages\n" );
-#endif
+#endif /* DEBUG */
        psinfo.pages.offset = count;
        psinfo.pages.end = strlen( token ) + count;
        while ( *token++ != ':' );
@@ -329,7 +337,7 @@ handletok( count, token )
        if ( strncmp( ATEND, token, strlen( ATEND )) == 0 ) {
 #if DEBUG
            fprintf( stderr, "it is a Pages: (atend)\n" );
-#endif
+#endif /* DEBUG */
            psinfo.pages.offset = 0;
            psinfo.pages.end = 0;
        } else {
@@ -342,14 +350,14 @@ handletok( count, token )
 #if DEBUG
            fprintf( stderr, "number of pages %s\n", psinfo.pages.num );
            fprintf( stderr, "order control number %s\n", psinfo.pages.order );
-#endif
+#endif /* DEBUG */
        }
 
     } else if ( !incdoc && 
            ( strncmp( PTRAILER, token, strlen( PTRAILER )) == 0 )) {
 #if DEBUG
        fprintf( stderr, "found the Trailer\n" );
-#endif
+#endif /* DEBUG */
        if  ( psinfo.trailer == 0 ) {
            psinfo.trailer = count;
        }