|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T o
Length: 2860 (0xb2c)
Types: TextFile
Names: »offconv.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
└─⟦this⟧ »EUUGD11/euug-87hel/sec1/offconv/offconv.c«
/*
*
* Name
* offconv
*
* Description
* Convert off (Object File Format) files from ASCII to binary
* and vice versa
*
* Author
* Randi J. Rost
* Digital Equipment Corp.
* Workstation Systems Engineering
* Palo Alto, CA
*
* Diagnostics
* Returns -1 if it blows up for any reason
*
* History
* Randi J. Rost 14-Nov-1986 created
*
*/
#include <stdio.h>
#include "off.h"
main(argc, argv)
int argc;
char *argv[];
{
OFFObjDesc obj;
char inbase[80], outbase[80];
char indir[80], outdir[80];
char inext[80], outext[80];
char newname[80];
int i;
int first = 1;
int toascii = 1;
int type;
char dir[80], base[80], ext[80];
OFFProperty *pProp;
if ((argc < 3) || (argc > 4))
{
fprintf(stderr, "usage: %s [-ab] inobj outobj\n", argv[0]);
exit(-1);
}
if (argv[1][0] == '-')
{
switch (argv[1][1])
{
case 'a': toascii = 1; first = 2; break;
case 'b': toascii = 0; first = 2; break;
default:
fprintf(stderr, "Unknown option '%s'\n", argv[1]);
fprintf(stderr, "usage: %s [-ab] inobj [outobj]\n", argv[0]);
exit(-1);
}
}
OFFReadObj(&obj, argv[first]);
basename(argv[first], indir, inbase, inext);
basename(argv[first + 1], outdir, outbase, outext);
pProp = obj.FirstProp;
while (pProp != NULL)
{
if (pProp->PropFileName != NULL)
{
basename(pProp->PropFileName, dir, base, ext);
if (toascii)
{
strcpy(newname, outbase);
strcat(newname, ".");
/* The following kludge will not work if there are valid */
/* ASCII file extensions that begin with 'b'. Right now */
/* we assume that if the extension begins with 'b', the */
/* file is in binary. */
if (ext[0] == 'b')
strcat(newname, &(ext[1]));
else
strcat(newname, ext);
}
else
{
strcpy(newname, outbase);
strcat(newname, ".b");
strcat(newname, ext);
}
strcpy(pProp->PropFileName, newname);
}
pProp = pProp->NextProp;
}
strcat(outbase, ".obj");
if (toascii)
type = OFF_ASCII;
else
type = OFF_BINARY;
/* OFFWriteObj(&obj, argv[first + 1], outdir, type);*/
OFFWriteObj(&obj, argv[first + 1], "/", type);
}
basename(fullname, dir, base, ext)
char *fullname;
char *dir;
char *base;
char *ext;
{
int i, j;
i = strlen(fullname);
while ((i >= 0) && (fullname[i] != '.')) i--;
if (i < 0)
{ i = 0; ext[0] = '\0'; }
else
strcpy(ext, &(fullname[i + 1]));
j = i;
while ((j >= 0) && (fullname[j] != '/')) j--;
if (j < 0)
{ dir[0] = '\0'; }
else
{
strncpy(dir, fullname, j);
dir[j] = '\0';
}
if ((j <= 0) && (i == 0))
strcpy(base, fullname);
else
{
strncpy(base, &(fullname[j + 1]), i - j - 1);
base[i - j - 1] = '\0';
}
}