Compare commits

...

10 Commits

Author SHA1 Message Date
54db089b71 add weak git integration 2025-11-22 10:22:26 -05:00
fc2e477665 wip 2025-11-18 15:21:22 -05:00
82635759a7 wip 2025-11-13 21:34:44 -05:00
52c0d05889 wip 2025-11-13 15:27:28 -05:00
e42881c4d1 wip 2025-11-13 15:27:13 -05:00
vx_clutch
cd6cf9ff4f Fix typo and update date in README 2025-11-13 09:33:48 -05:00
6a50590393 wip 2025-11-12 22:09:34 -05:00
27c248c9bb add license 2025-11-12 18:33:26 -05:00
f764bc6759 wip 2025-11-11 21:49:23 -05:00
vx_clutch
22242dc532 Update README 2025-11-11 08:26:42 -05:00
19 changed files with 369 additions and 60 deletions

39
COPYING Normal file
View File

@@ -0,0 +1,39 @@
Copyright (c) 2025 fSD version 1
This document is intended "as is", without modifications.
The binary and source code that this file is associated with and distributed
with is licensed under the following terms and conditions.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Maintainers Note:
This section is reserved for any deviations of the prior notice. Given that
you are reading this, that means this document is assumed unmodified. Any
modifications in this section most follow this format:
o the note.
If a note is provided here the header the at top of the document must be
changed to reflect that as such: "This document is intended "as is",
without modifications." must become "This is a modified version of the
fSD general license. See Maintainers Note.".

6
README
View File

@@ -19,14 +19,14 @@ yait/fSD 1.0 is an optionated C and SH project generator. For C project
generation is produces a similar layout to the source of this project. On
SH it generates a shell script with useful scaffolding for a script. For
more detailed useage compile the program for your system and run with the
`--help` option/
`--help` option.
WHAT IS NEW
Features:
o This is the inital commit, EVERYTHING is new!
o This is the first version, EVERYTHING is new!
Bug fixes - not very interesting:
@@ -48,4 +48,4 @@ derived from uEmacs/PK 4.0 specifically from the Linux Torvalds
distribution on GitHub. The README on from uEmacs/PK 4.0 has greater and
more accurate attributions, if you desire.
November 11, 2025
November 12, 2025

18
edef.h Normal file
View File

@@ -0,0 +1,18 @@
/* edef.h
*
* Global variable definition
*
* written by vx-clutch
*/
#ifndef EDEF_H_
#define EDEF_H_
/* Initialized global external declarations. */
extern int git;
/* Other constants declarations */
enum { SINGLE, FULL };
#endif /* EDEF_H_ */

View File

@@ -7,6 +7,12 @@
#define LICENSE "BSD-3-Clause" /* Default SPDX-License-Identifier */
#define QAUTHOR 0 /* Force use the default author option */
#define AUTHOR "fSD" /* Default author*/
#define AUTHOR "fSD" /* Default author */
#define DEFAULT_GIT 0 /* Default git state */
/* Internal constants */
#define NPAT 128
#endif /* ESTRUCT_H_ */

5
file.c
View File

@@ -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 <unistd.h>
#include "file.h"
#include "globals.h"
#include "estruct.h"
int ffwrite(char *path, char *fmt, ...) {
FILE *f;

3
full.c
View File

@@ -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;
}

17
git.c Normal file
View File

@@ -0,0 +1,17 @@
/* git.c
*
* Routines for initilizing a git repository
*
* written by vx-clutch
*/
#include "git.h"
#include "edef.h"
#include <stdlib.h>
int ginit()
{
if (git) return 0;
system("git init --quiet");
return 0;
}

6
git.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef GIT_H_
#define GIT_H_
int ginit();
#endif /* GIT_H_ */

6
globals.c Normal file
View File

@@ -0,0 +1,6 @@
#include "estruct.h"
#include "edef.h"
/* initialized global definitions */
int git = DEFAULT_GIT;

View File

@@ -1,14 +0,0 @@
/* globals.h
*
* Global definitions
*
* written by vx-clutch
*/
#ifndef GLOBALS_H_
#define GLOBALS_H_
enum { SINGLE = 1, FULL = 2 };
#define NPAT 4096 /* number of bytes for path buffer */
#endif /* GLOBALS_H_ */

View File

@@ -38,7 +38,7 @@ char *getstring(char *fmt, ...) {
return buf;
}
int yes_no_prompt(const char *fmt, ...) {
int yesno(char *fmt, ...) {
char prompt[256];
va_list ap;

View File

@@ -4,6 +4,6 @@
enum { TRUE, FALSE, GUARANTEE };
char *getstring(char *fmt, ...);
int mlyesno(char *fmt, ...);
int yesno(char *fmt, ...);
#endif /* INPUT_H_ */

43
main.c
View File

@@ -17,57 +17,58 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include "globals.h"
#include "edef.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(" --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);
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)
if (argc == 2) {
if (strcmp(argv[1], "--help") == 0)
usage(EXIT_SUCCESS);
else if (strcmp(argv[i], "--version") == 0)
{
else if (strcmp(argv[1], "--version") == 0) {
version();
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;
else if (strcmp(argv[i], "-S") == 0)
else if (argv[carg][1] == 'S')
shell_mode = FULL;
else if (strcmp(argv[i], "-i") == 0)
i = 1;
else if (strcmp(argv[carg], "--git"))
git = 1;
else
die("unknown option");
}
else
package = argv[i];
} else
package = argv[carg];
}
if (!package)

200
proj.c
View File

@@ -7,15 +7,19 @@
*/
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include "estruct.h"
#include "wrapper.h"
#include "file.h"
#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);
@@ -23,16 +27,20 @@ int makeproj(char *src)
if (chdir(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\
@@ -43,6 +51,9 @@ int makeproj(char *src)
#include <stdlib.h>\n\
#include <string.h>\n\
\n\
#include \"version.h\"\n\
#include \"estruct.h\"\n\
\n\
void usage(int status)\n\
{\n\
printf(\"Usage: %%s REQUIRED POSITIONAL ARGUMENT\\n\", PROGRAM_NAME);\n\
@@ -66,9 +77,188 @@ int main(int argc, char **argv)\n\
exit(EXIT_SUCCESS);\n\
}\n\
}\n\
\n\
puts(MESSAGE);\n\
\n\
return 0;\n\
}", src, author, src, src);
size_t len = strlen(src) + 1 + strlen(author) + 6; /* account for " 1.0 " */
char *pad = xmalloc(len + 1);
memset(pad, '-', len);
pad[len] = '\0';
ffwrite("README", "\
+%s+\n\
| %s/%s 1.0 |\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 %s %s\n\
\n\
LAST MODIFED DATE\
",
pad,
src, author,
pad,
description,
src, author,
src, year, author,
src, author,
src, author, description,
src, author,
src, PROGRAM_NAME_LONG, VERSION);
ffwrite("version.h", "\
#ifndef VERSION_H_\n\
#define VERSION_H_\n\
\n\
#define PROGRAM_NAME \"%s\"\n\
#define PROGRAM_NAME_LONG \"%s/%s\"\n\
\n\
#define VERSION \"1.0.0\"\n\
\n\
/* Print the version string. */\n\
void version(void);\n\
\n\
#endif /* VERSION_H_ */", src, src, author);
ffwrite("version.c", "\
#include <stdio.h>\n\
#include \"version.h\"\n\
\n\
void version(void)\n\
{\n\
printf(\"%%s version %%s\\n\", PROGRAM_NAME_LONG, VERSION);\n\
}");
ffwrite("Makefile", "\
# Makefile for %s\n\
\n\
# Make the build silent by default\n\
V =\n\
\n\
ifeq ($(strip $(V)),)\n\
E = @echo\n\
Q = @\n\
else\n\
E = @\\#\n\
Q =\n\
endif\n\
export E Q\n\
\n\
PROGRAM = %s\n\
TARBALL = $(PROGRAM).tar\n\
SRC = $(wildcard *.c)\n\
OBJ = $(SRC:.c=.o)\n\
HDR = $(wildcard *.h)\n\
\n\
CC = gcc\n\
WARNINGS = -Wall -Wstrict-prototypes\n\
CFLAGS = -O2 $(WARNINGS) -g\n\
DEFINES =\n\
LIBS =\n\
LDFLAGS =\n\
BINDIR = /usr/bin\n\
LIBDIR = /usr/lib\n\
\n\
$(PROGRAM): $(OBJ) $(HDR)\n\
$(E) \" LINK \" $@\n\
$(Q) $(CC) $(LDFLAGS) $(DEFINES) -o $@ $(OBJ) $(LIBS)\n\
\n\
clean:\n\
$(E) \" CLEAN\"\n\
$(Q) rm -f $(PROGRAM) $(OBJ)\n\
\n\
install: $(PROGRAM)\n\
cp $(PROGRAM) ${BINDIR}\n\
\n\
release: $(PROGRAM)\n\
tar cvf $(TARBALL) $(SRC) $(HDR) Makefile README\n\
\n\
.c.o:\n\
$(E) \" CC \" $@\n\
$(Q) $(CC) $(CFLAGS) $(DEFINES) -c $< -o $@", src, src);
ffwrite("usage.h", "\
#ifndef USAGE_H_\n\
#define USAGE_H_\n\
\n\
void die(const char* err, ...);\n\
\n\
#endif /* USAGE_H_ */");
ffwrite("usage.c", "\
#include \"usage.h\"\n\
\n\
#include <stdarg.h>\n\
#include <stdio.h>\n\
#include <stdlib.h>\n\
\n\
static void report(const char* prefix, const char *err, va_list params)\n\
{\n\
char msg[4096];\n\
vsnprintf(msg, sizeof(msg), err, params);\n\
fprintf(stderr, \"%%s%%s\\n\", prefix, msg);\n\
}\n\
\n\
void die(const char* err, ...)\n\
{\n\
va_list params;\n\
\n\
va_start(params, err);\n\
report(\"fatal: \", err, params);\n\
va_end(params);\n\
exit(128);\n\
}");
ffwrite("estruct.h", "\
#ifndef ESTRUCT_H_\n\
#define ESTRUCT_H_\n\
\n\
/* Configuration options */\n\
\n\
#define MESSAGE \"Hello, World!\" /* Default greeting */\n\
\n\
#endif /* ESTRUCT_H_ */");
return 0;
}

View File

@@ -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"
@@ -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__);

10
util.c Normal file
View 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;
}

6
util.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef UTIL_H_
#define UTIL_H_
int getyear();
#endif

13
wrapper.c Normal file
View File

@@ -0,0 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
#include "wrapper.h"
#include "usage.h"
void *xmalloc(size_t size)
{
void *ret = malloc(size);
if (!ret)
die("memory exhausted");
return ret;
}

8
wrapper.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef WRAPPER_H_
#define WRAPPER_H_
#include <stdio.h>
void *xmalloc(size_t size);
#endif