]> arthur.barton.de Git - netatalk.git/blobdiff - bin/megatron/megatron.c
Merge remote branch 'sf/branch-allea' into branch-allea
[netatalk.git] / bin / megatron / megatron.c
index 48810abdaab7f72acf9f374576137e76adc0955e..573a3dc88696c408e92a2173687cec417c978107 100644 (file)
@@ -1,7 +1,3 @@
-/*
- * $Id: megatron.c,v 1.11 2009-10-13 22:55:36 didg Exp $
- */
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif /* HAVE_CONFIG_H */
@@ -10,9 +6,7 @@
 #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>
@@ -24,9 +18,9 @@
 #include "macbin.h"
 #include "nad.h"
 
-char           forkbuf[8192];
 char           *forkname[] = { "data", "resource" };
-char           *name[] = { "unhex",
+static char    forkbuf[8192];
+static char    *name[] = { "unhex",
                            "unbin",
                            "unsingle",
                            "macbinary",
@@ -36,7 +30,7 @@ char          *name[] = { "unhex",
                            "binheader",
                            "megatron" };
 
-int from_open(int un, char *file, struct FHeader *fh, int flags)
+static int from_open(int un, char *file, struct FHeader *fh, int flags)
 {
     switch ( un ) {
        case MEGATRON :
@@ -61,7 +55,7 @@ int from_open(int un, char *file, struct FHeader *fh, int flags)
     }
 }
 
-int from_read(int un, int fork, char *buf, int len)
+static ssize_t from_read(int un, int fork, char *buf, size_t len)
 {
     switch ( un ) {
        case MEGATRON :
@@ -84,7 +78,7 @@ int from_read(int un, int fork, char *buf, int len)
     }
 }
 
-int from_close(int un)
+static int from_close(int un)
 {
     switch ( un ) {
        case MEGATRON :
@@ -107,7 +101,7 @@ int from_close(int un)
     }
 }
 
-int to_open(int to, char *file, struct FHeader *fh, int flags)
+static int to_open(int to, char *file, struct FHeader *fh, int flags)
 {
     switch ( to ) {
        case MEGATRON :
@@ -127,7 +121,7 @@ int to_open(int to, char *file, struct FHeader *fh, int flags)
     }
 }
 
-int to_write(int to, int fork, int bufc)
+static ssize_t to_write(int to, int fork, size_t bufc)
 {
     switch ( to ) {
        case MEGATRON :
@@ -147,7 +141,7 @@ int to_write(int to, int fork, int bufc)
     }
 }
 
-int to_close(int to, int keepflag)
+static int to_close(int to, int keepflag)
 {
     switch ( to ) {
        case MEGATRON :
@@ -167,13 +161,13 @@ int to_close(int to, int keepflag)
     }
 }
 
-int megatron( char *path, int module, char *newname, int flags)
+static int megatron( char *path, int module, char *newname, int flags)
 {
     struct stat                st;
     struct FHeader     fh;
-    int                        bufc;
+    ssize_t            bufc;
     int                        fork;
-    unsigned int       forkred;
+    size_t             forkred;
 
 /*
  * If the source file is not stdin, make sure it exists and
@@ -285,7 +279,7 @@ int main(int argc, char **argv)
     char       *progname, newname[ADEDLEN_NAME + 1];
 
     progname = strrchr( argv[ 0 ], '/' );
-    if (( progname == NULL ) || ( progname == '\0' )) {
+    if (( progname == NULL ) || ( *progname == '\0' )) {
        progname = argv[ 0 ];
     } else progname++;
 
@@ -309,6 +303,14 @@ int main(int argc, char **argv)
 
     *newname = '\0';
     for ( c = 1 ; c < argc ; ++c ) {
+        if ( strcmp( argv [ c ], "--version" ) == 0 ) {
+           printf("%s (Netatalk %s megatron)\n", argv[0], VERSION);
+           return( -1 );
+       }
+        if ( strcmp( argv [ c ], "-v" ) == 0 ) {
+           printf("%s (Netatalk %s megatron)\n", argv[0], VERSION);
+           return( -1 );
+       }
         if ( strcmp( argv [ c ], "--header" ) == 0 ) {
            flags |= OPTION_HEADERONLY;
            continue;
@@ -337,4 +339,3 @@ int main(int argc, char **argv)
     }
     return( rv );
 }
-