Skip to content

Commit 0b189ef

Browse files
authored
Merge pull request #123 from AleksArt000/main
fixed stuff
2 parents 258c13b + a3292cc commit 0b189ef

33 files changed

+1867
-2511
lines changed

Diff for: .github/workflows/c-cpp.yml

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ jobs:
2222
run: |
2323
sudo apt-get update
2424
sudo apt-get install -y libcurl4-openssl-dev
25+
- name: Install libsqlite3-dev
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get install -y libsqlite3-dev
2529
- name: Install libgit2
2630
run: |
2731
curl -L https://codeload.github.com/libgit2/libgit2/tar.gz/refs/tags/v1.8.1 --output libgit2-1.8.1.tar.gz

Diff for: compile_flags.txt

-1
This file was deleted.

Diff for: formats/ecmp/ecmp.c

+41-35
Original file line numberDiff line numberDiff line change
@@ -45,49 +45,47 @@ int open(char* path,struct package* pkg)
4545
}
4646

4747
void* parsers[][3] = {
48-
{parseinfo,pkg,NULL},
48+
{parseinfo,&pkg,NULL},
4949

50-
{parseraw,&pkg->info.make,NULL},
5150
{parseraw,&pkg->info.install,NULL},
52-
{parseraw,&pkg->info.download,NULL},
5351
{parseraw,&pkg->info.prepare,NULL},
5452
{parseraw,&pkg->info.special,NULL},
5553

5654
{parsenl,&pkg->files,&pkg->filesCount},
5755
{parsenl,&pkg->dependencies,&pkg->dependenciesCount},
5856
{parsenl,&pkg->optional,&pkg->optionalCount},
59-
{parsenl,&pkg->inputs,&pkg->inputsCount},
57+
6058
{parsenl,&pkg->locations,&pkg->locationsCount},
61-
{parseraw,&pkg->info.description,NULL},
62-
{parsenl,&pkg->exports,&pkg->exportsCount}
59+
{parseraw,&pkg->description,NULL},
60+
{parsenl,&pkg->config,&pkg->configCount}
6361
};
6462

6563
void* pairs[][2] = {
6664
{"info",parsers[0]},
6765

68-
{"make",parsers[1]},
69-
{"install",parsers[2]},
70-
{"download",parsers[3]},
71-
{"prepare",parsers[4]},
72-
{"special",parsers[5]},
73-
74-
{"files",parsers[6]},
75-
{"dependencies",parsers[7]},
76-
{"optional",parsers[8]},
77-
{"inputs",parsers[9]},
78-
{"locations",parsers[10]},
79-
{"description",parsers[11]},
80-
{"exports",parsers[12]},
66+
{"install",parsers[1]},
67+
{"prepare",parsers[2]},
68+
{"special",parsers[3]},
69+
70+
{"files",parsers[4]},
71+
{"dependencies",parsers[5]},
72+
{"optional",parsers[6]},
73+
74+
{"locations",parsers[7]},
75+
{"description",parsers[8]},
76+
{"config",parsers[9]},
8177
{NULL,NULL}
8278
};
8379

8480
void* infodict[][2] = {
81+
// This is very stupid, but basically I assume that the name was obtained from the database
82+
// This is to go around a memory leak caused by overwriting name when opening a package
83+
// This is very stupid
8584
{"name",&pkg->name},
8685
{"version",&pkg->version},
8786
{"type",&pkg->type},
8887
{"url",&pkg->url},
8988
{"license",&pkg->license},
90-
{"sha256",&pkg->sha256},
9189
{"environment",&pkg->environment},
9290
{NULL,NULL}
9391
};
@@ -104,7 +102,7 @@ int open(char* path,struct package* pkg)
104102
for (unsigned int i = 0; i < count; i++) {
105103
void** options = hm_get(hm,sections[i]->name);
106104
if (options == NULL) {
107-
msg(WARNING,"Unknown section : %s",sections[i]->name);
105+
msg(FATAL,"Unknown section : %s",sections[i]->name);
108106
free(sections[i]->buff);
109107
continue;
110108
}
@@ -118,14 +116,15 @@ int open(char* path,struct package* pkg)
118116

119117
}
120118
else {
121-
msg(WARNING,"Unknown parser for section : %s",sections[i]->name);
119+
msg(FATAL,"Unknown parser for section : %s",sections[i]->name);
122120
}
123121
}
124122
dbg(2,"done parsing | returning");
125123

126124
// free sections
127125
for (unsigned int i = 0; i < count; i++) {
128126
free(sections[i]->name);
127+
free(sections[i]->buff);
129128
free(sections[i]);
130129
}
131130
free(sections);
@@ -141,10 +140,10 @@ int open(char* path,struct package* pkg)
141140

142141
unsigned int parsenl(char* s,char*** dest)
143142
{
144-
char* str;
143+
//char* str;
145144
// the parseraw below is useless but i'll keep since in case
146-
parseraw(s,&str);
147-
return splita(str,'\n',dest);
145+
//parseraw(s,&str);
146+
return splita(s,'\n',dest);
148147
}
149148
unsigned int parseraw(char* s, char** dest)
150149
{
@@ -153,7 +152,7 @@ unsigned int parseraw(char* s, char** dest)
153152
// So we are just going to copy the pointer to it
154153
// In the last version , we were copying the string to a new buffer
155154
// Because the `s` string was a buffer that was going to be freed by `getline()`
156-
*dest = s;
155+
*dest = strdup(s);
157156
return strlen(s);
158157
}
159158

@@ -180,29 +179,37 @@ unsigned int parseinfo(char *s, struct package* dest) {
180179
char* key = strtok(nlist[i], "=");
181180
char* value = strtok(NULL, "=");
182181
if (key == NULL || value == NULL) {
183-
msg(WARNING, "Invalid key-value pair: '%s'", nlist[i]);
182+
msg(FATAL, "Invalid key-value pair: '%s'", nlist[i]);
184183
continue;
185184
}
186185

187186
// add to corresponding value in dict
188187
char** destbuff = hm_get(infohm, key);
188+
189+
if(strcmp(key, "name") == 0)
190+
{
191+
// This is very stupid
192+
free(nlist[i]);
193+
continue;
194+
}
189195
if (destbuff == NULL) {
190-
msg(WARNING, "Unknown key : '%s'", key);
196+
msg(FATAL, "Unknown key : '%s'", key);
191197
continue;
192198
}
193199

194200
*destbuff = strdup(value);
195201
if (*destbuff == NULL) {
196202
msg(ERROR, "Error allocating memory for %s value", key);
197203
free(nlist);
198-
free(s);
204+
//free(s);
199205
return 0;
200206
}
201207
dbg(3, "Setting destbuff to %p - %s", *destbuff, *destbuff);
208+
free(nlist[i]);
202209
}
203210

204211
free(nlist);
205-
free(s);
212+
//free(s);
206213
return 0;
207214
}
208215

@@ -221,7 +228,8 @@ unsigned int getsections(char* path,section*** sections) {
221228
(void)current;
222229
unsigned int alloc = 0;
223230

224-
while ((read = getline(&line,&len,fp)) != EOF) {
231+
while ((read = getline(&line,&len,fp)) != EOF)
232+
{
225233
if (line[0] == '#' || line[0] == '\n' || strlen(line) < 2) {
226234
continue;
227235
}
@@ -246,6 +254,7 @@ unsigned int getsections(char* path,section*** sections) {
246254
}
247255
strcat((*sections)[sectionscount-1]->buff,line);
248256
}
257+
free(line);
249258
return sectionscount;
250259
}
251260

@@ -259,15 +268,13 @@ int create(const char* path,struct package* pkg)
259268
// i love hashmaps but here we'll use maparray
260269
// we have the list[0] = section and list[1] = function to do stuff
261270
void* list[][3] = {
262-
{"download",pkg->info.download,NULL},
263271
{"prepare",pkg->info.prepare,NULL},
264-
{"make",pkg->info.make,NULL},
265272
{"install",pkg->info.install,NULL},
266273
{"special",pkg->info.special,NULL},
267274

268275
{"dependencies",pkg->dependencies,&pkg->dependenciesCount},
269276
{"optional",pkg->optional,&pkg->optionalCount},
270-
{"description",pkg->info.description,NULL},
277+
{"description",pkg->description,NULL},
271278

272279
{"locations",pkg->locations,&pkg->locationsCount},
273280
};
@@ -287,7 +294,6 @@ int create(const char* path,struct package* pkg)
287294
if (pkg->type != NULL) fprintf(ecmp,"type = %s\n",pkg->type);
288295
if (pkg->license != NULL) fprintf(ecmp,"license = %s\n",pkg->license);
289296
if (pkg->url != NULL) fprintf(ecmp,"url = %s\n",pkg->url);
290-
if (pkg->sha256 != NULL) fprintf(ecmp,"sha256 = %s\n",pkg->sha256);
291297
fprintf(ecmp,"\n"); // for improved readability
292298

293299
for (unsigned int i = 0;i < sizeof(list) / sizeof(list[0]);i++ )

Diff for: include/globals.h

+6-13
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
#include "stdbool.h"
22

3-
#define QUEUE_MAX 64
3+
// This is very stupid, but I don't want to work on this right now.
4+
#define QUEUE_MAX 65536
45

56
#define MAX_PATH 2048
67
/*
78
START OF THE (sort of) CONSTANTS DECALRATIONS
89
(They are not mean to be modified a lot)
910
*/
1011

11-
1212
// enable testing mode
1313
extern bool TESTING;
14-
// overwrite file when installing
15-
extern bool OVERWRITE;
1614
// enable verbose mode
1715
extern bool QUIET;
18-
// Flag for skipping checksum validation
19-
extern bool INSECURE;
20-
// Flag indicating that a user passed either Y or N to be used as default
21-
extern bool OVERWRITE_CHOISE;
22-
// Choise for passing N or Y to a prompt by default
23-
extern char* USER_CHOISE[2];
24-
25-
extern char* PACKAGE_QUEUE[QUEUE_MAX];
26-
extern int QUEUE_COUNT;
16+
// Flag indicating that no inputs are required
17+
extern bool AUTO;
18+
// Package queue
19+
extern struct packages* PACKAGE_QUEUE;
2720

0 commit comments

Comments
 (0)