home *** CD-ROM | disk | FTP | other *** search
- /* this program modifies files.ra of RA 2.5x so that older RA2.0x utilities
- can still work.
-
- Whenever the file areas have been altered (inserted/deleted/moved/renamed
- areas) follow these steps:
-
- 1. Run this program. It will create a new, compatible FILES.RA, rename the
- old file FILES.OLD, and delete the FILES.RDX file.
- 2. Run RACONFIG and go the the file area manager. This will cause a new
- FILES.RDX to be created.
- 3. When you are satisfied everything is working, delete the FILES.OLD.
-
- This program will not run if FILES.OLD exists or FILES.RDX is missing.
-
- Note -- FILES.RA will have as many records as the largest used file area
- number. It's not a good idea to use large area numbers unless you need
- to do so!
-
- IMPORTANT -- Area #0 is not supported.
-
- */
- #include <stdio.h>
- #include "ra250.h"
-
- void main(void) {
- FILES buff, nobuf={0};
- FILE *rdx, *ra, *ranew;
- unsigned areanum, offset=1;
-
- fprintf(stderr, "Fix Filebase for RemoteAccess 2.5x\n"
- "You should read the instructions before using!\n\n");
-
- if (fopen("files.old", "rb") != NULL) {
- fprintf(stderr, "Delete the old database file, FILES.OLD before running.\n");
- return;
- }
- if ((rdx = fopen("files.rdx", "rb")) == NULL) {
- fprintf(stderr, "The file FILES.RDX must exist to run this program.\n"
- "Run RACONFIG and enter the file area manager to re-create.\n");
- return;
- }
- if ((ra = fopen("files.ra", "rb")) == NULL) {
- fprintf(stderr, "The FILES.RA file is missing! You are in big trouble.\n");
- return;
- }
- if ((ranew = fopen("newfiles.$$$", "wb")) == NULL) {
- fprintf(stderr, "I can't create the temporary file NEWFILES.$$$\n");
- return;
- }
-
- while (fread(&areanum, sizeof(unsigned int), 1, rdx) > 0) {
- if (areanum != 0) {
- printf("New area %d from original position %d\n",
- offset, areanum);
-
- /* got a live one! */
- fseek(ra, sizeof(FILES)*(areanum-1), SEEK_SET);
- if (fread(&buff, sizeof(FILES), 1, ra) != 1) {
- fprintf(stderr,"There's a problem reading FILES.RA -- aborting\n");
- return;
- }
- buff.AreaNum = offset++;
- if (fwrite(&buff, sizeof(FILES), 1, ranew) < 1) {
- fprintf(stderr, "Disk full -- aborting\n");
- return;
- }
- }
- else {
- /* empty area */
- printf("Empty area %d\n", offset);
- nobuf.AreaNum = offset++;
- if (fwrite(&nobuf, sizeof(FILES), 1, ranew) < 1) {
- fprintf(stderr, "Disk full -- aborting\n");
- return;
- }
- }
- }
- fclose(rdx);
- fclose(ra);
- fclose(ranew);
- if(rename("files.ra", "files.old") != 0) {
- fprintf(stderr, "Darn, so close! I can't rename the original FILES.RA file -- aborting.\n");
- return;
- }
- rename("newfiles.$$$", "files.ra");
- remove("files.rdx");
- }
-
-