home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
online
/
source
/
c
/
compilers
/
Tickle-4.0.sit.hqx
/
Tickle-4.0
/
src
/
mbinfo.c
< prev
next >
Wrap
Text File
|
1993-11-18
|
3KB
|
138 lines
#pragma segment MACBIN
/*
** This source code was written by Tim Endres
** Email: time@ice.com.
** USMail: 8840 Main Street, Whitmore Lake, MI 48189
**
** Some portions of this application utilize sources
** that are copyrighted by ICE Engineering, Inc., and
** ICE Engineering retains all rights to those sources.
**
** Neither ICE Engineering, Inc., nor Tim Endres,
** warrants this source code for any reason, and neither
** party assumes any responsbility for the use of these
** sources, libraries, or applications. The user of these
** sources and binaries assumes all responsbilities for
** any resulting consequences.
*/
#include <types.h>
#include <standardfile.h>
#include <stdio.h>
typedef struct { /* note everything is char to avoid alignment padding */
unsigned char zero1;
unsigned char nlen;
unsigned char name[63];
unsigned char type[4];
unsigned char creator[4];
unsigned char flags;
unsigned char zero2;
unsigned char location[6];
unsigned char protected;
unsigned char zero3;
unsigned char dflen[4];
unsigned char rflen[4];
unsigned char cdate[4];
unsigned char mdate[4];
} F_BLK, *F_BLK_PTR;
#define MAC_BINARY_HDR_SIZE 128
#define MAC_UNIX_TIME_DIFF 0x7c25b080
#define MAC_TO_UNIX_TIME(time) ((time) - MAC_UNIX_TIME_DIFF)
#define UNIX_TO_MAC_TIME(time) ((time) + MAC_UNIX_TIME_DIFF)
#ifdef TCLAPPL
SF_mbinfo()
{
Point mypoint;
SFReply myreply;
SFTypeList mytypes;
FILE *mbfile;
extern int errno;
mypoint.h = mypoint.v = 75;
mytypes[0] = 'MacB';
MyGetFile(mypoint, "\p", NULL, (CheckOption()?-1:1), mytypes, NULL, &myreply);
if (myreply.good) {
p2cstr(myreply.fName);
SetVol(NULL, myreply.vRefNum);
mbfile = fopen(myreply.fName, "r");
if (mbfile != NULL) {
mbinfo(mbfile);
fclose(mbfile);
}
else
Feedback("Error #%d opening '%s'", errno, myreply.fName);
}
}
#endif /* TCLAPPL */
mbinfo(mbfile)
FILE *mbfile;
{
F_BLK_PTR fptr;
char hdrbuffer[MAC_BINARY_HDR_SIZE];
int retcode;
long dlength = 0;
long rlength = 0;
long cdate = 0;
long mdate = 0;
fptr = (F_BLK_PTR) &hdrbuffer[0];
retcode = fread(hdrbuffer, 1, MAC_BINARY_HDR_SIZE, mbfile);
if (retcode != MAC_BINARY_HDR_SIZE) {
Feedback("Warning - reading header bytes, needed %d, got %d.\n",
MAC_BINARY_HDR_SIZE, retcode);
}
dlength = 0;
dlength += fptr->dflen[0]; dlength <<= 8;
dlength += fptr->dflen[1]; dlength <<= 8;
dlength += fptr->dflen[2]; dlength <<= 8;
dlength += fptr->dflen[3];
rlength = 0;
rlength += fptr->rflen[0]; rlength <<= 8;
rlength += fptr->rflen[1]; rlength <<= 8;
rlength += fptr->rflen[2]; rlength <<= 8;
rlength += fptr->rflen[3];
cdate = 0;
cdate += fptr->cdate[0]; cdate <<= 8;
cdate += fptr->cdate[1]; cdate <<= 8;
cdate += fptr->cdate[2]; cdate <<= 8;
cdate += fptr->cdate[3];
mdate = 0;
mdate += fptr->mdate[0]; mdate <<= 8;
mdate += fptr->mdate[1]; mdate <<= 8;
mdate += fptr->mdate[2]; mdate <<= 8;
mdate += fptr->mdate[3];
Feedback("MacBinary file '%*.*s'",
fptr->nlen, fptr->nlen, fptr->name);
Feedback("File Type '%4.4s'", fptr->type);
Feedback("File Creator '%4.4s'", fptr->creator);
Feedback("Data Fork %d bytes.", dlength);
Feedback("Rsrc Fork %d bytes.", rlength);
/*cdate = MAC_TO_UNIX_TIME(cdate);*/
Feedback("Creation Date [%d] %s", cdate, ctime(&cdate));
/*mdate = MAC_TO_UNIX_TIME(mdate);*/
Feedback("Modification Date [%d] %s", mdate, ctime(&mdate));
}