home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (C) Walter L. Peacock 1984-1988. All rights reserved */
- /* Z A P H D R . C 01/30/85 */
-
- #include <stdio.h>
- #include "cbtree.h"
-
- #if AmigaDOS & LC
- #define printf iprintf
- #endif
-
- void main(argc, argv)
- int argc;
- char *argv[];
- {
- extern char *calloc();
- extern char *strcpy();
- extern int exit();
- extern int open();
- extern int close();
- BTBLKHDR freespc;
- int fd;
- char filename[32], num_s[15];
- long atol(), xtol();
- long lbuff[2], lseek();
-
- wopen("CON:0/0/640/200/Zaphdrl");
-
- scr_clr();
- printf(
- "\n\n ZAP file header record FREE SPACE and END-OF-FILE pointers.\n");
-
- fd = getfname(argc, argv, "idx", filename);
-
- /* get the current values for the freelst and eof pointers */
- getfhdr(&freespc, fd);
- lbuff[0] = freespc.freelst; /* remember these */
- lbuff[1] = freespc.eoflst;
-
- printf("\n Enter New Free List Pointer <%lu (0x%04lx)> ==> ",
- lbuff[0], lbuff[0]);
- gets(num_s);
-
- if (*num_s != '\0')
- lbuff[0] = (strncmp(num_s, "0x", 2) == 0) ?
- xtol(num_s+2) : atol(num_s);
-
- printf("\n Enter New End Of File Pointer <%lu (0x%04lx)> ==> ",
- lbuff[1], lbuff[1]);
- gets(num_s);
-
- if (*num_s != '\0')
- lbuff[1] = (strncmp(num_s, "0x", 2) == 0) ?
- xtol(num_s+2) : atol(num_s);
-
- printf("\n\n New Free List Pointer for file '%s' is: %lu (0x%04lx)",
- filename, lbuff[0], lbuff[0]);
- printf("\n\n New End Of File Pointer for file '%s' is: %lu (0x%04lx)",
- filename, lbuff[1], lbuff[1]);
-
- if (lseek(fd, 0L, 0) == -1L)
- ckerror(- CK_SEEK, "zaphdrl: fd");
- if (write(fd, (char *)lbuff, sizeof(lbuff) ) == ERR)
- ckerror(- CK_WRIT, "zaphdrl: lbuff");
-
- close(fd);
- wclose(); /* close Amiga window */
- puts("\n\n");
- }
-
- long xtol(s) /* NUL-terminated hex-ascii string to long */
- char *s;
- {
- char c;
- long l = 0L;
-
- while ( ((c = toupper(*s)) >= '0' && c <= '9') || (c >= 'A' && c <= 'F') )
- {
- ++s;
- l <<= 4;
- l += (c <= '9') ? (c - '0') : (c - 'A' + 0xA);
- }
- return (l);
- }
-
-