home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / CMDS / mtools_3.6.src.lzh / MTOOLS_3.6 / mtools.h < prev    next >
Text File  |  1997-11-12  |  5KB  |  170 lines

  1. #ifndef MTOOLS_MTOOLS_H
  2. #define MTOOLS_MTOOLS_H
  3.  
  4. #include "msdos.h"
  5.  
  6. #if defined(sco3)
  7. #define MAXPATHLEN 1024
  8. #include <signal.h>
  9. extern int lockf(int, int, off_t);  /* SCO has no proper include file for lockf */
  10. #endif 
  11.  
  12.  
  13. typedef struct device {
  14.     const char *name;       /* full path to device */
  15.  
  16.     char drive;               /* the drive letter */
  17.     int fat_bits;        /* FAT encoding scheme */
  18.  
  19.     int mode;               /* any special open() flags */
  20.     unsigned int tracks;    /* tracks */
  21.     unsigned int heads;    /* heads */
  22.     unsigned int sectors;    /* sectors */
  23.  
  24.     off_t offset;               /* skip this many bytes */
  25.  
  26.     int partition;
  27.     int scsi;
  28.  
  29.     int privileged;
  30.  
  31.     /* rarely used stuff */
  32.     int nolock;    
  33.  
  34.     /* Linux only stuff */
  35.     unsigned int ssize;
  36.     unsigned int use_2m;
  37.     int use_xdf;
  38.  
  39.     char *precmd;        /* command to be executed before opening
  40.                  * the drive */
  41.  
  42.     /* internal variables */
  43.     int file_nr;        /* used during parsing */
  44.     int hidden;        /* number of hidden sectors. Used for
  45.                  * mformatting partitioned devices */
  46. } device_t;
  47.  
  48. #include "stream.h"
  49.  
  50.  
  51. extern const char *short_illegals, *long_illegals;
  52.  
  53. size_t maximize(size_t *target, long max);
  54. size_t minimize(size_t *target, long max);
  55.  
  56. int init_geom(int fd, struct device *dev, struct device *orig_dev,
  57.           struct stat *stat);
  58.  
  59. int readwrite_sectors(int fd, /* file descriptor */
  60.               int *drive,
  61.               int rate,
  62.               int seektrack,
  63.               int track, int head, int sector, int size, /* address */
  64.               char *data, 
  65.               int bytes,
  66.               int direction,
  67.               int retries);
  68.  
  69. int lock_dev(int fd, int mode, struct device *dev);
  70.  
  71. char *unix_normalize (char *ans, char *name, char *ext);
  72. void dir_write(Stream_t *Dir, int num, struct directory *dir);
  73. char *dos_name(char *filename, int verbose, int *mangled, char *buffer);
  74. struct directory *mk_entry(const char *filename, char attr,
  75.                unsigned int fat, size_t size, long date,
  76.                struct directory *ndir);
  77. int copyfile(Stream_t *Source, Stream_t *Target);
  78. unsigned long getfree(Stream_t *Stream);
  79. unsigned long getfreeMin(Stream_t *Stream, size_t ref);
  80.  
  81. FILE *opentty(int mode);
  82.  
  83. int is_dir(Stream_t *Dir, char *path);
  84. Stream_t *descend(Stream_t *Dir, char *path, int barf,char *outname, int lock);
  85.  
  86. int dir_grow(Stream_t *Dir, int size);
  87. int match(const char *, const char *, char *, int);
  88. int hasWildcards(const char *string);
  89.  
  90. Stream_t *new_file(char *filename, char attr,
  91.            unsigned int fat, size_t size, long date,
  92.            struct directory *ndir);
  93. char *unix_name(char *name, char *ext, char Case, char *answer);
  94. void *safe_malloc(size_t size);
  95. Stream_t *open_filter(Stream_t *Next);
  96.  
  97. extern int got_signal;
  98. void setup_signal(void);
  99.  
  100.  
  101. #define SET_INT(target, source) \
  102. if(source)target=source
  103.  
  104.  
  105. UNUSED(static inline int compare (long ref, long testee))
  106. {
  107.     return (ref && ref != testee);
  108. }
  109.  
  110. Stream_t *GetFs(Stream_t *Fs);
  111. Stream_t *find_device(char drive, int mode, struct device *out_dev,
  112.               struct bootsector *boot,
  113.               char *name, int *media);
  114.  
  115. struct directory *labelit(char *dosname,
  116.               char *longname,
  117.               void *arg0,
  118.               struct directory *dir);
  119.  
  120. char *label_name(char *filename, int verbose, 
  121.          int *mangled, char *ans);
  122.  
  123. /* environmental variables */
  124. extern int mtools_skip_check;
  125. extern int mtools_fat_compatibility;
  126. extern int mtools_ignore_short_case;
  127. extern int mtools_no_vfat;
  128. extern int mtools_rate_0, mtools_rate_any, mtools_raw_tty;
  129.  
  130. void read_config(void);
  131. extern struct device *devices;
  132. extern struct device const_devices[];
  133. extern const int nr_const_devices;
  134.  
  135. #define New(type) ((type*)(malloc(sizeof(type))))
  136. #define Grow(adr,n,type) ((type*)(realloc((char *)adr,n*sizeof(type))))
  137. #define Free(adr) (free((char *)adr));
  138. #define NewArray(size,type) ((type*)(calloc((size),sizeof(type))))
  139.  
  140. void mattrib(int argc, char **argv, int type);
  141. void mbadblocks(int argc, char **argv, int type);
  142. void mcd(int argc, char **argv, int type);
  143. void mcopy(int argc, char **argv, int type);
  144. void mdel(int argc, char **argv, int type);
  145. void mdir(int argc, char **argv, int type);
  146. void mformat(int argc, char **argv, int type);
  147. void minfo(int argc, char **argv, int type);
  148. void mlabel(int argc, char **argv, int type);
  149. void mmd(int argc, char **argv, int type);
  150. void mmount(int argc, char **argv, int type);
  151. void mmove(int argc, char **argv, int type);
  152. void mpartition(int argc, char **argv, int type);
  153. void mtoolstest(int argc, char **argv, int type);
  154. void mzip(int argc, char **argv, int type);
  155.  
  156. void init_privs(void);
  157. void reclaim_privs(void);
  158. void drop_privs(void);
  159. void destroy_privs(void);
  160. void closeExec(int fd);
  161.  
  162. extern const char *progname;
  163.  
  164. Stream_t *subdir(Stream_t *, char *pathname, int lock);
  165. void precmd(struct device *dev);
  166.  
  167. void print_sector(char *message, unsigned char *data);
  168.  
  169. #endif
  170.