Software not on 3b1

Bill Mayhew wtm at neoucom.UUCP
Sun Apr 17 00:52:02 AEST 1988


<< missing strings and calendar >>

Hi,

Check out the Korn shell.  "strings" is one of the keywords
recognized by the shell, but it doesn't seem to exactly work the
way it should.  Oh well.  Must be another one of those kludges.

Below, I have attached a short c progam that is fairly analogous to
the Unix strings program that comes with BSD.  It was derived
separately by Jeff Friedl and myself, so I don't think it violates
any copyrights, as we have not seen the source.

As for calendar, I'm working on it.  Basically you need to write a
little bit of code that can generate a regular expression based on
the date (accounting for weekends, of course) that you feed to
egrep along with your calendar database.  My program ain't pretty,
so I don't want to post it yet.  I wrote a bourne shell procedure
that runs at 4:00 am everyday to egrep calendars for all the users
on my system by pulling names from /etc/passwd.  One thing that I
added is a #include directive (that is not on Sys V, but I think
Berkeley has it) so that work groups can share a common calendar.


Sorry to post source here, but our vax is braindamaged about
moderated gourps.  This is pretty short anyway:

----------------------------cut for strings.c----------------------

/* Bill Mayhew (impulse!wtm)
 * Jeff Friedl (location currently not known)
 * strings
 * usage: stings file  (finds ascii strings in files of any type)
 * on 3b1 compile with "make strings; strip strings"
 * No warranty expressed or implied...
 */

#include <fcntl.h>
#include <stdio.h>


main(argc,argv)
int	argc;
char	*argv[];
{
	int 	num, length=256, i;
	char 	c,str[100], buf[256];
	FILE 	*out;
	int	in;

	if (argc<2) {
		printf("Usage: %s file [ file ]\n",argv[0]);
		exit(-1);
		}

	if (argc>=2) {
		if ( (in=open(argv[1],O_RDONLY,0644))==-1) {
			perror(argv[1]);
			exit(-1);
			}
		}

	if (argc>=3) {
		if ( (out=fopen(argv[2],"w"))==NULL) {
			perror(argv[2]);
			exit(-1);
			}
		}
	else {
		out=stdout;
		}



	while(length==256) {
	    length=read(in,&buf[0],256);
	    for(i=0;i<length;i++) {
        	if ( (buf[i] >= ' ') && ( buf[i] <= '~' ) ) {
         		str[num++] = buf[i];
       			}
        	else {
        		if (num > 5 ) {
        			str[num] = '\0' ;
      				fprintf(out,"%s\n",str);
        			}
             		num = 0 ;
       			}
	    }
      	}
      	if (num > 5)
      	{
      		str[num] = '\0' ;
            	fprintf(out,"%s\n",str);
      	}
}



More information about the Comp.sys.att mailing list