diff options
| author | dacctal <donotcontactmevia@email.invalid> | 2026-07-02 03:54:29 +0000 |
|---|---|---|
| committer | dacctal <donotcontactmevia@email.invalid> | 2026-07-02 03:54:29 +0000 |
| commit | 2fe0443d7073e59b1e4d75f49f0a5a417678f4cd (patch) | |
| tree | 24a269f1fa532eacea4380d03882abe145dc297d /include | |
| parent | fe3caeefac7a2081f5c9db90bf5c821624a71082 (diff) | |
ezntek: checkpoint!
Diffstat (limited to 'include')
| -rw-r--r-- | include/globs.h | 20 | ||||
| -rw-r--r-- | include/pkg.h | 33 | ||||
| -rw-r--r-- | include/pkg/create.h | 25 | ||||
| -rw-r--r-- | include/str.h | 16 |
4 files changed, 53 insertions, 41 deletions
diff --git a/include/globs.h b/include/globs.h index 4611216..bec1dc9 100644 --- a/include/globs.h +++ b/include/globs.h @@ -1,28 +1,28 @@ /* - pkgit - package it! - + Copyright (C) 2026 dacctal + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. - */ #ifndef PKGIT_GLOBALS_H #define PKGIT_GLOBALS_H +#include <stdlib.h> + #include "str.h" -#include <stdint.h> #define VERSION "1.4.0_INDEV" #define RED "\x1b[0;31m" @@ -58,6 +58,8 @@ #define ITALIC "\x1b[3m" #define COLOR_RESET "\x1b[0m" +#define LENGTH(lst) (sizeof(lst) / sizeof(*(lst))) + #define eprintf(...) fprintf(stderr, __VA_ARGS__); #define check_alloc(ptr) \ @@ -66,7 +68,6 @@ panic("allocation of `%s` failed", #ptr); \ } while (0) -#include <stdlib.h> #define panic(...) \ do { \ eprintf(BOLD RED "panic:" COLOR_RESET " line %d, func \"%s\" in file " \ @@ -105,11 +106,6 @@ #define MAX_PATH_LEN 1024 typedef struct { - str name, url, version, target, src; - bool is_local; -} package_t; - -typedef struct { bool verbose, force; } cli_flags_t; diff --git a/include/pkg.h b/include/pkg.h new file mode 100644 index 0000000..9cb3944 --- /dev/null +++ b/include/pkg.h @@ -0,0 +1,33 @@ +/* + pkgit - package it! + + Copyright (C) 2026 dacctal + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. +*/ + +#ifndef PKGIT_PKG_H +#define PKGIT_PKG_H + +#include "str.h" + +typedef struct { + str name, url, version, target, src; + bool is_local; +} package_t; + +package_t pkg_create(str_slc arg); +void pkg_free(package_t *pkg); + +#endif diff --git a/include/pkg/create.h b/include/pkg/create.h deleted file mode 100644 index 95e12c6..0000000 --- a/include/pkg/create.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - - pkgit - package it! - - Copyright (C) 2026 dacctal - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. - -*/ - -#ifndef PKGIT_PKG_CREATE_H -#define PKGIT_PKG_CREATE_H -#include "globs.h" -package_t pkg_create(str_slc arg); -#endif diff --git a/include/str.h b/include/str.h index f5c79dd..8623312 100644 --- a/include/str.h +++ b/include/str.h @@ -116,36 +116,42 @@ void str_free(str *s); /** * Copies the entirety of src into dest, resizing it if necessary, while * overwriting all existing data. + * dest will be initialized if necessary. */ void str_copy_into(str *dest, const str *src); /** * Copies a source C string at src into an already initialized * str, resizing the buffer if necessary, overwriting all existing data. + * dest will be initialized if necessary. */ void str_copy_cstr_into(str *dest, const char *src); /** * Copies a source string slice at src into an already initialized * str, resizing the buffer if necessary, overwriting all existing data. + * dest will be initialized if necessary. */ void str_copy_str_slc_into(str *dest, const str_slc src); /** * Copies n bytes of src into an already initialized str dest, * resizing it if necessary, while overwriting all existing data. + * dest will be initialized if necessary. */ void str_ncopy_into(str *dest, const str *src, size_t count); /** * Copies n bytes of a C string src into an already initialized str dest, * resizing it if necessary, while overwriting all existing data. + * dest will be initialized if necessary. */ void str_ncopy_cstr_into(str *dest, const char *src, size_t count); /** * Copies n bytes of a string slice src into an already initialized str dest, * resizing it if necessary, while overwriting all existing data. + * dest will be initialized if necessary. */ void str_ncopy_str_slc_into(str *dest, const str_slc src, size_t count); @@ -157,23 +163,23 @@ str str_dupe(const str *src); /** * Appends a str into an existing str, resizing the buffer if necessary. */ -void str_append(str *src, const str *new); +void str_append(str *src, const str *new_str); /** * Appends a single character new into src, resizing the buffer if necessary. */ -void str_append_char(str *src, char new); +void str_append_char(str *src, char new_char); /** * Appends a C string into an existing str, resizing the buffer if necessary. */ -void str_append_cstr(str *src, const char *new); +void str_append_cstr(str *src, const char *new_cstr); /** * Appends a string slice into an existing str, resizing the buffer if * necessary. */ -void str_append_str_slc(str *src, const str_slc new); +void str_append_str_slc(str *src, const str_slc new_slc); /** * Removes the last character from src, returning it. @@ -521,7 +527,9 @@ ptrdiff_t str_slc_find_char(const str_slc s, char c); ptrdiff_t str_slc_find_char_right(const str_slc s, char c); str str_from_after_delim(str *arg, char delimiter); +str str_from_after_delim_str_slc(str_slc arg, char delimiter); str str_from_before_delim(str *arg, char delimiter); +str str_from_before_delim_str_slc(str_slc arg, char delimiter); str_slc str_slc_from_after_delim(str_slc arg, char delimiter); str_slc str_slc_from_before_delim(str_slc arg, char delimiter); |
