aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2004-05-10 15:22:29 +0000
committerDimitri Sokolyuk <demon@dim13.org>2004-05-10 15:22:29 +0000
commit99d84ecc0e6630fb736e9090f6570eb8abc473ed (patch)
tree7962649b5ea9d65b63a010cceef5ea60a1ee684c /lib
parent65a6c5505b29a946faa06fd55929238280176d32 (diff)
version 0.3
homedir added minor changes
Diffstat (limited to 'lib')
-rw-r--r--lib/common.c18
-rw-r--r--lib/update.c10
2 files changed, 28 insertions, 0 deletions
diff --git a/lib/common.c b/lib/common.c
index 56f7fd1..f1eac05 100644
--- a/lib/common.c
+++ b/lib/common.c
@@ -117,3 +117,21 @@ tgeb_free_sd(SORTED * sd)
free(sd->data);
free(sd);
}
+
+char *
+tgeb_read_date(char *file)
+{
+ FILE *fd;
+ char *datum;
+
+ if (!(datum = calloc(20, sizeof(char))))
+ err(1, "malloc");;
+
+ if(!(fd = fopen(file, "r")))
+ err(1, "fopen %s", file);
+
+ fread(datum, sizeof(char), 19, fd);
+
+ fclose(fd);
+ return(datum);
+}
diff --git a/lib/update.c b/lib/update.c
index f510861..6dd14d2 100644
--- a/lib/update.c
+++ b/lib/update.c
@@ -36,6 +36,7 @@
const char *TGebURL = "www.billiger-telefonieren.de";
const char *TGebGET = "GET /downloads/tgeb/tarife_%.4i%.2i%.2i.zip HTTP/1.0\n\n";
+extern char *__progname;
static void unzip(void);
@@ -52,6 +53,9 @@ tgeb_update(struct tm * tm)
int filelen;
int offset = 0;
+ printf("%s: updating database ", __progname);
+ fflush(stdout);
+
if (!(he = gethostbyname(TGebURL)))
err(1, "gethostbyname");
@@ -85,7 +89,10 @@ tgeb_update(struct tm * tm)
offset += block;
if (!(buf = realloc(buf, offset + BUF_SIZ)))
err(1, "malloc");
+ putchar('.');
+ fflush(stdout);
}
+ putchar('\n');
close(sockfd);
file = strstr(buf, "\r\n\r\n") + 4;
filelen = offset + buf - file;
@@ -120,6 +127,8 @@ unzip(void)
for (i = 0; i < gi.number_entry; i++) {
unzGetCurrentFileInfo(unzfd, &fi, FileName, sizeof(FileName),
NULL, 0, NULL, 0);
+ printf("extract %s ...", FileName);
+ fflush(stdout);
unzOpenCurrentFile(unzfd);
if (!(fd = fopen(FileName, "wb")))
err(1, "fopen %s", FileName);
@@ -127,6 +136,7 @@ unzip(void)
fwrite(buf, len, 1, fd);
}
fclose(fd);
+ printf(" done\n");
unzGoToNextFile(unzfd);
}
free(buf);