source: trunk/minix/commands/i386/mtools-3.9.7/mainloop.h@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 2.6 KB
RevLine 
[9]1#ifndef MTOOLS_MAINLOOP_H
2#define MTOOLS_MAINLOOP_H
3
4#ifndef OS_Minix
5#include <sys/param.h>
6#endif
7#include "vfat.h"
8#include "mtoolsDirent.h"
9
10typedef struct MainParam_t {
11 /* stuff needing to be initialised by the caller */
12 int (*loop)(Stream_t *Dir, struct MainParam_t *mp,
13 const char *filename);
14 int (*dirCallback)(direntry_t *, struct MainParam_t *);
15 int (*callback)(direntry_t *, struct MainParam_t *);
16 int (*unixcallback)(struct MainParam_t *mp);
17
18 void *arg; /* command-specific parameters
19 * to be passed to callback */
20
21 int openflags; /* flags used to open disk */
22 int lookupflags; /* flags used to lookup up using vfat_lookup */
23 int fast_quit; /* for commands manipulating multiple files, quit
24 * as soon as even _one_ file has a problem */
25
26 char *shortname; /* where to put the short name of the matched file */
27 char *longname; /* where to put the long name of the matched file */
28
29 /* out parameters */
30 Stream_t *File;
31
32 direntry_t *direntry; /* dir of this entry */
33 char *unixSourceName; /* filename of the last opened Unix source
34 * file (Unix equiv of Dos direntry) */
35
36 Stream_t *targetDir; /* directory where to place files */
37 char *unixTarget; /* directory on Unix where to put files */
38
39 const char *targetName; /* basename of target file, or NULL if same
40 * basename as source should be conserved */
41
42 char *originalArg; /* original argument, complete with wildcards */
43 int basenameHasWildcard; /* true if there are wildcards in the
44 * basename */
45
46
47 /* internal data */
48 char mcwd[MAX_PATH+4];
49
50 char *fileName; /* resolved Unix filename */
51} MainParam_t;
52
53void init_mp(MainParam_t *MainParam);
54int main_loop(MainParam_t *MainParam, char **argv, int argc);
55
56int target_lookup(MainParam_t *mp, const char *arg);
57
58Stream_t *open_root_dir(char *drivename, int flags);
59
60const char *mpGetBasename(MainParam_t *mp); /* statically allocated
61 * string */
62
63void mpPrintFilename(FILE *file, MainParam_t *mp);
64const char *mpPickTargetName(MainParam_t *mp); /* statically allocated string */
65
66char *mpBuildUnixFilename(MainParam_t *mp); /* dynamically allocated, must
67 * be freed */
68
69int isSpecial(const char *name);
70
71#define MISSED_ONE 2 /* set if one cmd line argument didn't match any files */
72#define GOT_ONE 4 /* set if a match was found, used for exit status */
73#define NO_CWD 8 /* file not found while looking for current working
74 * directory */
75#define ERROR_ONE 16 /* flat out error, such as problems with target file,
76 interrupt by user, etc. */
77#define STOP_NOW 32 /* stop as soon as possible, not necessarily an error */
78
79#endif
Note: See TracBrowser for help on using the repository browser.