util  Diff

Differences From Artifact [b2cd504148]:

To Artifact [be25cce95d]:


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
...
186
187
188
189
190
191
192




193


194
195
196
197
198
199
200
...
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
#else
#	define _http "?"
#endif
#define http _http "lang=" ds_lang " HTTP/1.1\r\nHost: api.darksky.net\r\n\r\n"
#define start "GET /forecast/" ds_apikey "/"

#define min(x,y) (x>y?y:x)
#define len(x) (sizeof(x)/sizeof(*x))

typedef enum bool { false, true } bool;

SSL_CTX* sc;
bool head(size_t* len, char* txt, char** body) {
	char* hend = strstr(txt, "\r\n\r\n");
	if (hend == NULL) return false;
................................................................................
	size_t len = *key++;
	for (size_t i = 0; i<len; ++i) {
		printf("/%.*s",*key,key+1);
		key += *key + 1;
	};
	printf("\n");
} */




void pplt(const char* str, const char* const end, const char** keys, const char** const keyend, jsv* values) {


	// initialize parser state
	size_t depth = 0;
	const char* fld = NULL;
	const char* path[32];
	path[0] = NULL;
	
	while(*str++!='{'); //cheat
................................................................................
			
			pstr summary = values[0].s;
			float pcpint = values[1].f,
				temp = values[2].f,
				windspd = values[3].f;

			printf("%.1f°  %%{F#ff9bbb}%.*s\n",
					summary.sz,
					summary.a,
					temp);
		}
		// dark sky's API allows us to make 1000 free requests a day.
		// let's try not to get too near that.
		// hours in day 24 - minutes in day 24 * 60 = 1440
		// so once a minute is almost half again too many
		// 1440 / 2 = 720 leaving reasonable refresh time without
		// going too near the limit. so we aim for one update
		// every two minutes.
	//	sleep(60 * 2);
//	}

	return 0;
}







|







 







>
>
>
>
|
>
>







 







|
|
|













72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
...
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
...
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
#else
#	define _http "?"
#endif
#define http _http "lang=" ds_lang " HTTP/1.1\r\nHost: api.darksky.net\r\n\r\n"
#define start "GET /forecast/" ds_apikey "/"

#define min(x,y) (x>y?y:x)
#define len(x) (sizeof(x)/sizeof(x)[0])

typedef enum bool { false, true } bool;

SSL_CTX* sc;
bool head(size_t* len, char* txt, char** body) {
	char* hend = strstr(txt, "\r\n\r\n");
	if (hend == NULL) return false;
................................................................................
	size_t len = *key++;
	for (size_t i = 0; i<len; ++i) {
		printf("/%.*s",*key,key+1);
		key += *key + 1;
	};
	printf("\n");
} */
void pplt
(	const char*        str,
	const char*  const end,
	const char**       keys,
	const char** const keyend,
	jsv* values
) {
	// initialize parser state
	size_t depth = 0;
	const char* fld = NULL;
	const char* path[32];
	path[0] = NULL;
	
	while(*str++!='{'); //cheat
................................................................................
			
			pstr summary = values[0].s;
			float pcpint = values[1].f,
				temp = values[2].f,
				windspd = values[3].f;

			printf("%.1f°  %%{F#ff9bbb}%.*s\n",
					temp,
					(int /*throwing table emoji*/)summary.sz,
					summary.a);
		}
		// dark sky's API allows us to make 1000 free requests a day.
		// let's try not to get too near that.
		// hours in day 24 - minutes in day 24 * 60 = 1440
		// so once a minute is almost half again too many
		// 1440 / 2 = 720 leaving reasonable refresh time without
		// going too near the limit. so we aim for one update
		// every two minutes.
	//	sleep(60 * 2);
//	}

	return 0;
}