Subversion Repositories SvarDOS

Rev

Rev 1964 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1964 Rev 1965
Line 1... Line 1...
1
/*
1
/*
2
 * This file is part of pkg (SvarDOS)
2
 * This file is part of pkg (SvarDOS)
3
 * Copyright (C) 2012-2021 Mateusz Viste.
3
 * Copyright (C) 2012-2024 Mateusz Viste.
4
 *
4
 *
5
 * Simple library providing functions to unzip files from zip archives.
5
 * Simple library providing functions to unzip files from zip archives.
6
 */
6
 */
7
 
7
 
8
#include <stdio.h>     /* printf(), FILE, fclose()... */
8
#include <stdio.h>     /* printf(), FILE, fclose()... */
Line 12... Line 12...
12
#include <utime.h>     /* utime() */
12
#include <utime.h>     /* utime() */
13
#include <unistd.h>   /* unlink() */
13
#include <unistd.h>   /* unlink() */
14
 
14
 
15
#include "crc32.h"
15
#include "crc32.h"
16
#include "helpers.h"
16
#include "helpers.h"
17
#include "kprintf.h"
-
 
18
#include "inf.h"   /* INFLATE support */
17
#include "inf.h"   /* INFLATE support */
-
 
18
#include "svarlang.lib\svarlang.h"
19
 
19
 
20
#include "libunzip.h"  /* include self for control */
20
#include "libunzip.h"  /* include self for control */
21
 
21
 
22
 
22
 
23
/* converts a "DOS format" timestamp into unix timestamp. The DOS timestamp is constructed an array of 4 bytes, that contains following data at the bit level:
23
/* converts a "DOS format" timestamp into unix timestamp. The DOS timestamp is constructed an array of 4 bytes, that contains following data at the bit level:
Line 87... Line 87...
87
      filenamelen <<= 8;
87
      filenamelen <<= 8;
88
      filenamelen |= hdrbuff[22];
88
      filenamelen |= hdrbuff[22];
89
      /* create new entry and link it into the list */
89
      /* create new entry and link it into the list */
90
      newentry = calloc(sizeof(struct ziplist) + filenamelen, 1);
90
      newentry = calloc(sizeof(struct ziplist) + filenamelen, 1);
91
      if (newentry == NULL) {
91
      if (newentry == NULL) {
92
        kitten_printf(2, 14, "libunzip"); /* "Out of memory! (%s)" */
92
        outputnl(svarlang_str(2,14)); /* Out of memory! */
93
        outputnl("");
-
 
94
        zip_freelist(&reslist);
93
        zip_freelist(&reslist);
95
        break;
94
        break;
96
      }
95
      }
97
      newentry->nextfile = reslist;
96
      newentry->nextfile = reslist;
98
      newentry->flags = 0;
97
      newentry->flags = 0;
Line 148... Line 147...
148
      fseek(fd, (filenamelen + extrafieldlen + compfilelen + filecommentlen), SEEK_CUR);
147
      fseek(fd, (filenamelen + extrafieldlen + compfilelen + filecommentlen), SEEK_CUR);
149
    } else if (entrysig == 0x08074b50ul) { /* Data descriptor header */
148
    } else if (entrysig == 0x08074b50ul) { /* Data descriptor header */
150
      /* no need to read the header we just have to skip it */
149
      /* no need to read the header we just have to skip it */
151
      fseek(fd, 12, SEEK_CUR); /* the header is 3x4 bytes (CRC + compressed len + uncompressed len) */
150
      fseek(fd, 12, SEEK_CUR); /* the header is 3x4 bytes (CRC + compressed len + uncompressed len) */
152
    } else { /* unknown sig */
151
    } else { /* unknown sig */
153
      kitten_printf(8, 1, entrysig); /* "unknown zip sig: 0x%08lx" */
-
 
154
      outputnl("");
-
 
155
      zip_freelist(&reslist);
152
      zip_freelist(&reslist);
156
      break;
153
      break;
157
    }
154
    }
158
  }
155
  }
159
  /* if we got no central directory record, the file is incomplete */
156
  /* if we got no central directory record, the file is incomplete */