diff --git a/legacy/embryo/src/bin/embryo_cc_sclib.c b/legacy/embryo/src/bin/embryo_cc_sclib.c deleted file mode 100644 index 760018e0af..0000000000 --- a/legacy/embryo/src/bin/embryo_cc_sclib.c +++ /dev/null @@ -1,218 +0,0 @@ -/* SCLIB.C - * - * This is an example file that shows how to embed the Small compiler into a - * program. This program contains the "default" implementation of all - * functions that the Small compiler calls for I/O. - * - * This program also contains a main(), so it compiles, again, to a - * stand-alone compiler. This is for illustration purposes only - * - * What this file does is (in sequence): - * 1. Declare the NO_MAIN macro, so that the function main() and all - * "callback" functions that are in SC1.C are not compiled. - * 2. Declare SC_FUNC and SC_VDEFINE as "static" so that all functions and - * global variables are "encapsulated" in the object file. This solves - * the global namespace polution problem. - * 3. Declare the SC_SKIP_VDECL macro which is needed to avoid variables to - * be doubly declared when the C files are *not* independently compiled. - * 4. And, the dirtiest trick of all, include the remaining C files. That is, - * the entire Small compiler compiles to a single object file (.OBJ in - * Windows). This is the only way to get rid of the global namespace - * polution. - * - * Note that the interface of the Small compiler is subject to change. - * - * Compilation: - * wcl386 /l=nt sclib.c - * - * Copyright (c) ITB CompuPhase, 2000-2003 - * This file may be freely used. No warranties of any kind. - */ -#include -#include -#include - -#define NO_MAIN -#define SC_FUNC static -#define SC_VDEFINE static -#define SC_SKIP_VDECL /* skip variable "forward declaration" */ -#include "sc.h" - -#include "scvars.c" -#include "sc1.c" -#include "sc2.c" -#include "sc3.c" -#include "sc4.c" -#include "sc5.c" -#include "sc6.c" -#include "sc7.c" -#include "sclist.c" -#include "scexpand.c" - -int main(int argc, char **argv) -{ - return sc_compile(argc,argv); -} - -/* sc_printf - * Called for general purpose "console" output. This function prints general - * purpose messages; errors go through sc_error(). The function is modelled - * after printf(). - */ -int sc_printf(const char *message,...) -{ - int ret; - va_list argptr; - - va_start(argptr,message); - ret=vprintf(message,argptr); - va_end(argptr); - - return ret; -} - -/* sc_error - * Called for producing error output. - * number the error number (as documented in the manual) - * message a string describing the error with embedded %d and %s tokens - * filename the name of the file currently being parsed - * firstline the line number at which the expression started on which - * the error was found, or -1 if there is no "starting line" - * lastline the line number at which the error was detected - * argptr a pointer to the first of a series of arguments (for macro - * "va_arg") - * Return: - * If the function returns 0, the parser attempts to continue compilation. - * On a non-zero return value, the parser aborts. - */ -int sc_error(int number,char *message,char *filename,int firstline,int lastline,va_list argptr) -{ -static char *prefix[3]={ "Error", "Fatal", "Warning" }; - - if (number!=0) { - char *pre; - - pre=prefix[number/100]; - if (firstline>=0) - printf("%s(%d -- %d) %s [%03d]: ",filename,firstline,lastline,pre,number); - else - printf("%s(%d) %s [%03d]: ",filename,lastline,pre,number); - } /* if */ - vprintf(message,argptr); - fflush(stdout); - return 0; -} - -/* sc_opensrc - * Opens a source file (or include file) for reading. The "file" does not have - * to be a physical file, one might compile from memory. - * filename the name of the "file" to read from - * Return: - * The function must return a pointer, which is used as a "magic cookie" to - * all I/O functions. When failing to open the file for reading, the - * function must return NULL. - */ -void *sc_opensrc(char *filename) -{ - return fopen(filename,"rt"); -} - -/* sc_closesrc - * Closes a source file (or include file). The "handle" parameter has the - * value that sc_opensrc() returned in an earlier call. - */ -void sc_closesrc(void *handle) -{ - assert(handle!=NULL); - fclose((FILE*)handle); -} - -/* sc_resetsrc - * "position" may only hold a pointer that was previously obtained from - * sc_getpossrc() */ -void sc_resetsrc(void *handle,void *position) -{ - assert(handle!=NULL); - fsetpos((FILE*)handle,(fpos_t *)position); -} - -char *sc_readsrc(void *handle,char *target,int maxchars) -{ - return fgets(target,maxchars,(FILE*)handle); -} - -void *sc_getpossrc(void *handle) -{ - static fpos_t lastpos; - - fgetpos((FILE*)handle,&lastpos); - return &lastpos; -} - -int sc_eofsrc(void *handle) -{ - return feof((FILE*)handle); -} - -/* should return a pointer, which is used as a "magic cookie" to all I/O - * functions; return NULL for failure - */ -void *sc_openasm(char *filename) -{ - return fopen(filename,"w+t"); -} - -void sc_closeasm(void *handle, int deletefile) -{ - fclose((FILE*)handle); - if (deletefile) - unlink(outfname); -} - -void sc_resetasm(void *handle) -{ - fflush((FILE*)handle); - fseek((FILE*)handle,0,SEEK_SET); -} - -int sc_writeasm(void *handle,char *st) -{ - return fputs(st,(FILE*)handle) >= 0; -} - -char *sc_readasm(void *handle, char *target, int maxchars) -{ - return fgets(target,maxchars,(FILE*)handle); -} - -/* Should return a pointer, which is used as a "magic cookie" to all I/O - * functions; return NULL for failure. - */ -void *sc_openbin(char *filename) -{ - return fopen(filename,"wb"); -} - -void sc_closebin(void *handle,int deletefile) -{ - fclose((FILE*)handle); - if (deletefile) - unlink(binfname); -} - -void sc_resetbin(void *handle) -{ - fflush((FILE*)handle); - fseek((FILE*)handle,0,SEEK_SET); -} - -int sc_writebin(void *handle,void *buffer,int size) -{ - return fwrite(buffer,1,size,(FILE*)handle) == size; -} - -long sc_lengthbin(void *handle) -{ - return ftell((FILE*)handle); -} - diff --git a/legacy/embryo/src/bin/embryo_cc_scpack.c b/legacy/embryo/src/bin/embryo_cc_scpack.c deleted file mode 100644 index a701e3a9e7..0000000000 --- a/legacy/embryo/src/bin/embryo_cc_scpack.c +++ /dev/null @@ -1,450 +0,0 @@ -/* compress.c -- Byte Pair Encoding compression */ -/* Copyright 1996 Philip Gage */ - -/* This program appeared in the September 1997 issue of - * C/C++ Users Journal. The original source code may still - * be found at the web site of the magazine (www.cuj.com). - * - * It has been modified by me (Thiadmer Riemersma) to - * compress only a section of the input file and to store - * the compressed output along with the input as "C" strings. - * - * Compiling instructions: - * Borland C++ 16-bit (large memory model is required): - * bcc -ml scpack.c - * - * Watcom C/C++ 32-bit: - * wcl386 scpack.c - * - * GNU C (Linux), 32-bit: - * gcc scpack.c -o scpack - */ - -#include -#include -#include -#include -#include - -#if UINT_MAX > 0xFFFFU - #define MAXSIZE 1024*1024L -#else - #define MAXSIZE UINT_MAX /* Input file buffer size */ -#endif -#define HASHSIZE 8192 /* Hash table size, power of 2 */ -#define THRESHOLD 3 /* Increase for speed, min 3 */ - -#define START_TOKEN "#ifdef SCPACK" /* start reading the buffer here */ -#define NAME_TOKEN "#define SCPACK_TABLE" -#define SEP_TOKEN "#define SCPACK_SEPARATOR" -#define TERM_TOKEN "#define SCPACK_TERMINATOR" -#define TEMPFILE "~SCPACK.TMP" -static char tablename[32+1] = "scpack_table"; -static char separator[16]=","; -static char terminator[16]=""; - -int compress(unsigned char *buffer, unsigned buffersize, unsigned char pairtable[128][2]) -{ - unsigned char *left, *right, *count; - unsigned char a, b, bestcount; - unsigned i, j, index, bestindex, code=128; - - /* Dynamically allocate buffers and check for errors */ - left = (unsigned char *)malloc(HASHSIZE); - right = (unsigned char *)malloc(HASHSIZE); - count = (unsigned char *)malloc(HASHSIZE); - if (left==NULL || right==NULL || count==NULL) { - printf("Error allocating memory\n"); - exit(1); - } - - /* Check for errors */ - for (i=0; i 127) { - printf("This program works only on text files (7-bit ASCII)\n"); - exit(1); - } - - memset(pairtable, 0, 128*2*sizeof(char)); - - do { /* Replace frequent pairs with bytes 128..255 */ - - /* Enter counts of all byte pairs into hash table */ - memset(count,0,HASHSIZE); - for (i=0; i bestcount) { - bestcount = count[i]; - bestindex = i; - } - } - - /* Compress if enough occurrences of pair */ - if (bestcount >= THRESHOLD) { - - /* Add pair to table using code as index */ - a = pairtable[code-128][0] = left[bestindex]; - b = pairtable[code-128][1] = right[bestindex]; - - /* Replace all pair occurrences with unused byte */ - for (i=0, j=0; i= 128 || *bufptr == '"' || *bufptr == '\\') - fprintf(output, "\\%03o", *bufptr); - else - fprintf(output, "%c", *bufptr); - bufptr++; - } /* while */ - fprintf(output, "\""); - needseparator = 1; - bufptr++; /* skip '\0' */ - } /* while */ - fprintf(output, "%s\n",terminator); - bufptr++; - - /* skip the input file until the #endif section */ - while (fgets(str,sizeof str,input)!=NULL) { - if (strmatch(str,"#endif",NULL)) { - fprintf(output,"%s",str); - break; /* done */ - } /* if */ - } /* while */ - } /* while - !feof(input) */ -} - -static void usage(void) -{ - printf("Usage: scpack [output file]\n"); - exit(1); -} - -int main(int argc, char **argv) -{ - FILE *in, *out; - unsigned char *buffer; - unsigned buffersize, orgbuffersize; - unsigned char pairtable[128][2]; - - if (argc < 2 || argc > 3) - usage(); - if ((in=fopen(argv[1],"rt"))==NULL) { - printf("SCPACK: error opening input %s\n",argv[1]); - usage(); - } /* if */ - if (argc == 2) { - if ((out=fopen(TEMPFILE,"wt"))==NULL) { - printf("SCPACK: error opening temporary file %s\n",TEMPFILE); - usage(); - } /* if */ - } else { - if ((out=fopen(argv[2],"wt"))==NULL) { - printf("SCPACK: error opening output file %s\n",argv[2]); - usage(); - } /* if */ - } /* if */ - - buffer = (unsigned char *)malloc(MAXSIZE); - if (buffer == NULL) { - printf("SCPACK: error allocating memory\n"); - return 1; - } /* if */ - /* 1. read the buffer - * 2. compress the buffer - * 3. copy the file, insert the compressed buffer - */ - buffersize = readbuffer(in, buffer); - orgbuffersize = buffersize; - if (buffersize > 0) { - buffersize = compress(buffer, buffersize, pairtable); - writefile(in, out, buffer, buffersize, pairtable); - printf("SCPACK: compression ratio: %ld%% (%d -> %d)\n", - 100L-(100L*buffersize)/orgbuffersize, orgbuffersize, buffersize); - } else { - printf("SCPACK: no SCPACK section found, nothing to do\n"); - } /* if */ - fclose(out); - fclose(in); - /* let the new file replace the old file */ - if (buffersize == 0) { - if (argc == 2) - unlink(TEMPFILE); - else - unlink(argv[2]); - } else if (argc == 2) { - unlink(argv[1]); - rename(TEMPFILE,argv[1]); - } /* if */ - return 0; -} diff --git a/legacy/embryo/src/bin/embryo_cc_scstub.c b/legacy/embryo/src/bin/embryo_cc_scstub.c deleted file mode 100644 index 4937d50830..0000000000 --- a/legacy/embryo/src/bin/embryo_cc_scstub.c +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include - -static char filename[] = "scdos.exe"; - -int main(int argc, char *argv[]) -{ - int result; - - /* build a command line to pass on to the "DOS" program */ - char path[80], *ptr; - strcpy(path,argv[0]); - ptr=strrchr(path,'\\'); - if (ptr==NULL) - ptr=strchr(path,':'); - if (ptr==NULL) { - strcpy(path,filename); - } else { - strcpy(ptr+1,filename); - } /* if */ - - /* launch the DOS version of the tool */ - result=execv(path,argv); - if (result==-1) - printf("Error launching '%s'\n",path); - return result; -} -