Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
char* pakfire_dirname(const char* path);
int pakfire_access(Pakfire pakfire, const char* dir, const char* file, int mode);
-char* pakfire_sgets(char* str, int num, char** input);
char* pakfire_remove_trailing_newline(char* str);
int pakfire_read_file_into_buffer(FILE* f, char** buffer, size_t* len);
return r;
}
-char* pakfire_sgets(char* str, int num, char** input) {
- char* next = *input;
- int numread = 0;
-
- while (numread + 1 < num && *next) {
- int isnewline = (*next == '\n');
-
- *str++ = *next++;
- numread++;
-
- if (isnewline)
- break;
- }
-
- // Terminate string
- *str = '\0';
-
- *input = next;
-
- return str;
-}
-
char* pakfire_remove_trailing_newline(char* str) {
ssize_t pos = strlen(str) - 1;