43 |
|
char *reply; |
44 |
|
char *reply_ptr; |
45 |
|
|
46 |
+ |
/* Check to see if anything needs to be free'd */ |
47 |
+ |
if (ihost_state->fm_host!=NULL) free(ihost_state->fm_host); |
48 |
+ |
if (ihost_state->my_fqdn!=NULL) free(ihost_state->my_fqdn); |
49 |
+ |
if (ihost_state->server_fqdn!=NULL) free(ihost_state->server_fqdn); |
50 |
+ |
if (ihost_state->last_modified!=NULL) free(ihost_state->last_modified); |
51 |
+ |
if (ihost_state->files_list!=NULL) free(ihost_state->files_list); |
52 |
+ |
|
53 |
|
if ((sd = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0) { |
54 |
|
errf("Can't create AF_INET socket (%m)"); |
55 |
|
return -1; |
260 |
|
errf("Server error"); |
261 |
|
return -1; |
262 |
|
} |
263 |
< |
|
263 |
> |
if (ihost_state->key!=NULL) free(ihost_state->key); |
264 |
> |
|
265 |
|
if((ihost_state->key=strdup(reply)) == NULL){ |
266 |
|
errf("strdup failed (%m)"); |
267 |
|
return -1; |
279 |
|
|
280 |
|
int main(int argc, char **argv){ |
281 |
|
ihost_state_t ihost_state; |
282 |
+ |
|
283 |
+ |
/* NULL'ify so i can tell if i need to free it or not */ |
284 |
+ |
ihost_state.fm_host=NULL; |
285 |
+ |
ihost_state.my_fqdn=NULL; |
286 |
+ |
ihost_state.server_fqdn=NULL; |
287 |
+ |
ihost_state.last_modified=NULL; |
288 |
+ |
ihost_state.files_list=NULL; |
289 |
+ |
ihost_state.key=NULL; |
290 |
+ |
|
291 |
|
errf_set_progname(argv[0]); |
292 |
|
if(argc!=3){ |
293 |
|
errf_usage("<host> <port>"); |
300 |
|
if(ihost_configure(&ihost_state)!=0){ |
301 |
|
errf("configure failed"); |
302 |
|
} |
303 |
+ |
|
304 |
|
|
305 |
|
return 0; |
306 |
|
} |