/*
- * Copyright (C) 2007 Neverball contributors
+ * Copyright (C) 2007 Neverball authors
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
#include <time.h>
#include <stdio.h>
+#include "fs.h"
-int read_line(char **, FILE *);
+#ifdef __GNUC__
+#define NULL_TERMINATED __attribute__ ((__sentinel__))
+#else
+#define NULL_TERMINATED
+#endif
+
+#define ARRAYSIZE(a) (sizeof (a) / sizeof ((a)[0]))
+#define MAXSTRLEN(a) (sizeof (a) - 1)
+
+#define MIN(x, y) ((x) < (y) ? (x) : (y))
+#define MAX(x, y) ((x) > (y) ? (x) : (y))
+
+#define SAFECPY(dst, src) (strncpy((dst), (src), MAXSTRLEN(dst)))
+#define SAFECAT(dst, src) (strncat((dst), \
+ (src), \
+ MAX(0, MAXSTRLEN(dst) - strlen(dst))))
+
+int read_line(char **, fs_file);
char *strip_newline(char *);
+char *dupe_string(const char *);
+char *concat_string(const char *first, ...) NULL_TERMINATED;
+
+#ifdef strdup
+#undef strdup
+#endif
+#define strdup dupe_string
+
+#define str_starts_with(s, h) (strncmp((s), (h), strlen(h)) == 0)
+#define str_ends_with(s, t) (strcmp((s) + strlen(s) - strlen(t), (t)) == 0)
+
time_t make_time_from_utc(struct tm *);
const char *date_to_str(time_t);
int file_rename(const char *, const char *);
void file_copy(FILE *fin, FILE *fout);
-char *base_name(const char *name, const char *suffix);
+int path_is_sep(int);
+int path_is_abs(const char *);
+
+char *path_join(const char *, const char *);
+
+const char *path_last_sep(const char *);
+const char *path_next_sep(const char *);
+
+const char *base_name(const char *name);
+const char *base_name_sans(const char *name, const char *suffix);
+const char *dir_name(const char *name);
+
+int rand_between(int low, int high);
#endif