]> wirehaze git hosting - MS-DOS.git/blob - v4.0/src/CMD/BACKUP/BACKUP.H

wirehaze git hosting

MZ is back!
[MS-DOS.git] / v4.0 / src / CMD / BACKUP / BACKUP.H
1 /*\ f\e0 */
2 /*-----------------------------------------------------------
3 /*-
4 /*- FILE: BACKUP.H
5 /*-
6 /*- PURPOSE: For the BACKUP utility, this file has the required
7 /*- BACKUP defines, message numbers, structures,
8 /*- and subroutine declarations.
9 /*-
10 /*---------------------------------------------------------*/
11
12 /*----------------------
13 /*- Utility #DEFINES...
14 /*----------------------*/
15
16 #define DHLENGTH 139 /* Length, in bytes, of a Disk Header */
17 #define DBLENGTH 70 /* Length, in bytes, of a Directory Block */
18 #define FHLENGTH 34 /* Length, in bytes, of a File Header */
19
20 #define BYTE unsigned char
21 #define WORD unsigned short
22 #define DWORD unsigned long
23
24 #define NOERROR 0
25 #define NUL 0
26
27 #define FALSE 0
28 #define TRUE !FALSE
29
30 #define BACKSLASH 0x5c
31
32 #define READONLYOFF 254 /* bit mask, will be ANDed with current attribute to turn off readonly bit */
33
34 #define READONLY 0x01 /* File Attributes */
35 #define HIDDEN 0x02
36 #define SYSTEM 0x04
37 #define VOLLABEL 0x08
38 #define SUBDIR 0x10
39 #define ARCHIVE 0x20
40
41 #define DENYALL 0x10 /* Sharing Mode */
42 #define DENYWRITE 0x20
43 #define DENYREAD 0x30
44 #define DENYNONE 0x40
45
46 #define READACCESS 0x00 /* Access Modes */
47 #define WRITEACCESS 0x01
48 #define READWRITE 0x02
49
50
51 #define NO_CP_CHECK 0x100 /*;AN000;5*/
52
53 #define SYNCHRONOUS 0x4000 /* OS/2 File Write-Through */
54 #define NOTSYNCHRONOUS 0x0000 /* OS/2 File Write-Through */
55 #define OPENDASD 0x8000 /* OS/2 Open a DASD device */
56 #define OPEN_IT 0x01 /*;AN000;5*/
57 #define CREATE_IT 0x12 /*;AN000;5*/
58
59 #define NO_INHERIT 0x80 /* Inheritance bit */
60
61 #define STDIN 0x00 /* Predefined handles */
62 #define STDOUT 0x01
63 #define STDERR 0x02
64
65 #define BOFILE 0 /* LSEEK move methods */
66 #define CURRPOS 1
67 #define EOFILE 2
68
69 #define GET 0 /* CHMOD functions */
70 #define SET 1
71
72 #define SSTRING 0x2000 /*;AN000;4 Parser Match Flags */
73 #define DATESTRING 0x1000 /*;AN000;4*/
74 #define TIMESTRING 0x0800 /*;AN000;4*/
75 #define FILESPEC 0x0200 /*;AN000;4*/
76 #define DRIVELETTER 0x0100 /*;AN000;4*/
77 #define OPTIONAL 0x0001 /*;AN000;4*/
78
79 #define CAP_FILETABLE 0x0001 /*;AN000;4 Parser Function flag*/
80 #define CAP_CHARTABLE 0x0002 /*;AN000;4 Parser Function flag*/
81
82 #define LABELLEN 11
83
84 #define SETLOGICALDRIVE 0x440F /*;AN000;8 */
85
86
87 /*--------APPEND FUNCTIONS-----------*/
88 #define INSTALL_CHECK 0xB700 /*;AN000;2*/
89 #define NOT_INSTALLED 0 /*;AN000;2*/
90 #define GET_APPEND_VER 0xB702 /*;AN000;2*/
91 #define NET_APPEND 1 /*;AN000;2*/
92 #define DOS_APPEND 2 /*;AN000;2*/
93 #define GET_STATE 0xB706 /*;AN000;2*/
94 #define SET_STATE 0xB707 /*;AN000;2*/
95
96 #define APPEND_X_BIT 0x8000 /*;AN000;2*/
97
98
99
100 #define ACTIONHOOK 2
101 #define CTRLC 1
102 #define CTRLBREAK 4
103
104 #define EOL -1 /*;AN000;4*/
105 #define QUOTED_STRING 9 /*;AN000;4*/
106 #define RET_DATE 7 /*;AN000;4*/
107 #define RET_TIME 8 /*;AN000;4*/
108
109 #define CPSW_ACTIVE 1 /*;AN000;3*/
110 #define CPSW_NOTACTIVE 0 /*;AN000;3*/
111 #define GET_CPSW 0x3303 /*;AN000;3*/
112
113 #define CARRY 0x0001 /*;AN000;*/
114 /***********************************/
115 /* Utility-specific definitions */
116 /***********************************/
117
118 #define ROOTDIR 0
119 #define BACKUPDIR 1
120
121 #define PUT_SEG(fp,seg) (*((unsigned *)&(fp)+1)) = (unsigned) seg
122 #define PUT_OFF(fp,off) (*((unsigned *)&(fp))) = (unsigned) off
123
124 #define MAXMSGLEN 160
125 #define PATHLEN 64
126 #define MAX_RETRY_OPEN_COUNT 5
127
128 #define RETCODE_NO_ERROR 0 /* Errorlevels */
129 #define RETCODE_NO_FILES 1
130 #define RETCODE_SHARE_ERROR 2
131 #define RETCODE_CTL_BREAK 3
132 #define RETCODE_ERROR 4
133
134 /************************************************/
135 /* NOTE FROM PARSER SUBROUTINE !!!!! */
136 /************************************************/
137 /* The SECONDS bits in the DOS Directory are in */
138 /* 2-second increments. Therefore, div by 2, */
139 /* take the integer portion and use in search. */
140 /* Note that files can be backed up that were */
141 /* modified 1 second before the time that a user*/
142 /* enters, which is better than not backing up */
143 /* a file that was modified at exactly that time*/
144 /************************************************/
145
146 /*-------------------------------------------*/
147 /*------ BACKUP messages --------*/
148 /*-------------------------------------------*/
149 #define BAD_DOS_VER 1 /*;AN000;6*/
150 #define INSUFF_MEMORY 2 /*;AN000;6*/
151
152 #define INV_DRIVE 6 /*;AN000;6*/
153 #define INV_DATE 7 /*;AN000;6*/
154 #define INV_TIME 8 /*;AN000;6*/
155
156 #define INV_PATH 11 /*;AN000;6*/
157 #define NO_SOURCE 12 /*;AN000;6*/
158 #define NO_TARGET 13 /*;AN000;6*/
159 #define SRC_AND_TGT_SAME 14 /*;AN000;6*/
160 #define ERR_EXEC_FORMAT 15 /*;AN000;6*/
161 #define CANT_FIND_FORMAT 16 /*;AN000;d178*/
162 #define CANT_OPEN_LOGFILE 17 /*;AN000;6*/
163 #define LOGGING 18 /*;AN000;6*/
164 #define NOTLASTMSG 19 /*;AN000;6*/
165 #define ERASEMSG 20 /*;AN000;6*/
166 #define FERASEMSG 21 /*;AN000;6*/
167 #define BUDISKMSG 22 /*;AN000;6*/
168 #define SEQUENCEMSG 23 /*;AN000;6*/
169 #define NONEFNDMSG 24 /*;AN000;6*/
170 #define INSERTSOURCE 25 /*;AN000;6*/
171 #define INSERTTARGET 26 /*;AN000;6*/
172 #define CONFLICTMSG 27 /*;AN000;6*/
173 #define LASTDISKMSG 28 /*;AN000;6*/
174 #define INVTARGET 29 /*;AN000;6*/
175 #define LASTNOTBACKUP 30 /*;AN000;6*/
176 #define FDISKFULLMSG 31 /*;AN000;6*/
177 #define LOGFILE_TARGET_FULL 32 /*;AN000;6*/
178 #define PRESS_ANY_KEY 33 /*;AN000;6*/
179 #define CRLF 34 /*;AN000;6*/
180 #define CANT_FORMAT_HARDFILE 35 /*;AN000;/*
181
182 /*------------------------------------*/
183 /*- MESSAGE CLASSES -*/
184 /*------------------------------------*/
185 #define EXTENDED 1 /*;AN000;6*/
186 #define PARSEERROR 2 /*;AN000;6*/
187 #define UTIL_MSG -1 /*;AN000;6*/
188
189 #define NOWAIT 0 /*;AN000;6*/
190 #define WAIT 0xc8 /*;AN000;6*/
191
192
193 /*-------------------------------------------------------------*/
194 /*- CONTROL BLOCK FOR EACH BACKUP DISKETTE */
195 /*-------------------------------------------------------------*/
196 /*- THIS STRUCTURE WILL MAKE UP THE FIRST DH_DHLength BYTES */
197 /*- OF THE control.xxx FILE ON THE BACKUP TARGET. */
198 /*- IT IDENTIFIES THE DISK AS BEING A BACKUP, AND INCLUDES */
199 /*- DISKETTE SEQUENCE NUMBER AND A FLAG INDICATING IF THIS */
200 /*- IS THE LAST TARGET. */
201 /*-------------------------------------------------------------*/
202
203 #define LAST_TARGET 0xFF
204 #define NOT_LAST_TARGET 0x00
205
206 struct Disk_Header
207 {
208 BYTE DH_Length; /* Length, in bytes, of disk header */
209 BYTE DH_Identifier[8]; /* Identifies disk as a backup */
210 BYTE DH_Sequence; /* Backup diskette seq num (1-255) */
211 BYTE DH_reserved [128]; /* Save area for nothing */
212 BYTE DH_LastDisk; /* Indicates if this is last target */
213 /* 0xFF if last target, 0 otherwise */
214 };
215
216
217 /*----------------------------------------------------------------------*/
218 /*- DIRECTORY BLOCK */
219 /*----------------------------------------------------------------------*/
220 /*- THIS STRUCTURE IS WRITTEN TO THE control.xxx FILE AT LEAST ONCE */
221 /*- FOR EACH SUBDIRECTORY, INCLUDING THE ROOT, BACKED UP. IT CONTAINS */
222 /*- THE PATH TO THAT DIRECTORY, THE NUMBER OF FILES FROM THAT */
223 /*- DIRECTORY THAT ARE BACKED UP ON CURRENT TARGET, AND THE OFFSET */
224 /*- OF THE NEXT DIRECTORY BLOCK ON THAT DISKETTE, IF ONE EXISTS. */
225 /*- IF THERE ARE NO OTHER DIRECTORY BLOCKS, IT EQUALS 0xffffffff. */
226 /*----------------------------------------------------------------------*/
227 #define LAST_DB 0xFFFFFFFF
228
229 struct Dir_Block
230 {
231 BYTE DB_Length; /* Length, in bytes, of dir block */
232 BYTE DB_Path[63];
233 /* ASCII path of this directory, */
234 /* drive letter omitted */
235 WORD DB_NumEntries; /* Num of filenames currently in list*/
236 DWORD DB_NextDB; /* Offset of next directory block */
237 }; /* =0xffffffff if there are no more*/
238 /* on current target */
239
240 /*--------------------------------------------------------------------*/
241 /*- CONTROL BLOCK FOR EACH BACKED-UP FILE */
242 /*--------------------------------------------------------------------*/
243 /*- THIS STRUCTURE WILL BE REPEATED AFTER THE DIRECTORYBLOCK ONCE */
244 /*- FOR EACH FILE BACKED UP FROM THAT DIRECTORY. IT CONTAINS THE */
245 /*- FILENAME, DIRECTORY INFORMATION, AND OTHER NECESSARY INFORMATION. */
246 /*--------------------------------------------------------------------*/
247 #define NOTLASTPART 0
248 #define LASTPART 1
249
250 #define NOTSUCCESSFUL 0
251 #define SUCCESSFUL 2
252
253 #define EXT_ATTR 4 /*;AN000;3*/
254
255 struct File_Header
256 {
257 BYTE FH_Length; /* Length, in bytes, of file header */
258 BYTE FH_FName[12]; /* ASCII file name (from directory)*/
259 BYTE FH_Flags; /* bit 0=1 if last part of file */
260 /* bit 1=1 if it is backed up successfully */
261 /* bit 2=1 if Extended Attributes are backed up (New for DOS4.00) ;AN000;3*/
262 DWORD FH_FLength; /* Total length of the file (from directory) */
263 WORD FH_FSequence; /* Sequence #, for files that span */
264 DWORD FH_BeginOffset; /* Offset in BACKUP.xxx where this segment begins */
265 DWORD FH_PartSize; /* Length of part of file on current target */
266 WORD FH_Attribute; /* File attribute (from directory) */
267 WORD FH_FTime; /* Time when file was last modified (from directory)*/
268 WORD FH_FDate; /* Date when file was last modified (from directory)*/
269 };
270
271 /*--------------------------------------------------------------------*/
272 /*- THIS IS THE STRUCTURE THAT IS USED IN THE LINKED LIST OF */
273 /*- DIRECTORIES THAT NEED TO BE PROCESSED (if /S option specified) */
274 /*--------------------------------------------------------------------*/
275 struct node
276 {
277 struct node *np;
278 char path[PATHLEN+15];
279 };
280
281
282 /*--------------------------------------------------------------------*/
283 /*- THIS IS THE STRUCTURE THAT IS USED BY THE DOS FUNCTION */
284 /*- "RETURN COUNTRY INFORMATION" */
285 /*--------------------------------------------------------------------*/
286 struct ctry_info_blk
287 {
288 WORD country_code;
289 WORD code_page;
290 WORD date_format;
291 #define USA 0
292 #define EUR 1
293 #define JAP 2
294 BYTE currency_symbol[5];
295 WORD thousands_separator;
296 WORD decimal_Separator;
297 WORD date_separator;
298 WORD time_separator;
299 BYTE currency_format;
300 BYTE num_sig_dec_dig_in_currency;
301 BYTE time_format;
302 DWORD case_map_call;
303 WORD data_list_separator;
304 WORD reserved[5];
305 };
306
307 /*------------------------------------------------------------------------*/
308 /*- THIS STRUCTURE IS USED BY THE DOS MESSAGE HANDLER SERVICE ROUTINES -*/
309 /*------------------------------------------------------------------------*/
310
311 /************************************************/
312 /* Substitution List for Message Retriever */
313 /************************************************/
314 /*-----------------------
315 ; SUBLIST Equates
316 ;------------------------*/
317 #define SUBLIST_SIZE 11 /*;AN000;6*/
318
319 #define LEFT_ALIGN 0x0 /*;AN000;600xxxxxx */
320 #define RIGHT_ALIGN 0x80 /*;AN000;610xxxxxx */
321
322 #define CHAR_FIELD_CHAR 0x0 /*;AN000;6a0000000 */
323 #define CHAR_FIELD_ASCIIZ 0x10 /*;AN000;6a0010000 */
324
325 #define UNSGN_BIN_BYTE 0x11 /*;AN000;6a0010001 - Unsigned BINary to Decimal CHARacter */
326 #define UNSGN_BIN_WORD 0x21 /*;AN000;6a0100001 */
327 #define UNSGN_BIN_DWORD 0x31 /*;AN000;6a0110001 */
328
329
330 /*---------------------------------------------*/
331 /*- Message substitution list structure -*/
332 /*---------------------------------------------*/
333 struct subst_list /*;AN000;6*/
334 { /*;AN000;6*/
335 BYTE sl_size1; /* Size of List */ /*;AN000;6*/
336 BYTE zero1; /* Reserved */ /*;AN000;6*/
337 char far *value1; /* Time, date, or ptr to data item*/ /*;AN000;6*/
338 BYTE one; /* n of %n */ /*;AN000;6*/
339 BYTE flags1; /* Data Type flags */ /*;AN000;6*/
340 BYTE max_width1; /* Maximum FIELD width */ /*;AN000;6*/
341 BYTE min_width1; /* Minimum FIELD width */ /*;AN000;6*/
342 BYTE pad_char1; /* Character for pad FIELD */ /*;AN000;6*/
343
344 BYTE sl_size2; /* Size of List */ /*;AN000;6*/
345 BYTE zero2; /* Reserved */ /*;AN000;6*/
346 char far *value2; /* Time; date; or ptr to data item*/ /*;AN000;6*/
347 BYTE two; /* n of %n */ /*;AN000;6*/
348 BYTE flags2; /* Data Type flags */ /*;AN000;6*/
349 BYTE max_width2; /* Maximum FIELD width */ /*;AN000;6*/
350 BYTE min_width2; /* Minimum FIELD width */ /*;AN000;6*/
351 BYTE pad_char2; /* Character for pad FIELD */ /*;AN000;6*/
352 }; /*;AN000;6*/
353
354 /*----------------------------------*/
355 /*- EXTENDED OPEN PARAMETER LIST -*/
356 /*----------------------------------*/
357 #define EXTATTBUFLEN 4086 /*;AN000;3*/
358 struct parm_list /*;AN000;3*/
359 { /*;AN000;3*/
360 DWORD ext_attr_addr; /*;AN000;3*/
361 WORD num_additional; /*;AN000;3*/
362 BYTE id_io_mode; /*;AN000;3*/
363 WORD io_mode; /*;AN000;3*/
364 }; /*;AN000;3*/
365
366 /* \f */
367 /*----------------------------------------------------*/
368 /*- SUBROUTINE DECLARATIONS -*/
369 /*----------------------------------------------------*/
370 int cdecl sprintf(char *, char *, ...);
371 int cdecl printf(char *,...);
372
373 void alloc_buffer(void);
374 void alloc_first_node(void);
375 struct node * alloc_node(unsigned int);
376 void check_appendX(void); /*;AN000;2*/
377 void alloc_seg(void);
378 void build_ext(int);
379 void change_levels(void);
380 void check_date(WORD,BYTE,BYTE); /*;AN000;4*/
381 void check_DOS_version(void);
382 void check_drive_validity(int,char * []);
383 void check_for_device_names(char * []); /*;AN000;p2592*/
384 void check_last_target(void);
385 void check_path_validity(char * []);
386 void check_time(BYTE,BYTE,BYTE,BYTE); /*;AN000;4*/
387 void clean_up_and_exit(void);
388 void close_file(WORD);
389 void close_out_current_target(void);
390 void control_break_handler(void);
391 void create_target(void);
392 void datetime(void);
393 void delete(char *);
394 void delete_files(char);
395 long disk_free_space(void);
396 void display_it(int,WORD,int,BYTE,BYTE); /*;AN000;6*/
397 void display_msg(int);
398 void do_backup(void);
399 void do_copy(void);
400 void do_dos_error(WORD);
401 extern unsigned far pascal set_int24_vector(void); /*;AN000;*/
402 void error_exit(int);
403 WORD exist(char *);
404 WORD extended_open(WORD,WORD,char far *,WORD); /*;AN000;5*/
405 void file_sharing_error(void); /*;AN000;9*/
406 char far * far_ptr(WORD,WORD);
407 void findclose(WORD);
408 void find_all_subdirs(void);
409 void find_first(char *,WORD *,struct FileFindBuf *,WORD);
410 void find_first_file(void);
411 void find_format(void); /*;AN000;d178*/
412 void find_next(WORD,struct FileFindBuf *);
413 void find_next_file(void);
414 void find_the_first(void);
415 void find_the_next(void);
416 void format_target(void);
417 void free_seg(unsigned);
418 WORD get_attribute(char *);
419 void get_current_dir(WORD,char *);
420 WORD get_current_drive(void);
421 void get_country_info(void);
422 void get_diskette(void);
423 void get_drive_types(void);
424 void get_extended_attributes(WORD); /*;AN000;3 */
425 void get_first_target(void);
426 void get_hardfile(void);
427 void get_next_target(void);
428 void get_path(char *); /*;AN002;*/
429 WORD handle_open(char *,WORD);
430 WORD handle_read(WORD,WORD,char far *);
431 WORD handle_write(WORD,WORD,char far *);
432 void init(void); /*;AN000;6*/
433 void insert_node(char *);
434 WORD ioctl(WORD);
435 void label_target_drive(void);
436 DWORD lseek(WORD,BYTE,DWORD);
437 int main(int, char * []);
438 void mark_as_last_target(void);
439 void mark_as_not_last_target(void);
440 void mark_files_read_only(void);
441 void open_logfile(void);
442 void open_source_file(void);
443 void open_target(void);
444 void parser(int,char * []); /*;AN000;4*/
445 void parse_error(WORD,WORD); /*;AN000;4*//*;AN008;*/
446 void parse_init(void); /*;AN000;4*/
447 void process_switch(void); /*;AN000;4*//*;AN008;*/
448 void put_disk_header(void);
449 void put_new_db(void);
450 void put_new_fh(void);
451 void remove_last_backslash_from_BDS(void);
452 void remove_node(void);
453 void replace_volume_label(char *);
454 void reset_archive_bit(char *);
455 void restore_default_directories(void);
456 void save_current_dirs(void);
457 void see_if_it_should_be_backed_up(void);
458 void set_attribute(char *,WORD);
459 void set_vectors(void); /*;AN000;*/
460 void set_default_dir(void);
461 void set_default_drive(WORD);
462 void setsignal(WORD,WORD);
463 void show_path(void);
464 char *strcat(char *,const char *); /* */
465 size_t strlen(const char *); /* */
466 char *strcpy(char *, const char *); /* */
467 char *strncpy(char *, const char *, unsigned int); /* */
468 int strncmp(const char *,const char *,unsigned int);/* */
469 int strcmp(const char *,const char *); /* */
470 void terminate(void);
471 void update_db_entries(WORD);
472 void update_fh_entries(void);
473 /***** void write_extended_attributes(void); /*;AN000;3*/
474 WORD write_till_target_full(WORD,WORD);
475 void write_to_control_file(char far *,WORD);
476 void write_to_target(WORD);
477 void xlat(char *,char *); /*;AN000;*/
478
479 extern void sysloadmsg(union REGS *, union REGS *); /*;AN000;6*/
480 extern void update_logfile(union REGS *, union REGS *); /*;AN000;9*/
481 extern void sysdispmsg(union REGS *, union REGS *); /*;AN000;6*/
482 extern void parse (union REGS *, union REGS *); /*;AN000;4*/
483
484 /*-------------------------------*/
485 /*- From COMSUB.H */
486 /*-------------------------------*/
487
488 /* convert character to uppercase */
489 extern int com_toupper(
490 unsigned char ); /* character to be converted to uppercase */
491
492
493 /* search the first occurrence of a character in a string */
494 extern char *com_strchr(
495 unsigned char *, /* a source string */
496 unsigned char ); /* a character to be searched */
497
498 /* search the last charater occurrence in a string */
499 extern unsigned char
500 *com_strrchr(
501 unsigned char *, /* source string */
502 unsigned char ); /* target string */