wip
This commit is contained in:
14
edef.h
Normal file
14
edef.h
Normal file
@@ -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_ */
|
||||||
2
file.c
2
file.c
@@ -17,7 +17,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "globals.h"
|
#include "edef.h"
|
||||||
|
|
||||||
int ffwrite(char *path, char *fmt, ...) {
|
int ffwrite(char *path, char *fmt, ...) {
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|||||||
10
globals.c
Normal file
10
globals.c
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/* globals.c
|
||||||
|
*
|
||||||
|
* Global implementation
|
||||||
|
*
|
||||||
|
* written by vx-clutch
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
|
int I = 0;
|
||||||
12
globals.h
12
globals.h
@@ -1,14 +1,6 @@
|
|||||||
/* globals.h
|
|
||||||
*
|
|
||||||
* Global definitions
|
|
||||||
*
|
|
||||||
* written by vx-clutch
|
|
||||||
*/
|
|
||||||
#ifndef GLOBALS_H_
|
#ifndef GLOBALS_H_
|
||||||
#define GLOBALS_H_
|
#define GLOBALS_H_
|
||||||
|
|
||||||
enum { SINGLE = 1, FULL = 2 };
|
extern int I;
|
||||||
|
|
||||||
#define NPAT 4096 /* number of bytes for path buffer */
|
#endif
|
||||||
|
|
||||||
#endif /* GLOBALS_H_ */
|
|
||||||
|
|||||||
44
main.c
44
main.c
@@ -18,61 +18,63 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "edef.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "proj.h"
|
#include "proj.h"
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "usage.h"
|
#include "usage.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
void usage(int status)
|
void usage(int status) {
|
||||||
{
|
|
||||||
printf("Usage: %s filename\n", PROGRAM_NAME);
|
printf("Usage: %s filename\n", PROGRAM_NAME);
|
||||||
printf(" or: %s [options]\n\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\n", stdout);
|
||||||
fputs(" -S enable shell creation mode as a full project\n", stdout);
|
fputs(" -S enable shell creation mode as a full project\n",
|
||||||
fputs(" -i ignore estruct.h and prompt for all\n", stdout);
|
stdout);
|
||||||
|
fputs(" -I ignore estruct.h and prompt for all\n", stdout);
|
||||||
fputs(" --help display this help and exit\n", stdout);
|
fputs(" --help display this help and exit\n", stdout);
|
||||||
fputs(" --version output version information and exit\n", stdout);
|
fputs(" --version output version information and exit\n", stdout);
|
||||||
|
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
int shell_mode = 0;
|
int shell_mode = 0;
|
||||||
char *package = NULL;
|
char *package = NULL;
|
||||||
|
int carg;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
die("not enough arguments");
|
die("not enough arguments");
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i)
|
if (argc == 2) {
|
||||||
{
|
if (strcmp(argv[1], "--help") == 0)
|
||||||
if (argv[i][0] == '-')
|
|
||||||
{
|
|
||||||
if (strcmp(argv[i], "--help") == 0)
|
|
||||||
usage(EXIT_SUCCESS);
|
usage(EXIT_SUCCESS);
|
||||||
else if (strcmp(argv[i], "--version") == 0)
|
else if (strcmp(argv[1], "--version") == 0) {
|
||||||
{
|
|
||||||
version();
|
version();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[i], "-s") == 0)
|
}
|
||||||
|
|
||||||
|
for (carg = 1; carg < argc; ++carg) {
|
||||||
|
if (argv[carg][0] == '-') {
|
||||||
|
if (argv[carg][1] == 's')
|
||||||
shell_mode = SINGLE;
|
shell_mode = SINGLE;
|
||||||
else if (strcmp(argv[i], "-S") == 0)
|
else if (argv[carg][1] == 'S')
|
||||||
shell_mode = FULL;
|
shell_mode = FULL;
|
||||||
else if (strcmp(argv[i], "-i") == 0)
|
else if (argv[carg][1] == 'i')
|
||||||
i = 1;
|
I = 1;
|
||||||
else
|
else
|
||||||
die("unknown option");
|
die("unknown option");
|
||||||
}
|
} else
|
||||||
else
|
package = argv[carg];
|
||||||
package = argv[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!package)
|
if (!package)
|
||||||
die("no package name provided");
|
die("no package name provided");
|
||||||
|
|
||||||
|
if (I)
|
||||||
|
puts("'i' is not implemented yet");
|
||||||
|
|
||||||
if (shell_mode)
|
if (shell_mode)
|
||||||
makeshell(package, shell_mode);
|
makeshell(package, shell_mode);
|
||||||
else
|
else
|
||||||
|
|||||||
69
proj.c
69
proj.c
@@ -13,9 +13,10 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "proj.h"
|
#include "proj.h"
|
||||||
#include "usage.h"
|
#include "usage.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
int makeproj(char *src)
|
int makeproj(char *src) {
|
||||||
{
|
|
||||||
if (ffexist(src))
|
if (ffexist(src))
|
||||||
die("%s already exists", src);
|
die("%s already exists", src);
|
||||||
|
|
||||||
@@ -23,16 +24,20 @@ int makeproj(char *src)
|
|||||||
if (chdir(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", "\
|
ffwrite("main.c", "\
|
||||||
/*\n\
|
/*\n\
|
||||||
* main.c\n\
|
* main.c\n\
|
||||||
*\n\
|
*\n\
|
||||||
* package/Author 1.0\n\
|
* %s/%s 1.0\n\
|
||||||
*\n\
|
*\n\
|
||||||
* Copying policy\n\
|
* Copying policy\n\
|
||||||
*\n\
|
*\n\
|
||||||
* yait 1.0 can be copied and distributed freely for any\n\
|
* %s 1.0 can be copied and distributed freely for any\n\
|
||||||
* non-commercial purposes. yait 1.0 can only be incorporated\n\
|
* non-commercial purposes. %s 1.0 can only be incorporated\n\
|
||||||
* into commercial software with the permission of the current author.\n\
|
* into commercial software with the permission of the current author.\n\
|
||||||
*\n\
|
*\n\
|
||||||
* This file contains the main driving routine.\n\
|
* This file contains the main driving routine.\n\
|
||||||
@@ -70,5 +75,59 @@ int main(int argc, char **argv)\n\
|
|||||||
return 0;\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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
2
shell.c
2
shell.c
@@ -12,7 +12,7 @@
|
|||||||
#include "estruct.h"
|
#include "estruct.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "full.h"
|
#include "full.h"
|
||||||
#include "globals.h"
|
#include "edef.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "single.h"
|
#include "single.h"
|
||||||
|
|||||||
10
util.c
Normal file
10
util.c
Normal file
@@ -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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user