diff --git a/edef.h b/edef.h index f32754c..667163e 100644 --- a/edef.h +++ b/edef.h @@ -1,14 +1,18 @@ /* edef.h - * - * Program definitions + * + * Global variable definition * * written by vx-clutch */ + #ifndef EDEF_H_ #define EDEF_H_ -enum { SINGLE = 1, FULL = 2 }; +/* Initialized global external declarations. */ -#define NPAT 4096 /* number of bytes for path buffer */ +extern int git; + +/* Other constants declarations */ +enum { SINGLE, FULL }; #endif /* EDEF_H_ */ diff --git a/estruct.h b/estruct.h index 9b514f9..8555adf 100644 --- a/estruct.h +++ b/estruct.h @@ -9,4 +9,10 @@ #define QAUTHOR 0 /* Force use the default author option */ #define AUTHOR "fSD" /* Default author */ +#define DEFAULT_GIT 0 /* Default git state */ + +/* Internal constants */ + +#define NPAT 128 + #endif /* ESTRUCT_H_ */ diff --git a/file.c b/file.c index f6d631c..51f3633 100644 --- a/file.c +++ b/file.c @@ -1,8 +1,7 @@ /* file.c * * The routines in this file handle the reading, writing - * and lookup of disk files. All of details about the - * reading and writing of the disk are in "fileio.c". + * and lookup of disk files. * * written by vx-clutch */ @@ -17,7 +16,7 @@ #include #include "file.h" -#include "edef.h" +#include "estruct.h" int ffwrite(char *path, char *fmt, ...) { FILE *f; diff --git a/full.c b/full.c index 1d1b92c..5529ab7 100644 --- a/full.c +++ b/full.c @@ -10,6 +10,7 @@ #include "file.h" #include "full.h" #include "usage.h" +#include "git.h" int full_project_init_and_cd(char *src) { @@ -72,5 +73,7 @@ more accurate attributions, if you desire.\n\ \n\ LATE MODIFIED DATE", src, src); + ginit(); /* initialize a git repository */ + return 0; } diff --git a/git.c b/git.c new file mode 100644 index 0000000..3e10277 --- /dev/null +++ b/git.c @@ -0,0 +1,17 @@ +/* git.c + * + * Routines for initilizing a git repository + * + * written by vx-clutch + */ + +#include "git.h" +#include "edef.h" +#include + +int ginit() +{ + if (git) return 0; + system("git init --quiet"); + return 0; +} diff --git a/git.h b/git.h new file mode 100644 index 0000000..f19f486 --- /dev/null +++ b/git.h @@ -0,0 +1,6 @@ +#ifndef GIT_H_ +#define GIT_H_ + +int ginit(); + +#endif /* GIT_H_ */ diff --git a/globals.c b/globals.c new file mode 100644 index 0000000..e749145 --- /dev/null +++ b/globals.c @@ -0,0 +1,6 @@ +#include "estruct.h" +#include "edef.h" + +/* initialized global definitions */ + +int git = DEFAULT_GIT; diff --git a/main.c b/main.c index 00d5d99..ce4392a 100644 --- a/main.c +++ b/main.c @@ -17,6 +17,10 @@ #include #include #include +#include +#include +#include +#include #include "edef.h" #include "proj.h" @@ -28,8 +32,8 @@ 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(" -S enable shell creation mode as a full project\n", stdout); + fputs(" --git initialize a git repository\n", stdout); fputs(" --help display this help and exit\n", stdout); fputs(" --version output version information and exit\n", stdout); @@ -59,6 +63,8 @@ int main(int argc, char **argv) { shell_mode = SINGLE; else if (argv[carg][1] == 'S') shell_mode = FULL; + else if (strcmp(argv[carg], "--git")) + git = 1; else die("unknown option"); } else diff --git a/shell.c b/shell.c index 2b5fc7c..d92a1d9 100644 --- a/shell.c +++ b/shell.c @@ -23,8 +23,9 @@ int makeshell(char *src, int complexity) { if (complexity == SINGLE) single_init(src); - else if (complexity == FULL) + else if (complexity == FULL) { full_project_init_and_cd(src); + } else die("invalid state! shell.c:%d", __LINE__);