~ubuntu-branches/ubuntu/quantal/unzip/quantal

« back to all changes in this revision

Viewing changes to tops20/tops20.c

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2009-05-08 20:02:40 UTC
  • mfrom: (2.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090508200240-rk23wg0jdoyc6caj
Tags: 6.0-1
* New upstream release. Closes: #496989.
* Enabled new Unicode support. Closes: #197427. This may or may not work
  for your already created zipfiles, but it's not a bug unless they were
  created using the Unicode feature present in zip 3.0.
* Built using DATE_FORMAT=DF_YMD so that unzip -l show dates in ISO format,
  as that's the only available one which makes sense. Closes: #312886.
* Enabled new bzip2 support. Closes: #426798.
* Exit code for zipgrep should now be the right one. Closes: #441997.
* The reason why a file may not be created is now shown. Closes: #478791.
* Summary of changes in this version not being the debian/* files:
- Manpages in section 1, not 1L.
- Branding patch. UnZip by Debian. Original by Info-ZIP.
- Always #include <unistd.h>. Debian GNU/kFreeBSD needs it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
  Copyright (c) 1990-2004 Info-ZIP.  All rights reserved.
 
2
  Copyright (c) 1990-2007 Info-ZIP.  All rights reserved.
3
3
 
4
4
  See the accompanying file LICENSE, version 2000-Apr-09 or later
5
5
  (the contents of which are also included in unzip.h) for terms of use.
100
100
    struct tm *t;
101
101
 
102
102
 
103
 
    if (G.extra_field &&
 
103
    /* skip restoring time stamps on user's request */
 
104
    if (uO.D_flag <= 1) {
 
105
 
 
106
        if (G.extra_field &&
104
107
#ifdef IZ_CHECK_TZ
105
 
        G.tz_is_valid &&
 
108
            G.tz_is_valid &&
106
109
#endif
107
 
        (ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length, 0,
108
 
                          G.lrec.last_mod_dos_date, &z_utime, NULL)
109
 
         & EB_UT_FL_MTIME))
110
 
        t = localtime(&(z_utime.mtime));
111
 
    else
112
 
        t = (struct tm *)NULL;
113
 
 
114
 
    if (t != (struct tm *)NULL)
115
 
    {
116
 
        yr = t->tm_year + 1900;
117
 
        mo = t->tm_mon;
118
 
        dy = t->tm_mday;
119
 
        hh = t->tm_hour;
120
 
        mm = t->tm_min;
121
 
        ss = t->tm_sec;
122
 
    }
123
 
    else
124
 
    {
 
110
            (ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length, 0,
 
111
                              G.lrec.last_mod_dos_date, &z_utime, NULL)
 
112
             & EB_UT_FL_MTIME))
 
113
            t = localtime(&(z_utime.mtime));
 
114
        else
 
115
            t = (struct tm *)NULL;
 
116
 
 
117
        if (t != (struct tm *)NULL)
 
118
        {
 
119
            yr = t->tm_year + 1900;
 
120
            mo = t->tm_mon;
 
121
            dy = t->tm_mday;
 
122
            hh = t->tm_hour;
 
123
            mm = t->tm_min;
 
124
            ss = t->tm_sec;
 
125
        }
 
126
        else
 
127
        {
 
128
            /* dissect the date */
 
129
            yr = ((G.lrec.last_mod_dos_date >> 9) & 0x7f) + 1980;
 
130
            mo = ((G.lrec.last_mod_dos_date >> 5) & 0x0f) - 1;
 
131
            dy = (G.lrec.last_mod_dos_date & 0x1f);
 
132
 
 
133
            /* dissect the time */
 
134
            hh = (G.lrec.last_mod_dos_time >> 11) & 0x1f;
 
135
            mm = (G.lrec.last_mod_dos_time >> 5) & 0x3f;
 
136
            ss = (G.lrec.last_mod_dos_time & 0x1f) * 2;
 
137
        }
 
138
#else /* !USE_EF_UT_TIME */
 
139
 
125
140
        /* dissect the date */
126
 
        yr = ((G.lrec.last_mod_dos_date >> 9) & 0x7f) + 1980;
127
 
        mo = ((G.lrec.last_mod_dos_date >> 5) & 0x0f) - 1;
128
 
        dy = (G.lrec.last_mod_dos_date & 0x1f);
 
141
        yr = ((G.lrec.last_mod_dos_datetime >> 25) & 0x7f) + (1980 - YRBASE);
 
142
        mo = (G.lrec.last_mod_dos_datetime >> 21) & 0x0f;
 
143
        dy = (G.lrec.last_mod_dos_datetime >> 16) & 0x1f;
129
144
 
130
145
        /* dissect the time */
131
 
        hh = (G.lrec.last_mod_dos_time >> 11) & 0x1f;
132
 
        mm = (G.lrec.last_mod_dos_time >> 5) & 0x3f;
133
 
        ss = (G.lrec.last_mod_dos_time & 0x1f) * 2;
134
 
    }
135
 
#else /* !USE_EF_UT_TIME */
136
 
 
137
 
    /* dissect the date */
138
 
    yr = ((G.lrec.last_mod_dos_datetime >> 25) & 0x7f) + (1980 - YRBASE);
139
 
    mo = (G.lrec.last_mod_dos_datetime >> 21) & 0x0f;
140
 
    dy = (G.lrec.last_mod_dos_datetime >> 16) & 0x1f;
141
 
 
142
 
    /* dissect the time */
143
 
    hh = (G.lrec.last_mod_dos_datetime >> 11) & 0x1f;
144
 
    mm = (G.lrec.last_mod_dos_datetime >> 5) & 0x3f;
145
 
    ss = (G.lrec.last_mod_dos_datetime << 1) & 0x1f;
 
146
        hh = (G.lrec.last_mod_dos_datetime >> 11) & 0x1f;
 
147
        mm = (G.lrec.last_mod_dos_datetime >> 5) & 0x3f;
 
148
        ss = (G.lrec.last_mod_dos_datetime << 1) & 0x1f;
146
149
#endif /* ?USE_EF_UT_TIME */
147
150
 
148
 
    sprintf(temp, "%02d/%02d/%02d %02d:%02d:%02d", mo, dy, yr, hh, mm, ss);
149
 
 
150
 
    ablock[1] = (int)(temp - 1);
151
 
    ablock[2] = 0;
152
 
    if (!jsys(IDTIM, ablock)) {
153
 
        Info(slide, 1, ((char *)slide, "error:  IDTIM failure for %s\n",
154
 
          G.filename));
155
 
        fclose(G.outfile);
156
 
        return;
157
 
    }
158
 
 
159
 
    tad = ablock[2];
160
 
    tblock[0] = tad;
161
 
    tblock[1] = tad;
162
 
    tblock[2] = -1;
163
 
 
164
 
    ablock[1] = fcntl(fileno(G.outfile), F_GETSYSFD, 0);
165
 
                                                /* _uffd[outfd]->uf_ch */
166
 
    ablock[2] = (int) tblock;
167
 
    ablock[3] = 3;
168
 
    if (!jsys(SFTAD, ablock))
169
 
        Info(slide, 1,((char *)slide, "error:  cannot set the time for %s\n",
170
 
          G.filename));
 
151
        sprintf(temp, "%02d/%02d/%02d %02d:%02d:%02d", mo, dy, yr, hh, mm, ss);
 
152
 
 
153
        ablock[1] = (int)(temp - 1);
 
154
        ablock[2] = 0;
 
155
        if (!jsys(IDTIM, ablock)) {
 
156
            Info(slide, 1, ((char *)slide, "error:  IDTIM failure for %s\n",
 
157
              G.filename));
 
158
            fclose(G.outfile);
 
159
            return;
 
160
        }
 
161
 
 
162
        tad = ablock[2];
 
163
        tblock[0] = tad;
 
164
        tblock[1] = tad;
 
165
        tblock[2] = -1;
 
166
 
 
167
        ablock[1] = fcntl(fileno(G.outfile), F_GETSYSFD, 0);
 
168
                                                    /* _uffd[outfd]->uf_ch */
 
169
        ablock[2] = (int) tblock;
 
170
        ablock[3] = 3;
 
171
        if (!jsys(SFTAD, ablock))
 
172
            Info(slide, 1,((char *)slide,
 
173
              "error:  cannot set the time for %s\n", G.filename));
 
174
 
 
175
    } /* if (uO.D_flag <= 1) */
171
176
 
172
177
    fclose(G.outfile);
173
178