home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / util / unix / unsea10.sha < prev    next >
Internet Message Format  |  1992-11-05  |  46KB

  1. Received: from mozart.ms.uky.edu by terminator.cc.umich.edu (5.65/1123-1.0)
  2.     id AA21965; Sun, 9 Aug 92 17:29:17 -0400
  3. Received: from s.ms.uky.edu by mozart.ms.uky.edu id aa29156; 9 Aug 92 21:26 GMT
  4. From: "David W. Rankin Jr." <rankin@ms.uky.edu>
  5. Date: Sun, 9 Aug 1992 17:26:16 EDT
  6. X-Mailer: Mail User's Shell (7.1.2 7/11/90)
  7. To: macgifts@terminator.cc.umich.edu
  8. Subject: Unsea 1.0 is here
  9. Message-Id:  <9208092126.aa06404@s.s.ms.uky.edu>
  10.  
  11. This letter marks the formal release of unsea 1.0. Unsea is a mainframe-
  12. level ANSI C program that removes the self-expanding code from MacBinary
  13. encoded StuffIt(TM) or Compact Pro(TM) files.
  14. Since unsea is ANSI C, you'll have to use an ANSI C compiler (like gcc)
  15. to compile it. (The reason for this is that the only C referecnce book
  16. is the 2nd edition of the K&R book, so I simply couldn't write it
  17. as K&R C code.)
  18.  
  19. To put it on your system, get the shar file(see below for where) and
  20. delete anything above the line "#!/bin/sh". Then unarchive it, using
  21. "sh <filename>" for UNIX machines or your local shar decoder for other
  22. machines. Then follow the instructions in "unsea.txt" and "Makefile"
  23. to compile the program.
  24.  
  25. The newest version of unsea will always be available on f.ms.uky.edu,
  26. in the /pub/mac/unix directory, as well as anyone who is on the MacGifts
  27. list that mac.archive.umich.edu runs.
  28.  
  29. Feel free to send any questions you have about unsea to me at
  30. rankin=irc@ms.uky.edu, rankin=irc@ukma.BITNET or rankin=irc@ukma.UUCP.
  31.  
  32. ---------------CUT HERE---------------------
  33. #! /bin/sh
  34. : This is a shell archive, meaning:
  35. : 1. Remove everything above the '#! /bin/sh' line.
  36. : 2. Save the resulting text in a file.
  37. : 3. Execute the file with /bin/sh '(not csh)' to create the files:
  38. :    'Makefile'
  39. :    'convert.c'
  40. :    'file.c'
  41. :    'macbin.c'
  42. :    'unsea.c'
  43. :    'unsea.h'
  44. :    'unsea.testers'
  45. :    'unsea.txt'
  46. :    'version.c'
  47. : This archive created: 'Sun Aug  9 15:01:22 1992
  48. '
  49. export PATH; PATH=/bin:$PATH
  50. if test -f 'Makefile'
  51. then
  52.     echo shar: will not over-write existing file "'Makefile'"
  53. else
  54. sed 's/^X//'  >'Makefile' <<'SHAR_EOF'
  55. X
  56. X# Makefile for the unsea program
  57. X#     Copyright 1992 David W. Rankin, Jr.
  58. X#
  59. X# See unsea.txt for all copyright details
  60. X
  61. X# Command line syntax:
  62. X#       make [option]
  63. X
  64. X# Options:
  65. X#
  66. X#       unsea
  67. X#         This option is the one you should pick for actually compiling 
  68. X#         unsea. It uses prepare (see below) to compile the code as needed.
  69. X#
  70. X#       prepare
  71. X#         This option, mainly for the use of the makefile itself, creates
  72. X#         the object code for the unsea options.
  73. X#
  74. X#       clean
  75. X#         Removes the file "unsea" and all objects from the directory.
  76. X
  77. X
  78. X# Makefile variables:
  79. X
  80. X# CC is the variable holding your compiler's name. The values used by a couple
  81. X# of the systems I know about are here, as well as the default value, GNU's
  82. X# gcc compiler. If you require a different value here, be sure to include any
  83. X# flags required to make your compiler ANSI compliant, if necessary.
  84. X
  85. X# On NeXTs and AIX, both come with ANSI compatable "cc" compilers standard.
  86. X# Therefore, they are fine for unsea, although for AIX I still recommend gcc
  87. X# if you have it. (NeXTs actually use gcc as their standard compiler, so you
  88. X# don't need to get gcc for them except to upgrade.)
  89. X
  90. X#CC=cc
  91. X
  92. X# For DYNIX (Sequent), A/UX (Apple UNIX), and SunOS, all the standard "cc"
  93. X# compilers I've seen are NOT ANSI compliant, so you will have to use gcc or
  94. X# another ANSI C compiler. I'll default here to "gcc".
  95. X# I think this is also true for ULTRIX (VAX) and HP-UX, but I wasn't able
  96. X# to check it out before releasing this version. I have no idea about any
  97. X# other OSes, so I have to assume they need gcc as well.
  98. XCC = gcc
  99. X
  100. X# CFLAGS specifies whether the compiler should allow for debugging
  101. X# (-g) or optimization of the code (-O). -O is recommended.
  102. X# Any other flags your compiler likes or needs should go here.
  103. X
  104. XCFLAGS = -O
  105. X
  106. X# Some compilers require specific libraries to be added during the program
  107. X# generation. LIBS should be used for this purpose, as well as any flags
  108. X# needed during the linking part only. Here are some choices that I know 
  109. X# work on the machines I've seen so far. (Feel free to change this, I can't
  110. X# know what libraries you actually have.)
  111. X
  112. X#For DYNIX (Sequents):
  113. X#LIBS= -lseq
  114. X
  115. X# For everyone else...
  116. XLIBS=
  117. X
  118. X#                *STOP*
  119. X# You should not change anything below here.
  120. X
  121. XSOURCES = unsea.c convert.c version.c file.c macbin.c
  122. X
  123. XOBJECTS = unsea.o convert.o version.o file.o macbin.o
  124. X
  125. Xunsea:
  126. X    @make prepare
  127. X    @$(CC) $(CFLAGS) -o unsea $(LIBS) $(OBJECTS)
  128. X
  129. X
  130. Xprepare:
  131. X    @$(CC) -c $(CFLAGS) $(SOURCES)
  132. X
  133. Xclean:
  134. X    rm -fr unsea $(OBJECTS)
  135. X
  136. SHAR_EOF
  137. fi # end of overwriting check
  138. if test -f 'convert.c'
  139. then
  140.     echo shar: will not over-write existing file "'convert.c'"
  141. else
  142. sed 's/^X//'  >'convert.c' <<'SHAR_EOF'
  143. X/* convert.c - Part of the unsea program.
  144. X *   Copyright 1992 by David W. Rankin, Jr.
  145. X * 
  146. X * See "unsea.txt" for full copyright information applying 
  147. X * to all text in this package. 
  148. X *
  149. X *
  150. X * This file contains the source code for the converters and interpreters
  151. X * within unsea, including the CRC conversion constants. */
  152. X
  153. X#include "unsea.h"
  154. X
  155. X/* crctab based upon BinHex and MacBinary standard CRC "seed" of
  156. X * 0x1021. */
  157. Xconst unsigned short crctab[] = { 
  158. X    0x0000,  0x1021,  0x2042,  0x3063,  0x4084,  0x50a5,  0x60c6,  0x70e7,
  159. X    0x8108,  0x9129,  0xa14a,  0xb16b,  0xc18c,  0xd1ad,  0xe1ce,  0xf1ef,
  160. X    0x1231,  0x0210,  0x3273,  0x2252,  0x52b5,  0x4294,  0x72f7,  0x62d6,
  161. X    0x9339,  0x8318,  0xb37b,  0xa35a,  0xd3bd,  0xc39c,  0xf3ff,  0xe3de,
  162. X    0x2462,  0x3443,  0x0420,  0x1401,  0x64e6,  0x74c7,  0x44a4,  0x5485,
  163. X    0xa56a,  0xb54b,  0x8528,  0x9509,  0xe5ee,  0xf5cf,  0xc5ac,  0xd58d,
  164. X    0x3653,  0x2672,  0x1611,  0x0630,  0x76d7,  0x66f6,  0x5695,  0x46b4,
  165. X    0xb75b,  0xa77a,  0x9719,  0x8738,  0xf7df,  0xe7fe,  0xd79d,  0xc7bc,
  166. X    0x48c4,  0x58e5,  0x6886,  0x78a7,  0x0840,  0x1861,  0x2802,  0x3823,
  167. X    0xc9cc,  0xd9ed,  0xe98e,  0xf9af,  0x8948,  0x9969,  0xa90a,  0xb92b,
  168. X    0x5af5,  0x4ad4,  0x7ab7,  0x6a96,  0x1a71,  0x0a50,  0x3a33,  0x2a12,
  169. X    0xdbfd,  0xcbdc,  0xfbbf,  0xeb9e,  0x9b79,  0x8b58,  0xbb3b,  0xab1a,
  170. X    0x6ca6,  0x7c87,  0x4ce4,  0x5cc5,  0x2c22,  0x3c03,  0x0c60,  0x1c41,
  171. X    0xedae,  0xfd8f,  0xcdec,  0xddcd,  0xad2a,  0xbd0b,  0x8d68,  0x9d49,
  172. X    0x7e97,  0x6eb6,  0x5ed5,  0x4ef4,  0x3e13,  0x2e32,  0x1e51,  0x0e70,
  173. X    0xff9f,  0xefbe,  0xdfdd,  0xcffc,  0xbf1b,  0xaf3a,  0x9f59,  0x8f78,
  174. X    0x9188,  0x81a9,  0xb1ca,  0xa1eb,  0xd10c,  0xc12d,  0xf14e,  0xe16f,
  175. X    0x1080,  0x00a1,  0x30c2,  0x20e3,  0x5004,  0x4025,  0x7046,  0x6067,
  176. X    0x83b9,  0x9398,  0xa3fb,  0xb3da,  0xc33d,  0xd31c,  0xe37f,  0xf35e,
  177. X    0x02b1,  0x1290,  0x22f3,  0x32d2,  0x4235,  0x5214,  0x6277,  0x7256,
  178. X    0xb5ea,  0xa5cb,  0x95a8,  0x8589,  0xf56e,  0xe54f,  0xd52c,  0xc50d,
  179. X    0x34e2,  0x24c3,  0x14a0,  0x0481,  0x7466,  0x6447,  0x5424,  0x4405,
  180. X    0xa7db,  0xb7fa,  0x8799,  0x97b8,  0xe75f,  0xf77e,  0xc71d,  0xd73c,
  181. X    0x26d3,  0x36f2,  0x0691,  0x16b0,  0x6657,  0x7676,  0x4615,  0x5634,
  182. X    0xd94c,  0xc96d,  0xf90e,  0xe92f,  0x99c8,  0x89e9,  0xb98a,  0xa9ab,
  183. X    0x5844,  0x4865,  0x7806,  0x6827,  0x18c0,  0x08e1,  0x3882,  0x28a3,
  184. X    0xcb7d,  0xdb5c,  0xeb3f,  0xfb1e,  0x8bf9,  0x9bd8,  0xabbb,  0xbb9a,
  185. X    0x4a75,  0x5a54,  0x6a37,  0x7a16,  0x0af1,  0x1ad0,  0x2ab3,  0x3a92,
  186. X    0xfd2e,  0xed0f,  0xdd6c,  0xcd4d,  0xbdaa,  0xad8b,  0x9de8,  0x8dc9,
  187. X    0x7c26,  0x6c07,  0x5c64,  0x4c45,  0x3ca2,  0x2c83,  0x1ce0,  0x0cc1,
  188. X    0xef1f,  0xff3e,  0xcf5d,  0xdf7c,  0xaf9b,  0xbfba,  0x8fd9,  0x9ff8,
  189. X    0x6e17,  0x7e36,  0x4e55,  0x5e74,  0x2e93,  0x3eb2,  0x0ed1,  0x1ef0
  190. X    };
  191. X
  192. Xunsigned short updatecrc(unsigned char i, unsigned short crc)
  193. X{
  194. X    extern const unsigned short crctab[];
  195. X    
  196. X    return ((crc<<8) ^ crctab[(crc>>8) ^ i]);
  197. X
  198. X} /* end of updatecrc() */
  199. X
  200. Xvoid convert_mb_header(unsigned char block[])
  201. X
  202. X{    
  203. X    extern struct starting_flags stflags;
  204. X    
  205. X    char newfilename[64], oldfilename[64];
  206. X            /* 64 is one more than the maximum length of a file in a
  207. X             * MB archive */
  208. X    
  209. X    unsigned short crc = 0;
  210. X    
  211. X    int i, j;
  212. X    
  213. X    
  214. X    j= (int) (block[1]);
  215. X    
  216. X    for(i=0; i<=j; i++)
  217. X        oldfilename[i] = block[i+2];
  218. X    
  219. X    strcpy(newfilename,"");
  220. X    
  221. X    /* Let's get the name converted here... (j is the length of the
  222. X     * new file name, which is not necessarily the same size as
  223. X     * the old one (but still less than 63 chars long) */
  224. X     
  225. X    convert_file_name(oldfilename, newfilename,FALSE);
  226. X        /* the FALSE means that cfn() will leave the filename alone if it
  227. X         * doesn't have *.sea as its structure (the optimal choice for
  228. X         * the internal name of a MacBinary file, since a lot of them have
  229. X         * more unconventional names. */
  230. X    
  231. X    j=strlen(newfilename);
  232. X    
  233. X    block[1] = j; /* put that length in the new block */
  234. X    
  235. X    for(i=0;i<j;i++)
  236. X        block[i+2] = newfilename[i];
  237. X    
  238. X    /* Now, we have to \0 the rest of the name space, as per
  239. X     * the standard. */
  240. X    
  241. X    for(i=(j+2); i<65; i++)
  242. X        block[i]= '\0';
  243. X    
  244. X    /* Let's change the creator and type, as appropriate.*/
  245. X    
  246. X    switch (stflags.sea_mode)
  247. X        {
  248. X        case 1: /* Compact Pro SEAs */
  249. X            /* first the type */
  250. X            restypecopy(block, 65, "PACT");
  251. X        
  252. X            /* then the creator */
  253. X            restypecopy(block, 69, "CPCT");
  254. X             
  255. X             break;
  256. X         
  257. X         case 3: /* StuffIt SEAs */
  258. X             /* first the type */
  259. X            restypecopy(block, 65, "SITD");
  260. X        
  261. X            /* then the creator */
  262. X            restypecopy(block, 69, "SIT!");
  263. X            
  264. X            break;
  265. X        
  266. X        }
  267. X        
  268. X    /* Now, let's tell the Finder that the SEA doesn't have an icon, by
  269. X     * zeroing the BNDL flag bit. */
  270. X     
  271. X    block[73] = block[73] & 0xdf;
  272. X    
  273. X    /* Need to make the resource block into length 0 */
  274. X    block[87]=block[88]=block[89]=block[90]=0;
  275. X
  276. X/* The MB2 parts of unsea don't work right, so I am making all unsea
  277. X * files MB1. The MB2 code is left in here for copyright's sake, however. *    
  278. X    /* for safety's sake, let's upgrade all MB files to MB 2 status *
  279. X    
  280. X    block[122]=block[123]=129;
  281. X    
  282. X    /* finally, we need to redo the CRC blocks for the header *
  283. X    
  284. X    for(i=0;i<124;i++)
  285. X        
  286. X        crc = updatecrc(block[i], crc);
  287. X        
  288. X    block[124] = (char) ((crc&0xff00)>>8); /* high byte of the CRC-16 *
  289. X    
  290. X    block[125] = (char) (crc&0xff); /* the low order of the CRC-16 *
  291. X    
  292. X    /* now we are done [CRC stuff] */
  293. X/* Here's the MB1 hack code. */
  294. X    block[122]=block[123]=block[124]=block[125]=0;    
  295. X/* End of MB1 hack */    
  296. X    
  297. X    return;
  298. X    
  299. X} /* end of convert_mb_header() */
  300. X
  301. Xunsigned long int getforksize(unsigned char block[4])
  302. X{ /* This routine takes 4 type unsigned char #s and makes them into
  303. X   * a type unsigned long. Used mainly to determine the length of the
  304. X   * two forks of the MacBinary and BinHex files. */
  305. X   
  306. X    unsigned long int x;
  307. X    
  308. X    x=((unsigned long)(block[0])<<24)|((unsigned long)(block[1])<<16);
  309. X    
  310. X    x+=((unsigned long)(block[2])<<8)|((unsigned long) (block[3]));
  311. X    
  312. X    return x;
  313. X    
  314. X} /* end of getforksize() */
  315. X
  316. Xunsigned long getblocksize(unsigned long x)
  317. X{ /* Converts an unsigned long byte count into an unsigned byte block
  318. X   * count. Used by unsea_mb() */
  319. X   
  320. X    unsigned long y;
  321. X    
  322. X    y = (x / 128);
  323. X    
  324. X    if (x % 128)
  325. X        
  326. X        y++;
  327. X    
  328. X    return y;
  329. X
  330. X} /* End of getblocksize() */
  331. X
  332. Xint convert_file_name(char *oldfname, char *newfname, const int convert_all)
  333. X
  334. X{
  335. X    /* NOTE: This routine either assumes the file is of form *.sea.bin
  336. X     * or of form *.sea. If neither, then it names the file "new_*",
  337. X     * with a maximum length of the lesser of FILENAME_MAX and 63. */
  338. X    
  339. X    extern struct starting_flags stflags;
  340. X    
  341. X    int i;
  342. X        
  343. X    strcpy(newfname, oldfname);
  344. X    
  345. X    i = strlen(newfname);
  346. X    
  347. X    if((!strncmp(&newfname[i-3],"bin",3))||(!strncmp(&newfname[i-3],"BIN",3)))
  348. X        {
  349. X        /* if the file has the suffix *.bin, check if it has the form
  350. X         * *.sea.bin.  */
  351. X        if((!strncmp(&newfname[i-7],"sea",3))||(!strncmp(&newfname[i-7],"SEA",3)))
  352. X            
  353. X            switch (stflags.sea_mode) {
  354. X            case 1:
  355. X                strncpy(&newfname[i-7],"cpt",3);
  356. X                break;
  357. X            
  358. X            case 3:
  359. X                strncpy(&newfname[i-7],"sit",3);
  360. X                break;
  361. X            
  362. X            default:
  363. X                printf("Catastrophic value error in sea_mode.\n");
  364. X                return 1;
  365. X            }
  366. X        else /* It doesn't have *.sea.bin, so make it new_*.bin */
  367. X            {
  368. X            strcpy(newfname, "new_");
  369. X            strcat(newfname, oldfname);
  370. X            newfname[63]= '\0'; /* Maximum length is 63 characters, if it
  371. X                                 * does not know better. (see below) */
  372. X            }
  373. X        
  374. X        } 
  375. X    /* it doesn't have *.bin, so convert from there */
  376. X    /* Here if of form *.sea*/
  377. X    else if((!strncmp(&newfname[i-3],"sea",3))||(!strncmp(&newfname[i-3],"SEA",3)))
  378. X            {
  379. X            switch (stflags.sea_mode)
  380. X                {
  381. X                case 1:
  382. X                    strncpy(&newfname[i-3],"cpt",3);
  383. X                    break;
  384. X            
  385. X                case 3:
  386. X                    strncpy(&newfname[i-3],"sit",3);
  387. X                    break;
  388. X            
  389. X                default:
  390. X                    printf("Catastrophic value error in sea_mode\n");
  391. X                    return 1;
  392. X                }
  393. X            
  394. X            }
  395. X        
  396. X    else if (convert_all)
  397. X        /* If none of these, and the calling routine desires all file
  398. X         * names to be converted... */
  399. X            {
  400. X            
  401. X            strcpy(newfname, "new_");
  402. X        
  403. X            strcat(newfname, oldfname);
  404. X        
  405. X            newfname[63]= '\0'; /* see comment at last newfname[63]='\0' */
  406. X            
  407. X            }
  408. X        /* end of if statements */
  409. X    
  410. X    return 0;
  411. X    
  412. X} /* end of convert_file_name() */
  413. SHAR_EOF
  414. fi # end of overwriting check
  415. if test -f 'file.c'
  416. then
  417.     echo shar: will not over-write existing file "'file.c'"
  418. else
  419. sed 's/^X//'  >'file.c' <<'SHAR_EOF'
  420. X/* block.c - Part of the unsea program.
  421. X *   Copyright 1992 by David W. Rankin, Jr.
  422. X * 
  423. X * See "unsea.txt" for full copyright information applying 
  424. X * to all text in this package. 
  425. X *
  426. X *
  427. X * Contains ANSI C library functions for reading blocks of chars,
  428. X * along with normal paranoia about error checking. :) */
  429. X#include "unsea.h"
  430. X
  431. Xint getfileblock(FILE *fp, unsigned char block[], const int blocksize)
  432. X
  433. X{    size_t i=0;
  434. X
  435. X    i = fread(block, 1, blocksize, fp);
  436. X    
  437. X    if ( (i != blocksize) || ferror(fp) || feof(fp) )
  438. X        return 1; /* something bad happened... */
  439. X    
  440. X    else return 0; /* This went OK... */
  441. X    
  442. X} /* end of getfileblock() */
  443. X
  444. Xint sendfileblock(FILE *fp, unsigned char block[], const int blocksize)
  445. X
  446. X{    size_t i;
  447. X
  448. X    i = fwrite(block, 1, blocksize, fp);
  449. X    
  450. X    if ( (i != blocksize) || ferror(fp) || feof(fp) )
  451. X        return 1; /* there was a file error, so tell it... */
  452. X    
  453. X    else return 0; /* a spotless finish.. */
  454. X
  455. X} /* end of sendfileblock() */
  456. SHAR_EOF
  457. fi # end of overwriting check
  458. if test -f 'macbin.c'
  459. then
  460.     echo shar: will not over-write existing file "'macbin.c'"
  461. else
  462. sed 's/^X//'  >'macbin.c' <<'SHAR_EOF'
  463. X/* macbin.c - Part of the unsea program.
  464. X *   Copyright 1992 by David W. Rankin, Jr.
  465. X * 
  466. X * See "unsea.txt" for full copyright information applying 
  467. X * to all text in this package. 
  468. X *
  469. X *
  470. X * macbin.c holds the unsea_mb() and associated routines. */
  471. X #include "unsea.h"
  472. Xint unsea_mb(char *oldfilename, char *newfilename)
  473. X{
  474. X    /* start of declared variables */
  475. X    
  476. X    extern struct starting_flags stflags;
  477. X    
  478. X    FILE *oldfilep; /* the original SEA MacBinary file */
  479. X    
  480. X    FILE *newfilep; /* the new non-SEA MacBinary file */
  481. X    
  482. X    unsigned long int i, /* general counter */
  483. X
  484. X        datablock,
  485. X            /* holds the number of blocks in the data fork of the sea */
  486. X
  487. X        resblock;
  488. X            /* same as datablock, except for the resource fork */
  489. X    
  490. X    unsigned char fileblock[128];  /* storage area for blocks in the MacBinary file */
  491. X    
  492. X    unsigned char *kfileblock; /* This pointer is for kblock transmission, if needed. */
  493. X    
  494. X    int j, kblocks;      /* other counters */
  495. X        
  496. X    /* start of code */
  497. X    
  498. X    /* Let's see if the file even exists */
  499. X    if ( (oldfilep=fopen(oldfilename,"rb") ) == NULL)
  500. X        {
  501. X         fprintf(stderr, "Cannot open %s to convert.\n", oldfilename);
  502. X         
  503. X         return 1; /* Standard error return */
  504. X        }
  505. X    
  506. X    /* Can I read the file?? */
  507. X    if (getfileblock(oldfilep,fileblock,128) ) /* getfileblock() 
  508. X                                              returns 1 as an error */
  509. X        { ERROR("Unable to read %s.\n", oldfilename);
  510. X        
  511. X          return 1;
  512. X        }
  513. X        
  514. X    /* Is it a SEA, and if so what kind? Let's check. */
  515. X    if ((!check_mb_sea(fileblock))||(!stflags.sea_mode))
  516. X        /* if check_mb_sea or sea_mode == 0, then the file is not
  517. X         * an mb_sea.*/
  518. X    
  519. X        { ERROR("%s is not a valid file for unsea.\n", oldfilename);
  520. X        
  521. X          return 1;  /* spit it back */
  522. X        
  523. X        }
  524. X    
  525. X    /* Get a new filename for the file if one was not provided */
  526. X    
  527. X    if (!strlen(newfilename))
  528. X        
  529. X        convert_file_name(oldfilename, newfilename, TRUE);
  530. X            /* The TRUE says that a "new_" prefix is to be used
  531. X             * if necessary */
  532. X    
  533. X    /* Can we open the new file?? If there is one there by the
  534. X     * same name, the answer is no, unless option 'o' has
  535. X     * been selected. In that case, it is yes, no matter what.*/
  536. X                   
  537. X    if(!(stflags.overwrite)&&((newfilep=fopen(newfilename,"r"))!=NULL))
  538. X    
  539. X        { ERROR3("New file %s for converting %s already exists.\n", newfilename, oldfilename);
  540. X    
  541. X          return 1;
  542. X        }
  543. X    
  544. X    /* Now let's see if the new file can be created... */
  545. X    if ( (newfilep=fopen(newfilename,"wb") ) == NULL) /* UNSEA can't open the output file */
  546. X    
  547. X        { printf("File error opening file %s for converting %s.\n", newfilename, oldfilename);
  548. X    
  549. X          fclose(oldfilep);
  550. X        
  551. X          return 1;
  552. X        }
  553. X    /* how long are the two forks of the Mac SEA file?? Note that
  554. X     * getforksize() produces a figure in x bytes, while getblocksize()
  555. X     * produces the number of 128 byte blocks in said number. */
  556. X     
  557. X    datablock=getblocksize(getforksize(&fileblock[83]));
  558. X    
  559. X    resblock=getblocksize(getforksize(&fileblock[87]));
  560. X    
  561. X    /* Let's now let the user know about what this SEA is like,
  562. X     * unless he already told us not to, via the b option. */
  563. X    if(!stflags.less_talk)
  564. X        {
  565. X        
  566. X        printf("Opening %s for MacBinary conversion.\n\t SEA type:",oldfilename);
  567. X    
  568. X        switch (stflags.sea_mode){
  569. X        
  570. X            case 1:
  571. X                printf("Compact Pro. \n");
  572. X                break;
  573. X        
  574. X            case 3:
  575. X                printf("StuffIt Deluxe/Lite\n");
  576. X                break;
  577. X            }
  578. X        printf("\t Output file: %s \n\t\
  579. X Output file size (in bytes): %ld \n",newfilename,((datablock+1)*128));
  580. X        }
  581. X    /* Let's produce a block header for "newfilename" */
  582. X    convert_mb_header(fileblock);
  583. X    
  584. X    /* now, push the converted header into the new file, dealing
  585. X       gracefully (at least somewhat gracefully...) with any
  586. X       file errors. */
  587. X    if (sendfileblock(newfilep,fileblock,128) )
  588. X        {
  589. X         ERROR3("File error accessing file %s for converting %s.\n", newfilename, oldfilename);
  590. X         
  591. X         DELETE_FILE(newfilename);
  592. X             /* Let's clean up the newly-generated file, as well. */
  593. X         return 1;
  594. X        }
  595. X    
  596. X    /* Send the data block through unmolested, if it exists at all. */
  597. X    if (datablock)
  598. X        {
  599. X        
  600. X        if(((datablock/8)>2)&&((kfileblock=calloc(1024,1))!=NULL))
  601. X            { /* Basically, is the "fast" method worth the effort, and if
  602. X               * so, can we get space for it?? */
  603. X            
  604. X            kblocks = (datablock / 8);
  605. X            
  606. X            for(i=1;i<= kblocks;i++)
  607. X                {
  608. X                if((getfileblock(oldfilep,kfileblock,1024))||(sendfileblock(newfilep,kfileblock,1024)))
  609. X                    {
  610. X                     ERROR3("File error during conversion of %s into %s.\n", oldfilename,newfilename);
  611. X                 
  612. X                     DELETE_FILE(newfilename);
  613. X                     /* Let's clean up the newly-generated file, as well. */
  614. X                      return 1;
  615. X                    }
  616. X                datablock -= 8;
  617. X                }
  618. X                
  619. X            free(kfileblock);
  620. X            }/* There, the "big" parts are out of the way... */
  621. X    
  622. X
  623. X/* Now, let's get the leftovers... */
  624. X        for(i=1;i<=datablock;i++)
  625. X        {
  626. X            if((getfileblock(oldfilep,fileblock,128))||(sendfileblock(newfilep,fileblock,128)))
  627. X                {
  628. X                 ERROR3("File error during conversion of %s into %s.\n", oldfilename,newfilename);
  629. X                 
  630. X                 DELETE_FILE(newfilename);
  631. X                     /* Let's clean up the newly-generated file, as well. */
  632. X                     return 1;
  633. X                 }
  634. X                 
  635. X        }
  636. X        
  637. X    } /* End of datablock sending */
  638. X    
  639. X    /* Now that we have sent the data block, we can trash the old res fork */
  640. X    if(((resblock/8)>2)&&((kfileblock=calloc(1024,1))!=NULL))
  641. X            { /* Again, is the "fast" method worth the effort, and if
  642. X               * so, can we get space for it?? */
  643. X            
  644. X            kblocks = (resblock / 8);
  645. X            
  646. X            for(i=1;i<= kblocks;i++)
  647. X                {
  648. X                if(getfileblock(oldfilep,kfileblock,1024))
  649. X                    {
  650. X                     ERROR3("File error during conversion of %s into %s.\n", oldfilename,newfilename);
  651. X                 
  652. X                     DELETE_FILE(newfilename);
  653. X                     /* Let's clean up the newly-generated file, as well. */
  654. X                      return 1;
  655. X                    }
  656. X                resblock -= 8;
  657. X                }
  658. X                
  659. X            free(kfileblock);
  660. X            }/* There, the "big" parts are out of the way... */
  661. X    for(i=1;i<=resblock;i++)
  662. X        {
  663. X        /* Again, let's check for errors (my, aren't we being paranoid
  664. X         * about errors.. ;) */
  665. X        if (getfileblock(oldfilep,fileblock,128) )
  666. X            {
  667. X             ERROR3("File error during conversion of %s into %s.\n", oldfilename,newfilename);
  668. X              
  669. X             DELETE_FILE(newfilename);
  670. X                 /* Let's clean up the newly-generated file, as well. */
  671. X             return 1;
  672. X             }
  673. X        }
  674. X
  675. X    /* Send the rest of oldfile over, if any. (for compatability with
  676. X     * standard, which allows Info block after the two forks.) */
  677. X    
  678. X    while ( (j=fgetc(oldfilep) ) != EOF)
  679. X        {
  680. X          fputc(j,newfilep);
  681. X        }
  682. X    
  683. X    ERROR3("%s successfully converted to %s.\n\n", oldfilename, newfilename);
  684. X    
  685. X    return 0; /* a job well done :) */
  686. X    
  687. X}  /* end of unsea_mb() */
  688. X
  689. Xint check_mb_sea(unsigned char block[])
  690. X{
  691. X    extern struct starting_flags stflags;
  692. X    
  693. X    int i;   /* counter, both general and specific */
  694. X    
  695. X    char restype[5]; /* 4 byte length, for file type and creator */
  696. X    
  697. X    int j;
  698. X
  699. X    stflags.sea_mode = 0;
  700. X    
  701. X    if (block[0] || block[74] || block[82])
  702. X        return 0;  /* If any of these are != 0, this is NOT a MB file */
  703. X    
  704. X    /* From this point on, cmb() should return 1, to indicate that this
  705. X     * is a MB file, simply not a MB SEA*/
  706. X    
  707. X    for(i=0;i<4;i++)
  708. X        restype[i]=block[65+i];
  709. X
  710. X    restype[4] = 0;
  711. X    
  712. X    if (strcmp(restype, "APPL")) /* This is TRUE if restype != "APPL" */
  713. X        return 1;  /* Can add "appe" here if needed later... */
  714. X    
  715. X    /* Time to do the same thing with the creator type */
  716. X    
  717. X    for(i=0; i<4; i++)
  718. X        restype[i]=block[69+i];
  719. X    
  720. X    if ((!stflags.ignore_cpt_seas)&&(!strcmp(restype, "EXTR")))
  721. X        /* If we can even read CompactPro SEAs, is it one? */
  722. X        {
  723. X        stflags.sea_mode = 1;
  724. X        
  725. X        return 1; /* it is */}
  726. X        
  727. X    else if ((!stflags.ignore_sitd_seas)&&(!strcmp(restype, "aust")))
  728. X        /* Can we read StuffIt SEAs, and if so is this file one? */
  729. X        {
  730. X        stflags.sea_mode = 3;
  731. X        
  732. X        return 1; /* Yep. :) */}
  733. X    
  734. X    return 1;
  735. X    /* None of these is true, so instead, let's just return 
  736. X     * that it's a MacBinary file. */
  737. X
  738. X} /* end of check_mb_sea() */
  739. SHAR_EOF
  740. fi # end of overwriting check
  741. if test -f 'unsea.c'
  742. then
  743.     echo shar: will not over-write existing file "'unsea.c'"
  744. else
  745. sed 's/^X//'  >'unsea.c' <<'SHAR_EOF'
  746. X/* unsea.c - Part of the unsea program.
  747. X *   Copyright 1992 by David W. Rankin, Jr.
  748. X * 
  749. X * See "unsea.txt" for full copyright information applying 
  750. X * to all text in this package. 
  751. X *
  752. X *
  753. X * This file holds main(), and other main parts of unsea. */
  754. X
  755. X/* include statements */
  756. X
  757. X#include "unsea.h"
  758. X
  759. X/* Beginning of code */
  760. X
  761. Xstruct starting_flags stflags;
  762. X
  763. Xvoid main(int argc, char *argv[])
  764. X{
  765. X    extern struct starting_flags stflags;
  766. X    
  767. X    char newfilename[FILENAME_MAX+1];/* the place for the file to be created */
  768. X
  769. X    int i, j, /* generic counters */
  770. X        
  771. X        arg_per_file; /* see its use */
  772. X    
  773. X    /* start of code */
  774. X
  775. X    strcpy(newfilename,""); /* This initializes this string */
  776. X    
  777. X/* This is for use on THINK_C compilers only. */
  778. X#ifdef THINK_C
  779. X    argc=ccommand(&argv);
  780. X#endif /*THINK_C*/
  781. X    
  782. X    startupmesg();
  783. X
  784. X    if (argc==1)
  785. X        {
  786. X        help();  /* tell basics, then quit */
  787. X        
  788. X        exit(EXIT_SUCCESS); }
  789. X        
  790. X    /* implied "else if (argc>=2)" */
  791. X        
  792. X    
  793. X     for(i=1;i<argc;i++)
  794. X         { /* Is argv[i] "--"? If so, quit looking for options
  795. X            * completely. */ 
  796. X         if(!strncmp(argv[i],"--",2))
  797. X             {
  798. X             i++;
  799. X
  800. X             break;  }
  801. X             /* If argv[i] doesn't have '-' at the beginning, quit looking
  802. X              * as well, but make no incrementation */
  803. X
  804. X         if(argv[i][0] != '-')
  805. X             break;
  806. X             
  807. X        if(check_startup_flags(argv[i]))
  808. X            {
  809. X            fprintf(stderr,"\
  810. XFatal error within option flags. Unable to proceed with conversion \n");
  811. X
  812. X             help();
  813. X
  814. X             exit(EXIT_FAILURE);
  815. X
  816. X             }
  817. X         } /* end of for() loop */
  818. X    if (stflags.name_given && ((argc-i) % 2) )
  819. X            /* If there are supposed to be an even # of arguments,
  820. X             * but aren't, then spit it back... */
  821. X        { fprintf(stderr, "Improper number of arguments for -n flag.\n");
  822. X
  823. X           exit(EXIT_FAILURE);
  824. X         }
  825. X
  826. X    if(i==argc)
  827. X        { /* this sees if no files were selected for conversion.
  828. X           * If so, give help and error out. */
  829. X        help();
  830. X
  831. X        exit(EXIT_FAILURE);
  832. X        }
  833. X
  834. X    arg_per_file = (stflags.name_given) ? 2 : 1;
  835. X
  836. X    while(i<argc)
  837. X        {
  838. X        if(stflags.name_given)
  839. X            strcpy(newfilename, argv[i+1]);
  840. X
  841. X        unsea_mb(argv[i], newfilename);
  842. X
  843. X        strcpy(newfilename, "");
  844. X
  845. X        i += arg_per_file;
  846. X
  847. X        }
  848. X                   
  849. X}  /* end of main() */
  850. X
  851. Xvoid restypecopy(unsigned char block[], const int startint, char s[])
  852. X
  853. X{    int i;
  854. X
  855. X    for (i=0;i<4;i++)
  856. X        block[startint+i] = s[i];
  857. X    
  858. X} /* end of restypecopy() */
  859. X
  860. Xint check_startup_flags(char *string)
  861. X{
  862. X    extern struct starting_flags stflags;
  863. X    int i, len,bad_flag=FALSE;
  864. X    
  865. X    len = strlen(string);
  866. X    
  867. X    for(i=0; i<len; i++)
  868. X        {
  869. X        switch (string[i]) {
  870. X            
  871. X            case 'B': /* 'b'rief descriptions mode. */
  872. X            case 'b':
  873. X                stflags.there = TRUE;
  874. X
  875. X                stflags.less_talk = TRUE;
  876. X                    /* less talk is what happens... */
  877. X                break;
  878. X            
  879. X            
  880. X        
  881. X        /* This case is put in for future versions of unsea, but is
  882. X         * dunsel for now. */
  883. X            case 'D': /* ignore 'D'iskDoubler SEAs */
  884. X            case 'd':
  885. X                stflags.there = TRUE;
  886. X
  887. X                stflags.ignore_dd_seas = TRUE;
  888. X
  889. X                break;
  890. X            
  891. X            case 'C': /*ignore 'C'ompact Pro SEAs */
  892. X            case 'c':
  893. X                stflags.there = TRUE;
  894. X
  895. X                stflags.ignore_cpt_seas = TRUE;
  896. X
  897. X                break;
  898. X            
  899. X            case 'S': /* Ignore 'S'tuffIt SEAs /*
  900. X            case 's':
  901. X                stflags.there = TRUE;
  902. X
  903. X                stflags.ignore_sitd_seas = TRUE;
  904. X
  905. X                break;
  906. X            
  907. X            case 'N': /* new 'n'ame given */
  908. X            case 'n':
  909. X                stflags.there = TRUE;
  910. X
  911. X                stflags.name_given = TRUE;
  912. X
  913. X                break;
  914. X            
  915. X            case 'O': /* 'O'verwrite "newfilename" */
  916. X            case 'o':
  917. X                stflags.there = TRUE;
  918. X
  919. X                stflags.overwrite = TRUE;
  920. X                    /* Overwrite any file in the way of the new file */
  921. X                break;
  922. X            
  923. X            case '-': /* Ignore '-', as per UNIX custom */
  924. X                break;
  925. X            
  926. X            default:  /* when a bad flag is found, let main() know*/
  927. X                bad_flag=TRUE; 
  928. X                break;
  929. X            }
  930. X        
  931. X        }
  932. X        return bad_flag;
  933. X} /* End of check_startup_flags() */
  934. SHAR_EOF
  935. fi # end of overwriting check
  936. if test -f 'unsea.h'
  937. then
  938.     echo shar: will not over-write existing file "'unsea.h'"
  939. else
  940. sed 's/^X//'  >'unsea.h' <<'SHAR_EOF'
  941. X/* unsea.h - Part of the unsea program.
  942. X *   Copyright 1992 by David W. Rankin, Jr.
  943. X * 
  944. X * See "unsea.txt" for full copyright information applying 
  945. X * to all text in this package. 
  946. X *
  947. X *
  948. X * Header file for the rest of unsea. */
  949. X
  950. X#include <stdio.h>
  951. X
  952. X#include <stdlib.h>
  953. X
  954. X#include <stddef.h>
  955. X
  956. X#include <string.h>
  957. X
  958. X/* USER DEFINABLE FLAGS 
  959. X * The flags in this area can be changed by the user to customize
  960. X * the way unsea works. */
  961. X
  962. X#undef UNIX_DELETE
  963. X    /* If this is defined, unlink() is used instead of remove().
  964. X     * For compiler libraries that aren't 100% ANSI compatable */
  965. X
  966. X/* End of user definable flags
  967. X * You SHOULD NOT change any of the statements below this line */
  968. X/* required define statements */
  969. X#undef TRUE
  970. X#define TRUE    1
  971. X
  972. X#undef FALSE
  973. X#define FALSE    0
  974. X
  975. X/* The next 2 defines are for use with exit(), to show explicitely
  976. X * whether the exit was successful or not. These should be defined
  977. X * in the C libraries, but I have grown not to trust the libraries
  978. X * a lot in things like this... */
  979. X
  980. X#ifndef EXIT_FAILURE
  981. X#    define EXIT_FAILURE 1
  982. X#endif
  983. X
  984. X#ifndef EXIT_SUCCESS
  985. X#    define EXIT_SUCCESS 0
  986. X#endif
  987. X
  988. X#ifndef FILENAME_MAX
  989. X#    define FILENAME_MAX 63
  990. X/* This is for the drain-bramaged compilers that refuse to 
  991. X * define all the constants. */
  992. X#endif /* FILENAME_MAX */
  993. X
  994. X#ifdef THINK_C /* This is true for THINK C compilers, usually */
  995. X#    define MACINTOSH
  996. X#    include <console.h>
  997. X#endif  /* THINK_C */
  998. X
  999. X#define ERROR(ARGUMENT1, ARGUMENT2) fprintf(stderr,ARGUMENT1, ARGUMENT2);\
  1000. Xfclose(oldfilep)
  1001. X#define ERROR3(ARGUMENT1, ARGUMENT2,ARGUMENT3) fprintf(stderr,ARGUMENT1,\
  1002. XARGUMENT2,ARGUMENT3);fclose(oldfilep);fclose(newfilep)
  1003. X
  1004. X    /* WARNING: This routine is unsea_mb specific!!! *
  1005. X       ERROR() allows the program to neatly deal with errors, by simply *
  1006. X       stating it in the code, and then the preprocessor comes along later *
  1007. X       and adds the rest. */
  1008. X
  1009. X#ifdef UNIX_DELETE
  1010. X#    define DELETE_FILE(arg) unlink(arg)
  1011. X/* Use the UNIX standard delete file routine */
  1012. X#else
  1013. X#    define DELETE_FILE(arg) remove(arg)
  1014. X/* Use the ANSI C standard delete file routine. The recommended 
  1015. X * macro */
  1016. X#endif /*UNIX_DELETE */
  1017. X
  1018. X/* end of definitions */
  1019. X
  1020. X/* start of struct definitions */
  1021. X
  1022. Xstruct starting_flags
  1023. X        {
  1024. X        char there,
  1025. X                /* This is TRUE if there are flags in the first place */
  1026. X
  1027. X            name_given,
  1028. X                /* This flag is true if each file has a "child" file name */
  1029. X
  1030. X            ignore_sitd_seas,
  1031. X                /* Used to record status of StuffIt SEAs, as decided on
  1032. X                 * the command line. */
  1033. X
  1034. X            ignore_cpt_seas,
  1035. X                /* Same as ignore_sitd_seas, except for Compact Pro SEAs. */
  1036. X
  1037. X            ignore_dd_seas,
  1038. X                /* At this time, unsea will not convert DiskDoubler SEAs. When
  1039. X                 * it does, this will be the boolean for allowing or preventing
  1040. X                 * conversion. */
  1041. X
  1042. X            less_talk,
  1043. X                /* when the 'b'rief mode is selected, unsea will refrain
  1044. X                 * from printing out a detailed analysis of the SEA being
  1045. X                 * converted. */
  1046. X
  1047. X            overwrite;
  1048. X                /* When selected, unsea will overwrite when it finds
  1049. X                 * a file with the same name as the new file to be
  1050. X                 * generated. */
  1051. X
  1052. X        int sea_mode;
  1053. X            /* This int will hold the type of SEA that the file is. */
  1054. X
  1055. X        }; /* end of struct starting_flags */
  1056. X
  1057. X/*  function declarations */
  1058. X
  1059. Xvoid main(int argc, char *argv[]);
  1060. X
  1061. Xvoid startupmesg(void);
  1062. X
  1063. Xvoid help(void);
  1064. X
  1065. Xvoid restypecopy(unsigned char block[], const int startint, char s[]);
  1066. X
  1067. Xint unsea_mb(char *oldfilename, char *newfilename);
  1068. X
  1069. Xint getfileblock(FILE *fp, unsigned char block[], const int blocksize);
  1070. X
  1071. Xint convert_file_name(char *oldfilename, char *newfilename, const int convert_all);
  1072. X
  1073. Xint check_mb_sea(unsigned char block[]);
  1074. X
  1075. Xvoid convert_mb_header(unsigned char block[]);
  1076. X
  1077. Xint sendfileblock(FILE *fp, unsigned char block[], const int blocksize);
  1078. X
  1079. Xunsigned long int getforksize(unsigned char block[]);
  1080. X
  1081. Xunsigned long int getblocksize(unsigned long int bytes);
  1082. X
  1083. Xunsigned short updatecrc(unsigned char c, unsigned short crc);
  1084. X
  1085. Xint check_startup_flags(char *argv);
  1086. X
  1087. X/* end of function prototypes */
  1088. SHAR_EOF
  1089. fi # end of overwriting check
  1090. if test -f 'unsea.testers'
  1091. then
  1092.     echo shar: will not over-write existing file "'unsea.testers'"
  1093. else
  1094. sed 's/^X//'  >'unsea.testers' <<'SHAR_EOF'
  1095. Xunsea.testers - Part of the unsea program.
  1096. X  Copyright 1992 by David W. Rankin, Jr.
  1097. X
  1098. X    I again want to thank everyone on this list for beta testing unsea,
  1099. Xbeta testing my programs is not at all an easy task. :) 
  1100. X
  1101. XBeta testers for unsea(by version)
  1102. X<1.0
  1103. XAlan D. Danziger
  1104. XKelvin Edmison
  1105. XAlan R. Fry
  1106. XJoey Gibson
  1107. XMarco Gonzalez of Aladdin Systems, Inc.
  1108. XKen Hancock
  1109. XBryan M. Kearney
  1110. XZeke Koch
  1111. XAnand C. Patel
  1112. XGreg Rabanes
  1113. XLeonard Rosenthol of Aladdin Systems, Inc.
  1114. XEdward John Sabol
  1115. XChris Schwenda
  1116. XJustin Sullivan
  1117. XMatthias Weismann
  1118. XKurt D. Whitmore
  1119. SHAR_EOF
  1120. fi # end of overwriting check
  1121. if test -f 'unsea.txt'
  1122. then
  1123.     echo shar: will not over-write existing file "'unsea.txt'"
  1124. else
  1125. sed 's/^X//'  >'unsea.txt' <<'SHAR_EOF'
  1126. X"Unsea 1.0 Release Version"
  1127. XAll parts of this package
  1128. X     Copyright 1992 David W. Rankin, Jr.
  1129. X
  1130. XDESCRIPTION:
  1131. X     Unsea is a "charityware" (see "CHARITYWARE" below) routine for removing
  1132. Xthe self-expanding code from MacBinary coded self-expanding archives ("SEAs").
  1133. XIt works with most SEAs created by Compact Pro(TM) 1.33 and compatable versions
  1134. Xand with StuffIt Classic(TM) 1.6, StuffIt Deluxe(TM) 1.0-3.0 and StuffIt
  1135. XLite(TM) 3.0 SEAs. (see "Non-Compatable SEAs" below.)
  1136. X
  1137. X     WARNING: This program uses techniques which remove all code from the
  1138. Xresource fork of the file converted. Therefore, you should not attempt
  1139. Xto use it on any file that requires data to remain in the resource fork.
  1140. XThis is especially important with StuffIt(TM) SEAs with encrypted files. (See
  1141. Xbelow.)
  1142. X
  1143. XLEGAL STUFF:
  1144. X     Unsea is NOT in the public domain; the copyright remains the property of
  1145. XDavid W. Rankin, Jr. (hereafter "I" or "me"). I hereby grant permission to
  1146. Xany group wishing to distribute the unsea package in a completly unmodified
  1147. Xform for no cost (not including on-line services that only charge per hour
  1148. Xconnection charges). Any group wishing to distribute unsea while charging any
  1149. Xfee not covered under the above exceptions for said distribution, especially
  1150. X"media" or "handling" charges, must obtain written permission from me before
  1151. Xso distributing this package.
  1152. X    This package contains material covered by a registered Copyright on
  1153. X"Unsea 1.0", as well as all copyrights on this version and copyrights on
  1154. Xany earlier versions of unsea.
  1155. X    I have made every effort to ensure that this package works and is safe
  1156. Xto use under normal operating conditions. However, I cannot and do not warrant
  1157. Xthis product to be free from defects, or that it will operate as advertised.
  1158. XUse at your own risk.
  1159. X    Any use of the names of any individuals, groups or companies within this
  1160. Xtext is for informational purposes only, and does not represent an endorsement
  1161. Xof unsea by any party so mentioned.
  1162. X    All trademarks presented are the property of their respective owners.
  1163. X
  1164. XCHARITYWARE:
  1165. X     Unsea is "charityware." If you like and use unsea, I ask that you make a
  1166. Xcontribution of $15 US or more to the Christian Appalachian Project (CAP) in
  1167. Xlieu of any payments to me. CAP is an inter-denominational Christian group
  1168. Xdedicated to helping the people of Appalachia help themselves out of the
  1169. Xcycle of poverty that has such a strong grip on that region.
  1170. X     CAP's address is:
  1171. X    
  1172. X    Christian Appalachian Project
  1173. X    322 Crab Orchard Road
  1174. X    Lancaster, KY 40446
  1175. X    US Phone Number: (606)792-3051
  1176. X
  1177. X     Whether or not you chose to donate to CAP, I also ask that you contact me,
  1178. Xso that I may add your name to my mailing lists for unsea. I will try to
  1179. Xcontact unsea users about new versions, bugs, etc. directly, in addition to
  1180. Xposting to Usenet. My addresses are at the end of this file.
  1181. X
  1182. XCOMPILING UNSEA:
  1183. X     Unsea uses parts of the ANSI standard that are not covered under the
  1184. Xoriginal Kernighan and Ritchie (K&R) standard of C. Therefore, you will have
  1185. Xto compile this program with an ANSI compliant compiler. If your system's "cc"
  1186. Xcompiler is not ANSI C compliant and you are on a UNIX machine, I suggest that
  1187. Xyou obtain GNU's C compiler, gcc.
  1188. X     If you are on a UNIX machine, you may simply use the command "make unsea"
  1189. Xto create the unsea program. (See the instructions inside "Makefile" for
  1190. Xmore information in that regard.) If you do not have the "make" program, then
  1191. Xyou will need to compile each .c file in this package into a program named
  1192. X"unsea", following the instructions that come with your compiler.
  1193. X     One problem that has come to my attention already is that some compiler
  1194. Xlibraries do not support the remove() function, which deletes files. If you
  1195. Xencounter an error mentioning _remove failing to link, then this is the
  1196. Xcase. To correct this, you can change "#undef UNIX_DELETE" in unsea.h to
  1197. X"#define UNIX_DELETE." This changes the remove() command to unlink(), a library
  1198. Xfunction common to UNIX compilers and often in other libraries, but not in the
  1199. XANSI C standard libraries.
  1200. X    
  1201. XUSE OF UNSEA:
  1202. X   Syntax for calling unsea:
  1203. X   unsea [-bcnos] oldfile1.sea.bin [newfile1.name.bin] [oldfile2.sea.bin ... ]
  1204. X    
  1205. XCommand Line Syntax:
  1206. X     Starting with the second word of the command line (unsea assumes the first
  1207. Xis its own name), unsea searches the command line for option flags starting
  1208. Xwith '-', up to either a file name not starting with '-', or the string "--"
  1209. X(for when you have a file name with '-' in it).
  1210. X     If unsea encounters an option flag it does not know [see below for a list
  1211. Xof legitimate option flags], it will report an error to the user and abort.
  1212. X     Once unsea has reached the end of the flags, it begins converting each
  1213. Xfile name given. If the n option has been selected (see below), it processes
  1214. Xthe filenames in the command line as pairs, with the first of the pair as the
  1215. Xname of the SEA file and the latter as the name of the unSEAed output file.
  1216. XIt continues processing these names until the end of the command line is
  1217. Xreached. Therefore, unsea is capable of converting multiple files during one
  1218. Xrun.
  1219. X
  1220. X     Option Flags:
  1221. X     b:   Normally unsea gives detailed information about a SEA as it is
  1222. X          being converted. However, this option places unsea into its
  1223. X          "brief descriptions" mode, in which only a small amount of
  1224. X          information is printed to the screen.
  1225. X
  1226. X     c:   This flag will cause any Compact Pro SEAs to be ignored by unsea
  1227. X          during its conversion of the named files. It is good for aliases
  1228. X          where you have a reason to not unSEA a Compact Pro file. The
  1229. X          default is to unSEA Compact Pro SEAs
  1230. X
  1231. X     n:   When this option is selected, unsea uses the string coming after
  1232. X          the SEA file name as the output for the unSEAed file. If the file
  1233. X          name already exists, it will NOT be overwritten, unless the "o"
  1234. X          option is selected. When this option is not selected, unsea
  1235. X          creates a name for the new file using an internal name generator.
  1236. X
  1237. X     o:   unsea will overwrite any file named the same as the new file it
  1238. X          will generate (either through the n option or its internal name
  1239. X          generator.) This option is not recommended except for use with
  1240. X          the n option, since the internal name generator might produce a
  1241. X          name that you did not anticipate. Unsea will not overwrite a
  1242. X          file by default.
  1243. X
  1244. X     s:   This option causes unsea to ignore StuffIt Deluxe SEAs that it
  1245. X          encounters. This option too is good for an alias to unsea. By
  1246. X          default, unsea converts StuffIt Deluxe SEAs.
  1247. X
  1248. X   Note on Options:
  1249. X       While unsea does not presently use option flag 'd', it also will not
  1250. X     report its use as an error. The code recognizing d as the option flag for
  1251. X     surpressing unseaing of DiskDoubler SEAs was added when I added other
  1252. X     code to unsea, even though DiskDoubler SEAs are not yet supported.
  1253. X
  1254. XNON-COMPATABLE SEAs
  1255. X     There are several types of self-expanding archives that unsea is presently
  1256. Xincapable of converting. The main one among these is SEAs generated by
  1257. XDiskDoubler(TM). I will attempt to correct this in the future, but, as I do not
  1258. Xown DiskDoubler, this will take time. (Anyone want to buy me a copy of
  1259. XDiskDoubler so I can try it?? ;).
  1260. X     On the other hand, unsea does not and will not support SEAs made by more
  1261. Xesoteric compressors, such as More Disk Space(TM). I am a college student with
  1262. Xa GPA that has to stay up, so I only have so much spare time.
  1263. X     Also, encrypted StuffIt SEAs use information in the resource fork to
  1264. Xdefine the encryption, so when unsea removes the resource fork, it corrupts the
  1265. Xencryption in the process. Unsea is not capable of detecting such encryption,
  1266. Xso it will blindly proceed to corrupt the archive. There is no practical way
  1267. Xthat I know of to fix this either, since even a checker would have to do
  1268. Xa lot of manipulations of the resource fork, something rather hard for
  1269. XMacBinary but almost impossible for BinHex.
  1270. X
  1271. XACKNOWLEDGEMENTS:
  1272. X     There are several people I want to thank for their help with unsea. First,
  1273. XMarco Gonzalez of Aladdin Systems, Inc. for the information about encrypted
  1274. XStuffIt SEAs, Bill Goodman for pointing out that the BNDL bit had to be
  1275. Xcleared and confirming my data on Compact Pro SEAs, Ken Hancock, for warning
  1276. Xme about funny things inside DiskDoubler SEAs and for help straightening out
  1277. Xmy #define statements, Justin Sullivan, for the original push to start unsea
  1278. Xand beta testing above and beyond the call of duty, and Greg Rabanes for
  1279. Xalpha testing and encouragement.
  1280. X     Next, the beta testers who took some of their valuable time to make unsea
  1281. Xbetter. It comforts a programmer to know there are always people out there
  1282. Xwilling to show you all of your stupid mistakes. ;) Seriously, I appreciate
  1283. Xthe help of all the testers. [A full list of all of unsea's beta testers is
  1284. Xin the file "unsea.testers".] 
  1285. X     Finally, I want to thank the Lord for giving me this knack called
  1286. Xprogramming.
  1287. X     If I left anyone out, feel free to complain to me, and I'll put in a
  1288. Xspecial mention in the next version. 
  1289. X
  1290. XCONTACTING THE AUTHOR:
  1291. X     The best way to contact me is through Electronic Mail, since I check it
  1292. Xoften. Please use the backup addresses only if you cannot get to reach the
  1293. Xprimary address for each net mentioned. Here are the addresses:
  1294. X     INTERNET: rankin=unsea@ms.uky.edu
  1295. X               Backup: rankin@mik.uky.edu, djrank00@ukpr.uky.edu
  1296. X     BITNET: rankin=unsea@ukma.BITNET
  1297. X               Backup: rankin%ms.uky.edu@ukcc.BITNET, djrank00@ukpr.BITNET
  1298. X     UUCP: rankin=unsea@ukma.UUCP or {uunet, gatech}!ukma!rankin=unsea
  1299. X               Backup: uunet!mik.uky.edu!rankin, uunet!ukpr.uky.edu!djrank00
  1300. X     US Postal Service:
  1301. X      As an absolute last resort, you may write to:
  1302. X           David W. Rankin, Jr.
  1303. X           Boyd Hall
  1304. X           University of Kentucky
  1305. X           Lexington, KY 40526-0008
  1306. X     However, please consider that this is not a complete address, so the post
  1307. Xoffice will have to process it. That means it will take a while to get to me.
  1308. XI hope to have a permanent mailing address by the time I have finished unsea
  1309. X1.1, at which time I will put it in this document.
  1310. X
  1311. XCOMING ATTRACTIONS
  1312. X     I am presently working on unsea 1.1, which will have any necessary bug
  1313. Xfixes for 1.0 (hopefully none :) and support for BinHex archives. Also, I
  1314. Xwill make unsea's CRC generator work right, so that it makes correct
  1315. XMacBinary 2 files (it will now only make MacBinary 1 files.) DiskDoubler
  1316. Xsupport is likely to take a while longer, especially since I have other irons
  1317. XREFERENCES:
  1318. X
  1319. XMacBinary Standard, Dennis F. Brothers. This is the original proposal outlining
  1320. X     the MacBinary format, and was the working document created by the original
  1321. X     MacBinary Working Group.
  1322. X
  1323. X"MacBinary II Standard", MacBinary II Conference. This document reflects the
  1324. X     concensus of the MacBinary II Conference, as to extending the MacBinary
  1325. X     standard to cover changes in the Macintosh Finder data and to add CRC
  1326. X     protection to the header of the file.
  1327. X
  1328. Xmcvert 1.65 and mcvert 1.70, Doug Moore et al. UNIX program that converts
  1329. X     MacBinary to BinHex and vice versa, in addition to UnPacking PackIt files
  1330. X     and neato conversions of text files. A prime example of durable code at
  1331. X     it's best. (Better than mine, that's for sure. :)
  1332. X
  1333. XBinHex 4.0 Definition, Peter N. Lewis. This document was created by Mr. Lewis
  1334. X     during the creation of DeHQX, and is a clear definition of the BinHex 4.0
  1335. X     standard, as far as I can tell. Unsea will be 100% compatable with the
  1336. X     BinHex format as described in this document and mcvert.
  1337. X
  1338. XThe C Programming Language, Second Edition, Kernighan and Ritchie. This is
  1339. X     the main code reference that I have used for unsea, especially for being
  1340. X     ANSI C compliant. I do reccomend this book.
  1341. X
  1342. XTHINK C(tm) 5.0, Symantec. During the development and early beta stages, all
  1343. X     of my programming for unsea was on THINK C. Also, I used the Standard
  1344. X     Libraries Reference included with the compiler as an additional reference
  1345. X     for the ANSI C library functions. 
  1346. SHAR_EOF
  1347. fi # end of overwriting check
  1348. if test -f 'version.c'
  1349. then
  1350.     echo shar: will not over-write existing file "'version.c'"
  1351. else
  1352. sed 's/^X//'  >'version.c' <<'SHAR_EOF'
  1353. X/* version.c - Part of the unsea program.
  1354. X *   Copyright 1992 by David W. Rankin, Jr.
  1355. X * 
  1356. X * See "unsea.txt" for full copyright information applying 
  1357. X * to all text in this package. 
  1358. X *
  1359. X *
  1360. X * version.c holds the version-dependant info as well as the
  1361. X * in-program help. */
  1362. X
  1363. X#include "unsea.h"
  1364. X
  1365. X
  1366. X#define VERSION "Unsea 1.0 Release Version"
  1367. X
  1368. X
  1369. X/* HELP CODE!!! */
  1370. X
  1371. Xvoid startupmesg(void)
  1372. X{
  1373. X    printf(VERSION "\n\
  1374. XCopyright 1992 David W. Rankin, Jr.\n\n\
  1375. X  WARNING: unsea will corrupt encrypted StuffIt SEAs. Do not use\n\
  1376. Xunsea to convert these files. \n\n");
  1377. X        
  1378. X}
  1379. X
  1380. Xvoid help(void)
  1381. X{
  1382. X    /* here I'll put the ever-helpful tips to those who need help */
  1383. X
  1384. X    printf("Syntax for calling unsea: \n\
  1385. Xunsea [-bcnos] [--] archive1.name [new.archive1.name] [archive2.name] ... \n\
  1386. XOptions:[None of these are defaults]\n\
  1387. X   b: This option places unsea in \"brief descriptions\" mode, surpressing\n\
  1388. X      the verbose descriptions of the SEA being converted that unsea\n\
  1389. X      normally gives.\n\
  1390. X   c: When selected, this flag surpresses conversion of Compact Pro files.\n\
  1391. X      By default, Compact Pro files are converted.\n\
  1392. X   n: For every original file, a file name is given for the\n\
  1393. X      output file. If this isn't selected, unsea generates\n\
  1394. X      a name using its internal naming algorithms.\n");   printf("\
  1395. X   o: Overwrite any file with the same name as the converted file.\n\
  1396. X      If not selected, unsea will not overwrite files.\n\
  1397. X   s: Surpress conversion of StuffIt Deluxe SEAs. By default, StuffIt SEAs\n\
  1398. X      are converted.\n\
  1399. XAfter the options, list the files you wish to convert, along\n\
  1400. Xwith the converted file's name, if using the -n option. \n");
  1401. X}
  1402. SHAR_EOF
  1403. fi # end of overwriting check
  1404. :    End of shell archive
  1405. exit 0
  1406.