Modify sandia code to use the library
This commit is contained in:
parent
086116422f
commit
c85a69fa93
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
|||||||
[submodule "source/sandia"]
|
|
||||||
path = source/sandia
|
|
||||||
url = https://git.donut.eu.org/libreshop/sandia-Wii.git
|
|
2
Makefile
2
Makefile
@ -33,7 +33,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# any extra libraries we wish to link with the project
|
# any extra libraries we wish to link with the project
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
LIBS := -lwiiuse -lbte -logc -lm -ljansson
|
LIBS := -lwiiuse -lbte -logc -lm -lsandia -ljansson
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
#include <wiiuse/wpad.h>
|
#include <wiiuse/wpad.h>
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <sandia.h>
|
||||||
#include "sandia/sandia.h"
|
|
||||||
|
|
||||||
#include "input_macros.h"
|
#include "input_macros.h"
|
||||||
|
|
||||||
@ -90,38 +89,20 @@ int main(int argc, char **argv) {
|
|||||||
printf("%s.\n", localip);
|
printf("%s.\n", localip);
|
||||||
|
|
||||||
sandia req = sandia_create("libreshop.donut.eu.org", 80);
|
sandia req = sandia_create("libreshop.donut.eu.org", 80);
|
||||||
sandia_response res = sandia_get_request(&req, "/");
|
sandia_response res = sandia_get_request(&req, "/", true, true);
|
||||||
bool lastWasNewline = false;
|
|
||||||
int resBodyLength = strlen(res.body);
|
|
||||||
for (int i = 0; i < resBodyLength; i++) {
|
|
||||||
if (res.body[i] == '\r') continue;
|
|
||||||
|
|
||||||
if (res.body[i] == '\n') {
|
json_error_t error;
|
||||||
if (lastWasNewline) {
|
json_t *root = json_loads(res.body, 0, &error);
|
||||||
int rBL = resBodyLength - i;
|
|
||||||
char* body = malloc(rBL);
|
|
||||||
for (int j = 0; j < rBL; j++) {
|
|
||||||
body[j] = res.body[j + i + 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
json_error_t error;
|
if (!root || !json_is_array(root)) {
|
||||||
json_t *root = json_loads(body, 0, &error);
|
printf("failed decoding\n");
|
||||||
if (!root || !json_is_array(root)) {
|
}
|
||||||
printf("failed decoding\n");
|
else {
|
||||||
}
|
printf("%s\n", res.body);
|
||||||
else {
|
for (int j = 0; j < json_array_size(root); j++) {
|
||||||
printf("%s\n", body);
|
json_t *data = json_array_get(root, j);
|
||||||
for (int j = 0; j < json_array_size(root); j++) {
|
printf("%s\n", json_string_value(data));
|
||||||
json_t *data = json_array_get(root, j);
|
|
||||||
printf("%s\n", json_string_value(data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else lastWasNewline = true;
|
|
||||||
}
|
}
|
||||||
else lastWasNewline = false;
|
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
sandia_close(&req);
|
sandia_close(&req);
|
||||||
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 8f4d62429b06bb851f03c21c7796ae69f78541a8
|
|
Loading…
Reference in New Issue
Block a user