aboutsummaryrefslogtreecommitdiff
path: root/tgeb/update.c
diff options
context:
space:
mode:
Diffstat (limited to 'tgeb/update.c')
-rw-r--r--tgeb/update.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/tgeb/update.c b/tgeb/update.c
index 307fb75..ea1d38b 100644
--- a/tgeb/update.c
+++ b/tgeb/update.c
@@ -30,25 +30,25 @@
#include "unzip.h"
#include "tgebup.h"
-#define DATFILE "/tmp/tarife.zip"
+#define DATFILE "tarife"
const char *TGebURL = "www.billiger-telefonieren.de";
const char *TGebGET = "GET /downloads/tgeb/tarife_%.4i%.2i%.2i.zip HTTP/1.0\n\n";
-static void unzip(void);
+static void unzip(void);
void
tgeb_update(struct tm * tm)
{
struct hostent *he;
struct sockaddr_in sin;
- int sockfd;
- char *get;
- char *buf;
- FILE *fd;
- char *file;
- int filelen;
- int offset = 0;
+ int sockfd;
+ char *get;
+ char *buf;
+ FILE *fd;
+ char *file;
+ int filelen;
+ int offset = 0;
if (!(he = gethostbyname(TGebURL)))
err(1, "gethostbyname");
@@ -58,10 +58,10 @@ tgeb_update(struct tm * tm)
memset(&sin, '\0', sizeof(struct sockaddr_in));
sin.sin_family = AF_INET;
sin.sin_port = htons(80);
- sin.sin_addr = *((struct in_addr *)he->h_addr);
+ sin.sin_addr = *((struct in_addr *) he->h_addr);
- if ((connect(sockfd, (struct sockaddr *)&sin,
- sizeof(struct sockaddr))) == -1)
+ if ((connect(sockfd, (struct sockaddr *) & sin,
+ sizeof(struct sockaddr))) == -1)
err(1, "connect");
if (!(get = malloc(sizeof(char) * strlen(TGebGET))))
@@ -74,8 +74,8 @@ tgeb_update(struct tm * tm)
if (!(buf = malloc(sizeof(char) * 1024)))
err(1, "malloc");
- for(;;) {
- int block;
+ for (;;) {
+ int block;
if ((block = recv(sockfd, &buf[offset], 1024, NULL)) == -1)
err(1, "recv");
if (block == 0)
@@ -100,24 +100,24 @@ tgeb_update(struct tm * tm)
void
unzip(void)
{
- FILE *fd;
- unzFile *unzfd;
+ FILE *fd;
+ unzFile *unzfd;
unz_global_info gi;
unz_file_info fi;
- char FileName[256];
- char buf[1024];
- int i, len;
-
+ char FileName[256];
+ char buf[1024];
+ int i, len;
+
if (!(unzfd = unzOpen(DATFILE)))
errx(1, "unzOpen %s", DATFILE);
unzGetGlobalInfo(unzfd, &gi);
for (i = 0; i < gi.number_entry; i++) {
unzGetCurrentFileInfo(unzfd, &fi, FileName, sizeof(FileName),
- NULL, 0, NULL, 0);
+ NULL, 0, NULL, 0);
unzOpenCurrentFile(unzfd);
if (!(fd = fopen(FileName, "wb")))
err(1, "fopen %s", FileName);
- while((len = unzReadCurrentFile(unzfd, &buf, 1024))) {
+ while ((len = unzReadCurrentFile(unzfd, &buf, 1024))) {
fwrite(buf, len, 1, fd);
}
fclose(fd);