[comp.periphs] CD-ROM retrieval software

davek@lakesys.UUCP (Dave Kraft) (05/26/89)

Hi,
Here's a program I wrote using Turbo C vers. 2.0 that searches for an entered
key and displays all data on that key.  The disk I'm using is the CIA's World
Factbook 1988 (from Quanta Press).  It doesn't work some of the time..  Any    
addiditions/enhancements/questions, mail them to the address below.  Flames
should be sent to /dev/null.

Hope this helps.

Dave
--cut here--

/*  Retrieval software for CD-ROMS using High Sierra format v. 0.5
 *  written by Dave k (davek@lakesys.lakesys.com or uunet!marque!lakesys!davek)
 *  Questions should be directed to the above addresses, or FidoNet addres
 *  1:154/666.0.
 */

#include <stdio.h>
#include <dir.h>
#include <conio.h>
#include <ctype.h>

FILE *f1, *fopen();

main()
{
	int c;
	char search[80], str[80];

	clrscr();
	printf("Enter string to search for:  ");
	gets(str);
	to_upper(str);
	clrscr();
    setdisk(3);        /*  Drive D:.  change this to appropriate drive */
    chdir("cia");      /*  Change to appropriate subdirectory */
    f1 = fopen("cia.cdt","r");  /* CIA Worldfactbook cardfile.  Change to */
    printf("\nSearching...");   /* appropriate file.
	while(fgets(search,(strlen(str)+1),f1) != NULL){
		to_upper(search);
		conv(search);
		if(srch(str,search) == strlen(str))
			print_info(str);
	}
	fclose(f1);
    setdisk(2);  /* Drive C:  change to appropriate drive. */
}
to_upper(s)
char s[];
{
	int i;

	for(i = 0; i < strlen(s); i++)
		s[i] = toupper(s[i]);
}
srch(s1, s2)
char s1[], s2[];
{
	int cnt=0,i;

	for(i = 0; i < strlen(s1); i++)
		if(s1[i] == s2[i])
			++cnt;
		else
			continue;
	return(cnt);
}
conv(s)
char s[];
{
	int i;

	for(i = 0; i < strlen(s); i++)
		s[i] =  toascii(s[i]);
}
print_info(s)
char s[];
{
	int c;

	clrscr();
	printf("%s",s);
	while((c = getc(f1)) != '"'){
		putchar(c);
		if(kbhit() != 0){
			clrscr();
			break;
		}
	}
}
-- 
davek@lakesys.lakesys.com
uunet!marque!lakesys!davek
------------------------------------------------------------------------------
Forgetting your superuser password is just God's way of saying "BOOGA, BOOGA!"

blob@apple.com (Brian Bechtel) (05/26/89)

In article <649@lakesys.UUCP> davek@lakesys.UUCP (Dave Kraft) writes:
> Here's a program I wrote using Turbo C vers. 2.0 that searches for an 
> entered key and displays all data on that key.  The disk I'm using is 
> the CIA's World Factbook 1988 (from Quanta Press).  It doesn't work 
> some of the time..  Any addiditions/enhancements/questions, mail them
>  to the address below. 

Note that this program has nothing at all to do with the High Sierra 
format; Dave is accessing files on a disk.  The disk happens to be in High 
Sierra format, but if you copied the file in question to a large enough 
hard disk, this program would work unaltered.  Dave's program is very
dependent upon the CIA's World Factbook 1988 and not at all on High 
Sierra.

High Sierra describes the volume format, not the data format. Microsoft provides transparent system support via the CD-ROM extensions so that a
High Sierra CD looks just like a regular disk.  Your programs work the
same on a High Sierra CD as they would on any other disk.

This is also true for Apple's efforts on the Macintosh and Apple IIgs and 
Digital's efforts under VMS and for other companies on other operating 
systems.  The operating system vendors supply software so that you, the 
application writer, don't have to worry about the High Sierra format.

The only people out there who have to worry about the High Sierra format 
are those trying to write pre-mastering software to press a CD, those 
trying to press a CD using such software, and the few operating system 
people trying to provide file system support.

--Brian Bechtel     blob@apple.com     "My opinion, not Apple's"