home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Da Capo
/
da_capo_vol1.bin
/
metatool
/
metatoolprefs2env.c
< prev
Wrap
C/C++ Source or Header
|
1995-05-15
|
2KB
|
79 lines
/* Public Domain program to read a named file, that is expected to be a
MetaTool prefs file, extract the metatypes and commands from the file,
and stuff them into environment variables of the same name as the
metatype in the ENV:MetaToolPrefs directory. I.E., given a MetaTool
prefs file like:
TEXT SYS:Utilities/MultiView
GUIDE SYS:Utilities/MultiView
HTML CLI Execute :Mosaic []
BIN SYS:Utilities/MultiView
Create the following files with contents as follows:
ENV:MetaToolPrefs/TEXT -> SYS:Utilities/MultiView
ENV:MetaToolPrefs/GUIDE -> SYS:Utilities/MultiView
ENV:MetaToolPrefs/HTML -> CLI Execute :Mosaic []
ENV:MetaToolPrefs/BIN -> SYS:Utilities/MultiView
This is primarily for the benefit of the standard Commodore installer
program, which cannot read files (stupid thing!) but can read the
contents of environment variables.
-Fred Fish
*/
#include <stdio.h>
main (argc, argv)
int argc;
char *argv[];
{
FILE *pfp, *tfp;
char linebuffer[128], envfile[128];
char *lptr;
extern int strlen (char *);
if (argc != 2)
{
fprintf (stderr, "usage: MetaToolPrefs2Env <preferences file name>\n");
exit (1);
}
pfp = fopen (argv[1], "r");
if (pfp == NULL)
{
fprintf (stderr, "%s: cannot open: ", argv[1]);
perror ("");
exit (1);
}
else
{
while (fgets (linebuffer, sizeof (linebuffer), pfp))
{
linebuffer[strlen (linebuffer) - 1] = '\000';
lptr = linebuffer;
if (*lptr == ';' || *lptr == '\000')
{
continue;
}
while (*lptr != ' ' && *lptr != '\t' && *lptr != '\000') { lptr++; }
if (*lptr != '\000')
{
*lptr++ = '\000';
while (*lptr == ' ' || *lptr == '\t') { lptr++; }
}
sprintf (envfile, "ENV:MetaToolPrefs/%s", linebuffer);
tfp = fopen (envfile, "w");
if (tfp == NULL)
{
fprintf (stderr, "%s: cannot open: ", envfile);
perror ("");
exit (1);
}
fputs (lptr, tfp);
fclose (tfp);
}
}
exit (0);
}