yait

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit f764bc6759fbd691fb5a563ee33b50be4586469e
parent 22242dc5321bafcd8690f813d689b9144b045702
Author: vx-clutch <[email protected]>
Date:   Tue, 11 Nov 2025 21:49:23 -0500

wip

Diffstat:
Aedef.h | 14++++++++++++++
Mfile.c | 2+-
Aglobals.c | 10++++++++++
Mglobals.h | 12++----------
Mmain.c | 60+++++++++++++++++++++++++++++++-----------------------------
Mproj.c | 71+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
Mshell.c | 2+-
Autil.c | 10++++++++++
Autil.h | 6++++++
9 files changed, 140 insertions(+), 47 deletions(-)

diff --git a/edef.h 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 @@ -17,7 +17,7 @@ #include <unistd.h> #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 @@ -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 @@ -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 @@ -18,61 +18,63 @@ #include <stdlib.h> #include <string.h> +#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 @@ -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 @@ -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 @@ -0,0 +1,10 @@ +#include "util.h" +#include <time.h> + +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 @@ -0,0 +1,6 @@ +#ifndef UTIL_H_ +#define UTIL_H_ + +int getyear(); + +#endif