/* _skel-1f one-file (1f) skeleton code base Copyright (C) 2016 MiNTed Games All Rights Reserved This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* one-file (-1f) compile g++ -Wall -O3 -DVERSION=\"1.0.2\" -o _skel-1f _skel-1f.cpp ; \ g++ -Wall -O3 -DVERSION=\"1.0.2\" -DPRG_SIZE=`ls -l _skel-1f|cut -d \ -f 5` -DSRC_SIZE=`ls -l _skel-1f.cpp|cut -d \ -f 5` -o _skel-1f _skel-1f.cpp ; \ cat _skel-1f.cpp >> _skel-1f */ /* one-file (1f) requires _space_seperated_list_of_dev_libraries_required_for_successful_compile_ */ /* one-file (1f) headers */ #include #include #include /* one-file source appendage */ //#define SRC_TYPE ".zip" // if its a ZIP appendage #define SRC_TYPE ".cpp" // if its a TEXT appendage #ifndef PRG_SIZE //#define PRG_SIZE 7370 // last checked binary size was ... #define PRG_SIZE 12345 // .. this should be close to actual #endif #ifndef SRC_SIZE // size of 1 text file or 1 zip file //#define SRC_SIZE 5893 // last checked source size was ... #define SRC_SIZE 12345 // .. affects binary size if too small #endif const long offset_1f = PRG_SIZE; // this has never been accurate (EXT4) const long sizeOf_1f = SRC_SIZE; // we use this (-sizeOf_1f) as offset /* one-file (1f) start */ /* one-file (1f) defines */ /* one-file (1f) enums */ /* one-file (1f) structs */ /* one-file (1f) classes */ /* one-file (1f) functions */ /* one-file (1f) specific */ void version_1f() { printf("_skel (one-file) v%s\n", VERSION); } void output_1f(char *file_1f) { FILE *source_1f; char out_1f[1]; if (offset_1f == 12345 || sizeOf_1f == 12345) { version_1f(); printf("error: no source file or zip\n"); exit(32); }else{ source_1f = fopen(file_1f, "rb"); if (source_1f == NULL) { version_1f(); printf("error: cant open '%s'\n", file_1f); exit(32); } // fseek(source_1f, offset_1f + 223, SEEK_SET); // off by ? fseek(source_1f, -sizeOf_1f, SEEK_END); while(true) { if (!fread(out_1f, 1, 1, source_1f)) { fclose(source_1f); break; }else putchar((int) out_1f[0]); } } } /* one-file (1f) main */ int main(int argc, char *argv[]) { /* place used variables here */ int j, argDone; /* this is the begining of commandline argument processing */ if ( (argc == 1) || ( (argc > 1) && (strcmp("--help", argv[1]) == 0) ) ) { version_1f(); printf("Copyright 2016 MiNTed Games\n\n"); printf("one-file (1f) skeleton code base.\n\n"); printf("usage: _skel-1f [_option_||||]\n"); if (argc > 1) { printf("_option_:"); printf("\t-1f one-file (1f) source information\n"); printf("\t--help This help information\n"); printf("\t-v|--version Version information\n"); } printf("\n"); exit(0); } if ( (argc > 1 ) && ( (strcmp("-1f", argv[1]) == 0) || (strcmp("--1f", argv[1]) == 0) ) ) { version_1f(); printf("Copyright 2016 MiNTed Games\n"); printf("one-file (1f) source information.\n\n"); if (offset_1f == 12345 || sizeOf_1f == 12345) { printf("no source file or zip\n"); exit(32); }else{ printf("usage: _skel-1f _option_\n"); printf("_option_:\n"); printf("\t--src|--source output attached one-file (1f) source file\n"); printf("\t--src-size size of appended source (in bytes) (%d)\n", sizeOf_1f); printf("\t--src-type type of source appended (TXT/ZIP) (%s)\n", SRC_TYPE); printf("\n"); printf("To save one-file (1f) source to file use one of the following:\n"); printf("\t_skel-1f --src > _skel-1f.cpp\n"); printf("\t_skel-1f --src > _skel-1f.zip\n"); printf("\t_skel-1f --src > _skel-1f`_skel-1f --src-type`\n"); printf("To verify one-file (1f) source file size:\n"); printf("\t_skel-1f --src-size (match this to the size in a directory listing)\n"); printf("or use:\n"); printf("NAME=_skel; if [ `ls -l $NAME-1f.cpp|cut -d \\ -f 5` = `./$NAME-1f --src-size` ]; then echo Verified; else echo Failed; fi\n"); printf("one-file (1f) options exit with status:\n"); printf("\t31 no error (0x1f)\n"); printf("\t32 an error occured (0x20)\n"); exit(31); } } if ( (argc > 1) && ( (strcmp("--source", argv[1]) == 0) || (strcmp("--src", argv[1]) == 0) ) ) { output_1f(argv[0]); exit(31); } if ( (argc > 1) && (strcmp("--src-type", argv[1]) == 0) ) { printf(SRC_TYPE); exit(31); } if ( (argc > 1) && (strcmp("--src-size", argv[1]) == 0) ) { printf("%d", SRC_SIZE); exit(31); } if ( (argc > 1) && ( (strcmp("--version", argv[1]) == 0) || (strcmp("-v", argv[1]) == 0) ) ) { version_1f(); exit(0); } /* the rest of your argv[] processing goes here */ /* sdlPlay_init(); j = 0; for (int i = 1; i < argc; i++) { argDone = 0; if (strcmp(argv[i], "--loop") == 0) { i++; if (i == argc) { printf("error: --loop needs a number\n"); exit(1); } sdlPlay.loop = atoi(argv[i]); argDone = 1; } if (argDone == 0) { strcpy(sdlPlay.playList[j], argv[i]); j++; } } sdlPlay.playlist = j; */ /* place your while(true) loop here (if you have one) */ /* section = 0; while (true) { // non-blocking (shows high CPU usage) // should be event driven, but this is faster switch(section) { case 0: section = getAudioFile(); break; case 1: section = isPlaying(); break; case 2: section = playLoop(); break; case 5: section = playMusic(); break; case 6: section = playMod(); break; case 7: section = playSound(); break; case 9: sdlPlay.next++; section = 0; break; } } */ /* this is the end, .. my friend, the end */ return(0); }