diff --git a/edef.h b/edef.h new file mode 100644 index 0000000..f32754c --- /dev/null +++ b/edef.h @@ -0,0 +1,14 @@ +/* edef.h + * + * Program definitions + * + * written by vx-clutch + */ +#ifndef EDEF_H_ +#define EDEF_H_ + +enum { SINGLE = 1, FULL = 2 }; + +#define NPAT 4096 /* number of bytes for path buffer */ + +#endif /* EDEF_H_ */ diff --git a/file.c b/file.c index a675866..f6d631c 100644 --- a/file.c +++ b/file.c @@ -17,7 +17,7 @@ #include #include "file.h" -#include "globals.h" +#include "edef.h" int ffwrite(char *path, char *fmt, ...) { FILE *f; diff --git a/globals.c b/globals.c new file mode 100644 index 0000000..36238ff --- /dev/null +++ b/globals.c @@ -0,0 +1,10 @@ +/* globals.c + * + * Global implementation + * + * written by vx-clutch + */ + +#include "globals.h" + +int I = 0; diff --git a/globals.h b/globals.h index 9125a16..8394d85 100644 --- a/globals.h +++ b/globals.h @@ -1,14 +1,6 @@ -/* globals.h - * - * Global definitions - * - * written by vx-clutch - */ #ifndef GLOBALS_H_ #define GLOBALS_H_ -enum { SINGLE = 1, FULL = 2 }; +extern int I; -#define NPAT 4096 /* number of bytes for path buffer */ - -#endif /* GLOBALS_H_ */ +#endif diff --git a/main.c b/main.c index 2ababc8..ccfc878 100644 --- a/main.c +++ b/main.c @@ -18,61 +18,63 @@ #include #include +#include "edef.h" #include "globals.h" #include "proj.h" #include "shell.h" #include "usage.h" #include "version.h" -void usage(int status) -{ +void usage(int status) { printf("Usage: %s filename\n", PROGRAM_NAME); printf(" or: %s [options]\n\n", PROGRAM_NAME); fputs(" -s enable shell creation mode\n", stdout); - fputs(" -S enable shell creation mode as a full project\n", stdout); - fputs(" -i ignore estruct.h and prompt for all\n", stdout); + fputs(" -S enable shell creation mode as a full project\n", + stdout); + fputs(" -I ignore estruct.h and prompt for all\n", stdout); fputs(" --help display this help and exit\n", stdout); fputs(" --version output version information and exit\n", stdout); exit(status); } -int main(int argc, char **argv) -{ - int i = 0; +int main(int argc, char **argv) { int shell_mode = 0; char *package = NULL; + int carg; if (argc < 2) die("not enough arguments"); - for (int i = 1; i < argc; ++i) - { - if (argv[i][0] == '-') - { - if (strcmp(argv[i], "--help") == 0) - usage(EXIT_SUCCESS); - else if (strcmp(argv[i], "--version") == 0) - { - version(); - exit(EXIT_SUCCESS); - } - else if (strcmp(argv[i], "-s") == 0) - shell_mode = SINGLE; - else if (strcmp(argv[i], "-S") == 0) - shell_mode = FULL; - else if (strcmp(argv[i], "-i") == 0) - i = 1; - else - die("unknown option"); - } - else - package = argv[i]; + if (argc == 2) { + if (strcmp(argv[1], "--help") == 0) + usage(EXIT_SUCCESS); + else if (strcmp(argv[1], "--version") == 0) { + version(); + exit(EXIT_SUCCESS); } + } + + for (carg = 1; carg < argc; ++carg) { + if (argv[carg][0] == '-') { + if (argv[carg][1] == 's') + shell_mode = SINGLE; + else if (argv[carg][1] == 'S') + shell_mode = FULL; + else if (argv[carg][1] == 'i') + I = 1; + else + die("unknown option"); + } else + package = argv[carg]; + } if (!package) die("no package name provided"); + if (I) + puts("'i' is not implemented yet"); + if (shell_mode) makeshell(package, shell_mode); else diff --git a/proj.c b/proj.c index 923a240..97f1a03 100644 --- a/proj.c +++ b/proj.c @@ -13,26 +13,31 @@ #include "input.h" #include "proj.h" #include "usage.h" +#include "util.h" +#include "version.h" -int makeproj(char *src) -{ +int makeproj(char *src) { if (ffexist(src)) die("%s already exists", src); fmkdir(src); if (chdir(src)) - die("could not cd into %s", src); + die("could not cd into %s", src); + + int year = getyear(); + char *author = getstring("Author"); + char *description = getstring("Description"); ffwrite("main.c", "\ /*\n\ * main.c\n\ *\n\ - * package/Author 1.0\n\ + * %s/%s 1.0\n\ *\n\ * Copying policy\n\ *\n\ - * yait 1.0 can be copied and distributed freely for any\n\ - * non-commercial purposes. yait 1.0 can only be incorporated\n\ + * %s 1.0 can be copied and distributed freely for any\n\ + * non-commercial purposes. %s 1.0 can only be incorporated\n\ * into commercial software with the permission of the current author.\n\ *\n\ * This file contains the main driving routine.\n\ @@ -70,5 +75,59 @@ int main(int argc, char **argv)\n\ return 0;\n\ }"); + ffwrite("README", "\ ++%%s+\n\ +| %%s |\n\ ++%%s+\n\ +\n\ + %s\n\ +\n\ + %s was written by %s\n\ +\n\ + Copyright Notices:\n\ +\n\ + %s 1.0 (c) Copyright %d %s\n\ +\n\ + Reference the COPYING file for detailed information\n\ +\n\ +\n\ +WHAT IS %s/%s?\n\ +\n\ +%s/%s 1.0 %s\n\ +\n\ +\n\ +WHAT IS NEW\n\ +\n\ +Features:\n\ +\n\ +o This is the first version, EVERYTHING is new!\n\ +\n\ +Bug fixes - not very interesting:\n\ +\n\ +o None\n\ +\n\ +Something is gone:\n\ +\n\ +o None\n\ +\n\ +HOW TO INSTALL %s/%s?\n\ +\n\ +o UNIX: Look at estruct.h, do a 'make', test the program, 'make install'.\n\ +\n\ +\n\ +ACKNOWLEDGEMENTS AND STATUS\n\ +\n\ +This project's file strucutre, file format, and certain contents are\n\ +derived from uEmacs/PK 4.0 specifically from the Linux Torvalds\n\ +distribution on GitHub. The README on from uEmacs/PK 4.0 has greater and\n\ +more accurate attributions, if you desire.\n\ +\n\ +%s was generated using yait/fSD %s.\n\ +\n\ +LAST MODIFED DATE\ +", + description, src, author, src, year, author, src, author, src, author, + description, src, author, VERSION); + return 0; } diff --git a/shell.c b/shell.c index cce21bb..2b5fc7c 100644 --- a/shell.c +++ b/shell.c @@ -12,7 +12,7 @@ #include "estruct.h" #include "file.h" #include "full.h" -#include "globals.h" +#include "edef.h" #include "input.h" #include "shell.h" #include "single.h" diff --git a/util.c b/util.c new file mode 100644 index 0000000..26a0795 --- /dev/null +++ b/util.c @@ -0,0 +1,10 @@ +#include "util.h" +#include + +int getyear() +{ + time_t now = time(NULL); + struct tm *t = localtime(&now); + + return t->tm_year + 1900; +} diff --git a/util.h b/util.h new file mode 100644 index 0000000..58b59f8 --- /dev/null +++ b/util.h @@ -0,0 +1,6 @@ +#ifndef UTIL_H_ +#define UTIL_H_ + +int getyear(); + +#endif