| 1 |
/* |
| 2 |
Copyright (c) 1990-2002 Info-ZIP. All rights reserved. |
| 3 |
|
| 4 |
See the accompanying file LICENSE, version 2000-Apr-09 or later |
| 5 |
(the contents of which are also included in zip.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 |
| 8 |
*/ |
| 9 |
/*--------------------------------------------------------------------------- |
| 10 |
|
| 11 |
extrafld.c |
| 12 |
|
| 13 |
contains functions to build extra-fields. |
| 14 |
|
| 15 |
---------------------------------------------------------------------------*/ |
| 16 |
|
| 17 |
/*****************************************************************************/ |
| 18 |
/* Includes */ |
| 19 |
/*****************************************************************************/ |
| 20 |
|
| 21 |
#include <sound.h> |
| 22 |
#include "zip.h" |
| 23 |
#include "unixlike.h" |
| 24 |
#include "helpers.h" |
| 25 |
#include "pathname.h" |
| 26 |
|
| 27 |
|
| 28 |
/*****************************************************************************/ |
| 29 |
/* Macros, typedefs */ |
| 30 |
/*****************************************************************************/ |
| 31 |
|
| 32 |
/* ---------------------------------------------------------------------- */ |
| 33 |
/* Add a 'MAC3' extra field to the zlist data pointed to by z. */ |
| 34 |
/* This is the (new) Info-zip extra block for Macintosh */ |
| 35 |
#define EB_MAC3_HLEN 14 /* fixed length part of MAC3's header */ |
| 36 |
#define EB_L_MAC3_FINFO_LEN 52 /* fixed part of MAC3 compressible data */ |
| 37 |
|
| 38 |
#define EB_MAX_OF_VARDATA 1300 /* max possible datasize */ |
| 39 |
|
| 40 |
#define EB_L_MAC3_SIZE (EB_HEADSIZE + EB_MAC3_HLEN) |
| 41 |
#define EB_C_MAC3_SIZE (EB_HEADSIZE + EB_MAC3_HLEN) |
| 42 |
|
| 43 |
/* maximum memcompress overhead is the sum of the compression header length */ |
| 44 |
/* (6 = ush compression type, ulg CRC) and the worstcase deflate overhead */ |
| 45 |
/* when uncompressible data are kept in 2 "stored" blocks (5 per block = */ |
| 46 |
/* byte blocktype + 2 * ush blocklength) */ |
| 47 |
#define MEMCOMPRESS_OVERHEAD (EB_MEMCMPR_HSIZ + EB_DEFLAT_EXTRA) |
| 48 |
|
| 49 |
#define EB_M3_FL_COMPRESS 0x00 |
| 50 |
#define EB_M3_FL_DATFRK 0x01 /* data is data-fork */ |
| 51 |
#define EB_M3_FL_NOCHANGE 0x02 /* filename will be not changed */ |
| 52 |
#define EB_M3_FL_UNCMPR 0x04 /* data is 'natural' (not compressed) */ |
| 53 |
#define EB_M3_FL_TIME64 0x08 /* time is coded in 64 bit */ |
| 54 |
#define EB_M3_FL_NOUTC 0x10 /* only 'local' time-stamps are stored */ |
| 55 |
|
| 56 |
|
| 57 |
#define EB_L_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(2)) |
| 58 |
#define EB_C_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(1)) |
| 59 |
|
| 60 |
/* disable compressing of extra field |
| 61 |
#define MAC_EXTRAFLD_UNCMPR */ |
| 62 |
|
| 63 |
/* ---------------------------------------------------------------------- */ |
| 64 |
/* Add a 'JLEE' extra field to the zlist data pointed to by z. */ |
| 65 |
/* This is the (old) Info-zip resource-fork extra block for Macintosh |
| 66 |
(last Revision 1996-09-22) Layout made by Johnny Lee, Code made by me :-) */ |
| 67 |
#define EB_L_JLEE_LEN 40 /* fixed length of JLEE's header */ |
| 68 |
#define EB_C_JLEE_LEN 40 /* fixed length of JLEE's header */ |
| 69 |
|
| 70 |
#define EB_L_JLEE_SIZE (EB_HEADSIZE + EB_L_JLEE_LEN) |
| 71 |
#define EB_C_JLEE_SIZE (EB_HEADSIZE + EB_C_JLEE_LEN) |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
/*****************************************************************************/ |
| 76 |
/* Global Vars */ |
| 77 |
/*****************************************************************************/ |
| 78 |
|
| 79 |
extern MacZipGlobals MacZip; |
| 80 |
extern unsigned long count_of_Zippedfiles; |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
/*****************************************************************************/ |
| 85 |
/* Prototypes */ |
| 86 |
/*****************************************************************************/ |
| 87 |
|
| 88 |
static int add_UT_ef(struct zlist far *z, iztimes *z_utim); |
| 89 |
static int add_JLEE_ef(struct zlist far *z); /* old mac extra field */ |
| 90 |
static int add_MAC3_ef(struct zlist far *z); /* new mac extra field */ |
| 91 |
|
| 92 |
static void make_extrafield_JLEE(char *l_ef); |
| 93 |
static unsigned make_extrafield_MAC3(char *ef); |
| 94 |
static char *make_EF_Head_MAC3(char *ef, unsigned compsize, ulg attrsize, |
| 95 |
unsigned flag); |
| 96 |
|
| 97 |
static void print_extra_info(void); |
| 98 |
void UserStop(void); |
| 99 |
|
| 100 |
|
| 101 |
/*****************************************************************************/ |
| 102 |
/* Functions */ |
| 103 |
/*****************************************************************************/ |
| 104 |
|
| 105 |
|
| 106 |
/* |
| 107 |
* Set the extra-field's for each compressed file |
| 108 |
*/ |
| 109 |
int set_extra_field(struct zlist far *z, iztimes *z_utim) |
| 110 |
/* store full data in local header but just modification time stamp info |
| 111 |
in central header */ |
| 112 |
{ |
| 113 |
int retval; |
| 114 |
|
| 115 |
Assert_it(z, "set_extra_field","") |
| 116 |
Assert_it(z_utim, "set_extra_field","") |
| 117 |
|
| 118 |
z_utim = z_utim; |
| 119 |
|
| 120 |
/* Check to make sure z is valid. */ |
| 121 |
if( z == NULL ) { |
| 122 |
return ZE_LOGIC; |
| 123 |
} |
| 124 |
|
| 125 |
/* Resource forks are always binary */ |
| 126 |
if (MacZip.CurrentFork == ResourceFork) z->att = BINARY; |
| 127 |
|
| 128 |
if (noisy) |
| 129 |
{ |
| 130 |
count_of_Zippedfiles++; |
| 131 |
InformProgress(MacZip.RawCountOfItems, count_of_Zippedfiles ); |
| 132 |
} |
| 133 |
|
| 134 |
/* |
| 135 |
PrintFileInfo(); |
| 136 |
*/ |
| 137 |
switch (MacZip.MacZipMode) |
| 138 |
{ |
| 139 |
case JohnnyLee_EF: |
| 140 |
{ |
| 141 |
retval = add_JLEE_ef( z ); |
| 142 |
if (retval != ZE_OK) return retval; |
| 143 |
break; |
| 144 |
} |
| 145 |
case NewZipMode_EF: |
| 146 |
{ /* */ |
| 147 |
#ifdef USE_EF_UT_TIME |
| 148 |
retval = add_UT_ef(z, z_utim); |
| 149 |
if (retval != ZE_OK) return retval; |
| 150 |
#endif |
| 151 |
|
| 152 |
retval = add_MAC3_ef( z ); |
| 153 |
if (retval != ZE_OK) return retval; |
| 154 |
break; |
| 155 |
} |
| 156 |
default: |
| 157 |
{ |
| 158 |
printerr("Unknown Extrafieldmode", -1, -1, __LINE__, __FILE__, ""); |
| 159 |
return ZE_LOGIC; /* function should never reach this point */ |
| 160 |
} |
| 161 |
} |
| 162 |
|
| 163 |
/* MacStat information is now outdated and |
| 164 |
must be refreshed for the next file */ |
| 165 |
MacZip.isMacStatValid = false; |
| 166 |
|
| 167 |
return ZE_OK; |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
#ifdef USE_EF_UT_TIME |
| 174 |
/* |
| 175 |
* Build and add the Unix time extra-field. This extra field |
| 176 |
* will be included be default. Johnny Lee's implementation does |
| 177 |
* not use this kind of extra-field. |
| 178 |
* All datas are in Intel (=little-endian) format |
| 179 |
|
| 180 |
Extra field info: |
| 181 |
- 'UT' - UNIX time extra field |
| 182 |
|
| 183 |
This is done the same way ../unix/unix.c stores the 'UT'/'Ux' fields |
| 184 |
(full data in local header, only modification time in central header), |
| 185 |
with the 'M3' field added to the end and the size of the 'M3' field |
| 186 |
in the central header. |
| 187 |
*/ |
| 188 |
|
| 189 |
static int add_UT_ef(struct zlist far *z, iztimes *z_utim) |
| 190 |
{ |
| 191 |
char *l_ef = NULL; |
| 192 |
char *c_ef = NULL; |
| 193 |
|
| 194 |
Assert_it(z, "add_UT_ef","") |
| 195 |
|
| 196 |
#ifdef IZ_CHECK_TZ |
| 197 |
if (!zp_tz_is_valid) |
| 198 |
return ZE_OK; /* skip silently if no valid TZ info */ |
| 199 |
#endif |
| 200 |
|
| 201 |
/* We can't work if there's no entry to work on. */ |
| 202 |
if( z == NULL ) { |
| 203 |
return ZE_LOGIC; |
| 204 |
} |
| 205 |
|
| 206 |
/* Check to make sure we've got enough room in the extra fields. */ |
| 207 |
if( z->ext + EB_L_UT_SIZE > EF_SIZE_MAX || |
| 208 |
z->cext + EB_C_UT_SIZE > EF_SIZE_MAX ) { |
| 209 |
return ZE_MEM; |
| 210 |
} |
| 211 |
|
| 212 |
/* Allocate memory for the local and central extra fields. */ |
| 213 |
if( z->extra && z->ext != 0 ) { |
| 214 |
l_ef = (char *)realloc( z->extra, z->ext + EB_L_UT_SIZE ); |
| 215 |
} else { |
| 216 |
l_ef = (char *)malloc( EB_L_UT_SIZE ); |
| 217 |
z->ext = 0; |
| 218 |
} |
| 219 |
if( l_ef == NULL ) { |
| 220 |
return ZE_MEM; |
| 221 |
} |
| 222 |
z->extra = l_ef; |
| 223 |
l_ef += z->ext; |
| 224 |
|
| 225 |
if( z->cextra && z->cext != 0 ) { |
| 226 |
c_ef = (char *)realloc( z->cextra, z->cext + EB_C_UT_SIZE ); |
| 227 |
} else { |
| 228 |
c_ef = (char *)malloc( EB_C_UT_SIZE ); |
| 229 |
z->cext = 0; |
| 230 |
} |
| 231 |
if( c_ef == NULL ) { |
| 232 |
return ZE_MEM; |
| 233 |
} |
| 234 |
z->cextra = c_ef; |
| 235 |
c_ef += z->cext; |
| 236 |
|
| 237 |
/* Now add the local version of the field. */ |
| 238 |
*l_ef++ = 'U'; |
| 239 |
*l_ef++ = 'T'; |
| 240 |
*l_ef++ = (char)(EB_UT_LEN(2)); /* length of data in local EF */ |
| 241 |
*l_ef++ = (char)0; |
| 242 |
*l_ef++ = (char)(EB_UT_FL_MTIME | EB_UT_FL_CTIME); |
| 243 |
*l_ef++ = (char)(z_utim->mtime); |
| 244 |
*l_ef++ = (char)(z_utim->mtime >> 8); |
| 245 |
*l_ef++ = (char)(z_utim->mtime >> 16); |
| 246 |
*l_ef++ = (char)(z_utim->mtime >> 24); |
| 247 |
*l_ef++ = (char)(z_utim->ctime); |
| 248 |
*l_ef++ = (char)(z_utim->ctime >> 8); |
| 249 |
*l_ef++ = (char)(z_utim->ctime >> 16); |
| 250 |
*l_ef++ = (char)(z_utim->ctime >> 24); |
| 251 |
|
| 252 |
z->ext += EB_L_UT_SIZE; |
| 253 |
|
| 254 |
/* Now add the central version. */ |
| 255 |
memcpy(c_ef, l_ef-EB_L_UT_SIZE, EB_C_UT_SIZE); |
| 256 |
c_ef[EB_LEN] = (char)(EB_UT_LEN(1)); /* length of data in central EF */ |
| 257 |
|
| 258 |
z->cext += EB_C_UT_SIZE; |
| 259 |
|
| 260 |
return ZE_OK; |
| 261 |
} |
| 262 |
#endif /* USE_EF_UT_TIME */ |
| 263 |
|
| 264 |
|
| 265 |
/* |
| 266 |
* Build and add the old 'Johnny Lee' Mac extra field |
| 267 |
* All native datas are in Motorola (=big-endian) format |
| 268 |
*/ |
| 269 |
|
| 270 |
static int add_JLEE_ef( struct zlist far *z ) |
| 271 |
{ |
| 272 |
char *l_ef = NULL; |
| 273 |
char *c_ef = NULL; |
| 274 |
|
| 275 |
Assert_it(z, "add_JLEE_ef","") |
| 276 |
|
| 277 |
/* Check to make sure we've got enough room in the extra fields. */ |
| 278 |
if ( z->ext + EB_L_JLEE_SIZE > EF_SIZE_MAX || |
| 279 |
z->cext + EB_C_JLEE_SIZE > EF_SIZE_MAX ) { |
| 280 |
return ZE_MEM; |
| 281 |
} |
| 282 |
|
| 283 |
|
| 284 |
/* Allocate memory for the local extra fields. */ |
| 285 |
if ( z->extra && z->ext != 0 ) { |
| 286 |
l_ef = (char *)realloc( z->extra, z->ext + EB_L_JLEE_SIZE ); |
| 287 |
} else { |
| 288 |
l_ef = (char *)malloc( EB_L_JLEE_SIZE ); |
| 289 |
z->ext = 0; |
| 290 |
} |
| 291 |
if ( l_ef == NULL ) { |
| 292 |
return ZE_MEM; |
| 293 |
} |
| 294 |
z->extra = l_ef; |
| 295 |
l_ef += z->ext; |
| 296 |
|
| 297 |
/* Allocate memory for the central extra fields. */ |
| 298 |
if ( z->cextra && z->cext != 0 ) { |
| 299 |
c_ef = (char *)realloc( z->cextra, z->cext + EB_C_JLEE_SIZE ); |
| 300 |
} else { |
| 301 |
c_ef = (char *)malloc( EB_C_JLEE_SIZE ); |
| 302 |
z->cext = 0; |
| 303 |
} |
| 304 |
if ( c_ef == NULL ) { |
| 305 |
return ZE_MEM; |
| 306 |
} |
| 307 |
z->cextra = c_ef; |
| 308 |
c_ef += z->cext; |
| 309 |
|
| 310 |
|
| 311 |
if ( verbose ) { |
| 312 |
print_extra_info(); |
| 313 |
} |
| 314 |
|
| 315 |
|
| 316 |
/** |
| 317 |
** |
| 318 |
** Now add the local version of the field. |
| 319 |
**/ |
| 320 |
make_extrafield_JLEE(l_ef); |
| 321 |
z->ext += EB_L_JLEE_SIZE; |
| 322 |
|
| 323 |
|
| 324 |
/** |
| 325 |
** |
| 326 |
** Now add the central version of the field. |
| 327 |
** It's identical to the local header. I wonder why ?? |
| 328 |
* the first two fields are in Intel little-endian format */ |
| 329 |
make_extrafield_JLEE(c_ef); |
| 330 |
z->cext += EB_C_JLEE_SIZE; |
| 331 |
|
| 332 |
return ZE_OK; |
| 333 |
} |
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
/* |
| 338 |
* This is an implementation of Johnny Lee's extra field. |
| 339 |
* I never saw Johnny Lee's code. My code is based on the extra-field |
| 340 |
* definition mac (see latest appnote 1997-03-11) |
| 341 |
* and on some experiments with Johnny Lee's Zip-app version 1.0, 1992 |
| 342 |
* |
| 343 |
* Unfortunately I cannot agree with his extra-field layout. |
| 344 |
* - it wasted space |
| 345 |
* - and holds not all mac-specific information |
| 346 |
* |
| 347 |
* I coded this extra-field only for testing purposes. |
| 348 |
* I don't want support this extra-field. Please use my implementation. |
| 349 |
* |
| 350 |
* This is old implementation of Johnny Lee's extra field. |
| 351 |
* All native datas are in Motorola (=big-endian) format |
| 352 |
*/ |
| 353 |
|
| 354 |
static void make_extrafield_JLEE(char *ef) |
| 355 |
{ |
| 356 |
|
| 357 |
Assert_it(ef, "make_extrafield_JLEE","") |
| 358 |
|
| 359 |
if (MacZip.isMacStatValid == false) |
| 360 |
{ |
| 361 |
fprintf(stderr,"Internal Logic Error: [%d/%s] MacStat is out of sync !", |
| 362 |
__LINE__,__FILE__); |
| 363 |
exit(-1); |
| 364 |
} |
| 365 |
|
| 366 |
|
| 367 |
/* the first two fields are in Intel little-endian format */ |
| 368 |
*ef++ = 0xC8; /* tag for this extra block */ |
| 369 |
*ef++ = 0x07; |
| 370 |
|
| 371 |
*ef++ = (char)(EB_L_JLEE_LEN); /* total data size this block */ |
| 372 |
*ef++ = (char)((EB_L_JLEE_LEN) >> 8); |
| 373 |
|
| 374 |
/* the following fields are in motorola big-endian format */ |
| 375 |
*ef++ = 'J'; /* extra field signature: 4 Bytes */ |
| 376 |
*ef++ = 'L'; /* the old style extra field */ |
| 377 |
*ef++ = 'E'; |
| 378 |
*ef++ = 'E'; |
| 379 |
|
| 380 |
/* Start Macintosh Finder FInfo structure 16 Bytes overall */ |
| 381 |
/* Type: 4 Bytes */ |
| 382 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType >> 24); |
| 383 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType >> 16); |
| 384 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType >> 8); |
| 385 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType); |
| 386 |
|
| 387 |
/* Creator: 4 Bytes */ |
| 388 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator >> 24); |
| 389 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator >> 16); |
| 390 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator >> 8); |
| 391 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator); |
| 392 |
|
| 393 |
/* file Finder Flags: 2 Bytes */ |
| 394 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdFlags >> 8); |
| 395 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdFlags); |
| 396 |
|
| 397 |
/* Finders Icon position of a file*/ |
| 398 |
/* V/Y-Position: 2 Bytes */ |
| 399 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdLocation.v >> 8); |
| 400 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdLocation.v); |
| 401 |
/* H/X-Position: 2 Bytes */ |
| 402 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdLocation.h >> 8); |
| 403 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdLocation.h); |
| 404 |
|
| 405 |
/* fdFldr Folder containing file 2 Bytes */ |
| 406 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdFldr >> 8); |
| 407 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdFldr); |
| 408 |
/* End Macintosh Finder FInfo structure */ |
| 409 |
|
| 410 |
|
| 411 |
/* Creation-time 4 Bytes */ |
| 412 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlCrDat >> 24); |
| 413 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlCrDat >> 16); |
| 414 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlCrDat >> 8); |
| 415 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlCrDat); |
| 416 |
|
| 417 |
/* Modification-time 4 Bytes */ |
| 418 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlMdDat >> 24); |
| 419 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlMdDat >> 16); |
| 420 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlMdDat >> 8); |
| 421 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlMdDat); |
| 422 |
|
| 423 |
/* info Bits 4 Bytes */ |
| 424 |
*ef++ = 0x00; |
| 425 |
*ef++ = 0x00; |
| 426 |
*ef++ = 0x00; |
| 427 |
if (MacZip.DataForkOnly) |
| 428 |
{ /* don't convert filename for unzipping */ |
| 429 |
/* 0x01 = data-fork; 0x00 = resource-fork */ |
| 430 |
*ef++ = (char) (MacZip.CurrentFork == DataFork) | 2; |
| 431 |
} |
| 432 |
else |
| 433 |
{ |
| 434 |
*ef++ = (char) (MacZip.CurrentFork == DataFork); |
| 435 |
} |
| 436 |
|
| 437 |
/* file's location folder ID 4 Bytes */ |
| 438 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlParID >> 24); |
| 439 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlParID >> 16); |
| 440 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlParID >> 8); |
| 441 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlParID); |
| 442 |
/* ============ */ |
| 443 |
/* 40 Bytes */ |
| 444 |
} |
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
/* |
| 449 |
* Build and add the new mac extra field |
| 450 |
* All native data are stored in Intel (=little-endian) format |
| 451 |
*/ |
| 452 |
|
| 453 |
static int add_MAC3_ef( struct zlist far *z ) |
| 454 |
{ |
| 455 |
char *l_ef = NULL; |
| 456 |
char *c_ef = NULL; |
| 457 |
char *attrbuff = NULL; |
| 458 |
off_t attrsize = (EB_L_MAC3_FINFO_LEN + EB_MAX_OF_VARDATA); |
| 459 |
char *compbuff = NULL; |
| 460 |
unsigned compsize = 0; |
| 461 |
unsigned m3_compr; |
| 462 |
Boolean compress_data = true; |
| 463 |
|
| 464 |
Assert_it(z, "add_MAC3_ef","") |
| 465 |
|
| 466 |
UserStop(); /* do event handling and let the user stop */ |
| 467 |
|
| 468 |
if( verbose ) { |
| 469 |
print_extra_info(); |
| 470 |
} |
| 471 |
|
| 472 |
/* allocate temporary buffer to collect the Mac extra field info */ |
| 473 |
attrbuff = (char *)malloc( (size_t)attrsize ); |
| 474 |
if( attrbuff == NULL ) { |
| 475 |
return ZE_MEM; |
| 476 |
} |
| 477 |
|
| 478 |
/* fill the attribute buffer, to get its (uncompressed) size */ |
| 479 |
attrsize = make_extrafield_MAC3(attrbuff); |
| 480 |
|
| 481 |
if (compress_data && |
| 482 |
((compbuff = (char *)malloc((size_t)attrsize + MEMCOMPRESS_OVERHEAD)) |
| 483 |
!= NULL)) |
| 484 |
{ |
| 485 |
/* Try compressing the data */ |
| 486 |
compsize = memcompress( compbuff, |
| 487 |
(size_t)attrsize + MEMCOMPRESS_OVERHEAD, |
| 488 |
attrbuff, |
| 489 |
(size_t)attrsize ); |
| 490 |
#ifdef MAC_EXTRAFLD_UNCMPR |
| 491 |
compsize = attrsize; |
| 492 |
#endif |
| 493 |
} |
| 494 |
else |
| 495 |
{ |
| 496 |
compsize = attrsize; |
| 497 |
} |
| 498 |
|
| 499 |
if ((compsize) < attrsize) { |
| 500 |
/* compression gained some space ... */ |
| 501 |
free(attrbuff); /* no longer needed ... */ |
| 502 |
m3_compr = EB_M3_FL_COMPRESS; |
| 503 |
} else { |
| 504 |
/* compression does not help, store data in uncompressed mode */ |
| 505 |
if (compbuff != NULL) free(compbuff); |
| 506 |
compbuff = attrbuff; |
| 507 |
compsize = attrsize; |
| 508 |
m3_compr = EB_M3_FL_UNCMPR; |
| 509 |
} |
| 510 |
|
| 511 |
/* Check to make sure we've got enough room in the extra fields. */ |
| 512 |
if( z->ext + (EB_L_MAC3_SIZE + compsize) > EF_SIZE_MAX || |
| 513 |
z->cext + EB_C_MAC3_SIZE > EF_SIZE_MAX ) { |
| 514 |
if (compbuff != NULL) free(compbuff); |
| 515 |
return ZE_MEM; |
| 516 |
} |
| 517 |
|
| 518 |
/* Allocate memory for the local extra fields. */ |
| 519 |
if( z->extra && z->ext != 0 ) { |
| 520 |
l_ef = (char *)realloc( z->extra, z->ext + |
| 521 |
EB_L_MAC3_SIZE + compsize); |
| 522 |
} else { |
| 523 |
l_ef = (char *)malloc( EB_L_MAC3_SIZE + compsize); |
| 524 |
z->ext = 0; |
| 525 |
} |
| 526 |
if( l_ef == NULL ) { |
| 527 |
return ZE_MEM; |
| 528 |
} |
| 529 |
z->extra = l_ef; |
| 530 |
l_ef += z->ext; |
| 531 |
|
| 532 |
/* Allocate memory for the central extra fields. */ |
| 533 |
if( z->cextra && z->cext != 0 ) { |
| 534 |
c_ef = (char *)realloc( z->cextra, z->cext + EB_C_MAC3_SIZE); |
| 535 |
} else { |
| 536 |
c_ef = (char *)malloc( EB_C_MAC3_SIZE ); |
| 537 |
z->cext = 0; |
| 538 |
} |
| 539 |
if( c_ef == NULL ) { |
| 540 |
return ZE_MEM; |
| 541 |
} |
| 542 |
z->cextra = c_ef; |
| 543 |
c_ef += z->cext; |
| 544 |
|
| 545 |
/** |
| 546 |
** Now add the local version of the field. |
| 547 |
**/ |
| 548 |
l_ef = make_EF_Head_MAC3(l_ef, compsize, (ulg)attrsize, m3_compr); |
| 549 |
memcpy(l_ef, compbuff, (size_t)compsize); |
| 550 |
l_ef += compsize; |
| 551 |
z->ext += EB_L_MAC3_SIZE + compsize; |
| 552 |
free(compbuff); |
| 553 |
/* And the central version. */ |
| 554 |
c_ef = make_EF_Head_MAC3(c_ef, 0, (ulg)attrsize, m3_compr); |
| 555 |
z->cext += EB_C_MAC3_SIZE; |
| 556 |
|
| 557 |
return ZE_OK; |
| 558 |
} |
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
/* |
| 564 |
* Build the new mac local extra field header. |
| 565 |
* It's identical with the central extra field. |
| 566 |
* All native data are in Intel (=little-endian) format |
| 567 |
*/ |
| 568 |
static char *make_EF_Head_MAC3(char *ef, unsigned compsize, ulg attrsize, |
| 569 |
unsigned flag) |
| 570 |
{ |
| 571 |
unsigned info_flag = flag; |
| 572 |
|
| 573 |
Assert_it(ef, "make_EF_Head_MAC3","") |
| 574 |
|
| 575 |
/* the first four fields are in Intel little-endian format */ |
| 576 |
*ef++ = 'M'; /* tag for this extra block 2 Bytes */ |
| 577 |
*ef++ = '3'; |
| 578 |
|
| 579 |
/* total data size this block 2 Bytes */ |
| 580 |
*ef++ = (char) (EB_MAC3_HLEN + compsize); |
| 581 |
*ef++ = (char)((EB_MAC3_HLEN + compsize) >> 8); |
| 582 |
|
| 583 |
*ef++ = (char)(attrsize); |
| 584 |
*ef++ = (char)(attrsize >> 8); |
| 585 |
*ef++ = (char)(attrsize >> 16); |
| 586 |
*ef++ = (char)(attrsize >> 24); |
| 587 |
|
| 588 |
/* info Bits (flags) 2 Bytes */ |
| 589 |
|
| 590 |
if (MacZip.DataForkOnly) info_flag |= (EB_M3_FL_DATFRK | |
| 591 |
EB_M3_FL_NOCHANGE); |
| 592 |
if (MacZip.CurrentFork == DataFork) info_flag |= EB_M3_FL_DATFRK; |
| 593 |
if (!MacZip.HaveGMToffset) info_flag |= EB_M3_FL_NOUTC; |
| 594 |
|
| 595 |
*ef++ = (char)info_flag; |
| 596 |
*ef++ = (char)0x00; /* reserved at the moment */ |
| 597 |
|
| 598 |
/* Note: Apple defined File-Type/-Creator as OSType ( =unsigned long, |
| 599 |
see Universal Headers 3.1). However, File-Type/-Creator are a |
| 600 |
unique four-character sequence. Therefore the byteorder of the |
| 601 |
File-Type/-Creator are NOT changed. The native format is used. */ |
| 602 |
|
| 603 |
/* Type: 4 Bytes */ |
| 604 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType >> 24); |
| 605 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType >> 16); |
| 606 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType >> 8); |
| 607 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType); |
| 608 |
|
| 609 |
/* Creator: 4 Bytes */ |
| 610 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator >> 24); |
| 611 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator >> 16); |
| 612 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator >> 8); |
| 613 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator); |
| 614 |
|
| 615 |
return ef; |
| 616 |
} |
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
/* |
| 623 |
* Build the new mac local extra field header. |
| 624 |
* All native data are in Intel (=little-endian) format |
| 625 |
*/ |
| 626 |
unsigned make_extrafield_MAC3(char *ef) |
| 627 |
{ |
| 628 |
char *ef_m3_begin = ef; |
| 629 |
char *temp_Pathname; |
| 630 |
char tmp_buffer[NAME_MAX]; |
| 631 |
unsigned char comment[257]; |
| 632 |
unsigned short FLength = 0; |
| 633 |
unsigned short CLength = 0; |
| 634 |
short tempFork; |
| 635 |
OSErr err; |
| 636 |
|
| 637 |
Assert_it(ef, "make_extrafield_MAC3","") |
| 638 |
|
| 639 |
if (MacZip.isMacStatValid == false) |
| 640 |
{ |
| 641 |
fprintf(stderr, |
| 642 |
"Internal Logic Error: [%d/%s] MacStat is out of sync !", |
| 643 |
__LINE__, __FILE__); |
| 644 |
exit(-1); |
| 645 |
} |
| 646 |
|
| 647 |
/* Start Macintosh Finder FInfo structure except Type/Creator |
| 648 |
(see make_EF_Head_MAC3()) 8 Bytes overall */ |
| 649 |
|
| 650 |
/* file Finder Flags: 2 Bytes */ |
| 651 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdFlags); |
| 652 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdFlags >> 8); |
| 653 |
|
| 654 |
/* Finders Icon position of a file*/ |
| 655 |
/* V/Y-Position: 2 Bytes */ |
| 656 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdLocation.v); |
| 657 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdLocation.v >> 8); |
| 658 |
|
| 659 |
/* H/X-Position: 2 Bytes */ |
| 660 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdLocation.h); |
| 661 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdLocation.h >> 8); |
| 662 |
|
| 663 |
/* fdFldr Folder containing file 2 Bytes */ |
| 664 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdFldr); |
| 665 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdFldr >> 8); |
| 666 |
|
| 667 |
/* End Macintosh Finder FInfo structure */ |
| 668 |
|
| 669 |
/* 8 Bytes so far ... */ |
| 670 |
|
| 671 |
/* Start Macintosh Finder FXInfo structure 16 Bytes overall */ |
| 672 |
/* Icon ID: 2 Bytes */ |
| 673 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdIconID); |
| 674 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdIconID >> 8); |
| 675 |
|
| 676 |
/* unused: 6 Bytes */ |
| 677 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdUnused[0]); |
| 678 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdUnused[0] >> 8); |
| 679 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdUnused[1]); |
| 680 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdUnused[1] >> 8); |
| 681 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdUnused[2]); |
| 682 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdUnused[2] >> 8); |
| 683 |
/* Script flag: 1 Byte */ |
| 684 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdScript); |
| 685 |
/* More flag bits: 1 Byte */ |
| 686 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdXFlags); |
| 687 |
/* Comment ID 2 Bytes */ |
| 688 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdComment); |
| 689 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdComment >> 8); |
| 690 |
|
| 691 |
/* Home Dir ID: 4 Bytes */ |
| 692 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdPutAway); |
| 693 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdPutAway >> 8); |
| 694 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdPutAway >> 16); |
| 695 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlXFndrInfo.fdPutAway >> 24); |
| 696 |
/* End Macintosh Finder FXInfo structure */ |
| 697 |
|
| 698 |
/* 24 Bytes so far ... */ |
| 699 |
|
| 700 |
/* file version number 1 Byte */ |
| 701 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFVersNum); |
| 702 |
|
| 703 |
/* directory access rights 1 Byte */ |
| 704 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioACUser); |
| 705 |
|
| 706 |
/* Creation-time 4 Bytes */ |
| 707 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlCrDat); |
| 708 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlCrDat >> 8); |
| 709 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlCrDat >> 16); |
| 710 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlCrDat >> 24); |
| 711 |
/* Modification-time 4 Bytes */ |
| 712 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlMdDat); |
| 713 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlMdDat >> 8); |
| 714 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlMdDat >> 16); |
| 715 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlMdDat >> 24); |
| 716 |
/* Backup-time 4 Bytes */ |
| 717 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlBkDat); |
| 718 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlBkDat >> 8); |
| 719 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlBkDat >> 16); |
| 720 |
*ef++ = (char)(MacZip.fpb.hFileInfo.ioFlBkDat >> 24); |
| 721 |
|
| 722 |
/* 38 Bytes so far ... */ |
| 723 |
#ifdef USE_EF_UT_TIME |
| 724 |
if (MacZip.HaveGMToffset) { |
| 725 |
/* GMT-Offset times 12 Bytes */ |
| 726 |
*ef++ = (char)(MacZip.Cr_UTCoffs); |
| 727 |
*ef++ = (char)(MacZip.Cr_UTCoffs >> 8); |
| 728 |
*ef++ = (char)(MacZip.Cr_UTCoffs >> 16); |
| 729 |
*ef++ = (char)(MacZip.Cr_UTCoffs >> 24); |
| 730 |
*ef++ = (char)(MacZip.Md_UTCoffs); |
| 731 |
*ef++ = (char)(MacZip.Md_UTCoffs >> 8); |
| 732 |
*ef++ = (char)(MacZip.Md_UTCoffs >> 16); |
| 733 |
*ef++ = (char)(MacZip.Md_UTCoffs >> 24); |
| 734 |
*ef++ = (char)(MacZip.Bk_UTCoffs); |
| 735 |
*ef++ = (char)(MacZip.Bk_UTCoffs >> 8); |
| 736 |
*ef++ = (char)(MacZip.Bk_UTCoffs >> 16); |
| 737 |
*ef++ = (char)(MacZip.Bk_UTCoffs >> 24); |
| 738 |
} |
| 739 |
/* 50 Bytes so far ... */ |
| 740 |
#endif |
| 741 |
|
| 742 |
/* Text Encoding Base (charset) 2 Bytes */ |
| 743 |
*ef++ = (char)(MacZip.CurrTextEncodingBase); |
| 744 |
*ef++ = (char)(MacZip.CurrTextEncodingBase >> 8); |
| 745 |
/* 52 Bytes so far ... */ |
| 746 |
|
| 747 |
/* MacZip.CurrentFork will be changed, so we have to save it */ |
| 748 |
tempFork = MacZip.CurrentFork; |
| 749 |
if (!MacZip.StoreFullPath) { |
| 750 |
temp_Pathname = StripPartialDir(tmp_buffer, MacZip.SearchDir, |
| 751 |
MacZip.FullPath); |
| 752 |
} else { |
| 753 |
temp_Pathname = MacZip.FullPath; |
| 754 |
} |
| 755 |
MacZip.CurrentFork = tempFork; |
| 756 |
|
| 757 |
FLength = strlen(temp_Pathname) + 1; |
| 758 |
memcpy( ef, temp_Pathname, (size_t)FLength ); |
| 759 |
ef += FLength; /* make room for the string - variable length */ |
| 760 |
|
| 761 |
err = FSpLocationFromFullPath(strlen(MacZip.FullPath), MacZip.FullPath, |
| 762 |
&MacZip.fileSpec); |
| 763 |
printerr("FSpLocationFromFullPath:", err, err, |
| 764 |
__LINE__, __FILE__, tmp_buffer); |
| 765 |
|
| 766 |
err = FSpDTGetComment(&MacZip.fileSpec, comment); |
| 767 |
printerr("FSpDTGetComment:", (err != -5012) && (err != 0), err, |
| 768 |
__LINE__, __FILE__, ""); |
| 769 |
PToCCpy(comment,tmp_buffer); |
| 770 |
|
| 771 |
CLength = strlen(tmp_buffer) + 1; |
| 772 |
memcpy( ef, tmp_buffer, (size_t)CLength ); |
| 773 |
ef += CLength; /* make room for the string - variable length */ |
| 774 |
|
| 775 |
if (verbose) printf("\n comment: [%s]", tmp_buffer); |
| 776 |
|
| 777 |
return (unsigned)(ef - ef_m3_begin); |
| 778 |
} |
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
/* |
| 786 |
* Print all native data of the new mac local extra field. |
| 787 |
* It's for debugging purposes and disabled by default. |
| 788 |
*/ |
| 789 |
|
| 790 |
static void PrintFileInfo(void) |
| 791 |
{ |
| 792 |
DateTimeRec MacTime; |
| 793 |
|
| 794 |
printf("\n\n---------------------------------------------"\ |
| 795 |
"----------------------------------"); |
| 796 |
printf("\n FullPath Name = [%s]", MacZip.FullPath); |
| 797 |
printf("\n File Attributes = %s 0x%x %d", |
| 798 |
sBit2Str(MacZip.fpb.hFileInfo.ioFlAttrib), |
| 799 |
MacZip.fpb.hFileInfo.ioFlAttrib, |
| 800 |
MacZip.fpb.hFileInfo.ioFlAttrib); |
| 801 |
printf("\n Enclosing Folder ID# = 0x%x %d", |
| 802 |
MacZip.fpb.hFileInfo.ioFlParID, |
| 803 |
MacZip.fpb.hFileInfo.ioFlParID); |
| 804 |
|
| 805 |
if (!MacZip.isDirectory) |
| 806 |
{ |
| 807 |
printf("\n File Type = [%c%c%c%c] 0x%lx", |
| 808 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType >> 24, |
| 809 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType >> 16, |
| 810 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType >> 8, |
| 811 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType, |
| 812 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType); |
| 813 |
|
| 814 |
printf("\n File Creator = [%c%c%c%c] 0x%lx", |
| 815 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator >> 24, |
| 816 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator >> 16, |
| 817 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator >> 8, |
| 818 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator, |
| 819 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator); |
| 820 |
|
| 821 |
printf("\n Data Fork :" ); |
| 822 |
printf("\n Actual (Logical) Length = %d 0x%x ", |
| 823 |
MacZip.fpb.hFileInfo.ioFlLgLen, |
| 824 |
MacZip.fpb.hFileInfo.ioFlLgLen); |
| 825 |
printf("\n Allocated (Physical) Length = %d 0x%x", |
| 826 |
MacZip.fpb.hFileInfo.ioFlPyLen, |
| 827 |
MacZip.fpb.hFileInfo.ioFlPyLen); |
| 828 |
printf("\n Resource Fork :" ); |
| 829 |
printf("\n Actual (Logical) Length = %d 0x%x", |
| 830 |
MacZip.fpb.hFileInfo.ioFlRLgLen, |
| 831 |
MacZip.fpb.hFileInfo.ioFlRLgLen ); |
| 832 |
printf("\n Allocated (Physical) Length = %d 0x%x", |
| 833 |
MacZip.fpb.hFileInfo.ioFlRPyLen, |
| 834 |
MacZip.fpb.hFileInfo.ioFlRPyLen ); |
| 835 |
} |
| 836 |
|
| 837 |
printf("\n Dates : "); |
| 838 |
|
| 839 |
SecondsToDate (MacZip.CreatDate, &MacTime); |
| 840 |
printf("\n Created = %4d/%2d/%2d %2d:%2d:%2d ", |
| 841 |
MacTime.year, |
| 842 |
MacTime.month, |
| 843 |
MacTime.day, |
| 844 |
MacTime.hour, |
| 845 |
MacTime.minute, |
| 846 |
MacTime.second); |
| 847 |
|
| 848 |
SecondsToDate (MacZip.BackDate, &MacTime); |
| 849 |
printf("\n Backup = %4d/%2d/%2d %2d:%2d:%2d ", |
| 850 |
MacTime.year, |
| 851 |
MacTime.month, |
| 852 |
MacTime.day, |
| 853 |
MacTime.hour, |
| 854 |
MacTime.minute, |
| 855 |
MacTime.second); |
| 856 |
|
| 857 |
SecondsToDate (MacZip.ModDate, &MacTime); |
| 858 |
printf("\n Modified = %4d/%2d/%2d %2d:%2d:%2d ", |
| 859 |
MacTime.year, |
| 860 |
MacTime.month, |
| 861 |
MacTime.day, |
| 862 |
MacTime.hour, |
| 863 |
MacTime.minute, |
| 864 |
MacTime.second); |
| 865 |
|
| 866 |
if (!MacZip.isDirectory) |
| 867 |
{ |
| 868 |
printf("\n Finder Flags : %s 0x%x %d", |
| 869 |
sBit2Str(MacZip.fpb.hFileInfo.ioFlFndrInfo.fdFlags), |
| 870 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdFlags, |
| 871 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdFlags); |
| 872 |
printf("\n Finder Icon Position = X: %d 0x%x ", |
| 873 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdLocation.h, |
| 874 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdLocation.h); |
| 875 |
printf("\n Y: %d 0x%x ", |
| 876 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdLocation.v, |
| 877 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdLocation.v); |
| 878 |
} |
| 879 |
else |
| 880 |
{ |
| 881 |
printf("\n Finder Flags : %s 0x%x %d", |
| 882 |
sBit2Str(MacZip.fpb.dirInfo.ioDrUsrWds.frFlags), |
| 883 |
MacZip.fpb.dirInfo.ioDrUsrWds.frFlags, |
| 884 |
MacZip.fpb.dirInfo.ioDrUsrWds.frFlags); |
| 885 |
printf("\n Finder Icon Position = X: %d 0x%x ", |
| 886 |
MacZip.fpb.dirInfo.ioDrUsrWds.frLocation.h, |
| 887 |
MacZip.fpb.dirInfo.ioDrUsrWds.frLocation.h); |
| 888 |
printf("\n Y: %d 0x%x ", |
| 889 |
MacZip.fpb.dirInfo.ioDrUsrWds.frLocation.v, |
| 890 |
MacZip.fpb.dirInfo.ioDrUsrWds.frLocation.v); |
| 891 |
} |
| 892 |
|
| 893 |
printf("\n----------------------------------------------------"\ |
| 894 |
"---------------------------\n"); |
| 895 |
} |
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
/* |
| 900 |
* If the switch '-v' is used, print some more info. |
| 901 |
*/ |
| 902 |
|
| 903 |
static void print_extra_info(void) |
| 904 |
{ |
| 905 |
char Fork[20]; |
| 906 |
|
| 907 |
if (MacZip.CurrentFork == DataFork) sstrcpy(Fork,"<DataFork>"); |
| 908 |
else sstrcpy(Fork,"<ResourceFork>"); |
| 909 |
|
| 910 |
printf("\n%16s [%c%c%c%c] [%c%c%c%c]",Fork, |
| 911 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType >> 24, |
| 912 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType >> 16, |
| 913 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType >> 8, |
| 914 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdType, |
| 915 |
|
| 916 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator >> 24, |
| 917 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator >> 16, |
| 918 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator >> 8, |
| 919 |
MacZip.fpb.hFileInfo.ioFlFndrInfo.fdCreator); |
| 920 |
} |