]> arthur.barton.de Git - netatalk.git/blobdiff - bin/afile/achfile.c
call readt with ONE_DELAY = 5 s
[netatalk.git] / bin / afile / achfile.c
index 8c4f90178c489769af96fcf6f1c7d10eb1cb3171..99133cc95d13b01037dbc97727b33323b4bc93e0 100644 (file)
@@ -1,4 +1,7 @@
-/*  afile - determine the MacOS creator/type of files
+/*
+ * $Id: achfile.c,v 1.7 2009-10-14 01:38:28 didg Exp $
+ *
+    afile - determine the MacOS creator/type of files
 
     Copyright (C) 2001 Sebastian Rittau.
     All rights reserved.
@@ -31,7 +34,9 @@
     SUCH DAMAGE.
 */
 
-#include <config.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
 
 #include <stdio.h>
 #include <string.h>
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
+#endif /* HAVE_FCNTL_H */
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif /* HAVE_UNISTD_H */
 
 #include <atalk/adouble.h>
 
 #include "common.h"
 
-/* Please change this whenever you change this file. */
-#define ACHFILE_VERSION "1.0.0"
-
 /* Global Variables */
-const char *type    = NULL;
-const char *creator = NULL;
+static const char *type    = NULL;
+static const char *creator = NULL;
 
 
 /* Print usage information. */
-void usage(char *prog)
+static void usage(char *prog)
 {
   fprintf(stderr, "Usage: %s [-t TYPE] [-c CREATOR] FILE ...\n", prog);
 }
 
 /* Print extensive help. */
-void help(char *prog)
+static void help(char *prog)
 {
   usage(prog);
   fprintf(stderr,
@@ -75,9 +81,9 @@ void help(char *prog)
 }
 
 /* Print the version. */
-void version()
+static void version(void)
 {
-  fprintf(stderr, "achfile " ACHFILE_VERSION " (netatalk " VERSION ")\n");
+  fprintf(stderr, "achfile (netatalk " VERSION ")\n");
 }
 
 /* Argument Handling
@@ -85,7 +91,7 @@ void version()
  * known long options: --help, --version
  */
 #define OPTSTRING "t:c:hv-:"
-const char *get_long_arg(int argc, char *argv[], const char *arg, const char *oa) {
+static const char *get_long_arg(int argc, char *argv[], const char *arg, const char *oa) {
   switch (*oa) {
   case '=':
     return &oa[1];
@@ -102,7 +108,7 @@ const char *get_long_arg(int argc, char *argv[], const char *arg, const char *oa
   }
 }
 
-int parse_args(int argc, char *argv[])
+static int parse_args(int argc, char *argv[])
 {
   int c;
   const char *longarg;
@@ -172,7 +178,7 @@ int parse_args(int argc, char *argv[])
 
 
 /* Change the owner/creator of each file specified on the command line. */
-int handle_file(const char *filename)
+static int handle_file(const char *filename)
 {
   int fd;
   struct stat statbuf;
@@ -208,7 +214,7 @@ int handle_file(const char *filename)
     close(fd);
     return -1;
   }
-  if (ad->ad_magic != AD_MAGIC) {
+  if ( ntohl(ad->ad_magic) != AD_MAGIC) {
     fprintf(stderr, "achfile:%s: corrupt resource fork\n", filename);
     free(adname);
     close(fd);