yait

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

commit 7a1a6b99652d535f89cd696cd2f1514d9471fdfb
parent ad46dba3db615b2e5701f8453ab70a9dc8ef66b0
Author: vx-clutch <[email protected]>
Date:   Thu, 17 Jul 2025 13:47:53 -0400

format: GNU

Diffstat:
Mcore/e.c | 13++++++++-----
Mcore/file.c | 60+++++++++++++++++++++++++++++++++---------------------------
Mcore/print.c | 14++++++++------
Myait/main.c | 51+++++++++++++++++++++++++++++----------------------
4 files changed, 78 insertions(+), 60 deletions(-)

diff --git a/core/e.c b/core/e.c @@ -2,10 +2,13 @@ #include "print.h" #include <stdlib.h> -error_t unwrap(error_t err) { - if (!err.null) { - printfn("error: %s", err.src); - exit(err.status); - } +error_t +unwrap (error_t err) +{ + if (!err.null) + { + printfn ("error: %s", err.src); + exit (err.status); + } return err; } diff --git a/core/file.c b/core/file.c @@ -7,46 +7,52 @@ #include <sys/stat.h> #include <sys/types.h> -error_t touch(char *path, char *format, ...) { - error_t err = {0}; +error_t +touch (char *path, char *format, ...) +{ + error_t err = { 0 }; err.null = true; // success by default va_list args; - va_start(args, format); - - FILE *fp = fopen(path, "w"); - if (!fp) { - err.null = false; - err.status = errno; - err.src = strerror(errno); - va_end(args); - return err; - } - - vfprintf(fp, format, args); - fclose(fp); - - va_end(args); + va_start (args, format); + + FILE *fp = fopen (path, "w"); + if (!fp) + { + err.null = false; + err.status = errno; + err.src = strerror (errno); + va_end (args); + return err; + } + + vfprintf (fp, format, args); + fclose (fp); + + va_end (args); return err; } -error_t dir(char *format, ...) { - error_t err = {0}; +error_t +dir (char *format, ...) +{ + error_t err = { 0 }; err.null = true; // success by default va_list args; - va_start(args, format); + va_start (args, format); char path[1024]; - vsnprintf(path, sizeof(path), format, args); + vsnprintf (path, sizeof (path), format, args); - va_end(args); + va_end (args); - if (mkdir(path, 0777) < 0) { - err.null = false; - err.status = errno; - err.src = strerror(errno); - } + if (mkdir (path, 0777) < 0) + { + err.null = false; + err.status = errno; + err.src = strerror (errno); + } return err; } diff --git a/core/print.c b/core/print.c @@ -2,13 +2,15 @@ #include <stdarg.h> #include <stdio.h> -int printfn(char *format, ...) { +int +printfn (char *format, ...) +{ int len; va_list args; - va_start(args, format); - fprintf(stderr, "yait: "); - len = vfprintf(stderr, format, args); - putchar('\n'); - va_end(args); + va_start (args, format); + fprintf (stderr, "yait: "); + len = vfprintf (stderr, format, args); + putchar ('\n'); + va_end (args); return len; } diff --git a/yait/main.c b/yait/main.c @@ -1,35 +1,42 @@ -#include "../core/print.h" #include "../core/file.h" +#include "../core/print.h" #include "format.h" -int create(format_t); - -int main(int argc, char **argv) { - if (argc < 2) { - printfn("error: not enough arguments."); - return 1; - } +int create (format_t); +int +main (int argc, char **argv) +{ + if (argc < 2) + { + printfn ("error: not enough arguments."); + return 1; + } format_t conf; conf.name = argv[1]; conf.nogit = false; - - create(conf); + create (conf); return 0; } -int create(format_t fmt) { - take(fmt.name); - - touch("README", - "%s ( concise description )\n\n" - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor\n" - "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis\n" - "nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n" - "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu\n" - "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in\n" - "culpa qui officia deserunt mollit anim id est laborum.", - fmt.name); +int +create (format_t fmt) +{ + take (fmt.name); + touch ("README", + "%s ( concise description )\n\n" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do " + "eiusmod tempor\n" + "incididunt ut labore et dolore magna aliqua. Ut enim ad minim " + "veniam, quis\n" + "nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo " + "consequat.\n" + "Duis aute irure dolor in reprehenderit in voluptate velit esse " + "cillum dolore eu\n" + "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non " + "proident, sunt in\n" + "culpa qui officia deserunt mollit anim id est laborum.", + fmt.name); touch ("hello", "world"); return 0; }