File: all.c

package info (click to toggle)
rdiff-backup-fs 1.0.0-8
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 952 kB
  • sloc: sh: 3,800; ansic: 2,944; makefile: 23
file content (81 lines) | stat: -rw-r--r-- 1,830 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "all.h"

// prototypes:

int get_internals(struct file_system_info *, const char *path, char **repo, char **revision, char **internal);

// public:

int all_init(struct file_system_info *fsinfo){
	return struct_build(fsinfo);
};

int all_init_multi(struct file_system_info *fsinfo){
	return struct_build_multi(fsinfo);
};

int all_get_file(struct file_system_info *fsinfo, const char *path, struct stats **stats){

	char *revision = NULL;
	char *repo = NULL;
	char *internal = NULL;

	if (get_internals(fsinfo, path, &repo, &revision, &internal) != 0)
		return -1;
	int result = struct_get_file(fsinfo, repo, revision, internal, stats);
    free(revision);
    free(repo);
    free(internal);
    return result;
	
};

char** all_get_children(struct file_system_info *fsinfo, const char *path){
	char *revision = NULL;
	char *repo = NULL;
	char *internal = NULL;
	
	if (get_internals(fsinfo, path, &repo, &revision, &internal) != 0)
		return NULL;
	char** result = struct_get_children(fsinfo, repo, revision, internal);
    free(revision);
    free(repo);
    free(internal);
    return result;
};

// private:

int get_internals(struct file_system_info *fsinfo, const char *path, char **repo, char **revision, char **internal){

	char *temp = NULL;

	(*repo) = NULL;
	(*revision) = NULL;
	(*internal) = NULL;

	if (strcmp(path, "/") == 0)
		gstrcpy(internal, "/");
	else{
		if (fsinfo->repo_count == 1){
			if (((*revision) = gpthprt(path, 0)) == NULL)
				return -1;
			(*internal) = gpthcut(path);
		}
		else{
			if (((*repo) = gpthprt(path, 0)) == NULL)
				return -1;
			if (((*revision) = gpthprt(path, 1)) != NULL){
				if ((temp = gpthcut(path)) == NULL){
					gstrdel(repo);
					gstrdel(revision);
					return -1;
				};
				(*internal) = gpthcut(temp);
                free(temp);
			};
		};
	};
	return 0;

};