unsigned char ad[6], *cur, *adp, *portp;
unsigned int temp[6];
struct sockaddr_in dataAddr;
- size_t dataAddrLen;
+ socklen_t dataAddrLen;
dataFd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (dataFd < 0) {
* closeFtpSocket
*/
-int closeFtpSocket(int socket) {
+int closeFtpSocket() {
return(dataConnectEndFtp());
}
callback(userData, buf, len);
} while (len != 0);
- return(closeFtpSocket(dataFd));
+ return(closeFtpSocket());
}
/*
ns->last_read_trans = t;
/*** ip addr patch ***/
-
- s = (char*)socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
+ i = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
conf.ifc_buf = malloc(sizeof(struct ifreq) * 16);
conf.ifc_len = sizeof(struct ifreq) * 16;
- ioctl((long)s, SIOCGIFCONF, &conf);
+ ioctl((long)i, SIOCGIFCONF, &conf);
for (k=0; k < conf.ifc_len / sizeof(struct ifreq); k++) {
struct net_stat *ns;
ns->addr = ((struct ifreq*)conf.ifc_buf)[k].ifr_ifru.ifru_addr;
}
- close((long)s);
+ close((long)i);
free(conf.ifc_buf);
#include <string.h>
#include "ftp.h"
#include <math.h>
+#include <time.h>
#include <pthread.h>
#include "metarinfo.h"
void ftpData(void *userData, const char *data, int len)
{
-
+ if(userData) {} // do nothing to make stupid warning go away
if (len <= 0)
return;
}
}
+extern unsigned int sleep(unsigned int);
void *fetch_ftp( ) {
// try three times if it fails
/* this happens too often, so i'll leave it commented fprintf(stderr, "METAR update failed for some reason, retry %i\n", tries); */
sleep(15); /* give it some time in case the server is busy or down */
}
+
tries++;
if ( strlen(metar_station) != 8 ){
- fprintf(stderr,"You didn't supply a valid station code\n");
+ ERR("You didn't supply a valid METAR station code\n");
return NULL;
}
if (metar_server == NULL)
initFtp();
res = connectFtp(metar_server, 0);
if (res < 0) {
- fprintf(stderr, "Couldn't connect to %s\n", metar_server);
+ ERR("Couldn't connect to %s\n", metar_server);
return NULL;
}
res = changeFtpDirectory(metar_path);
if (res < 0) {
- fprintf(stderr, "Metar update failed (couldn't CWD to %s)\n", metar_path);
+ ERR("Metar update failed (couldn't CWD to %s)\n", metar_path);
disconnectFtp();
return NULL;
}
if (res == 0) {
- fprintf(stderr,
- "Metar update failed\n");
+ ERR("Metar update failed\n");
return NULL;
}
if (getFtp(ftpData, NULL, metar_station) < 0) {
- fprintf(stderr, "Failed to get file %s\n", metar_station);
+ ERR("Failed to get file %s\n", metar_station);
}
disconnectFtp();