home *** CD-ROM | disk | FTP | other *** search
-
- /************************************************************************/
- /* */
- /* MakeBarflyFD.c --- creates the file ram:BARFLY.FD */
- /* */
- /* V1.01 - KS 2.04 required */
- /* */
- /*----------------------------------------------------------------------*/
- /* */
- /* 07/24/91 "Small C-Hack" (V1.00) by Ralph Schmidt */
- /* */
- /* 11/28/91 Rewrite (call it V1.01) by Michael Böhnisch (billy) */
- /* Executable shrinks to less than 1/2 of original size */
- /* 3/2/94 Update some paths(V1.02) */
- /* */
- /************************************************************************/
-
- #include <exec/exec.h>
-
- #include <dos/dos.h>
- #include <dos/dostags.h>
-
- #include <proto/exec.h>
- #include <proto/dos.h>
-
- #include <stdlib.h> /* ANSI includes. DO NOT INCLUDE STDIO.H ! */
- #include <stdarg.h>
- #include <stddef.h>
- #include <string.h>
- #include <ctype.h>
-
- const UBYTE Version[] = "$VER: MakeBarflyFD 1.02 ("__DATE__")";
-
- #define BUFFERSIZE 256
-
- /*extern struct Library *DOSBase;*/
-
- /*----------------------------------------------------------------------*/
- /* I/O filehandles & filenames */
- /*----------------------------------------------------------------------*/
-
- BPTR Source, Dest, stdout;
-
- UBYTE *SourceName = "T:BARFLY.FD_bak",
- *DestName = "ram:BARFLY.FD",
- *stdoutName = "CON:0/0/640/200/MakeBarFlyFD/AUTO/NOCLOSE";
-
- /*----------------------------------------------------------------------*/
- /* Close anything opened at runtime */
- /*----------------------------------------------------------------------*/
-
- void CloseAll(void)
- {
- if ( Source ) Close(Source);
- if ( Dest ) Close(Dest );
-
- DeleteFile(SourceName);
-
- if ( stdout ) {
- Delay(500);
- Close(stdout);
- }
- }
-
- /*----------------------------------------------------------------------*/
- /* fake main program (lc will replace this by tinymain) */
- /*----------------------------------------------------------------------*/
-
- void main(int argc, char **argv)
- {
- UBYTE Buffer[BUFFERSIZE];
- int i;
-
- /*--------------------------------------------------------------*/
- /* assign I/O file handles */
- /*--------------------------------------------------------------*/
-
- stdout = Open(stdoutName, MODE_NEWFILE);
- if ( ! stdout ) {
- exit(20);
- }
-
- /*--------------------------------------------------------------*/
- /* introductory messages */
- /*--------------------------------------------------------------*/
-
- FPuts(stdout,
- "\033[0;0H\033[J" /* Clear window */
- "This program creates the file 'ram:Barfly.FD'.\n\n"
-
- "Please check the following files:\n"
- "exec_lib.fd\t\t1. line: \"* exec.library\"\n"
- "misc_lib.fd\t\t1. line: \"* misc.resource\"\n"
- "expansion_lib.fd\t1. line: \"* expansion.library\"\n"
- "Better check all library definition files and add it\n"
- "where necessary!\n\n"
-
- "Joining #?.FD files...\n\n"
- );
-
- /*--------------------------------------------------------------*/
- /* Join fd files to temporary. SystemTagList() is the preferred */
- /* method for calling external programs since the actual progam */
- /* return code is returned, -1 for not executable. */
- /* Additonally SystemTagList() does not read commands from */
- /* Input() filehandle. */
- /*--------------------------------------------------------------*/
-
- if ( SystemTagList("Join >NIL: FD:#?.fd AS T:BARFLY.FD_bak", NULL) ) {
- FPuts(stdout,
- "Join failed.\n"
- "Make sure that \"FD:\" is assigned to the directory"
- "containing\n"
- "the #?.fd files.\n"
- );
- CloseAll();
- exit(10);
- }
-
- /*--------------------------------------------------------------*/
- /* Open temporary file as input */
- /*--------------------------------------------------------------*/
-
- if ( ! ( Source = Open(SourceName, MODE_OLDFILE) ) ) {
- FPuts(stdout, "Can't open T:BARFLY.FD_bak\n");
- CloseAll();
- exit(10);
- }
-
- /*--------------------------------------------------------------*/
- /* Create new library description file for Barfly */
- /*--------------------------------------------------------------*/
-
- if ( ! ( Dest = Open(DestName, MODE_NEWFILE) ) ) {
- FPuts(stdout, "Can't create new file ram:BARFLY.FD\n");
- CloseAll();
- exit(10);
- }
-
- FPuts(stdout, "Creating ram:BARFLY.FD...\n\n");
-
- /*--------------------------------------------------------------*/
- /* Main step: filter comments and argument strings */
- /*--------------------------------------------------------------*/
-
- while ( FGets(Source, Buffer, BUFFERSIZE) ) {
- switch ( Buffer[0] ) {
-
- /*--------------------------------------------------*/
- /* filter comments (except lib/resource/... names) */
- /*--------------------------------------------------*/
-
- case '*':
- if ( ( Buffer[1] == ' ' ) && (Buffer[2] == '\"') ) {
- FPuts(Dest, Buffer);
- }
- break;
-
- /*--------------------------------------------------*/
- /* filter fd commands (except ##bias) */
- /*--------------------------------------------------*/
-
- case '#':
- if ( ( Buffer[1] == '#') &&
- (tolower(Buffer[2]) == 'b') &&
- (tolower(Buffer[3]) == 'i') ) {
- FPuts(Dest, Buffer);
- }
- break;
-
- /*--------------------------------------------------*/
- /* filter argument strings */
- /*--------------------------------------------------*/
-
- default:
- if ( isalpha(Buffer[0]) ) {
- for ( i = 0; Buffer[i] != '('; i++ ) { ; }
- Buffer[i] = '\n';
- Buffer[i+1] = '\0';
- FPuts(Dest, Buffer);
- }
- break;
- }
- }
-
- /*--------------------------------------------------------------*/
- /* Cleanup: Close anything opened at runtime */
- /*--------------------------------------------------------------*/
-
- FPuts(stdout, "All done!!!\n");
- CloseAll();
- }
-