#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'args.c' <<'END_OF_FILE' X/* ARGS -- Test the command line argument interface. X * X * usage: args [arg1 [arg2 ...]] X * ------------------------------------------------------------------------ X */ X main() /* program args */ X X{ X char argstr[80]; int nargs, ier, i; X X/* --- Test raw command line access. */ X clrawc (argstr, &ier); X if (ier != 0) X printf ("clrawc returns status %d\n", ier); X else X printf ("clrawc: %s\n", argstr); X X/* --- Test parsed command line access. */ X clnarg (&nargs); X printf ("nargs = %d\n", nargs); X X for (i=1; i <= nargs; i++) { X clargc (i, argstr, &ier); X if (ier != 0) X printf ("unexpected error %d\n", ier); X else X printf ("%d, %s\n", i, argstr); X } X} END_OF_FILE if test 680 -ne `wc -c <'args.c'`; then echo shar: \"'args.c'\" unpacked with wrong size! fi # end of 'args.c' fi if test -f 'imcopy.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'imcopy.c'\" else echo shar: Extracting \"'imcopy.c'\" \(2067 characters\) sed "s/^X//" >'imcopy.c' <<'END_OF_FILE' X/* IMCOPY -- Copy an image of up to 2048 pixels per line. Works for images of X * up to three dimensions with a pixel type of either short or real. X * X * usage: imcopy oldimage newimage X * ---------------------------------------------------------------------------- X */ X X main () /* program imcopy */ X X{ X float rpix[2048]; X short spix[2048]; X char oimage[80], nimage[80], errmsg[80]; X int ncols, nlines, nbands, j, k, oim, nim; X int ier, axlen[7], naxis, pixtype, nargs; X X /* --- Get command line arguments.*/ X clnarg (&nargs); X if (nargs == 2) { X clargc (1, oimage, &ier); X if (ier != 0) X goto error; X clargc (2, nimage, &ier); X if (ier != 0) X goto error; X } else { X printf ("input image: "); X scanf ("%s", oimage); X printf ("output image: "); X scanf ("%s", nimage); X } X X/* --- Open the input image.*/ X imopen (oimage, 1, &oim, &ier); X if (ier != 0) X goto error; X X/* --- Create a new output image with the same header and size as the X * input image. X */ X imopnc (nimage, oim, &nim, &ier); X if (ier != 0) X goto error; X X/* --- Determine the size and pixel type of the image being copied. */ X imgsiz (oim, axlen, &naxis, &pixtype, &ier); X if (ier != 0) X goto error; X ncols = axlen[0]; X nlines = axlen[1]; X nbands = axlen[2]; X X/* --- Copy the image. */ X if (pixtype == 3) { X for (k=1; k <= nbands; k++) { X for (j=1; j <= nlines; j++) { X imgl3s (oim, spix, j, k, &ier); X if (ier != 0) X goto error; X impl3s (nim, spix, j, k, &ier); X if (ier != 0) X goto error; X } X } X } else { X for (k=1; k <= nbands; k++) { X for (j=1; j <= nlines; j++) { X imgl3r (oim, rpix, j, k, &ier); X if (ier != 0 ) X goto error; X impl3r (nim, rpix, j, k, &ier); X if (ier != 0) X goto error; X } X } X } X X/* --- Clean up. */ X imclos (oim, &ier); X if (ier != 0) X goto error; X imclos (nim, &ier); X if (ier != 0) X goto error; X else X goto noerror; X X/* -- Error actions. */ error: imemsg (ier, errmsg); X printf ("%s\n", errmsg); noerror: X ; X} END_OF_FILE if test 2067 -ne `wc -c <'imcopy.c'`; then echo shar: \"'imcopy.c'\" unpacked with wrong size! fi # end of 'imcopy.c' fi if test -f 'imdel.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'imdel.c'\" else echo shar: Extracting \"'imdel.c'\" \(583 characters\) sed "s/^X//" >'imdel.c' <<'END_OF_FILE' X/* IMDEL -- Delete an image. X * X * usage: imdel imagename X * ---------------------------------------------------------------------- X */ X main () /* program imdel */ X X{ X int ier; X char image[80], errmsg[80]; X X/* --- Get the name of the image to be deleted. */ X clargc (1, image, &ier); X if (ier != 0) { X printf ("enter image name: "); X scanf ("%s", image); X } X X/* --- Delete the image. */ X imdele (image, &ier); X if (ier != 0) X goto error; X else X goto noerror; X X/* --- Error exit. */ error: imemsg (ier, errmsg); X printf ("Error: %s\n", errmsg); noerror: X ; X X} END_OF_FILE if test 583 -ne `wc -c <'imdel.c'`; then echo shar: \"'imdel.c'\" unpacked with wrong size! fi # end of 'imdel.c' fi if test -f 'imren.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'imren.c'\" else echo shar: Extracting \"'imren.c'\" \(828 characters\) sed "s/^X//" >'imren.c' <<'END_OF_FILE' X/* IMREN -- Rename an image. X * X * usage: imren oldname newname X * ---------------------------------------------------------------------- X */ X main () /* program imren */ X X{ X int nargs, ier; char oname[80], nname[80], errmsg[80]; X X/* --- Get the old and new names of the image to be renamed. */ X clnarg (&nargs); X if (nargs >= 2) { X clargc (1, oname, &ier); X if (ier != 0) X goto error; X clargc (2, nname, &ier); X if (ier != 0) X goto error; X } else { X printf ("enter old image name: "); X scanf ("%s", oname); X printf ("enter new image name: "); X scanf ("%s", nname); X } X X/* --- Rename the image. */ X imrnam (oname, nname, &ier); X if (ier != 0) X goto error; X else X goto noerror; X X/* --- Error exit. */ error: imemsg (ier, errmsg); X printf ("Error: %s\n", errmsg); noerror: X ; X} END_OF_FILE if test 828 -ne `wc -c <'imren.c'`; then echo shar: \"'imren.c'\" unpacked with wrong size! fi # end of 'imren.c' fi if test -f 'keyw.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'keyw.c'\" else echo shar: Extracting \"'keyw.c'\" \(2977 characters\) sed "s/^X//" >'keyw.c' <<'END_OF_FILE' X/* KEYW -- Test the image header get/put interface routines. X * X * usage: keyw imagename X * ---------------------------------------------------------------------------- X */ X X# include X main() /* program keyw */ X X{ X char image[80], errmsg[80], valstr[80], commnt[80], keywrd[8], option[8]; int ncols, nlines, ival, dtype, im, ier, axlen[7], naxis; float rval; X X/* --- Get image name. */ X clargc (1, image, &ier); X if (ier != 0) { X printf ("enter image name: "); X scanf ("%s", image); X } X X/* --- Open the image. */ X imopen (image, 3, &im, &ier); X if (ier != 0) X goto error; X imgsiz (im, axlen, &naxis, &dtype, &ier); X if (ier != 0) X goto error; X X ncols = axlen[0]; X nlines = axlen[1]; X X/* --- Interpreter loop. */ nextcmd: X printf ("enter command (quit,gkw[cir],pkw[cir],addk,delk): "); X scanf ("%s", option); X X if (strcmp (option, "pkwc") == 0) { X printf ("keyword name: "); X scanf ("%s", keywrd); X printf ("value: "); X scanf ("%s", valstr); X impkwc (im, keywrd, valstr, &ier); X if (ier != 0) X goto error; X goto nextcmd; X } X X else if (strcmp (option, "pkwi") == 0) { X printf ("keyword name: "); X scanf ("%s", keywrd); X printf ("value: "); X scanf ("%d", &ival); X impkwi (im, keywrd, ival, &ier); X if (ier != 0) X goto error; X goto nextcmd; X } X X else if (strcmp (option, "pkwr") == 0) { X printf ("keyword name: "); X scanf ("%s", keywrd); X printf ("value: "); X scanf ("%f", &rval); X impkwr (im, keywrd, rval, &ier); X if (ier != 0) X goto error; X goto nextcmd; X } X X else if (strcmp (option, "gkwc") == 0) { X printf ("keyword name: "); X scanf ("%s", keywrd); X imgkwc (im, keywrd, valstr, &ier); X if (ier != 0) X goto error; X printf ("value %s\n", valstr); X goto nextcmd; X } X X else if (strcmp (option, "gkwi") == 0) { X printf ("keyword name: "); X scanf ("%s", keywrd); X imgkwi (im, keywrd, &ival, &ier); X if (ier != 0) X goto error; X printf ("value %d\n", ival); X goto nextcmd; X } X X else if (strcmp (option, "gkwr") == 0) { X printf ("keyword name: "); X scanf ("%s", keywrd); X imgkwr (im, keywrd, &rval, &ier); X if (ier != 0) X goto error; X printf ("value %f\n", rval); X goto nextcmd; X } X X else if (strcmp (option, "addk") == 0) { X printf ("keyword name: "); X scanf ("%s", keywrd); X printf ("keyword datatype: "); X scanf ("%d", &dtype); X printf ("comment field : "); X scanf ("%s", commnt); X imaddk (im, keywrd, dtype, commnt, &ier); X if (ier != 0) X goto error; X goto nextcmd; X } X X else if (strcmp (option, "delk") == 0) { X printf ("keyword name: "); X scanf ("%s", keywrd); X imdelk (im, keywrd, &ier); X if (ier != 0) X goto error; X goto nextcmd; X } X X/* --- Clean up. */ X imclos (im, &ier); X if (ier != 0) X goto error; X else X goto noerror; X error: X imemsg (ier, errmsg); X printf ("Error: %s\n", errmsg); noerror: X ; X} END_OF_FILE if test 2977 -ne `wc -c <'keyw.c'`; then echo shar: \"'keyw.c'\" unpacked with wrong size! fi # end of 'keyw.c' fi if test -f 'minmax.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'minmax.c'\" else echo shar: Extracting \"'minmax.c'\" \(1633 characters\) sed "s/^X//" >'minmax.c' <<'END_OF_FILE' X/* MINMAX -- Compute the minimum and maximum pixel values in an image. X * The new values are printed as well as updated in the image header. X * X * usage: minmax image X * ---------------------------------------------------------------------- X */ X X#define max(a,b) ((a) > (b) ? (a) : (b)) X#define min(a,b) ((a) < (b) ? (a) : (b)) X main () /* program minmax*/ X X{ X char image[80], errmsg[80]; X float pix[8192], dmin, dmax, vmin, vmax; X int im, axlen[7], naxis, dtype, ier, j; X X/* --- Get image name. */ X clargc (1, image, &ier); X if (ier != 0) { X printf ("Enter image name: "); X scanf ("%s", image); X } X X/* --- Open the image for readwrite access (we need to update the header). */ X imopen (image, 3, &im, &ier); X if (ier != 0) X goto error; X imgsiz (im, axlen, &naxis, &dtype, &ier); X if (ier != 0) X goto error; X X/* --- Read through the image and compute the limiting pixel values. */ X for (j=1; j <= axlen[1]; j++) { X /*imgl2r (im, pix, j, &ier);*/ X imgl1r (im, pix, &ier); X if (ier != 0) X goto error; X alimr_ (pix, &axlen[0], &vmin, &vmax); X if (j == 1) { X dmin = vmin; X dmax = vmax; X } else { X dmin = min (dmin, vmin); X dmax = max (dmax, vmax); X } X } X X/* --- Update the image header. */ X impkwr (im, "datamin", dmin, &ier); X if (ier != 0) X goto error; X impkwr (im, "datamax", dmax, &ier); X if (ier != 0) X goto error; X X/* --- Clean up. */ X imclos (im, &ier); X if (ier != 0) X goto error; X printf ("%20s: %12.5g %12.5g\n", image, dmin, dmax); X goto noerror; X X/* --- Error exit. */ error: X imemsg (ier, errmsg); X printf ("Error: %s\n", errmsg); noerror: X ; X} END_OF_FILE if test 1633 -ne `wc -c <'minmax.c'`; then echo shar: \"'minmax.c'\" unpacked with wrong size! fi # end of 'minmax.c' fi if test -f 'mkim.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mkim.c'\" else echo shar: Extracting \"'mkim.c'\" \(2034 characters\) sed "s/^X//" >'mkim.c' <<'END_OF_FILE' X/* MKIM -- Make a two dimensional test image of type short or real. The pixel X * values go 1, 2, 3, etc. in storage order. X * X * usage: mkim image ncols nlines [dtype] X * X * The data type defaults to type short if not specified on the command line. X * ---------------------------------------------------------------------------- X */ X main () /* program mkim */ X X{ X char image[80], errmsg[80], pixdir[80]; X int nlines, ncols, i, j; X int im, ier, axlen[7], naxis, dtype; X float pix[8192]; X char str[80]; X float tr; X double td; X X /* --- Get image name. */ X clargc (1, image, &ier); X if (ier != 0) { X printf ("enter image name: "); X scanf ("%s", image); X } X X /* --- Get image size. */ X clargi (2, &ncols, &ier); X if (ier != 0) { X printf ("ncols: "); X scanf ("%d", &ncols); X } X clargi (3, &nlines, &ier); X if (ier != 0) { X printf ("nlines: "); X scanf ("%d", &nlines); X } X X /* --- Get pixel datatype. */ X clargi (4, &dtype, &ier); X if (ier != 0) X dtype = 3; X X /* --- Get pixel directory (optional). */ X clargc (5, pixdir, &ier); X if (ier == 0) X imsdir (pixdir); X X axlen[0] = ncols; X axlen[1] = nlines; X naxis = 2; X X/* --- Create the image. */ X imcrea (image, axlen, naxis, dtype, &ier); X if (ier != 0) X goto error; X X/* --- Open the image for writing, and write the data. */ X imopen (image, 3, &im, &ier); X if (ier != 0) X goto error; X X for (j=1; j<=nlines; j++) { X for (i=1; i<=ncols; i++) X pix[i-1] = j * ncols + i; X impl2r (im, pix, j, &ier); X if (ier != 0) X goto error; X } X X/* --- Write in Rick Fisher's keywords. */ X X i = 0; X sprintf(str, "TCAL%d", i+1); X tr = 500.0; X imakwr(im, str, tr, "", &ier); X strcat(str, "X"); X imakwr_(&im, str, &tr, "", &ier, strlen(str), strlen("")); X strcat(str, "X"); X td = tr; X imakwd(im, str, tr, "", &ier); X X/* --- Close the image and quit. */ X imclos (im, &ier); X if (ier != 0) X goto error; X else X goto noerror; X X/* --- Error exit. */ error: X imemsg (ier, errmsg); X printf ("Error: %s\n", errmsg); noerror: X ; X} END_OF_FILE if test 2034 -ne `wc -c <'mkim.c'`; then echo shar: \"'mkim.c'\" unpacked with wrong size! fi # end of 'mkim.c' fi if test -f 'mkimx.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mkimx.c'\" else echo shar: Extracting \"'mkimx.c'\" \(1725 characters\) sed "s/^X//" >'mkimx.c' <<'END_OF_FILE' X/* MKIM -- Make a two dimensional test image of type short or real. The pixel X * values go 1, 2, 3, etc. in storage order. X * X * usage: mkim image ncols nlines [dtype] X * X * The data type defaults to type short if not specified on the command line. X * ---------------------------------------------------------------------------- X */ X main () /* program mkim */ X X{ X char image[80], pixdir[80], errmsg[80]; X int nlines, ncols, i, j; X int im, ier, axlen[7], naxis, dtype; X float pix[8192]; X X /* --- Get image name. */ X clargc (1, image, &ier); X if (ier != 0) { X printf ("enter image name: "); X scanf ("%s", image); X } X X /* --- Get image size. */ X clargi (2, &ncols, &ier); X if (ier != 0) { X printf ("ncols: "); X scanf ("%d", &ncols); X } X clargi (3, &nlines, &ier); X if (ier != 0) { X printf ("nlines: "); X scanf ("%d", &nlines); X } X X /* --- Get pixel datatype. */ X clargi (4, &dtype, &ier); X if (ier != 0) X dtype = 3; X X /* --- Get pixel directory (optional). */ X clargc (5, pixdir, &ier); X if (ier != 0) X imsdirx (pixdir); X X axlen[0] = ncols; X axlen[1] = nlines; X naxis = 2; X X/* --- Create the image. */ X imcrea (image, axlen, naxis, dtype, &ier); X if (ier != 0) X goto error; X X/* --- Open the image for writing, and write the data. */ X imopen (image, 3, &im, &ier); X if (ier != 0) X goto error; X X for (j=1; j<=nlines; j++) { X for (i=1; i<=ncols; i++) X pix[i-1] = j * ncols + i; X impl2r (im, pix, j, &ier); X if (ier != 0) X goto error; X } X X/* --- Close the image and quit. */ X imclos (im, &ier); X if (ier != 0) X goto error; X else X goto noerror; X X/* --- Error exit. */ error: X imemsg (ier, errmsg); X printf ("Error: %s\n", errmsg); noerror: X ; X} END_OF_FILE if test 1725 -ne `wc -c <'mkimx.c'`; then echo shar: \"'mkimx.c'\" unpacked with wrong size! fi # end of 'mkimx.c' fi if test -f 'phead.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'phead.c'\" else echo shar: Extracting \"'phead.c'\" \(3428 characters\) sed "s/^X//" >'phead.c' <<'END_OF_FILE' X#include X X/* PHEAD -- Print the header of the named image in FITS format, one keyword X * per line. A pattern may optionally be specified to list some subset of the X * header keywords. X * X * usage: phead image [pattern] X * ---------------------------------------------------------------------------- X */ X X#define TRUE 1 X#define FALSE 0 X#define btoc(bval) ((bval == 1) ? ("T") : ("F")) X#define min(a,b) ((a) < (b) ? (a) : (b)) X main() /* program phead */ X X{ X char kwname[20], image[80], patstr[80], errmsg[80]; X int im, kwl, ier, sortit; X X /* --- Get image name. */ X clargc (1, image, &ier); X if (ier != 0) { X printf (" enter image name: "); X scanf ("%79s", image); X } X X /* --- Get pattern string (list everything if no pattern given). */ X clargc (2, patstr, &ier); X if (ier != 0) X strcpy (patstr, "*\0"); X X /* --- Open the image. */ X imopen (image, 1, &im, &ier); X if (ier != 0) X goto error; X X /* --- Open the keyword list and print each keyword in FITS format X *on the standard output device. X */ X X sortit = FALSE; X imokwl (im, patstr, sortit, &kwl, &ier); X kwloop: X imgnkw (kwl, kwname, &ier); X if (ier == 0) { X putkey (im, kwname, &ier); X if (ier != 0) X goto error; X goto kwloop; X } X X imckwl (kwl, &ier); X if (ier != 0) X goto error; X X /* --- Clean up. */ X imclos (im, &ier); X if (ier != 0) X goto error; X else X goto noerror; X X /* --- Error exit. */ error: X imemsg (ier, errmsg); X printf ("Error: %s\n", errmsg); noerror: X ; X} X X/* PUTKEY -- Read the value and comment fields of the named image header X * keyword, and print the value of the keyword in FITS format on the X * standard output device. X * X * 000000000111111111122222222223333333333444444444455555555556 X * 123456789012345678901234567890123456789012345678901234567890 X * keyword = xxx / comment X * keyword = 'sval ' / comment X * X * Datatype codes: 1=bool, 2=char, 3,4,5=int, 6,7=real/double, 8=complex X * Only codes 1, 2, 4, and 6 (bool,char,int,real) are returned by IMTYPK. X * ------------------------------------------------------------------------ X */ X putkey (im, kwname, ier) X int im, *ier; char *kwname; X X{ X int bval, ival; X char sval[80], valstr[80], comstr[80], lngstr[80]; X double dval, tdval; X int dtype, i; X X /* --- Get the keyword data type and comment information. */ X imtypk (im, kwname, &dtype, comstr, ier); X if (*ier != 0) X return; X X /* --- Print the value of the keyword in FITS format. The format X *depends upon the datatype of the parameter. X */ X X if (dtype == 1) { X imgkwb (im, kwname, &bval, ier); X if (*ier != 0) X return; X printf ("%-8s= %20s / %-47s\n", kwname, btoc(bval), comstr); X X } else if (dtype >= 3 && dtype <= 5) { X imgkwi (im, kwname, &ival, ier); X if (*ier != 0) X return; X printf ("%-8s= %20d / %-47s\n", kwname, ival, comstr); X X } else if (dtype == 6 || dtype == 7) { X imgkwd (im, kwname, &dval, ier); X if (*ier != 0) X return; X tdval = fabs(dval); X if ((tdval < 1.0E6) && (tdval >= 1.0E-1)) X printf ("%-8s= %20.2f / %-47s\n", kwname, dval, comstr); X else X printf ("%-8s= %20.12e / %-47s\n", kwname, dval, comstr); X } else { X imgkwc (im, kwname, sval, ier); X if (*ier != 0) X return; X X if (strlen(sval) <= 18) X printf ("%-8s= '%-18s' / %-47s\n", kwname, sval, comstr); X else X printf ("%-8s= '%-s' / \n", kwname, sval); X } X X *ier = 0; X} END_OF_FILE if test 3428 -ne `wc -c <'phead.c'`; then echo shar: \"'phead.c'\" unpacked with wrong size! fi # end of 'phead.c' fi if test -f 'planck.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'planck.c'\" else echo shar: Extracting \"'planck.c'\" \(1924 characters\) sed "s/^X//" >'planck.c' <<'END_OF_FILE' X/* PLANCK -- Compute the Planck blackbody radiation distribution for a X * given temperature and wavelength region. X * X * usage: planck temperature lambda1 lambda2 X * X * The temperature is specified in degrees Kelvin and the wavelength X * region in microns (1u=10000A). 100 [x,y] data points defining the X * curve are output. X * ---------------------------------------------------------------------- X */ X X# include main () /* program planck */ X X{ X char errmsg[80]; X int nargs, ier, i; X float w1, w2, dw, cm, t, xv[100], yv[100]; X double num, denom; X X /* --- Get the temperature in degrees kelvin. */ X clargr (1, &t, &ier); X if (ier != 0) { X printf (" temperature (degrees kelvin): "); X scanf ("%f", &t); X ier = 0; X } X X /* --- Get the wavelength region to be computed. */ X clnarg (&nargs); X if (nargs >= 3) { X clargr (2, &w1, &ier); X if (ier != 0) X goto error; X clargr (3, &w2, &ier); X if (ier != 0) X goto error; X } else { X printf (" start wavelength (microns): "); X scanf ("%f", &w1); X printf (" end wavelength (microns): "); X scanf ("%f", &w2); X ier = 0; X } X X /* --- Compute the blackbody curve. */ X dw = (w2 - w1) / 99.0; X for (i=1; i <= 100; i++) { X xv[i-1] = ((i-1) * dw) + w1; X cm = xv[i-1] * 1.0E-4; X num = pow ((double) cm, (double) -5); X denom = pow ((double) 2.71828, (double) (1.43883 / (cm * t))); X yv[i-1] = (3.74185E-5 * num) / (denom - 1.0); X X /* yv[i-1] = (3.74185E-5 * (cm ** -5)) / X (2.71828 ** (1.43883 / (cm * t)) - 1.0); */ X } X X /* c --- Print the curve as a table. */ X for (i=1; i<= 100; i++) X printf (" %7.4f %12.4g\n", xv[i-1], yv[i-1]); X X if (ier == 0) X goto noerror; X X /* --- Error exit. */ error: X imemsg (ier, errmsg); X printf (" Error: %s\n", errmsg); noerror: X ; X} END_OF_FILE if test 1924 -ne `wc -c <'planck.c'`; then echo shar: \"'planck.c'\" unpacked with wrong size! fi # end of 'planck.c' fi if test -f 'readim.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'readim.c'\" else echo shar: Extracting \"'readim.c'\" \(1171 characters\) sed "s/^X//" >'readim.c' <<'END_OF_FILE' X/* READIM -- Read through an image and count the lines (used for timing tests). X * Tests line sequential i/o. X * X * usage: readim image X * ---------------------------------------------------------------------------- X */ X main () /* program readim*/ X X{ X char image[80], errmsg[80]; X int ncols, nlines, nbands, j, k; X int im, ier, axlen[7], naxis, dtype; X short pix[8192]; X X /* --- Get image name. */ X clargc (1, image, &ier); X if (ier != 0) { X printf ("enter image name: "); X scanf ("%s", image); X } X X /* --- Open the image. */ X imopen (image, 1, &im, &ier); X if (ier != 0) X goto error; X imgsiz (im, axlen, &naxis, &dtype, &ier); X if (ier != 0) X goto error; X X ncols = axlen[0]; X nlines = axlen[1]; X nbands = axlen[2]; X X /* --- Read through the image. */ X for (k=1; k <= nbands; k++) { X for (j=1; j <= nlines; j++) { X imgl3s (im, pix, j, k, &ier); X if (ier != 0) X goto error; X } X } X X /* --- Clean up. */ X imclos (im, &ier); X if (ier != 0) X goto error; X X printf ("read %d lines from image %s\n", nlines, image); X goto noerror; X X /* --- Error exit. */ error: X imemsg (ier, errmsg); X printf ("Error: %s\n", errmsg); noerror: X ; X} END_OF_FILE if test 1171 -ne `wc -c <'readim.c'`; then echo shar: \"'readim.c'\" unpacked with wrong size! fi # end of 'readim.c' fi echo shar: End of shell archive. exit 0