-/* 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.
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,
}
/* 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
* 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];
}
}
-int parse_args(int argc, char *argv[])
+static int parse_args(int argc, char *argv[])
{
int c;
const char *longarg;
/* 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;
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);