Skip to content

Commit b4cce32

Browse files
committed
Compiled with latest libnx to work in Atmosphere 1.10
1 parent 13328e0 commit b4cce32

File tree

3 files changed

+28
-32
lines changed

3 files changed

+28
-32
lines changed

.github/workflows/build.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@ name: Build
22

33
on:
44
push:
5-
branches:
6-
- master
75
pull_request:
86

97
jobs:
108
build:
119
name: Test build
1210
runs-on: ubuntu-latest
1311
container:
14-
image: 'devkitpro/devkita64'
12+
##image: 'devkitpro/devkita64'
13+
image: 'ghcr.io/irneracoonovich/devkita64'
1514

1615
steps:
17-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1817
with:
1918
persist-credentials: false
2019

source/download.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,19 @@ bool FILE_TRANSFER_HTTP(char *lat, char *lon) {
174174

175175

176176
//https://forecast.weather.gov/MapClick.php?lat=40.6&lon=-111.64&FcstType=json
177-
char *url = "https://forecast.weather.gov/MapClick.php?";
178-
char *finalurl = "";
179-
180-
snprintf(finalurl, 256, "%slat=%s&lon=%s&FcstType=json", url, lat, lon);
181-
177+
char url[256];
178+
snprintf(url, sizeof(url)+1, "https://forecast.weather.gov/MapClick.php?lat=%s&lon=%s&FcstType=json", lat, lon);
182179

183180

184181
//char *filename = NULL;
185182

186183

187-
if (finalurl == (void *) -1) {
184+
if (url == (void *) -1) {
188185
return (false);
189-
} else if (finalurl != NULL) {
186+
} else if (url != NULL) {
190187

191188

192-
downloadFile(finalurl, "weather.txt");
189+
downloadFile(url, "weather.txt");
193190

194191

195192

source/main.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ SDL_Surface* weatherImage;
5656
SDL_Texture* weatherTexture;
5757

5858

59-
char *weathertemp = "00°F";
60-
char *weathericon = "romfs:/gfx/unknown.png";
61-
char *weathertext = "unknown";
62-
char *weatherlocation = "unknown location";
59+
char weathertemp[256];
60+
char weathericon[256];
61+
char weathertext[256];
62+
char weatherlocation[256];
6363

6464
static inline SDL_Color SDL_MakeColour(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
6565
{
@@ -112,7 +112,7 @@ void SDL_DrawTextf(SDL_Renderer *renderer, TTF_Font *font, int x, int y, SDL_Col
112112
char buffer[256];
113113
va_list args;
114114
va_start(args, text);
115-
vsnprintf(buffer, 256, text, args);
115+
vsnprintf(buffer, sizeof(buffer), text, args);
116116
SDL_DrawText(renderer, font, x, y, colour, buffer);
117117
va_end(args);
118118
}
@@ -157,7 +157,7 @@ char *Clock(void) {
157157

158158

159159
//Clock
160-
char *clock = "time";
160+
char clock[256];
161161
const char* ampm = "AM";
162162
time_t unixTime = time(NULL);
163163
struct tm* timeStruct = localtime((const time_t *)&unixTime);
@@ -181,7 +181,7 @@ char *Clock(void) {
181181
ampm = "PM";
182182
}
183183

184-
snprintf(clock, 256, "%s %s %i %i %02i:%02i:%02i %s", weekDays[wday], months[month], day, year, hours, minutes, seconds, ampm);
184+
snprintf(clock, sizeof(clock)+1, "%s %s %i %i %02i:%02i:%02i %s", weekDays[wday], months[month], day, year, hours, minutes, seconds, ampm);
185185
SDL_DrawTextf(renderer, font, SCREEN_WIDTH / 2, 3, CYAN, clock);
186186

187187
return (clock);
@@ -306,10 +306,10 @@ void *getjson(char *JsonString) {
306306
jsmn_parser p;
307307
jsmntok_t t[256]; /* We expect no more than 128 tokens */
308308

309-
char *gettemp = "";
310-
char *getweather = "";
311-
char *getweatherimage = "";
312-
char *getlocation = "";
309+
char gettemp[256];
310+
char getweather[256];
311+
char getweatherimage[256];
312+
char getlocation[256];
313313

314314

315315
jsmn_init(&p);
@@ -330,24 +330,24 @@ void *getjson(char *JsonString) {
330330
for (i = 1; i < r; i++) {
331331
if (jsoneq(JsonString, &t[i], "Temp") == 0) {
332332
//printf("Temp: %.*s\n", t[i+1].end-t[i+1].start, JsonString + t[i+1].start);
333-
snprintf(gettemp, 256, "%.*s", t[i+1].end-t[i+1].start, JsonString + t[i+1].start);
333+
snprintf(gettemp, sizeof(gettemp)+1, "%.*s", t[i+1].end-t[i+1].start, JsonString + t[i+1].start);
334334
i++;
335335
}
336336

337337
else if (jsoneq(JsonString, &t[i], "Weather") == 0) {
338338
//printf("Weather: %.*s\n", t[i+1].end-t[i+1].start, JsonString + t[i+1].start);
339-
snprintf(getweather, 256, "%.*s", t[i+1].end-t[i+1].start, JsonString + t[i+1].start);
339+
snprintf(getweather, sizeof(getweather)+1, "%.*s", t[i+1].end-t[i+1].start, JsonString + t[i+1].start);
340340
i++;
341341
} else if (jsoneq(JsonString, &t[i], "Weatherimage") == 0) {
342342
//printf("Weatherimage: %.*s\n", t[i+1].end-t[i+1].start, JsonString + t[i+1].start);
343-
snprintf(getweatherimage, 256, "%.*s", t[i+1].end-t[i+1].start, JsonString + t[i+1].start);
343+
snprintf(getweatherimage, sizeof(getweatherimage)+1, "%.*s", t[i+1].end-t[i+1].start, JsonString + t[i+1].start);
344344
i++;
345345
}
346346

347347

348348
else if (jsoneq(JsonString, &t[i], "name") == 0) {
349349
//printf("Location: %.*s\n", t[i+1].end-t[i+1].start, JsonString + t[i+1].start);
350-
snprintf(getlocation, 256, "%.*s", t[i+1].end-t[i+1].start, JsonString + t[i+1].start);
350+
snprintf(getlocation, sizeof(getlocation)+1, "%.*s", t[i+1].end-t[i+1].start, JsonString + t[i+1].start);
351351
i++;
352352
}
353353

@@ -364,20 +364,20 @@ void *getjson(char *JsonString) {
364364
SDL_DrawTextf(renderer, font, SCREEN_WIDTH / 2, 3, CYAN, myclock);
365365

366366

367-
snprintf(weathertemp, 256, "%s°F", gettemp);
367+
snprintf(weathertemp, sizeof(weathertemp)+1, "%s°F", gettemp);
368368
SDL_DrawTextf(renderer, lgfont, SCREEN_WIDTH / 2, SCREEN_HEIGHT - 30, CYAN, weathertemp);
369369

370370

371-
snprintf(weathericon, 256, "romfs:/gfx/%s", getweatherimage);
371+
snprintf(weathericon, sizeof(weathericon)+1, "romfs:/gfx/%s", getweatherimage);
372372
weatherImage = IMG_Load(weathericon);
373373
weatherTexture = SDL_CreateTextureFromSurface(renderer, weatherImage);
374374
SDL_FreeSurface(weatherImage);
375375

376-
snprintf(weathertext, 256, "%s", getweather);
376+
snprintf(weathertext, sizeof(weathertext)+1, "%s", getweather);
377377
SDL_DrawTextf(renderer, font, SCREEN_WIDTH / 2, SCREEN_HEIGHT + 73, CYAN, weathertext);
378378

379379

380-
snprintf(weatherlocation, 256, "%s", getlocation);
380+
snprintf(weatherlocation, sizeof(weatherlocation)+1, "%s", getlocation);
381381
SDL_DrawTextf(renderer, font, SCREEN_WIDTH / 2, SCREEN_HEIGHT + 136, CYAN, weatherlocation);
382382

383383

@@ -523,7 +523,7 @@ int main()
523523
lat = strtok(mygps, ",");
524524
lon = strtok(NULL, ",");
525525
char gpsstring[256];
526-
snprintf(gpsstring, 256, "My GPS: %s,%s", lat,lon);
526+
snprintf(gpsstring, sizeof(gpsstring)+1, "My GPS: %s,%s", lat,lon);
527527
SDL_DrawTextf(renderer, font, SCREEN_WIDTH / 2, 43, CYAN, gpsstring);
528528

529529

0 commit comments

Comments
 (0)