This repository was archived by the owner on Dec 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfm.h
More file actions
133 lines (115 loc) · 2.78 KB
/
fm.h
File metadata and controls
133 lines (115 loc) · 2.78 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* fm - manages the json files and stuff
* few extras added
* HEADER
*/
#ifndef USPM_FM_H
#define USPM_FM_H
#include <cjson/cJSON.h>
#include <stddef.h>
#include <stdio.h>
/**
* concatenate strings
*
* @param s1 first string
* @param s2 second string
* */
char* concat(const char *s1, const char *s2);
/**
* Given a filename/file location [file], attempts to parse as JSON
* and then loads it in as a cJSON object.
*
* @param file file to load
*/
cJSON *load_file(char *file);
/**
* Writes a fresh new packages file
*
* @param out the char array to output to the file
*/
void write_packages_file(char *out);
/**
* Writes a fresh new config file
*
* @param out the char array to output to the file
*/
void write_config_file(char *out);
/**
* Adds a package [packagename] to the list of packages along with its PACKAGEDATA contents [packagedata]
*
* @param packagename the Package
* @param packagedata the internal data
*/
int add_to_packages(char *packagename, cJSON *packagedata);
/**
* Removes a package [packagename] from the list of packages along with its PACKAGEDATA contents [packagedata]
*
*
* @param packagename package to remove
*/
int remove_from_packages(char *packagename);
/**
* Downloads a package [package] file from a mirror [mirror]
*
*
* @param mirror the web mirror to load from
* @param package the package
*/
int download_package(char *mirror, char *package);
/**
* Checks for the existence of a config file
*
* Returns 1 if nonexistant
* Returns 0 if exists
*/
int check_config_file();
/**
* Checks for the existence of a packages file
*
* Returns 1 if nonexistant
* Returns 0 if exists
*/
int check_packages_file();
/**
* Performs a file [file] checksum and outputs the value to a char array [o]
*
* @param filename the file
* @param o the char array to output the data to
*/
void checksum(char *filename, char *o[16]);
/**
* Given two [a] and [b] checksums, compares them
*
* @param a first file's checksum
* @param b second file's checksum
*/
int checksum_compare(char *a, char *b);
/**
* @param json the char array to load as a JSON object
* @param json
* @return cJSON
*/
cJSON *load_json(char *json);
/**
* Gets the package.json file from a mirror [url]
*
* @param url the repo
*/
cJSON *get_repo_json(char* url);
/**
* Verifies the checksum of a package [package] downloaded with the checksum of the
* mirror [mirror]
*
* @param package the package
* @param mirror the repo to pull from
*/
int verify_checksum(char *mirror, char *package);
/**
* Checks if a package exists
* @param mirror the domain that holds the repos
* @param folder The folder (core, extra, community) that data is held in
* @param package
* @return
*/
int check_if_package_exists(char *mirror, char *folder, char *package);
#endif //USPM_FM_H