Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : IMG2DB.ZIP
Filename : IMG2DB.C

 
Output of file : IMG2DB.C contained in archive : IMG2DB.ZIP
/*
* img2db.c process save screen LS/2000 file
* (c) 1988, GMUtant Software
* Fenwick Library, George Mason University
*/

#include
#include
#include
#include

int i,j,k,v;
char line[MAX];
char stringout[MAX];

char call[MAX];
char auth[MAX];
char titl[MAX];
char publ[MAX];
char subj[MAX];

FILE *infile,*outfile;

main(argc,argv)
int argc;
char *argv[];
{
if (argc < 2)
{
printf("IMG2DB.EXE (c) 1988 GMUtant Software\n");
printf("Usage: IMG2DB InputFileName OutputFileName \n\n");
printf("This utility processes save screen files from the LS/2000\n");
printf("system. It selects from saved MARC FORMAT screen images\n");
printf("the following fields: 050 100 245 260 and 650\n");
printf("Subfield codes (a, b, c, x) are removed.\n");
printf("Note: Only one line of text per tag is extracted.\n");
exit(0);
}

if (!(infile = fopen(argv[1],"r"))) {
printf("Error. Can not find input file %s\n",argv[1]);
exit(0);
}

if (!(outfile = fopen(argv[2],"a"))) {
printf("Error. Can not open output file: %s\n",argv[2]);
exit(0);
}

printf("Working...");

while (fgets(line,MAX,infile) != NULL) {

if (str_index(line,"050 ") != -1) {
strcpy(stringout,line);
remove_substr(stringout,0,16);
zap_subs(stringout);
strcpy(call,stringout);
}

if (str_index(line,"100 ") != -1) {
strcpy(stringout,line);
remove_substr(stringout,0,16);
zap_subs(stringout);
strcpy(auth,stringout);
}

if (str_index(line,"245 ") != -1) {
strcpy(stringout,line);
remove_substr(stringout,0,16);
zap_subs(stringout);
strcpy(titl,stringout);
}

if (str_index(line,"260 ") != -1) {
strcpy(stringout,line);
remove_substr(stringout,0,16);
zap_subs(stringout);
strcpy(publ,stringout);
}

if (str_index(line,"650 ") != -1) {
strcpy(stringout,line);
remove_substr(stringout,0,16);
zap_subs(stringout);
strcpy(subj,stringout);
}

if (str_index(line,"Enter ^ to exit, /F") != -1) {
fputs(call,outfile);
fputs(auth,outfile);
fputs(titl,outfile);
fputs(publ,outfile);
fputs(subj,outfile);
fputs(" \n",outfile);
}

}

printf("Done. Converted file is: %s ",argv[2]);

} /* end of main */


int zap_subs(string) /* remove subfield codes */
char string[];
{
int v;
v = str_index(stringout," a ");
remove_substr(stringout,v,3);
v = str_index(stringout," b ");
remove_substr(stringout,v,3);
v = str_index(stringout," c ");
remove_substr(stringout,v,3);
v = str_index(stringout," x ");
remove_substr(stringout,v,3);
return;
}


/* str_index(s1,substring) returns location of substring in string */

str_index(string,substring)
char string[];
char substring[];
{
int i,j,k=0;

for(i=0;string[i] != NULL;i++)
for (j=i,k=0;substring[k] == string[j];k++,j++)
if (substring[k+1] == NULL)
return(i); /* found */
return(-1); /* not found */
}


remove_substr(string,first,num_char) /* remove substring at 1st char, # chars
*/
char string[];
int first;
int num_char;
{
int length; /* length of string */
register int index1;
int index2;

length = strlen(string);

if (first >= length || first < 0)
return (-1);
if (first + num_char <= length)
index2 = first+num_char;
else
index2 = length;

for (index1 = first;string[index1] = string[index2];index1++)
index2++;

} /* end of remove_substr() */



/* end of IMG2DB.C */


This version (still in development) doesn't make a dbase ready
file. Instead, it currently produces this:
GN316 .G43 1983
Geertz, Clifford and his merry men.
Local knowledge : further essays in interpretive
New York : Basic Books, c1983.
Ethnology Addresses, essays, lectures.

GN316 .G43 1983
Geertz, Clifford. CITE 2
Local knowledge : further essays in interpretive
New York : Basic Books, c1983.
Ethnology Addresses, essays, lectures.

GN316 .G43 1983
Geertz, Clifford.
More Local knowledge : further essays in interpretive
New York : Basic Books, c1983.
Ethnology Addresses, essays, lectures.



  3 Responses to “Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : IMG2DB.ZIP
Filename : IMG2DB.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/