2
Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
4
See the accompanying file LICENSE, version 2000-Apr-09 or later
5
(the contents of which are also included in unzip.h) for terms of use.
6
If, for some reason, all these files are missing, the Info-ZIP license
7
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
9
/*---------------------------------------------------------------------------
13
TOPS20-specific routines for use with Info-ZIP's UnZip 5.1 and later.
23
(not yet ported: do_wild(), mapname(), checkdir(), ...)
25
---------------------------------------------------------------------------*/
28
#define UNZIP_INTERNAL
32
/**********************/
33
/* Function mapattr() */
34
/**********************/
36
int mapattr(__G) /* just like Unix except no umask() */
39
ulg tmp = G.crec.external_file_attributes;
41
switch (G.pInfo->hostnum) {
48
G.pInfo->file_attr = (unsigned)(tmp >> 16);
51
tmp = (unsigned)(tmp>>1 & 7); /* Amiga RWE bits */
52
G.pInfo->file_attr = (unsigned)(tmp<<6 | tmp<<3 | tmp);
54
case FS_FAT_: /* MSDOS half of attributes should always be correct */
60
tmp = !(tmp & 1) << 1; /* read-only bit --> write perms bits */
61
G.pInfo->file_attr = (unsigned)(0444 | tmp<<6 | tmp<<3 | tmp);
67
G.pInfo->file_attr = 0666;
70
} /* end switch (host-OS-created-by) */
74
} /* end function mapattr() */
80
/****************************/
81
/* Function close_outfile() */
82
/****************************/
84
void close_outfile(__G)
87
# define JSYS_CLASS 0070000000000
88
# define FLD(val,mask) (((unsigned)(val)*((mask)&(-(mask))))&(mask))
89
# define _DEFJS(name,class) (FLD(class,JSYS_CLASS) | (monsym(name)&0777777))
90
# define IDTIM _DEFJS("IDTIM%", 1)
91
# define SFTAD _DEFJS("SFTAD%", 0)
93
int ablock[5], tblock[2];
94
int yr, mo, dy, hh, mm, ss;
106
(ef_scan_for_izux(G.extra_field, G.lrec.extra_field_length, 0,
107
G.lrec.last_mod_dos_date, &z_utime, NULL)
109
t = localtime(&(z_utime.mtime));
111
t = (struct tm *)NULL;
113
if (t != (struct tm *)NULL)
115
yr = t->tm_year + 1900;
124
/* dissect the date */
125
yr = ((G.lrec.last_mod_dos_date >> 9) & 0x7f) + 1980;
126
mo = ((G.lrec.last_mod_dos_date >> 5) & 0x0f) - 1;
127
dy = (G.lrec.last_mod_dos_date & 0x1f);
129
/* dissect the time */
130
hh = (G.lrec.last_mod_dos_time >> 11) & 0x1f;
131
mm = (G.lrec.last_mod_dos_time >> 5) & 0x3f;
132
ss = (G.lrec.last_mod_dos_time & 0x1f) * 2;
134
#else /* !USE_EF_UT_TIME */
136
/* dissect the date */
137
yr = ((G.lrec.last_mod_dos_datetime >> 25) & 0x7f) + (1980 - YRBASE);
138
mo = (G.lrec.last_mod_dos_datetime >> 21) & 0x0f;
139
dy = (G.lrec.last_mod_dos_datetime >> 16) & 0x1f;
141
/* dissect the time */
142
hh = (G.lrec.last_mod_dos_datetime >> 11) & 0x1f;
143
mm = (G.lrec.last_mod_dos_datetime >> 5) & 0x3f;
144
ss = (G.lrec.last_mod_dos_datetime << 1) & 0x1f;
145
#endif /* ?USE_EF_UT_TIME */
147
sprintf(temp, "%02d/%02d/%02d %02d:%02d:%02d", mo, dy, yr, hh, mm, ss);
149
ablock[1] = (int)(temp - 1);
151
if (!jsys(IDTIM, ablock)) {
152
Info(slide, 1, ((char *)slide, "error: IDTIM failure for %s\n",
163
ablock[1] = fcntl(fileno(G.outfile), F_GETSYSFD, 0);
164
/* _uffd[outfd]->uf_ch */
165
ablock[2] = (int) tblock;
167
if (!jsys(SFTAD, ablock))
168
Info(slide, 1,((char *)slide, "error: cannot set the time for %s\n",
173
} /* end function close_outfile() */
181
/************************/
182
/* Function version() */
183
/************************/
192
sprintf((char *)slide, LoadFarString(CompiledWith),
198
"cc ", (sprintf(buf, " version %d", _RELEASE), buf),
200
# ifdef __COMPILER_KCC__
203
"unknown compiler", "",
210
#if defined(foobar) || defined(FOOBAR)
211
" (Foo BAR)", /* OS version or hardware */
223
(*G.message)((zvoid *)&G, slide, (ulg)strlen((char *)slide), 0);
225
} /* end function version() */
233
/**********************/
234
/* Function upper() */
235
/**********************/
237
int upper(s) /* returns s in uppercase */
238
char *s; /* string to be uppercased */
248
/************************/
249
/* Function enquote() */
250
/************************/
252
int enquote(s) /* calls dequote(s) to normalize string, then */
253
char *s; /* inserts ^Vs before otherwise illegal characters */
254
{ /* in s, assuming that s is a TOPS-20 filename */
278
/************************/
279
/* Function dequote() */
280
/************************/
282
int dequote(s) /* returns s without ^Vs */
283
char *s; /* string to be dequoted */
305
/************************/
306
/* Function fnlegal() */
307
/************************/
309
int fnlegal(c) /* returns TRUE if c is a member of the */
310
char c; /* legal character set for filenames */
313
static char *legals = {"$%**-<>>AZ[[]]__az"};