| 1 | 
< | 
/* Copyright (c) 1990 Regents of the University of California */ | 
| 1 | 
> | 
/* Copyright (c) 1992 Regents of the University of California */ | 
| 2 | 
  | 
 | 
| 3 | 
  | 
#ifndef lint | 
| 4 | 
  | 
static char SCCSid[] = "$SunId$ LBL"; | 
| 11 | 
  | 
 */ | 
| 12 | 
  | 
 | 
| 13 | 
  | 
#include <stdio.h> | 
| 14 | 
+ | 
#include <math.h> | 
| 15 | 
  | 
#include <ctype.h> | 
| 16 | 
+ | 
#include "color.h" | 
| 17 | 
+ | 
#include "paths.h" | 
| 18 | 
  | 
 | 
| 19 | 
  | 
#define PI              3.14159265358979323846 | 
| 20 | 
  | 
                                        /* floating comparisons */ | 
| 37 | 
  | 
                                        /* string lengths */ | 
| 38 | 
  | 
#define MAXLINE         132 | 
| 39 | 
  | 
#define MAXWORD         76 | 
| 37 | 
– | 
#define MAXPATH         128 | 
| 40 | 
  | 
                                        /* file types */ | 
| 41 | 
  | 
#define T_RAD           ".rad" | 
| 42 | 
  | 
#define T_DST           ".dat" | 
| 43 | 
< | 
#define T_TLT           "+.dat" | 
| 43 | 
> | 
#define T_TLT           "%.dat" | 
| 44 | 
  | 
                                        /* shape types */ | 
| 45 | 
  | 
#define RECT            1 | 
| 46 | 
  | 
#define DISK            2 | 
| 50 | 
  | 
 | 
| 51 | 
  | 
#define F_M             .3048           /* feet to meters */ | 
| 52 | 
  | 
 | 
| 53 | 
< | 
#define abspath(p)      ((p)[0] == '/' || (p)[0] == '.') | 
| 53 | 
> | 
#define abspath(p)      (ISDIRSEP((p)[0]) || (p)[0] == '.') | 
| 54 | 
  | 
 | 
| 55 | 
+ | 
static char     default_name[] = "default"; | 
| 56 | 
+ | 
 | 
| 57 | 
  | 
char    *libdir = NULL;                 /* library directory location */ | 
| 58 | 
  | 
char    *prefdir = NULL;                /* subdirectory */ | 
| 59 | 
  | 
char    *lampdat = "lamp.tab";          /* lamp data file */ | 
| 60 | 
  | 
 | 
| 61 | 
  | 
double  meters2out = 1.0;               /* conversion from meters to output */ | 
| 62 | 
  | 
char    *lamptype = NULL;               /* selected lamp type */ | 
| 63 | 
< | 
float   *lampcolor = NULL;              /* pointer to lamp color */ | 
| 63 | 
> | 
char    *deflamp = NULL;                /* default lamp type */ | 
| 64 | 
  | 
float   defcolor[3] = {1.,1.,1.};       /* default lamp color */ | 
| 65 | 
+ | 
float   *lampcolor = defcolor;          /* pointer to current lamp color */ | 
| 66 | 
  | 
double  multiplier = 1.0;               /* multiplier for all light sources */ | 
| 67 | 
  | 
char    units[64] = "meters";           /* output units */ | 
| 63 | 
– | 
double  minaspect = 0.0;                /* minimum allowed aspect ratio */ | 
| 64 | 
– | 
int     maxemitters = 1;                /* maximum emitters per hemisphere */ | 
| 68 | 
  | 
double  illumrad = 0.0;                 /* radius for illum sphere */ | 
| 69 | 
  | 
 | 
| 70 | 
  | 
typedef struct { | 
| 71 | 
  | 
        int     type;                           /* RECT, DISK, SPHERE */ | 
| 72 | 
  | 
        double  w, l, h;                        /* width, length, height */ | 
| 73 | 
< | 
        double  area;                           /* effective radiating area */ | 
| 73 | 
> | 
        double  area;                           /* max. projected area */ | 
| 74 | 
  | 
} SHAPE;                                /* a source shape */ | 
| 75 | 
  | 
 | 
| 76 | 
  | 
int     gargc;                          /* global argc (minus filenames) */ | 
| 77 | 
  | 
char    **gargv;                        /* global argv */ | 
| 78 | 
  | 
 | 
| 79 | 
  | 
extern char     *strcpy(), *strcat(), *stradd(), *tailtrunc(), *filetrunc(), | 
| 80 | 
< | 
                *filename(), *libname(), *fullname(), *malloc(); | 
| 81 | 
< | 
extern double   atof(); | 
| 80 | 
> | 
                *filename(), *libname(), *fullname(), *malloc(), | 
| 81 | 
> | 
                *getword(), *atos(); | 
| 82 | 
  | 
extern float    *matchlamp(); | 
| 83 | 
  | 
 | 
| 84 | 
+ | 
#define scnint(fp,ip)   cvtint(ip,getword(fp)) | 
| 85 | 
+ | 
#define scnflt(fp,rp)   cvtflt(rp,getword(fp)) | 
| 86 | 
+ | 
#define isint           isflt                   /* IES allows real as integer */ | 
| 87 | 
  | 
 | 
| 88 | 
+ | 
 | 
| 89 | 
  | 
main(argc, argv) | 
| 90 | 
  | 
int     argc; | 
| 91 | 
  | 
char    *argv[]; | 
| 160 | 
  | 
                case 'o':               /* output file name */ | 
| 161 | 
  | 
                        outfile = argv[++i]; | 
| 162 | 
  | 
                        break; | 
| 156 | 
– | 
                case 's':               /* square emitters */ | 
| 157 | 
– | 
                        minaspect = .6; | 
| 158 | 
– | 
                        if (argv[i][2] == '/') { | 
| 159 | 
– | 
                                maxemitters = atoi(argv[i]+3); | 
| 160 | 
– | 
                                if (maxemitters < 1) | 
| 161 | 
– | 
                                        goto badopt; | 
| 162 | 
– | 
                        } | 
| 163 | 
– | 
                        break; | 
| 163 | 
  | 
                case 'i':               /* illum */ | 
| 164 | 
  | 
                        illumrad = atof(argv[++i]); | 
| 165 | 
  | 
                        if (illumrad < MINDIM) | 
| 166 | 
  | 
                                illumrad = MINDIM; | 
| 167 | 
  | 
                        break; | 
| 168 | 
< | 
                case 't':               /* select lamp type */ | 
| 168 | 
> | 
                case 't':               /* override lamp type */ | 
| 169 | 
  | 
                        lamptype = argv[++i]; | 
| 170 | 
  | 
                        break; | 
| 171 | 
+ | 
                case 'u':               /* default lamp type */ | 
| 172 | 
+ | 
                        deflamp = argv[++i]; | 
| 173 | 
+ | 
                        break; | 
| 174 | 
  | 
                case 'c':               /* default lamp color */ | 
| 175 | 
  | 
                        defcolor[0] = atof(argv[++i]); | 
| 176 | 
  | 
                        defcolor[1] = atof(argv[++i]); | 
| 187 | 
  | 
                } | 
| 188 | 
  | 
        gargc = i; | 
| 189 | 
  | 
        gargv = argv; | 
| 190 | 
< | 
                                        /* get lamp data */ | 
| 189 | 
< | 
        if ((status = loadlamps(lampdat)) < 0) | 
| 190 | 
< | 
                exit(1); | 
| 191 | 
< | 
        if (status == 0 || (lamptype != NULL && | 
| 192 | 
< | 
                        (lampcolor = matchlamp(lamptype)) == NULL)) { | 
| 193 | 
< | 
                lampcolor = defcolor; | 
| 194 | 
< | 
                fprintf(stderr, "%s: warning - no lamp data\n", argv[0]); | 
| 195 | 
< | 
        } | 
| 190 | 
> | 
        initlamps();                    /* get lamp data (if needed) */ | 
| 191 | 
  | 
                                        /* convert ies file(s) */ | 
| 192 | 
  | 
        if (outfile != NULL) { | 
| 193 | 
  | 
                if (i == argc) | 
| 214 | 
  | 
} | 
| 215 | 
  | 
 | 
| 216 | 
  | 
 | 
| 217 | 
+ | 
initlamps()                             /* set up lamps */ | 
| 218 | 
+ | 
{ | 
| 219 | 
+ | 
        float   *lcol; | 
| 220 | 
+ | 
        int     status; | 
| 221 | 
+ | 
 | 
| 222 | 
+ | 
        if (lamptype != NULL && !strcmp(lamptype, default_name) && | 
| 223 | 
+ | 
                        deflamp == NULL) | 
| 224 | 
+ | 
                return;                         /* no need for data */ | 
| 225 | 
+ | 
                                                /* else load file */ | 
| 226 | 
+ | 
        if ((status = loadlamps(lampdat)) < 0) | 
| 227 | 
+ | 
                exit(1); | 
| 228 | 
+ | 
        if (status == 0) { | 
| 229 | 
+ | 
                fprintf(stderr, "%s: warning - no lamp data\n", lampdat); | 
| 230 | 
+ | 
                lamptype = default_name; | 
| 231 | 
+ | 
                return; | 
| 232 | 
+ | 
        } | 
| 233 | 
+ | 
        if (deflamp != NULL) {                  /* match default type */ | 
| 234 | 
+ | 
                if ((lcol = matchlamp(deflamp)) == NULL) | 
| 235 | 
+ | 
                        fprintf(stderr, | 
| 236 | 
+ | 
                                "%s: warning - unknown default lamp type\n", | 
| 237 | 
+ | 
                                        deflamp); | 
| 238 | 
+ | 
                else | 
| 239 | 
+ | 
                        copycolor(defcolor, lcol); | 
| 240 | 
+ | 
        } | 
| 241 | 
+ | 
        if (lamptype != NULL) {                 /* match selected type */ | 
| 242 | 
+ | 
                if (strcmp(lamptype, default_name)) { | 
| 243 | 
+ | 
                        if ((lcol = matchlamp(lamptype)) == NULL) { | 
| 244 | 
+ | 
                                fprintf(stderr, | 
| 245 | 
+ | 
                                        "%s: warning - unknown lamp type\n", | 
| 246 | 
+ | 
                                                lamptype); | 
| 247 | 
+ | 
                                lamptype = default_name; | 
| 248 | 
+ | 
                        } else | 
| 249 | 
+ | 
                                copycolor(defcolor, lcol); | 
| 250 | 
+ | 
                } | 
| 251 | 
+ | 
                freelamps();                    /* all done with data */ | 
| 252 | 
+ | 
        } | 
| 253 | 
+ | 
                                                /* else keep lamp data */ | 
| 254 | 
+ | 
} | 
| 255 | 
+ | 
 | 
| 256 | 
+ | 
 | 
| 257 | 
  | 
char * | 
| 258 | 
  | 
stradd(dst, src, sep)                   /* add a string at dst */ | 
| 259 | 
  | 
register char   *dst, *src; | 
| 280 | 
  | 
        else if (abspath(fname)) | 
| 281 | 
  | 
                strcpy(stradd(path, fname, 0), suffix); | 
| 282 | 
  | 
        else | 
| 283 | 
< | 
                libname(stradd(path, libdir, '/'), fname, suffix); | 
| 283 | 
> | 
                libname(stradd(path, libdir, DIRSEP), fname, suffix); | 
| 284 | 
  | 
 | 
| 285 | 
  | 
        return(path); | 
| 286 | 
  | 
} | 
| 293 | 
  | 
        if (abspath(fname)) | 
| 294 | 
  | 
                strcpy(stradd(path, fname, 0), suffix); | 
| 295 | 
  | 
        else | 
| 296 | 
< | 
                strcpy(stradd(stradd(path, prefdir, '/'), fname, 0), suffix); | 
| 296 | 
> | 
                strcpy(stradd(stradd(path, prefdir, DIRSEP), fname, 0), suffix); | 
| 297 | 
  | 
 | 
| 298 | 
  | 
        return(path); | 
| 299 | 
  | 
} | 
| 306 | 
  | 
        register char   *cp; | 
| 307 | 
  | 
 | 
| 308 | 
  | 
        for (cp = path; *path; path++) | 
| 309 | 
< | 
                if (*path == '/') | 
| 309 | 
> | 
                if (ISDIRSEP(*path)) | 
| 310 | 
  | 
                        cp = path+1; | 
| 311 | 
  | 
        return(cp); | 
| 312 | 
  | 
} | 
| 319 | 
  | 
        register char   *p1, *p2; | 
| 320 | 
  | 
 | 
| 321 | 
  | 
        for (p1 = p2 = path; *p2; p2++) | 
| 322 | 
< | 
                if (*p2 == '/') | 
| 322 | 
> | 
                if (ISDIRSEP(*p2)) | 
| 323 | 
  | 
                        p1 = p2; | 
| 324 | 
  | 
        *p1 = '\0'; | 
| 325 | 
  | 
        return(path); | 
| 407 | 
  | 
        } | 
| 408 | 
  | 
        if (lampcolor == NULL) { | 
| 409 | 
  | 
                fprintf(stderr, "%s: warning - no lamp type\n", inpname); | 
| 410 | 
+ | 
                fputs("# Unknown lamp type (used default)\n", outfp); | 
| 411 | 
  | 
                lampcolor = defcolor; | 
| 412 | 
< | 
        } | 
| 412 | 
> | 
        } else if (lamptype == NULL) | 
| 413 | 
> | 
                fprintf(outfp,"# CIE(x,y) = (%f,%f)\n# Depreciation = %.1f%%\n", | 
| 414 | 
> | 
                                lampcolor[3], lampcolor[4], 100.*lampcolor[5]); | 
| 415 | 
  | 
        if (feof(inpfp)) { | 
| 416 | 
  | 
                fprintf(stderr, "%s: not in IES format\n", inpname); | 
| 417 | 
  | 
                goto readerr; | 
| 418 | 
  | 
        } | 
| 419 | 
< | 
        sscanf(buf+TLTSTRLEN, "%s", tltid); | 
| 419 | 
> | 
        atos(tltid, MAXWORD, buf+TLTSTRLEN); | 
| 420 | 
  | 
        if (inpfp == stdin) | 
| 421 | 
  | 
                buf[0] = '\0'; | 
| 422 | 
  | 
        else | 
| 456 | 
  | 
                datin = in; | 
| 457 | 
  | 
                strcpy(tltname, dfltname); | 
| 458 | 
  | 
        } else { | 
| 459 | 
< | 
                if (tltspec[0] == '/') | 
| 459 | 
> | 
                if (ISDIRSEP(tltspec[0])) | 
| 460 | 
  | 
                        strcpy(buf, tltspec); | 
| 461 | 
  | 
                else | 
| 462 | 
< | 
                        strcpy(stradd(buf, dir, '/'), tltspec); | 
| 462 | 
> | 
                        strcpy(stradd(buf, dir, DIRSEP), tltspec); | 
| 463 | 
  | 
                if ((datin = fopen(buf, "r")) == NULL) { | 
| 464 | 
  | 
                        perror(buf); | 
| 465 | 
  | 
                        return(-1); | 
| 473 | 
  | 
                                fclose(datin); | 
| 474 | 
  | 
                        return(-1); | 
| 475 | 
  | 
                } | 
| 476 | 
< | 
                if (fscanf(datin, "%d %d", &tlt_type, &nangles) != 2 | 
| 476 | 
> | 
                if (!scnint(datin,&tlt_type) || !scnint(datin,&nangles) | 
| 477 | 
  | 
                        || cvdata(datin,datout,1,&nangles,1.,minmax) != 0) { | 
| 478 | 
  | 
                        fprintf(stderr, "%s: data format error\n", tltspec); | 
| 479 | 
  | 
                        fclose(datout); | 
| 525 | 
  | 
        int     nangles[2], pmtype, unitype; | 
| 526 | 
  | 
        double  d1; | 
| 527 | 
  | 
 | 
| 528 | 
< | 
        if (fscanf(in, "%*d %*f %lf %d %d %d %d %lf %lf %lf %lf %lf %lf", | 
| 529 | 
< | 
                        &mult, &nangles[0], &nangles[1], &pmtype, &unitype, | 
| 530 | 
< | 
                        &width, &length, &height, &bfactor, &pfactor, | 
| 531 | 
< | 
                        &wattage) != 11) { | 
| 528 | 
> | 
        if (!isint(getword(in)) || !isflt(getword(in)) || !scnflt(in,&mult) | 
| 529 | 
> | 
                        || !scnint(in,&nangles[0]) || !scnint(in,&nangles[1]) | 
| 530 | 
> | 
                        || !scnint(in,&pmtype) || !scnint(in,&unitype) | 
| 531 | 
> | 
                        || !scnflt(in,&width) || !scnflt(in,&length) | 
| 532 | 
> | 
                        || !scnflt(in,&height) || !scnflt(in,&bfactor) | 
| 533 | 
> | 
                        || !scnflt(in,&pfactor) || !scnflt(in,&wattage)) { | 
| 534 | 
  | 
                fprintf(stderr, "dosource: bad lamp specification\n"); | 
| 535 | 
  | 
                return(-1); | 
| 536 | 
  | 
        } | 
| 551 | 
  | 
                perror(buf); | 
| 552 | 
  | 
                return(-1); | 
| 553 | 
  | 
        } | 
| 554 | 
< | 
        if (cvdata(in, datout, 2, nangles, 1./683., bounds) != 0) { | 
| 554 | 
> | 
        if (cvdata(in, datout, 2, nangles, 1./WHTEFFICACY, bounds) != 0) { | 
| 555 | 
  | 
                fprintf(stderr, "dosource: bad distribution data\n"); | 
| 556 | 
  | 
                fclose(datout); | 
| 557 | 
  | 
                unlink(fullname(buf,name,T_DST)); | 
| 567 | 
  | 
        else if (pmtype == PM_B) | 
| 568 | 
  | 
                fprintf(out, "5 "); | 
| 569 | 
  | 
        else if (FEQ(bounds[1][0],90.) && FEQ(bounds[1][1],270.)) | 
| 570 | 
< | 
                fprintf(out, "8 "); | 
| 570 | 
> | 
                fprintf(out, "7 "); | 
| 571 | 
  | 
        else | 
| 572 | 
< | 
                fprintf(out, "6 "); | 
| 572 | 
> | 
                fprintf(out, "5 "); | 
| 573 | 
  | 
        fprintf(out, "%s %s source.cal ", | 
| 574 | 
  | 
                        srcshape.type==SPHERE ? "corr" : "flatcorr", | 
| 575 | 
  | 
                        libname(buf,name,T_DST)); | 
| 588 | 
  | 
                                fprintf(out, "src_phi2 "); | 
| 589 | 
  | 
                        else | 
| 590 | 
  | 
                                fprintf(out, "src_phi "); | 
| 591 | 
< | 
                        fprintf(out, "src_theta -my "); | 
| 591 | 
> | 
                        fprintf(out, "src_theta "); | 
| 592 | 
  | 
                        if (FEQ(bounds[1][0],90.) && FEQ(bounds[1][1],270.)) | 
| 593 | 
  | 
                                fprintf(out, "-rz -90 "); | 
| 594 | 
  | 
                } else | 
| 619 | 
  | 
                        lampcolor[2]/shp->area); | 
| 620 | 
  | 
        if (doupper && dolower && shp->type != SPHERE && shp->h > MINDIM) { | 
| 621 | 
  | 
                fprintf(fp, "\n%s glow %s_glow\n", mod, name); | 
| 622 | 
< | 
                fprintf(fp, "0\n0\n4 %g %g %g 0\n", | 
| 622 | 
> | 
                fprintf(fp, "0\n0\n4 %g %g %g -1\n", | 
| 623 | 
  | 
                                lampcolor[0]/shp->area, | 
| 624 | 
  | 
                                lampcolor[1]/shp->area, | 
| 625 | 
  | 
                                lampcolor[2]/shp->area); | 
| 660 | 
  | 
register SHAPE  *shp; | 
| 661 | 
  | 
double  width, length, height; | 
| 662 | 
  | 
{ | 
| 663 | 
< | 
        if (illumrad >= MINDIM/2.) { | 
| 663 | 
> | 
        if (illumrad/meters2out >= MINDIM/2.) { | 
| 664 | 
  | 
                shp->type = SPHERE; | 
| 665 | 
< | 
                shp->w = shp->l = shp->h = 2.*illumrad; | 
| 665 | 
> | 
                shp->w = shp->l = shp->h = 2.*illumrad / meters2out; | 
| 666 | 
  | 
        } else if (width < MINDIM) { | 
| 667 | 
  | 
                width = -width; | 
| 668 | 
  | 
                if (width < MINDIM) { | 
| 696 | 
  | 
                shp->area = shp->w * shp->l; | 
| 697 | 
  | 
                break; | 
| 698 | 
  | 
        case DISK: | 
| 699 | 
+ | 
        case SPHERE: | 
| 700 | 
  | 
                shp->area = PI/4. * shp->w * shp->w; | 
| 701 | 
  | 
                break; | 
| 661 | 
– | 
        case SPHERE: | 
| 662 | 
– | 
                shp->area = PI * shp->w * shp->w; | 
| 663 | 
– | 
                break; | 
| 702 | 
  | 
        } | 
| 703 | 
  | 
        return(0); | 
| 704 | 
  | 
} | 
| 807 | 
  | 
int     ndim, npts[]; | 
| 808 | 
  | 
double  mult, lim[][2]; | 
| 809 | 
  | 
{ | 
| 810 | 
< | 
        register double *pt[4]; | 
| 810 | 
> | 
        double  *pt[4]; | 
| 811 | 
  | 
        register int    i, j; | 
| 812 | 
  | 
        double  val; | 
| 813 | 
  | 
        int     total; | 
| 823 | 
  | 
        for (i = 0; i < ndim; i++) { | 
| 824 | 
  | 
                pt[i] = (double *)malloc(npts[i]*sizeof(double)); | 
| 825 | 
  | 
                for (j = 0; j < npts[i]; j++) | 
| 826 | 
< | 
                        fscanf(in, "%lf", &pt[i][j]); | 
| 826 | 
> | 
                        if (!scnflt(in, &pt[i][j])) | 
| 827 | 
> | 
                                return(-1); | 
| 828 | 
  | 
                if (lim != NULL) { | 
| 829 | 
  | 
                        lim[i][0] = pt[i][0]; | 
| 830 | 
  | 
                        lim[i][1] = pt[i][npts[i]-1]; | 
| 855 | 
  | 
        for (i = 0; i < total; i++) { | 
| 856 | 
  | 
                if (i%4 == 0) | 
| 857 | 
  | 
                        putc('\n', out); | 
| 858 | 
< | 
                if (fscanf(in, "%lf", &val) != 1) | 
| 858 | 
> | 
                if (!scnflt(in, &val)) | 
| 859 | 
  | 
                        return(-1); | 
| 860 | 
  | 
                fprintf(out, "\t%g", val*mult); | 
| 861 | 
  | 
        } | 
| 862 | 
  | 
        putc('\n', out); | 
| 863 | 
  | 
        return(0); | 
| 864 | 
+ | 
} | 
| 865 | 
+ | 
 | 
| 866 | 
+ | 
 | 
| 867 | 
+ | 
char * | 
| 868 | 
+ | 
getword(fp)                     /* scan a word from fp */ | 
| 869 | 
+ | 
register FILE   *fp; | 
| 870 | 
+ | 
{ | 
| 871 | 
+ | 
        static char     word[MAXWORD]; | 
| 872 | 
+ | 
        register char   *cp; | 
| 873 | 
+ | 
        register int    c; | 
| 874 | 
+ | 
 | 
| 875 | 
+ | 
        while (isspace(c=getc(fp))) | 
| 876 | 
+ | 
                ; | 
| 877 | 
+ | 
        for (cp = word; c != EOF && cp < word+MAXWORD-1; | 
| 878 | 
+ | 
                        *cp++ = c, c = getc(fp)) | 
| 879 | 
+ | 
                if (isspace(c) || c == ',') { | 
| 880 | 
+ | 
                        while (isspace(c)) | 
| 881 | 
+ | 
                                c = getc(fp); | 
| 882 | 
+ | 
                        if (c != EOF & c != ',') | 
| 883 | 
+ | 
                                ungetc(c, fp); | 
| 884 | 
+ | 
                        *cp = '\0'; | 
| 885 | 
+ | 
                        return(word); | 
| 886 | 
+ | 
                } | 
| 887 | 
+ | 
        *cp = '\0'; | 
| 888 | 
+ | 
        return(cp > word ? word : NULL); | 
| 889 | 
+ | 
} | 
| 890 | 
+ | 
 | 
| 891 | 
+ | 
 | 
| 892 | 
+ | 
cvtint(ip, word)                /* convert a word to an integer */ | 
| 893 | 
+ | 
int     *ip; | 
| 894 | 
+ | 
char    *word; | 
| 895 | 
+ | 
{ | 
| 896 | 
+ | 
        if (word == NULL || !isint(word)) | 
| 897 | 
+ | 
                return(0); | 
| 898 | 
+ | 
        *ip = atoi(word); | 
| 899 | 
+ | 
        return(1); | 
| 900 | 
+ | 
} | 
| 901 | 
+ | 
 | 
| 902 | 
+ | 
 | 
| 903 | 
+ | 
cvtflt(rp, word)                /* convert a word to a double */ | 
| 904 | 
+ | 
double  *rp; | 
| 905 | 
+ | 
char    *word; | 
| 906 | 
+ | 
{ | 
| 907 | 
+ | 
        if (word == NULL || !isflt(word)) | 
| 908 | 
+ | 
                return(0); | 
| 909 | 
+ | 
        *rp = atof(word); | 
| 910 | 
+ | 
        return(1); | 
| 911 | 
  | 
} |