Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOIRLAB: Add SGI metacode file for translator debugging #407

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion dev/graphcap
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,10 @@ uhplj|UNIX generic interface to Hewlett-Packard LaserJet IIIsi:\
:DD=uhplj,tmp$sgk,!{ sgidispatch sgi2uhplj $F \
-l$(XO) -b$(YO) -w$(PX) -h$(PY) $F | lpr ; rm $F; }&:\
:tc=sgi_hplaserjet3:
sgidbg|DEBUG INTERFACE:\
:XO#300:XW#1950:YO#1000:YW#1300:PW#1.2:\
:DD=eps,tmp$sgk,!{ sgidebug sgi2ueps $F -l$(XO) \
-w$(XW) -b$(YO) -h$(YW) -p$(PW) > sgi$$.eps; rm $F; }&:tc=sgi_apl:
uepsf|ueps|Encapsulated Postscript file (portrait) UNIX:\
:XO#300:XW#1950:YO#1000:YW#1300:PW#1.2:\
:DD=eps,tmp$sgk,!{ sgidispatch sgi2ueps $F -l$(XO) \
Expand Down Expand Up @@ -543,7 +547,6 @@ sgi_image_format|Generic raster file format specification:\
:ar#.75:xr#640:yr#480:PX#640:PY#480:XW#640:YW#480:\
:BI:MF#1:YF:NB#8:LO#1:LS#0:XO#0:YO#0:


# The following 2 entries submitted by Joe Harrington, MIT Planetary
# Science Group <jh@athena.mit.edu>. The first entry writes a PostScript
# file in /tmp. The second entry spools PostScript to the UNIX default
Expand Down
1 change: 1 addition & 0 deletions test/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ host$bin/sgi2uimp.e
host$bin/sgi2uptx.e
host$bin/sgi2uqms.e
host$bin/sgi2xbm.e
host$bin/sgidebug.e
host$bin/sgidispatch.e
host$bin/wtar.e
host$bin/xc.e
Expand Down
2 changes: 1 addition & 1 deletion unix/gdev/sgidev/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
EXE := sgidispatch.e sgi2uimp.e sgi2uapl.e sgi2uqms.e sgi2uptx.e \
EXE := sgidispatch.e sgi2uimp.e sgi2uapl.e sgi2uqms.e sgi2uptx.e sgidebug.e \
sgi2uhplj.e sgi2uhpgl.e sgi2ueps.e sgi2gif.e sgi2xbm.e sgi2svg.e

%.e: sgiUtil.o %.o
Expand Down
211 changes: 211 additions & 0 deletions unix/gdev/sgidev/sgidebug.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define import_spp
#define import_error
#define import_kernel
#define import_knames
#include <iraf.h>


/*
* SGIDEBUG.C -- Determine pathname to the executable for the named SGI
* translator, and execute the translator. Pass all command line arguments
* to the child, which also inherits stdin, stdout, and stderr.
*
* NOTE: This is the debug version of the SGIDISPATCH command.
*
* Usage: sgidebug translator [args]
*/

#define DEF_HOST "unix" /* default host system */
#define F_OK 0 /* access mode `file exists' */
#ifndef X_OK
#define X_OK 1 /* access mode `executable' */
#endif

FILE *dbg = (FILE *) NULL;

char *irafpath (char *path);


/* MAIN -- Main entry point for SGIDISPATCH.
*/
int
main (int argc, char *argv[])
{
char tpath[SZ_PATHNAME+1];
char translator[SZ_PATHNAME+1];
int ip;

/* Do nothing if called with no arguments.
*/
if (argc < 2)
exit (OSOK);

if ((dbg = fopen ("/tmp/sgidbg", "w")) == (FILE *) NULL)
dbg = stderr;

/* Construct pathname to translator.
*/
strcpy (translator, argv[1]);
ip = strlen (translator);
if (strcmp (&translator[ip], ".e") != 0)
strcat (translator, ".e");
sprintf (tpath, "%s", irafpath(translator));
fprintf (dbg, "sgidispatch path: %s\n", tpath);

if (access (tpath, X_OK) == ERR) {
fprintf (stderr, "Fatal (sgidispatch): unable to access SGI");
fprintf (stderr, " translator `%s'\n", tpath);
fflush (stderr);
exit (OSOK+1);
}

/* Set up i/o for translator and attempt to fork.
*/
fprintf (dbg, "Calling translator....\n");
fclose (dbg);

argv[argc] = 0;
execv (tpath, &argv[1]);
fprintf (stderr, "Fatal (sgidispatch): unable to execv(%s, ...)\n",
tpath);
fflush (stderr);
exit (OSOK+1);
}


#define SZ_ULIBSTR 512
#define ULIB "IRAFULIB"

/* VOS Prototypes.
*/
extern int ZGTENV (PKCHAR *envvar, PKCHAR *outstr, XINT *maxch, XINT *status);


/* IRAFPATH -- Determine the pathname of the given IRAF library file. If the
* file is found the full pathname is returned, else the given filename is
* returned. A list of user directories is first searched if defined, followed
* by the IRAF system directories, allowing users to have custom versions of
* the system files, e.g., for testing purposes.
*/
char *
irafpath (char *fname)
/* simple filename, no dirs */
{
static char pathname[SZ_PATHNAME+1];
PKCHAR ulibs[SZ_ULIBSTR+1];
PKCHAR hostdir[SZ_LINE+1];
PKCHAR irafdir[SZ_LINE+1];
PKCHAR ldir[SZ_FNAME+1];
XINT sz_ulibs=SZ_ULIBSTR;
XINT x_maxch=SZ_LINE, x_status;
char *ip, *op, *irafarch;

/* Search any user libraries first. */
strcpy ((char *)ldir, ULIB);
(void) ZGTENV (ldir, ulibs, &sz_ulibs, &x_status);
if (x_status > 0)
for (ip=(char *)ulibs; *ip; ) {
/* Get next user directory pathname. */
while (isspace (*ip))
ip++;
if (!*ip)
break;
for (op=pathname; *ip && !isspace(*ip); )
*op++ = *ip++;
if (*(op-1) != '/')
*op++ = '/';
*op = '\0';

strcat (pathname, fname);
fprintf (dbg, "irafpath IRAFULIB: %s\n", pathname);
if (access (pathname, 0) == 0)
return (pathname);
}

/* Get the root pathnames. */
strcpy ((char *)ldir, "host");
ZGTENV (ldir, hostdir, &x_maxch, &x_status);
fprintf (dbg, "irafpath host(%ld): %s\n", x_status, (char *)hostdir);
if (x_status <= 0)
return (fname);
strcpy ((char *)ldir, "iraf");
ZGTENV (ldir, irafdir, &x_maxch, &x_status);
fprintf (dbg, "irafpath iraf(%ld): %s\n", x_status, (char *)irafdir);
if (x_status <= 0)
return (fname);

/* Look first in HBIN. Use IRAFARCH if defined. */
if ( (irafarch = getenv("IRAFARCH"))
&& (strlen(irafarch) > 0) ) {
strcpy (pathname, (char *)hostdir);
strcat (pathname, "bin.");
strcat (pathname, irafarch);
strcat (pathname, "/");
strcat (pathname, fname);
if (access (pathname, 0) == 0)
fprintf (dbg, "irafpath returning: %s\n", pathname);
return (pathname);
}

/* Look in HBIN. */
strcpy (pathname, (char *)hostdir);
strcat (pathname, "bin/");
strcat (pathname, fname);
if (access (pathname, 0) == 0) {
fprintf (dbg, "irafpath returning: %s\n", pathname);
return (pathname);
}

/* Try HLIB */
strcpy (pathname, (char *)hostdir);
strcat (pathname, "hlib/");
strcat (pathname, fname);
fprintf (dbg, "irafpath HLIB: %s\n", pathname);
if (access (pathname, 0) == 0) {
fprintf (dbg, "irafpath returning: %s\n", pathname);
return (pathname);
}

/* Try BIN - use IRAFARCH if defined. */
if ( (irafarch = getenv("IRAFARCH"))
&& (strlen(irafarch) > 0) ) {
strcpy (pathname, (char *)irafdir);
strcat (pathname, "bin.");
strcat (pathname, irafarch);
strcat (pathname, "/");
strcat (pathname, fname);
if (access (pathname, 0) == 0)
return (pathname);
}

/* Try BIN. */
strcpy (pathname, (char *)irafdir);
strcat (pathname, "bin/");
strcat (pathname, fname);
fprintf (dbg, "irafpath BIN: %s\n", pathname);
if (access (pathname, 0) == 0) {
fprintf (dbg, "irafpath returning: %s\n", pathname);
return (pathname);
}

/* Try LIB */
strcpy (pathname, (char *)irafdir);
strcat (pathname, "lib/");
strcat (pathname, fname);
fprintf (dbg, "irafpath LIB: %s\n", pathname);
if (access (pathname, 0) == 0) {
fprintf (dbg, "irafpath returning: %s\n", pathname);
return (pathname);
}

fprintf (dbg, "irafpath default returning: %s\n", fname);
return (fname);
}