]> arthur.barton.de Git - netatalk.git/blobdiff - bin/megatron/megatron.c
- merge branch-netatalk-afp-3x-dev, HEAD was tagged before
[netatalk.git] / bin / megatron / megatron.c
index 8d9ffe442be360fdea9113fd403a901dc7af6838..09035f4c09050d24447c058402e87b76162dcacc 100644 (file)
@@ -1,18 +1,28 @@
+/*
+ * $Id: megatron.c,v 1.10 2005-04-28 20:49:20 bfernhomberg Exp $
+ */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
+#endif /* HAVE_CONFIG_H */
 
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/uio.h>
+#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
+#endif /* HAVE_FCNTL_H */
+#include <time.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <string.h>
-#include <syslog.h>
 #include <netatalk/endian.h>
+#include "asingle.h"
 #include "megatron.h"
+#include "hqx.h"
+#include "macbin.h"
+#include "nad.h"
 
 char           forkbuf[8192];
 char           *forkname[] = { "data", "resource" };
@@ -181,7 +191,7 @@ int megatron( path, module, newname, flags )
     struct FHeader     fh;
     int                        bufc;
     int                        fork;
-    int                        forkred;
+    unsigned int       forkred;
 
 /*
  * If the source file is not stdin, make sure it exists and
@@ -204,7 +214,7 @@ int megatron( path, module, newname, flags )
  */
 
     memset( &fh, 0, sizeof( fh ));
-    if ( from_open( module, path, &fh ) < 0 ) {
+    if ( from_open( module, path, &fh, flags ) < 0 ) {
        return( -1 );
     }
 
@@ -263,7 +273,7 @@ int megatron( path, module, newname, flags )
        fprintf( stderr, "megatron: forkred is \t\t%d\n", forkred );
        fprintf( stderr, "megatron: fh.forklen[%d] is \t%d\n", fork, 
                ntohl( fh.forklen[ fork ] ));
-#endif
+#endif /* DEBUG */
        if (( bufc < 0 ) || ( forkred != ntohl( fh.forklen[ fork ] ))) {
            fprintf( stderr, "%s: Problem with input, dude\n", path );
            to_close( module, TRASH );
@@ -304,7 +314,7 @@ int main( argc, argv )
        fprintf( stderr, "megatron: list of program links messed up\n" );
        return( -1 );
     }
-#endif
+#endif /* DEBUG */
 
     for ( c = 0 ; (( c < converts ) && ( module < 0 )) ; ++c ) {
        if ( strcmp( name[ c ], progname ) == 0 ) module = c;
@@ -331,8 +341,16 @@ int main( argc, argv )
          flags |= OPTION_STDOUT;
          continue;
        }
-         
-       if ( rc = megatron( argv[ c ], module, newname, flags) != 0 ) {
+       if (strcmp(argv[c], "--euc") == 0) {
+         flags |= OPTION_EUCJP;
+         continue;
+       }  
+       if (strcmp(argv[c], "--sjis") == 0) {
+         flags |= OPTION_SJIS;
+         continue;
+       }  
+       rc = megatron( argv[ c ], module, newname, flags);
+       if ( rc != 0 ) {
            rv = rc;
        }
        *newname = '\0';