
SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 1
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)



    1        	/*
    2        	 *			    ---   SHAR_CMD.C   ---
    3        	 *			---   Command Portion of   ---
    4        	 *			     ---   UNSHAR.C   ---
    5        	 *
    6        	 *		  ---   Copywrite 24 September, 1986   ---
    7        	 *		      ---    John Birchfield      ---
    8        	 *		      ---    411 Crane Ave.       ---
    9        	 *		      ---    Turlock, CA  95380   ---
   10        	 *		      ---      (209) 634-6243     ---
   11        	 *
   12        	 *	Program to decode files created by the shell archive { shar }
   13        	 *	utility on Un*x machines or pc's.  Current capabilities include
   14        	 *
   15        	 *	1.	Able to unshar into a user specified directory or subdirectory
   16        	 *		as specified by a command line option { -Ddirectory_name }
   17        	 *
   18        	 *	2.	Recognizes the following commands
   19        	 *			cat, sed, uudecode, mkdir, chdir, 
   20        	 *			{test -f, test -d, test <number -ne wc ... }
   21        	 *
   22        	 *	3.	Can handle shar scripts created with the
   23        	 *			Options { -a -v -p -b -c -d }
   24        	 *
   25        	 *	4.	Successfully traverses directories and sub-directories
   26        	 *		creating the necessary subdirectories as necessary.
   27        	 *
   28        	 *	CAVEATS:
   29        	 *		Word Counting between Un*x machines and pc's just isn't
   30        	 *		gonna work out too well.  The \r\n - \n thing is not
   31        	 *		an easy thing to work around - and to be quite frank
   32        	 *		I just ain't up to it.
   33        	 *
   34        	 *	Program written for the Desmet (C-Ware) C Compiler Version 2.61
   35        	 *	not all of the routines in DOS_C.C and DOS_A.A are used by this
   36        	 *	program.  The program consists of the following modules:
   37        	 *		UNSHAR.C
   38        	 *		SHAR_CMD.C
   39        	 *		DOS_C.C
   40        	 *		DOS_A.A
   41        	 *
   42        	 *	This program is hereby placed in the public domain for 
   43        	 *	non-commersial use.
   44        	 *
   45        	 */
   46        	
   47        	# include stdio
  188        	# include "unshar.h"
  248        	#ifdef	VMS
  249        	# include stat
  289        	#else
  290   X    	# include "dos.h"
  291        	#endif
  292        	
  293        	extern	void	fix_file_name(char *s);

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 2
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)

  294        	
  295        	extern	int	first_period;
  296        	
  297        	
  298        	/*
  299        	 *	P_ERROR ()	-	p_error () is a simple routine for
  300        	 *		displaying a message consisting of a sequence of
  301        	 *		strings thru stdout.  The first parameter is an
  302        	 *		integer { if non-zero an exit occurs } the last
  303        	 *		parameter is an empty string.
  304        	 */
  305        	 
  306        	void p_error (no, args)
  307        	int no;
  308        	char *args;
  309        	{
  310    1   		char **tmp;
  311    1   		tmp = &args;
  312    1   		while (**tmp)
  313    1   			fputs (*tmp++, stdout);
  314    1   		if (no)
  315    1   			_exit (no);
  316    1   	}
  317        	
  318        	
  319        	
  320        	
  321        	/*
  322        	 *	DO_CD ()	-	change directories
  323        	 */
  324        	 
  325        	int do_cd (fp)
  326        	FILE *fp;
  327        	{
  328    1   		char buf [20];
  329    1   		get_tok (buf, fp);
  330    1   		return (chdir (buf));
  331    1   	}
  332        	
  333        	
  334        	
  335        	
  336        	/*
  337        	 *	DO_MKDIR ()	-	make a directory
  338        	 */
  339        	 
  340        	int do_mkdir (fp)
  341        	FILE *fp;
  342        	{
  343    1   		char buf [20];
  344    1   		get_tok (buf, fp);
  345    1   		return (mkdir (buf));
  346    1   	}
  347        	
  348        	
  349        	
  350        	

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 3
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)

  351        	/*
  352        	 *	DO_EXIT ()	-	Bye Bye
  353        	 */
  354        	 
  355        	void do_exit (fp)
  356        	FILE *fp;
  357        	{
  358    1   		char buf [20];
  359    1   		get_tok (buf, fp);
  360    1   		exit (atoi (buf));
  361    1   	}
  362        	
  363        	
  364        	
  365        	
  366        	/*
  367        	 *	DO_CAT ()	-	get the destination filename, get the
  368        	 *		terminating string open the file and pass the contents
  369        	 *		of the input stream to it until the termination flag
  370        	 *		is recognized.
  371        	 */
  372        	
  373        	void do_cat (fp)
  374        	FILE *fp;
  375        	{
  376    1   		FILE *f_out;
  377    1   		char delimiter [80], fname [65], *dp,
  378    1   		     buf [256],
  379    1   		     tmp [15];
  380    1   		int len;
  381    1   		
  382    1   		fname [0] = delimiter [0] = '\0';
  383    1   		do {
  384    2   			get_tok (tmp, fp);
  385    2   			if (strncmp (tmp, "<<", 2)==0)
  386    2   				get_tok (delimiter, fp);
  387    2   			else if (strncmp (tmp, ">", 1)==0)
  388    2   				get_tok (fname, fp);
  389    2   		} while (fname [0]=='\0' || delimiter [0]=='\0');
  390    1   	
  391    1   		fix_file_name (fname);
  392    1   	#ifdef	VMS
  393    1   		if ((f_out=fopen(fname,"wt","rfm=var","rat=cr"))==NULL)
  394    1   	#else
  395   X    		if ((f_out=creat (fname))==-1)
  396    1   	#endif
  397    1   			p_error (1, "Cat Can't Create '", fname, "'\n", "");
  398    1   		dp = delimiter;
  399    1   		len = strlen (dp);
  400    1   		while (fgets (buf, 256, fp)) {
  401    2   			if (strncmp (dp, buf, len)==0)
  402    2   				break;
  403    2   			fputs (buf, f_out);
  404    2   		}
  405    1   		fclose (f_out);
  406    1   	}
  407        	

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 4
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)

  408        	
  409        	
  410        	
  411        	/*
  412        	 *	DO_SED ()	-	do_sed () works just like do_cat ()
  413        	 *		except that the command line has the sed s/ //
  414        	 *		translation parameter in it { one more token }
  415        	 *		Command lines are of the form
  416        	 *			sed 's/^	X//' << \SHAR_EOF > '.cshrc'
  417        	 */
  418        	 
  419        	void do_sed (fp)
  420        	FILE *fp;
  421        	{
  422    1   		FILE *f_out;
  423    1   		char  replace [40], delimiter [80], fname [65], *dp, *rp,
  424    1   		      buf [256], *nbuf,
  425    1   		      tmp [15];
  426    1   		int len, rlen;
  427    1   	
  428    1   	#ifdef	VMS
  429    1   		char *index();
  430    1   	#endif
  431    1   	
  432    1   		get_tok (replace, fp);
  433    1   		fname [0] = delimiter [0] = '\0';
  434    1   		do {
  435    2   			get_tok (tmp, fp);
  436    2   			if (strncmp (tmp, "<<", 2)==0)
  437    2   				get_tok (delimiter, fp);
  438    2   			else if (strncmp (tmp, ">", 1)==0)
  439    2   				get_tok (fname, fp);
  440    2   		} while (fname [0]=='\0' || delimiter [0]=='\0');
  441    1   	
  442    1   		fix_file_name (fname);
  443    1   		rp = &replace [3];
  444    1   		if (index (rp, '/'))
  445    1   			*index (rp, '/') = '\0';
  446    1   		rlen = strlen (rp);
  447    1   		nbuf = &buf [0] + rlen;
  448    1   	#ifdef	VMS
  449    1   		if ((f_out=fopen(fname,"wt","rfm=var","rat=cr"))==NULL)
  450    1   	#else
  451   X    		if ((f_out=creat (fname))==-1)
  452    1   	#endif
  453    1   			p_error (1, "Sed Can't Open '", fname, "'\n", "");
  454    1   	
  455    1   		dp = delimiter;
  456    1   		len = strlen (dp);
  457    1   		while (fgets (buf, 256, fp)) {
  458    2   			if (strncmp (dp, buf, len)==0)
  459    2   				break;
  460    2   			if (strncmp (rp, buf, rlen)==0)
  461    2   				fputs (nbuf, f_out);
  462    2   			else	
  463    2   				fputs (buf, f_out);
  464    2   		}

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 5
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)

  465    1   		fclose (f_out);
  466    1   		;
  467    1   	}
  468        	
  469        	
  470        	
  471        	/*
  472        	 *	DO_UUDECODE ()	-	do_uudecode () handles uudecoding
  473        	 *		chores in the same way that do_cat () and do_sed ()
  474        	 *		process their input.  There are differnces in that
  475        	 *		the uuencoded stream has it's filename as the
  476        	 *		beginning of the file and not imbedded in
  477        	 *		the uudecode command line.
  478        	 */
  479        	
  480        	void do_uudecode (fp)
  481        	FILE *fp;
  482        	{
  483    1   		FILE *f_out;
  484    1   		char delimiter [80], fname [65], *dp,
  485    1   		     buf [256];
  486    1   		int len;
  487    1   		
  488    1   		do {
  489    2   			get_tok (delimiter, fp);
  490    2   		} while (strncmp (delimiter, "<<", 2));
  491    1   	
  492    1   		get_tok (delimiter, fp);
  493    1   		dp = &delimiter [1];
  494    1   		len = strlen (dp);
  495    1   		fname [0] = '\0';
  496    1   		do {
  497    2   			if (get_tok (fname, fp)==0)
  498    2   				p_error (2, "Uudecode: No begin statement\n", "");
  499    2   		} while (strcmp (fname, "begin"));
  500    1   		get_tok (fname, fp);
  501    1   		get_tok (fname, fp);
  502    1   		fix_file_name (fname);
  503    1   	#ifdef	VMS
  504    1   		if ((f_out=fopen(fname,"wb"))==NULL)
  505    1   	#else
  506   X    		if ((f_out=creat (fname))==-1)
  507    1   	#endif
  508    1   			p_error (1, "Uudecode Can't Create '", fname, "'\n", "");
  509    1   	
  510    1   		decode(fp, f_out);
  511    1   	
  512    1   		if (fgets(buf, sizeof buf, fp) == NULL || strcmp(buf, "end\n"))
  513    1   			p_error (5, "Uudecode No end line\n", "");
  514    1   		while (fgets (buf, sizeof (buf), fp))
  515    1   			if (strncmp (buf, dp, len)==0)
  516    1   				break;
  517    1   		fclose (f_out);
  518    1   	}
  519        	
  520        	
  521        	

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 6
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)

  522        	
  523        	/*
  524        	 * copy from in to out, decoding as you go along.
  525        	 */
  526        	
  527        	#define DEC(c)	(((c) - ' ') & 077)
  528        	
  529        	decode(in, out)
  530        	FILE *in;
  531        	FILE *out;
  532        	{
  533    1   		char buf[80];
  534    1   		char *bp;
  535    1   		int n;
  536    1   	
  537    1   		for (;;) {
  538    2   			/* for each input line */
  539    2   			if (fgets(buf, sizeof buf, in) == NULL)
  540    2   				p_error (10, "Uudecode Short file\n", "");
  541    2   	
  542    2   			n = DEC(buf[0]);
  543    2   			if (n <= 0)
  544    2   				break;
  545    2   			bp = &buf[1];
  546    2   			while (n > 0) {
  547    3   				outdec(bp, out, n);
  548    3   				bp += 4;
  549    3   				n -= 3;
  550    3   			}
  551    2   		}
  552    1   	}
  553        	
  554        	
  555        	
  556        	
  557        	/*
  558        	 * output a group of 3 bytes (4 input characters).
  559        	 * the input chars are pointed to by p, they are to
  560        	 * be output to file f.  n is used to tell us not to
  561        	 * output all of them at the end of the file.
  562        	 */
  563        	
  564        	outdec(p, f, n)
  565        	char *p;
  566        	FILE *f;
  567        	{
  568    1   		int c1, c2, c3;
  569    1   	
  570    1   		c1 = DEC(*p) << 2 | DEC(p[1]) >> 4;
  571    1   		c2 = DEC(p[1]) << 4 | DEC(p[2]) >> 2;
  572    1   		c3 = DEC(p[2]) << 6 | DEC(p[3]);
  573    1   		if (n >= 1)
  574    1   			fputc(c1, f);
  575    1   		if (n >= 2)
  576    1   			fputc(c2, f);
  577    1   		if (n >= 3)
  578    1   			fputc(c3, f);

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 7
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)

  579    1   	}
  580        	
  581        	
  582        	
  583        	
  584        	/*
  585        	 *	DO_TEST ()	-	do_test () tries to perform the test
  586        	 *		requested by the shar script.  At the moment the 
  587        	 *		following tests are recognized
  588        	 *
  589        	 *		test ! -d directoryname
  590        	 *		test -f filename
  591        	 *		test <number> -ne wc ...  do a word count of
  592        	 *		                          the file
  593        	 */
  594        	 
  595        	int do_test (fp)
  596        	FILE *fp;
  597        	{
  598    1   		FILE *tfp;
  599    1   		
  600    1   		char flag [10], fname [100];
  601    1   		int	invert = FALSE;
  602    1   		long	wc_arg;
  603    1   	
  604    1   	#ifdef	VMS
  605    1   		struct stat	stat_buf;
  606    1   	#endif
  607    1   	
  608    1   		get_tok (flag, fp);
  609    1   		if (strcmp (flag, "!")==0) {
  610    2   			invert = TRUE;
  611    2   			get_tok (flag, fp);
  612    2   		}
  613    1   		if (strcmp (flag, "-f")==0) {
  614    2   			get_tok (fname, fp);
  615    2   			fix_file_name (fname);
  616    2   			if (tfp=fopen (fname, "r"))
  617    2   				fclose (tfp);
  618    2   		}
  619    1   		else if (strcmp (flag, "-d")==0) {
  620    2   			get_tok (fname, fp);
  621    2   			fix_file_name (fname);
  622    2   	#ifdef	VMS
  623    2   			strcat(fname,".dir.1");
  624    2   			tfp = NULL;
  625    2   			if ((!stat(fname,&stat_buf)) &&
  626    2   			    (stat_buf.st_mode & S_IFDIR))
  627    2   				tfp = (FILE *) fname;
  628    2   	#else
  629   X    			if (tfp=(FILE *) opendir (fname))
  630   X    				closedir (tfp);
  631    2   	#endif
  632    2   		}
  633    1   		else if (isdigit(flag [0])) {
  634    2   			wc_arg = atol (flag);
  635    2   			get_tok (flag, fp);

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 8
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)

  636    2   			if (strcmp (flag, "-ne")==0) {
  637    3   				get_tok (fname, fp);
  638    3   				return ((w_cnt (fname, wc_arg)));
  639    3   			}
  640    2   			else {
  641    3   				cmd_init ();
  642    3   				return ((int) test_flag);
  643    3   			}
  644    2   		}
  645    1   		else {		
  646    2   			cmd_init ();
  647    2   			return ((int) test_flag);
  648    2   		}
  649    1   	
  650    1   	#ifdef	VMS
  651    1   		if (invert)
  652    1   			return(tfp == NULL);
  653    1   		 else	return(tfp != NULL);
  654    1   	#else
  655   X    		return ((invert)?!(tfp):tfp);
  656    1   	#endif
  657    1   	}
  658        	
  659        	
  660        	
  661        	
  662        	/*
  663        	 *	W_CNT ()	-	This part of test is a separate function
  664        	 *		'cause I don't like to nest that deep.  by the time
  665        	 *		w_cnt () has been passed control it's broken down the
  666        	 *		shar script command of the form
  667        	 *			if test 488 -ne "`wc -c < 'FileName'`"
  668        	 *		to
  669        	 *			`wc -c < 'FileName'`
  670        	 *		which is not too hard to extract the filename from
  671        	 */
  672        	
  673        	int w_cnt (name, arg)
  674        	char *name;
  675        	long  arg;
  676        	{
  677    1   	#ifdef	VMS
  678    1   		FILE		*file;
  679    1   		int		count;
  680    1   		char		buffer[255];
  681    1   	#endif
  682    1   	
  683    1   		char filename [65];
  684    1   		struct stat statbuf;
  685    1   		char *np, *index (), *rindex ();
  686    1   		np = index (name, '\'') +1;
  687    1   		*index (np, '\'') = '\0';
  688    1   		strcpy (filename, np);
  689    1   		fix_file_name (filename);
  690    1   	#ifdef	VMS
  691    1   		if ((file = fopen(filename,"r")) == NULL)
  692    1   			{

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 9
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)

  693    2   			p_error (1, "WC Can't Open '", filename, "'\n", "");
  694    2   			}
  695    1   		 else	{
  696    2   			count = 0;
  697    2   			while (fgets(buffer,sizeof(buffer),file) != 0)
  698    2   				count += strlen(buffer);
  699    2   			fclose(file);
  700    2   			if (count != arg)
  701    2   				{
  702    3   				return(1);
  703    3   				}
  704    2   			}
  705    1   	#else
  706   X    		stat (filename, &statbuf);
  707   X    		if (statbuf.st_size != arg)
  708   X    			return (1);
  709    1   	#endif
  710    1   		return (0);
  711    1   	}
  712        	
  713        	
  714        	
  715        	
  716        	/*
  717        	 *	DO_SKIP ()	-	do_skip () passes thru the input until
  718        	 *		he has determined that the command that would have
  719        	 *		been processed at this point in the stream has been
  720        	 *		flushed.
  721        	 */
  722        	 
  723        	void do_skip (fp)
  724        	FILE *fp;
  725        	{
  726    1   		char buf [256], delimiter [80], *dp;
  727    1   		int len;
  728    1   	
  729    1   		do {
  730    2   			get_tok (delimiter, fp);
  731    2   		} while (strncmp (delimiter, "<<", 2));
  732    1   		get_tok (delimiter, fp);
  733    1   		dp = delimiter;
  734    1   		len = strlen (dp);
  735    1   		while (fgets (buf, sizeof (buf), fp))
  736    1   			if (strncmp (dp, buf, len)==0)
  737    1   				break;
  738    1   		cmd_init ();
  739    1   	}
  740        	
  741        	
  742        	
  743        	
  744        	/*
  745        	 *	FIX_FILE_NAME ()	-	 does two things
  746        	 *		(1)  strips off any leading path identifiers
  747        	 *		(2)  appends the leading path header to the
  748        	 *		     filename presented to it.
  749        	 *

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 10
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)

  750        	 *	VMS :  Replaces all but the first "." with "-"
  751        	 */
  752        	 
  753        	void fix_file_name (s)
  754        	char *s;
  755        	{
  756    1   		int i;
  757    1   		char buf [65], *tp, *index (), *rindex (), *j;
  758    1   	
  759    1   		strcpy (buf, root_dir);
  760    1   	
  761    1   		if (tp=rindex (s, '/'))
  762    1   			strcat (buf, tp+1);
  763    1   		else
  764    1   			strcat (buf, s);
  765    1   		strcpy (s, buf);
  766    1   	
  767    1   	#ifdef VMS
  768    1   		if (first_period)
  769    1   			j = index (s, '.');
  770    1   		else
  771    1   			j = rindex (s, '.');
  772    1   	
  773    1   		for (i=0; i<strlen(s); i++) {
  774    2   			if ('.' == s[i])
  775    2   				s[i] = '-';
  776    2   		}
  777    1   	
  778    1   		if (j)
  779    1   			*j = '.';
  780    1   	#endif
  781    1   	
  782    1   	}


SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 11
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)

                                       +-------------+
                                       | Storage Map |
                                       +-------------+
 
 

External Declarations
---------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

<generated_name_0001>            126     8 bytes                      Structure tag
 /* No Name */                   126     32 bits                       Member (offset = 0), unsigned field
 /* No Name */                   126     32 bits                       Member (offset = 4 bytes), unsigned field
<generated_name_0002>            128     8 bytes                      Structure tag
 /* No Name */                   128     32 bits                       Member (offset = 0), unsigned field
 /* No Name */                   128     32 bits                       Member (offset = 4 bytes), unsigned field
c$v_ctypedefs                    202     1 longword      Globalvalue  Long int
decode                           529                     Extern def.  Function returning long int
dev_t                            256     1 longword                   Typedef:  pointer to char
do_cat                           373                     Extern def.  Void function
do_cd                            325                     Extern def.  Function returning long int
do_exit                          355                     Extern def.  Void function
do_mkdir                         340                     Extern def.  Function returning long int
do_sed                           419                     Extern def.  Void function
do_skip                          723                     Extern def.  Void function
do_test                          595                     Extern def.  Function returning long int
do_uudecode                      480                     Extern def.  Void function
errno                            62      1 longword      Extern       Noshare volatile long int
fclose                           138                     Extern       Function returning long int
fdopen                           134                     Extern       Function returning pointer to pointer to struct _iobuf
fflush                           168                     Extern       Function returning long int
fgetc                            140                     Extern       Function returning long int
fgetname                         130                     Extern       Function returning pointer to char
fgetpos                          128                     Extern       Function returning long int
fgets                            143                     Extern       Function returning pointer to char
FILE                             91      1 longword                   Typedef:  pointer to struct _iobuf
first_period                     295     1 longword      Extern       Long int
fix_file_name                    293                     Extern       Void function
fix_file_name                    753                     Extern def.  Void function
fopen                            132                     Extern       Function returning pointer to pointer to struct _iobuf
fprintf                          161                     Extern       Function returning long int
fputc                            165                     Extern       Function returning long int
fputs                            146                     Extern       Function returning long int
fread                            149                     Extern       Function returning long int
freopen                          136                     Extern       Function returning pointer to pointer to struct _iobuf
fscanf                           155                     Extern       Function returning long int
fseek                            170                     Extern       Function returning long int
fsetpos                          126                     Extern       Function returning long int
ftell                            172                     Extern       Function returning long int
fwrite                           152                     Extern       Function returning long int
gets                             144                     Extern       Function returning pointer to char
getw                             141                     Extern       Function returning long int
ino_t                            255     1 word                       Typedef:  unsigned short int
off_t                            254     1 longword                   Typedef:  unsigned long int
outdec                           564                     Extern def.  Function returning long int

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 12
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

printf                           162                     Extern       Function returning long int
puts                             147                     Extern       Function returning long int
putw                             166                     Extern       Function returning long int
p_error                          306                     Extern def.  Void function
rewind                           174                     Extern       Function returning long int
root_dir                         247     byte            Extern       Array of char
scanf                            156                     Extern       Function returning long int
setbuf                           180                     Extern       Void function
setvbuf                          181                     Extern       Function returning long int
sprintf                          163                     Extern       Function returning long int
sscanf                           157                     Extern       Function returning long int
stat                             257     49 bytes                     Structure tag
 st_dev                          259     1 longword                    Member (offset = 0), pointer to char
 st_ino                          260     3 words                       Member (offset = 4 bytes), array [3] of unsigned short int
 st_mode                         261     1 word                        Member (offset = 10 bytes), unsigned short int
 st_nlink                        262     1 longword                    Member (offset = 12 bytes), long int
 st_uid                          263     1 longword                    Member (offset = 16 bytes), unsigned long int
 st_gid                          264     1 word                        Member (offset = 20 bytes), unsigned short int
 st_rdev                         265     1 longword                    Member (offset = 22 bytes), pointer to char
 st_size                         266     1 longword                    Member (offset = 26 bytes), unsigned long int
 st_atime                        267     1 longword                    Member (offset = 30 bytes), unsigned long int
 st_mtime                        268     1 longword                    Member (offset = 34 bytes), unsigned long int
 st_ctime                        269     1 longword                    Member (offset = 38 bytes), unsigned long int
 st_fab_rfm                      270     1 byte                        Member (offset = 42 bytes), char
 st_fab_rat                      271     1 byte                        Member (offset = 43 bytes), char
 st_fab_fsz                      272     1 byte                        Member (offset = 44 bytes), char
 st_fab_mrs                      273     1 longword                    Member (offset = 45 bytes), unsigned long int
stderr                           92      1 longword      Extern       Noshare pointer to pointer to struct _iobuf
stdin                            92      1 longword      Extern       Noshare pointer to pointer to struct _iobuf
stdout                           92      1 longword      Extern       Noshare pointer to pointer to struct _iobuf
test_flag                        246     1 byte          Extern       Char
tmpfile                          176                     Extern       Function returning pointer to pointer to struct _iobuf
tmpnam                           178                     Extern       Function returning pointer to char
ungetc                           159                     Extern       Function returning long int
vfprintf                         183                     Extern       Function returning long int
vprintf                          184                     Extern       Function returning long int
vsprintf                         185                     Extern       Function returning long int
w_cnt                            673                     Extern def.  Function returning long int
_ctype_                          204     byte            Extern       Const array of char
_iobuf                           71      14 bytes                     Structure tag
 _cnt                            73      1 longword                    Member (offset = 0), long int
 _ptr                            74      1 longword                    Member (offset = 4 bytes), pointer to char
 _base                           75      1 longword                    Member (offset = 8 bytes), pointer to char
 _flag                           76      1 byte                        Member (offset = 12 bytes), char
 _file                           87      1 byte                        Member (offset = 13 bytes), char
 
 

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 13
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)


Function "p_error" defined at line 306
--------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

args                             308     1 longword                   Parameter # 2, pointer to char
no                               307     1 longword                   Parameter # 1, long int
tmp                              310     1 longword      Register     Pointer to pointer to char
_exit                            315                     Extern       Function returning long int
 
 

Function "do_cd" defined at line 325
------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

buf                              328     20 bytes        Auto         Array [20] of char
chdir                            330                     Extern       Function returning long int
fp                               326     1 longword                   Parameter # 1, pointer to pointer to struct _iobuf
get_tok                          329                     Extern       Function returning long int
 
 

Function "do_mkdir" defined at line 340
---------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

buf                              343     20 bytes        Auto         Array [20] of char
fp                               341     1 longword                   Parameter # 1, pointer to pointer to struct _iobuf
get_tok                          344                     Extern       Function returning long int
mkdir                            345                     Extern       Function returning long int
 
 

Function "do_exit" defined at line 355
--------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

atoi                             360                     Extern       Function returning long int
buf                              358     20 bytes        Auto         Array [20] of char
exit                             360                     Extern       Function returning long int
fp                               356     1 longword                   Parameter # 1, pointer to pointer to struct _iobuf
get_tok                          359                     Extern       Function returning long int
 
 

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 14
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)


Function "do_cat" defined at line 373
-------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

buf                              378     256 bytes       Auto         Array [256] of char
delimiter                        377     80 bytes        Auto         Array [80] of char
dp                               377     1 longword      Register     Pointer to char
fname                            377     65 bytes        Auto         Array [65] of char
fp                               374     1 longword                   Parameter # 1, pointer to pointer to struct _iobuf
f_out                            376     1 longword      Register     Pointer to pointer to struct _iobuf
get_tok                          384                     Extern       Function returning long int
len                              380     1 longword      Register     Long int
strlen                           399                     Extern       Function returning long int
strncmp                          385                     Extern       Function returning long int
tmp                              379     15 bytes        Auto         Array [15] of char
 
 

Function "do_sed" defined at line 419
-------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

buf                              424     256 bytes       Auto         Array [256] of char
delimiter                        423     80 bytes        Auto         Array [80] of char
dp                               423     1 longword      Register     Pointer to char
fname                            423     65 bytes        Auto         Array [65] of char
fp                               420     1 longword                   Parameter # 1, pointer to pointer to struct _iobuf
f_out                            422     1 longword      Register     Pointer to pointer to struct _iobuf
get_tok                          432                     Extern       Function returning long int
len                              426     1 longword      Register     Long int
nbuf                             424     1 longword      Register     Pointer to char
replace                          423     40 bytes        Auto         Array [40] of char
rlen                             426     1 longword      Register     Long int
rp                               423     1 longword      Register     Pointer to char
strchr                           429                     Extern       Function returning pointer to char
strlen                           446                     Extern       Function returning long int
strncmp                          436                     Extern       Function returning long int
tmp                              425     15 bytes        Auto         Array [15] of char
 
 

Function "do_uudecode" defined at line 480
------------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

buf                              485     256 bytes       Auto         Array [256] of char
decode                           510                     Extern       Function returning long int
delimiter                        484     80 bytes        Auto         Array [80] of char
dp                               484     1 longword      Register     Pointer to char
fname                            484     65 bytes        Auto         Array [65] of char

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 15
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

fp                               481     1 longword                   Parameter # 1, pointer to pointer to struct _iobuf
f_out                            483     1 longword      Register     Pointer to pointer to struct _iobuf
get_tok                          489                     Extern       Function returning long int
len                              486     1 longword      Register     Long int
strcmp                           499                     Extern       Function returning long int
strlen                           494                     Extern       Function returning long int
strncmp                          490                     Extern       Function returning long int
 
 

Function "decode" defined at line 529
-------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

bp                               534     1 longword      Register     Pointer to char
buf                              533     80 bytes        Auto         Array [80] of char
in                               530     1 longword                   Parameter # 1, pointer to pointer to struct _iobuf
n                                535     1 longword      Register     Long int
out                              531     1 longword                   Parameter # 2, pointer to pointer to struct _iobuf
outdec                           547                     Extern       Function returning long int
 
 

Function "outdec" defined at line 564
-------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

c1                               568     1 longword      Not Alloc.   Long int
c2                               568     1 longword      Not Alloc.   Long int
c3                               568     1 longword      Not Alloc.   Long int
f                                566     1 longword                   Parameter # 2, pointer to pointer to struct _iobuf
n                                567     1 longword                   Parameter # 3, long int
p                                565     1 longword                   Parameter # 1, pointer to char
 
 

Function "do_test" defined at line 595
--------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

atol                             634                     Extern       Function returning long int
cmd_init                         641                     Extern       Function returning long int
flag                             600     10 bytes        Auto         Array [10] of char
fname                            600     100 bytes       Auto         Array [100] of char
fp                               596     1 longword                   Parameter # 1, pointer to pointer to struct _iobuf
get_tok                          608                     Extern       Function returning long int
invert                           601     1 longword      Register     Initialized long int
stat                             625                     Extern       Function returning long int

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 16
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

stat_buf                         605     49 bytes        Auto         Struct stat
strcat                           623                     Extern       Function returning long int
strcmp                           609                     Extern       Function returning long int
tfp                              598     1 longword      Register     Pointer to pointer to struct _iobuf
wc_arg                           602     1 longword      Not Alloc.   Long int
w_cnt                            638                     Extern       Function returning long int
 
 

Function "w_cnt" defined at line 673
------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

arg                              675     1 longword                   Parameter # 2, long int
buffer                           680     255 bytes       Auto         Array [255] of char
count                            679     1 longword      Register     Long int
file                             678     1 longword      Register     Pointer to pointer to struct _iobuf
filename                         683     65 bytes        Auto         Array [65] of char
name                             674     1 longword                   Parameter # 1, pointer to char
np                               685     1 longword      Not Alloc.   Pointer to char
statbuf                          684     49 bytes        Not Alloc.   Struct stat
strchr                           685                     Extern       Function returning pointer to char
strcpy                           688                     Extern       Function returning long int
strlen                           698                     Extern       Function returning long int
strrchr                          685                     Extern       Function returning pointer to char
 
 

Function "do_skip" defined at line 723
--------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

buf                              726     256 bytes       Auto         Array [256] of char
cmd_init                         738                     Extern       Function returning long int
delimiter                        726     80 bytes        Auto         Array [80] of char
dp                               726     1 longword      Register     Pointer to char
fp                               724     1 longword                   Parameter # 1, pointer to pointer to struct _iobuf
get_tok                          730                     Extern       Function returning long int
len                              727     1 longword      Register     Long int
strlen                           734                     Extern       Function returning long int
strncmp                          731                     Extern       Function returning long int
 
 

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 17
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)


Function "fix_file_name" defined at line 753
--------------------------------------------

 Identifier Name                 Line    Size            Class        Type
 ---------------                 ----    ----            -----        ----

buf                              757     65 bytes        Auto         Array [65] of char
i                                756     1 longword      Register     Long int
j                                757     1 longword      Register     Pointer to char
s                                754     1 longword                   Parameter # 1, pointer to char
strcat                           762                     Extern       Function returning long int
strchr                           757                     Extern       Function returning pointer to char
strcpy                           759                     Extern       Function returning long int
strlen                           773                     Extern       Function returning long int
strrchr                          757                     Extern       Function returning pointer to char
tp                               757     1 longword      Not Alloc.   Pointer to char
 
 

Psect Synopsis
--------------

 Psect Name                     Allocation  Attributes
 ----------                     ----------  ----------

$CODE                           2323 bytes  Position-independent, relocatable, shareable, executable, readable
ERRNO                           4 bytes     Position-independent, overlay, relocatable, global, readable, writeable
STDIN                           4 bytes     Position-independent, overlay, relocatable, global, readable, writeable
STDOUT                          4 bytes     Position-independent, overlay, relocatable, global, readable, writeable
STDERR                          4 bytes     Position-independent, overlay, relocatable, global, readable, writeable
_CTYPE_                         0           Position-independent, overlay, relocatable, global, shareable, readable
TEST_FLAG                       1 byte      Position-independent, overlay, relocatable, global, shareable, readable, writeable
ROOT_DIR                        0           Position-independent, overlay, relocatable, global, shareable, readable, writeable
FIRST_PERIOD                    4 bytes     Position-independent, overlay, relocatable, global, shareable, readable, writeable
$CHAR_STRING_CONSTANTS          257 bytes   Position-independent, relocatable, readable, writeable
 
 

Function Definition Map
-----------------------

 Line   Name
 ----   ----

306     p_error
325     do_cd
340     do_mkdir
355     do_exit
373     do_cat
419     do_sed
480     do_uudecode
529     decode
564     outdec
595     do_test
673     w_cnt
723     do_skip

SHAR_CMD                                                        28-OCT-1988 12:15:53    VAX C      V2.3-024                 Page 18
V1.0                                                            28-OCT-1988 12:14:13    [VMSNET.DEVEL.UNSHAR.SRC]SHAR_CMD.C;4 (1)

 Line   Name
 ----   ----

753     fix_file_name
 
 
Command Line
------------
 
CC/LIST=[-.BLD]/OBJE=[-.BLD]/SHOW=(SOURCE,SYMBOLS)/DEFINE=LOG SHAR_CMD

