yait

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

commit 174e80f4f8afc4cb62be40c13cd28e69fdb3c9e8
parent 6245723dc021e16f8aac07cc15db46bacb5c1a07
Author: vx-clutch <[email protected]>
Date:   Sun, 13 Jul 2025 18:20:10 -0400

some libs done

Diffstat:
MMakefile | 10+---------
Alib/e.h | 9+++++++++
Alib/file.c | 22++++++++++++++++++++++
Alib/file.h | 9+++++++++
Alib/print.c | 14++++++++++++++
Alib/print.h | 9+++++++++
Dyait-doc/main.c | 6------
Myait/main.c | 2+-
8 files changed, 65 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,13 +1,10 @@ prefix = /usr/bin YAIT_SRCS := $(wildcard yait/*.c) -YAIT_DOC_SRCS := $(wildcard yait-doc/*.c) YAIT_OBJS := $(patsubst yait/%.c,obj/yait/%.o,$(YAIT_SRCS)) -YAIT_DOC_OBJS := $(patsubst yait-doc/%.c,obj/yait-doc/%.o,$(YAIT_DOC_SRCS)) YAIT := bin/yait -YAIT_DOC := bin/yait-doc -include config.mak @@ -20,7 +17,7 @@ else all: obj bin $(YAIT) $(YAIT_DOC) obj: - mkdir -p obj/yait obj/yait-doc + mkdir -p obj/yait bin: mkdir -p bin @@ -28,14 +25,9 @@ bin: obj/yait/%.o: yait/%.c $(CC) $(CFLAGS) -c $< -o $@ -obj/yait-doc/%.o: yait-doc/%.c - $(CC) $(CFLAGS) -c $< -o $@ - $(YAIT): $(YAIT_OBJS) $(CC) $(CFLAGS) $^ -o $@ -$(YAIT_DOC): $(YAIT_DOC_OBJS) - $(CC) $(CFLAGS) $^ -o $@ endif diff --git a/lib/e.h b/lib/e.h @@ -0,0 +1,9 @@ +#ifndef ERROR_H +#define ERROR_H + +typedef struct { + int stat; + const char *src; +} error_t; + +#endif diff --git a/lib/file.c b/lib/file.c @@ -0,0 +1,22 @@ +#include "file.h" +#include "e.h" +#include <errno.h> +#include <stdarg.h> +#include <stdio.h> +#include <string.h> + +error_t write(char *path, char *format, ...) { + error_t err; + va_list args; + va_start(args, format); + FILE *fp; + fp = fopen(path, "w"); + if (!fp) { + err.stat = errno; + err.src = strerror(errno); + } + vfprintf(fp, format, args); + fclose(fp); + va_end(args); + return err; +} diff --git a/lib/file.h b/lib/file.h @@ -0,0 +1,9 @@ +#ifndef FILE_H +#define FILE_H + +#include "e.h" + +error_t write(char *, char *, ...); +void printfn(char *, ...); + +#endif diff --git a/lib/print.c b/lib/print.c @@ -0,0 +1,14 @@ +#include "print.h" +#include <stdarg.h> +#include <stdio.h> + +int printfn(char *format, ...) { + int len; + va_list args; + va_start(args, format); + printf("yait: "); + len = vfprintf(stderr, format, args); + putchar('\n'); + va_end(args); + return len; +} diff --git a/lib/print.h b/lib/print.h @@ -0,0 +1,9 @@ +#ifndef PRINT_H +#define PRINT_H + +#include <stdarg.h> +#include <stdio.h> + +int printfn(char *, ...); + +#endif diff --git a/yait-doc/main.c b/yait-doc/main.c @@ -1,6 +0,0 @@ -#include <stdio.h> - -int main(void) { - printf("Hello, Yait-doc!\n"); - return 0; -} diff --git a/yait/main.c b/yait/main.c @@ -1,6 +1,6 @@ #include <stdio.h> int main(void) { - printf("Hello, Yait!\n"); + printf("Hello, Yait!\n"); return 0; }