summaryrefslogtreecommitdiff
path: root/src/lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.h')
-rw-r--r--[-rwxr-xr-x]src/lib.h61
1 files changed, 42 insertions, 19 deletions
diff --git a/src/lib.h b/src/lib.h
index 999e7d7..6c098c7 100755..100644
--- a/src/lib.h
+++ b/src/lib.h
@@ -1,24 +1,47 @@
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <dirent.h>
+#ifndef LIB_H_
+#define LIB_H_
+
+#include <git2.h>
+#include <linux/limits.h>
#include <stdio.h>
-#include <stdlib.h>
-#define NULL_STR (char*)0
-#define DEFAULT_CONFIG_CONTENTS "^node_modules$\n^target$\n^build$\n^dist$\n^\\.next$\n^\\.output$\n^\\.vercel$\n^\\.wrangler$\n^\\.venv$\n^\\.astro$\n^\\.devenv$\n^__pycache__$"
+#define debugf(...) if (debug) (void)printf("[debug] " __VA_ARGS__)
+
+int is_git_metadata_dir(char *path);
+
+struct tmp_repo {
+ git_repository* repo;
+ char path[70];
+};
+struct tmp_repo tmp_repo_init();
+void tmp_repo_deinit(struct tmp_repo repo);
+
+int check_for_backupignore();
+void copy_over_backupignore(struct tmp_repo repo);
+
+int is_ignored(struct tmp_repo repo, char *path);
+
+struct recursive_reader {
+ FILE *pfile;
+ char *line;
+ size_t capacity;
+};
+struct recursive_reader recursive_reader_init();
+int recursive_reader_read(struct recursive_reader *reader);
+void recursive_reader_deinit(struct recursive_reader reader);
+
+struct backup_streamer {
+ int cwd_length;
+ char to_prefix[PATH_MAX];
+ char cursor[PATH_MAX];
+};
+struct backup_streamer backup_streamer_init(char *cwd);
+void get_backup_destination(struct backup_streamer *streamer, char* from);
-typedef enum {
- path_type_unknown,
- path_type_directory,
- path_type_file
-} path_type;
+int is_dir(char *path);
+void backup_file(char *from, char *to);
+void ensure_parents_exist(char *path);
-char* get_default_config();
-char* shift(int* argc, char*** argv);
-char* get_ignore_file(char* ignore_file, int VERBOSE);
-void mkdir_if_not_exist(char* path, int VERBOSE);
-void verify_parent_dirs_exist(char* file_path, int VERBOSE);
+int debug;
-void backup(char* target, char* ignore_instructions, int VERBOSE);
+#endif // LIB_H_