/************************************************* -*- mode: C -*- ** ** $Header: /u/gcmpack/MITgcm/tools/embed_encode/encode_files.c,v 1.1 2006/01/11 04:50:30 edhill Exp $ ** $Name: $ ** */ /* Encode one or more files for later writing */ #include #include #include #include #include int main(int argc, char** argv) { FILE * fout; FILE * fin; int ii; int nbytes; struct stat astat; unsigned char c; unsigned char buf[1024]; /* fout = fopen("t8", "w"); for (ii=0; ii<256; ii++) { c = (unsigned char)ii; fprintf(fout,"%c",c); } fclose(fout); */ if (argc < 3) { printf("ERROR: usage is: " "\"%s OUTPUT_FILE INPUT_FILE [...INPUT_FILES...]\"\n", argv[0]); return 1; } fout = fopen(argv[1], "w"); if (! fout) { printf("ERROR: cannot open \"%s\" for output\n", argv[1]); return 1; } fprintf(fout,"struct embeded_file {\n char * name;\n" " int ndat;\n char * dat;\n};\n"); fprintf(fout,"const int n_flist = %d;\n", argc-2); fprintf(fout,"struct embeded_file flist[] = {\n"); for (ii=2; ii