diff options
| author | dacctal <donotcontactmevia@email.invalid> | 2026-06-29 23:58:00 +0000 |
|---|---|---|
| committer | dacctal <donotcontactmevia@email.invalid> | 2026-06-29 23:58:00 +0000 |
| commit | e54a7dbdbb7c65d50f713f5f816dcb884259adea (patch) | |
| tree | bb8345c737bacfae1415cf06a22110b54b6c0c59 /include/pkgit_string.h | |
| parent | b8a96b5fa7ccb6b170b1fb40c5ea4efe4519e568 (diff) | |
string concatenation (probably)
Diffstat (limited to 'include/pkgit_string.h')
| -rw-r--r-- | include/pkgit_string.h | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/include/pkgit_string.h b/include/pkgit_string.h index ae6098c..c81bcbd 100644 --- a/include/pkgit_string.h +++ b/include/pkgit_string.h @@ -1,3 +1,23 @@ +/* + + 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_STRING_H #define PKGIT_STRING_H #include <stddef.h> @@ -5,7 +25,7 @@ typedef struct { char* data; size_t len; -} str_s; +} str_slc; typedef struct { char* data; @@ -13,15 +33,18 @@ typedef struct { size_t len; } str; -#define format_string(s) (int)((s).len), (s).data -// Usage: printf("%.*s", format_string(ss)); +#define str_fmt(slice) (int)((slice).len), (slice).data +// Usage: printf("%.*s", format_string(slice)); -void print_slice(str_s s); -str_s slice_from_cstr(char* cstr); -int slice_eq(str_s a, str_s b); -int slice_starts_with(str_s slice, str_s prefix); -str_s slice_take(str_s slice, size_t n); -str_s slice_drop(str_s slice, size_t n); -str_s slice_trim(str_s slice); +void print_slice(str_slc s); +str_slc slc_from_cstr(char* cstr); +#define slc_from_cstr(cstr) slc_from_cstr(cstr) +int slc_eq(str_slc a, str_slc b); +int slc_starts_with(str_slc slice, str_slc prefix); +str_slc slc_take(str_slc slice, size_t n); +str_slc slc_drop(str_slc slice, size_t n); +str_slc slc_trim(str_slc slice); +void slc_cat(str_slc first, str_slc second, str_slc *new_slc); +//#define slc_cat(first, second, new_slc) slc_cat(first, second, *new_slc) #endif |
