summaryrefslogtreecommitdiff
path: root/src/base/archive.c
diff options
context:
space:
mode:
authorTomas Chvatal (scarabeus) <tomas.chvatal@gmail.com>2008-10-22 22:51:24 +0200
committerTomas Chvatal (scarabeus) <tomas.chvatal@gmail.com>2008-10-22 22:51:24 +0200
commit44daf03024fbf7cbffa10349044786f6ab784821 (patch)
treefe311eb22e2d853dfc18fde1a9e55d21815f4f82 /src/base/archive.c
parente12753d2ec9db83ec08bb9db63902a82fb245cdd (diff)
Revert "X"
This reverts commit e12753d2ec9db83ec08bb9db63902a82fb245cdd.
Diffstat (limited to 'src/base/archive.c')
-rw-r--r--src/base/archive.c81
1 files changed, 41 insertions, 40 deletions
diff --git a/src/base/archive.c b/src/base/archive.c
index 52118f8..ac57721 100644
--- a/src/base/archive.c
+++ b/src/base/archive.c
@@ -10,63 +10,64 @@
#define ARCHIVE_BUFFER_SIZE 1024
#define STR_TMP_FILE_NAME 4096
-char *
-extractFileFromArchive(char *archive, char *filename)
+char *extractFileFromArchive(char *archive, char *filename)
{
- char buf[ARCHIVE_BUFFER_SIZE];
- char archive_name[STR_TMP_FILE_NAME];
- char name[STR_TMP_FILE_NAME];
+ char buf[ARCHIVE_BUFFER_SIZE];
+ char archive_name[STR_TMP_FILE_NAME];
+ char name[STR_TMP_FILE_NAME];
- ZZIP_FILE *zip_file;
- FILE *file;
- zzip_ssize_t len;
+ ZZIP_FILE *zip_file;
+ FILE *file;
+ zzip_ssize_t len;
- strcpy(archive_name, archive);
- sprintf(strrchr(archive_name, '.'), "/%s", filename);
+ strcpy(archive_name, archive);
+ sprintf(strrchr(archive_name, '.'), "/%s", filename);
- sprintf(name, "/tmp/tuxanci%d-%s", getpid(), filename);
+ sprintf(name,"/tmp/tuxanci%d-%s", getpid(), filename);
- if ((zip_file = zzip_open(archive_name, O_RDONLY)) == NULL) {
- fprintf(stderr, "No do not open %s archive\n", archive_name);
- return NULL;
- }
+ if( (zip_file = zzip_open(archive_name, O_RDONLY)) == NULL )
+ {
+ fprintf(stderr, "No do not open %s archive\n", archive_name);
+ return NULL;
+ }
- if ((file = fopen(name, "wb")) == NULL) {
- fprintf(stderr, "No do not create temp file %s\n", name);
- return NULL;
- }
+ if( (file = fopen(name, "wb")) == NULL )
+ {
+ fprintf(stderr, "No do not create temp file %s\n", name);
+ return NULL;
+ }
- do {
- len = zzip_read(zip_file, buf, ARCHIVE_BUFFER_SIZE);
- //printf("len = %d\n", len);
+ do{
+ len = zzip_read(zip_file, buf, ARCHIVE_BUFFER_SIZE);
+ //printf("len = %d\n", len);
- if (len > 0) {
- fwrite(buf, len, 1, file);
- }
- } while (len > 0);
+ if( len > 0 )
+ {
+ fwrite(buf, len, 1, file);
+ }
+ }while( len > 0 );
- zzip_close(zip_file);
- fclose(file);
+ zzip_close(zip_file);
+ fclose(file);
- return strdup(name);
+ return strdup(name);
}
-void
-deleteExtractFile(char *s)
+void deleteExtractFile(char *s)
{
- unlink(s);
- free(s);
+ unlink(s);
+ free(s);
}
#if ARCHIVE_TEST
-int
-main()
+int main()
{
- char *name;
+ char *name;
- name = extractFileFromArchive("hello/a/b/hello");
- printf("name = %s\n", name);
- deleteExtractFile(name);
- return 0;
+ name = extractFileFromArchive("hello/a/b/hello");
+ printf("name = %s\n", name);
+ deleteExtractFile(name);
+ return 0;
}
#endif
+