helvete
This commit is contained in:
13
weather.c
13
weather.c
@@ -1,4 +1,5 @@
|
||||
/**
|
||||
* this is a test
|
||||
* weather.c
|
||||
* Implementation of weather information fetching and display for Linux
|
||||
* Uses wttr.in service to display weather with its rich UI
|
||||
@@ -28,12 +29,12 @@ int lsh_weather(char **args) {
|
||||
// No location provided, use current location (blank parameter to wttr.in)
|
||||
location[0] = '\0';
|
||||
}
|
||||
|
||||
|
||||
// Properly URL-encode spaces in the location
|
||||
char encoded_location[256] = "";
|
||||
char *src = location;
|
||||
char *dst = encoded_location;
|
||||
|
||||
|
||||
while (*src) {
|
||||
if (*src == ' ') {
|
||||
*dst++ = '%';
|
||||
@@ -45,12 +46,12 @@ int lsh_weather(char **args) {
|
||||
src++;
|
||||
}
|
||||
*dst = '\0';
|
||||
|
||||
|
||||
// Format command with the location - using default wttr.in display format
|
||||
snprintf(command, sizeof(command), "curl -s wttr.in/%s", encoded_location);
|
||||
|
||||
|
||||
// Execute the command and display the full wttr.in UI
|
||||
system(command);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user