home *** CD-ROM | disk | FTP | other *** search
- /*
- * this driver is for the new Acorn DDE -- it assumes
- * the parameter is a fully-qualified filename. I'm
- * not allowed to release any DDE utilities yet (having
- * signed a non-disclosure agreement), but if you want
- * to use this file as a prototype for a driver you are
- * welcome to.
- */
-
-
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- #include <stdarg.h>
- #include <stdlib.h>
-
- void error(int rc) {
- fprintf(stderr, "ptc: error %d\n", rc); exit(rc);
- }
-
- int systemf(char *fmt,...)
- {
- static char comm[256];
- va_list argptr;
- int rc;
-
- va_start(argptr, fmt);
- vsprintf(comm, fmt, argptr);
- va_end(argptr);
- fprintf(stderr, "PTC: %s", comm);
- rc = (system(comm));
- fprintf(stderr, " -> %d\n", rc);
- return(rc);
- }
-
- int main(int argc, char **argv) {
- char *cp, *leaf, *ptcargsp;
- char buff[256], infile[256], outfile[256],
- outfile_c[256], outdir[256], ptcargs[256];
- int rc;
-
- if (argc != 3) error(1);
- strcpy(infile, argv[1]);
- strcpy(outfile, argv[2]);
- if (strcmp(infile, outfile) != 0) error(2);
- strcpy(buff, infile);
- leaf = buff;
- cp = strrchr(buff, '.');
- if (cp == NULL) error(3);
- *cp = '\0'; leaf = cp+1;
- cp -= 2;
- if (cp[0] == '.' && tolower(cp[1]) == 'p') {
- *cp = '\0';
- }
- strcpy(outdir, buff);
- sprintf(outfile, "%s.c.%s", outdir, leaf);
- sprintf(outfile_c, "%s.%s.c", outdir, leaf);
- ptcargsp = getenv("PTC$Args");
- if (ptcargs != NULL) {
- strcpy(ptcargs, ptcargsp);
- } else {
- strcpy(ptcargs,
- "-J$.clib,<PTC$Dir> ptc:ptcerror.o ptc:argvgt.o ptc:fopen.o ptc:getl.o");
- }
- /*fprintf(stderr, "PTC: <ptc$args> = %s\n", ptcargs);*/
- if (strcmp(leaf, "PTC") == 0) {
- sprintf(ptcargs+strlen(ptcargs), " -o %s.!RunImage", outdir);
- } else {
- sprintf(ptcargs+strlen(ptcargs), " -o %s.%s", outdir, leaf);
- }
- systemf("cdir %s.c", outdir);
- systemf("cdir %s.h", outdir);
- if ((rc = systemf("<ptc$dir>.!RunImage < %s > %s", infile, outfile)) != 0) {
- exit(rc);
- }
- systemf("<ptc$dir>.toansip %s > <ptc$dir>.temp", outfile);
- systemf("<ptc$dir>.mkptypesp -e -s -A %s", outfile);
- systemf("copy <ptc$dir>.temp %s f~q~c~vd", outfile);
- systemf("CHAIN:ptccc %s %s", outfile_c, ptcargs);
- return(0);
- }
-