util  Diff

Differences From Artifact [b2cd504148]:

To Artifact [be25cce95d]:


    72     72   #else
    73     73   #	define _http "?"
    74     74   #endif
    75     75   #define http _http "lang=" ds_lang " HTTP/1.1\r\nHost: api.darksky.net\r\n\r\n"
    76     76   #define start "GET /forecast/" ds_apikey "/"
    77     77   
    78     78   #define min(x,y) (x>y?y:x)
    79         -#define len(x) (sizeof(x)/sizeof(*x))
           79  +#define len(x) (sizeof(x)/sizeof(x)[0])
    80     80   
    81     81   typedef enum bool { false, true } bool;
    82     82   
    83     83   SSL_CTX* sc;
    84     84   bool head(size_t* len, char* txt, char** body) {
    85     85   	char* hend = strstr(txt, "\r\n\r\n");
    86     86   	if (hend == NULL) return false;
................................................................................
   186    186   	size_t len = *key++;
   187    187   	for (size_t i = 0; i<len; ++i) {
   188    188   		printf("/%.*s",*key,key+1);
   189    189   		key += *key + 1;
   190    190   	};
   191    191   	printf("\n");
   192    192   } */
   193         -void pplt(const char* str, const char* const end, const char** keys, const char** const keyend, jsv* values) {
          193  +void pplt
          194  +(	const char*        str,
          195  +	const char*  const end,
          196  +	const char**       keys,
          197  +	const char** const keyend,
          198  +	jsv* values
          199  +) {
   194    200   	// initialize parser state
   195    201   	size_t depth = 0;
   196    202   	const char* fld = NULL;
   197    203   	const char* path[32];
   198    204   	path[0] = NULL;
   199    205   	
   200    206   	while(*str++!='{'); //cheat
................................................................................
   365    371   			
   366    372   			pstr summary = values[0].s;
   367    373   			float pcpint = values[1].f,
   368    374   				temp = values[2].f,
   369    375   				windspd = values[3].f;
   370    376   
   371    377   			printf("%.1f°  %%{F#ff9bbb}%.*s\n",
   372         -					summary.sz,
   373         -					summary.a,
   374         -					temp);
          378  +					temp,
          379  +					(int /*throwing table emoji*/)summary.sz,
          380  +					summary.a);
   375    381   		}
   376    382   		// dark sky's API allows us to make 1000 free requests a day.
   377    383   		// let's try not to get too near that.
   378    384   		// hours in day 24 - minutes in day 24 * 60 = 1440
   379    385   		// so once a minute is almost half again too many
   380    386   		// 1440 / 2 = 720 leaving reasonable refresh time without
   381    387   		// going too near the limit. so we aim for one update
   382    388   		// every two minutes.
   383    389   	//	sleep(60 * 2);
   384    390   //	}
   385    391   
   386    392   	return 0;
   387    393   }