void G77_getenv_0 (char *fname, char *value, ftnlen flen, ftnlen vlen) { char buf[256], *ep, *fp; integer i; if (flen <= 0) goto add_blanks; for (i = 0; i < (integer) sizeof (buf); i++) { if (i == flen || (buf[i] = fname[i]) == ' ') { buf[i] = 0; ep = getenv (buf); goto have_ep; } } while (i < flen && fname[i] != ' ') i++; strncpy (fp = F77_aloc (i + 1, "getenv_"), fname, (int) i); fp[i] = 0; ep = getenv (fp); free (fp); have_ep: if (ep) while (*ep && vlen-- > 0) *value++ = *ep++; add_blanks: while (vlen-- > 0) *value++ = ' '; }
void s_cat (char *lp, char *rpp[], ftnint rnp[], ftnint * np, ftnlen ll) { ftnlen i, nc; char *rp; ftnlen n = *np; #ifndef NO_OVERWRITE ftnlen L, m; char *lp0, *lp1; lp0 = 0; lp1 = lp; L = ll; i = 0; while (i < n) { rp = rpp[i]; m = rnp[i++]; if (rp >= lp1 || rp + m <= lp) { if ((L -= m) <= 0) { n = i; break; } lp1 += m; continue; } lp0 = lp; lp = lp1 = F77_aloc (L = ll, "s_cat"); break; } lp1 = lp; #endif /* NO_OVERWRITE */ for (i = 0; i < n; ++i) { nc = ll; if (rnp[i] < nc) nc = rnp[i]; ll -= nc; rp = rpp[i]; while (--nc >= 0) *lp++ = *rp++; } while (--ll >= 0) *lp++ = ' '; #ifndef NO_OVERWRITE if (lp0) { memcpy (lp0, lp1, L); free (lp1); } #endif }
integer G77_system_0 (register char *s, ftnlen n) { char buff0[256], *buff; register char *bp, *blast; integer rv; buff = bp = n < (ftnlen) sizeof (buff0) ? buff0 : F77_aloc (n + 1, "system_"); blast = bp + n; while (bp < blast && *s) *bp++ = *s++; *bp = 0; rv = system (buff); if (buff != buff0) free (buff); return rv; }
integer system_(register char *s, ftnlen n) #endif { #ifndef CSPICE_MACPPC char buff0[256], *buff; register char *bp, *blast; integer rv; buff = bp = n < sizeof(buff0) ? buff0 : F77_aloc(n+1, "system_"); blast = bp + n; while(bp < blast && *s) { *bp++ = *s++; } *bp = 0; rv = system(buff); if (buff != buff0) { free(buff); } return rv; #endif #ifdef CSPICE_MACPPC /* The Macintosh Classic environment lacks a system command. Return a fail. */ return 0; #endif }