mshowfat.c

Go to the documentation of this file.
00001 /*
00002  * mcopy.c
00003  * Copy an MSDOS files to and from Unix
00004  *
00005  */
00006 
00007 
00008 #define LOWERCASE
00009 
00010 #include "sysincludes.h"
00011 #include "msdos.h"
00012 #include "mtools.h"
00013 #include "vfat.h"
00014 #include "mainloop.h"
00015 #include "plain_io.h"
00016 #include "nameclash.h"
00017 #include "file.h"
00018 #include "fs.h"
00019 
00020 
00021 
00022 typedef struct Arg_t {
00023         char *target;
00024         MainParam_t mp;
00025         ClashHandling_t ch;
00026         Stream_t *sourcefile;
00027 } Arg_t;
00028 
00029 static int dos_showfat(direntry_t *entry, MainParam_t *mp)
00030 {
00031         Stream_t *File=mp->File;
00032 
00033         fprintPwd(stdout, entry,0);
00034         putchar(' ');
00035         printFat(File);
00036         printf("\n");
00037         return GOT_ONE;
00038 }
00039 
00040 static int unix_showfat(MainParam_t *mp)
00041 {
00042         fprintf(stderr,"File does not reside on a Dos fs\n");
00043         return ERROR_ONE;
00044 }
00045 
00046 
00047 static void usage(void)
00048 {
00049         fprintf(stderr,
00050                 "Mtools version %s, dated %s\n", mversion, mdate);
00051         fprintf(stderr,
00052                 "Usage: %s file ...\n", progname);
00053         exit(1);
00054 }
00055 
00056 void mshowfat(int argc, char **argv, int mtype)
00057 {
00058         Arg_t arg;
00059         int c, ret;
00060         
00061         /* get command line options */
00062 
00063         init_clash_handling(& arg.ch);
00064 
00065         /* get command line options */
00066         while ((c = getopt(argc, argv, "")) != EOF) {
00067                 switch (c) {
00068                         case '?':
00069                                 usage();
00070                                 break;
00071                 }
00072         }
00073 
00074         if (argc - optind < 1)
00075                 usage();
00076 
00077         /* only 1 file to copy... */
00078         init_mp(&arg.mp);
00079         arg.mp.arg = (void *) &arg;
00080 
00081         arg.mp.callback = dos_showfat;
00082         arg.mp.unixcallback = unix_showfat;
00083 
00084         arg.mp.lookupflags = ACCEPT_PLAIN | ACCEPT_DIR | DO_OPEN;
00085         ret=main_loop(&arg.mp, argv + optind, argc - optind);
00086         exit(ret);
00087 }

Generated on Fri Apr 14 22:56:56 2006 for minix by  doxygen 1.4.6