VOID ted_set(LONG taddr, BYTE *tmplt, BYTE *valid, BYTE *text) { WORD imap, itmp; if (!tmplt[0]) { tmplt[0] = '@'; LLSTRCPY(LLGET(TE_PVALID(taddr)), (LONG)ADDR(valid)); LLSTRCPY(LLGET(TE_PTEXT(taddr)), (LONG)ADDR(text)); if (!valid[0]) valid[0] = '@'; if (!text[0]) text[0] = '@'; } else { for (imap = itmp = 0; tmplt[itmp]; itmp++) if (tmplt[itmp] == '_') { tmplt[itmp] = '~'; valid[itmp] = LBGET(imap + LLGET(TE_PVALID(taddr))); text[itmp] = LBGET(imap + LLGET(TE_PTEXT(taddr))); imap++; } else valid[itmp] = text[itmp] = '~'; valid[itmp] = text[itmp] = '\0'; } }
WORD sh_path(WORD whichone, LONG dp, BYTE *pname) { register BYTE tmp, last; BYTE *lp; register WORD i; last = 0; /* find PATH= in the */ /* command tail which */ /* is a double null- */ /* terminated string */ sh_envrn(&lp, PATH_ENV); if (!lp) return(0); /* if found count in to */ /* appropriate path */ i = whichone; tmp = ';'; while (i) { while (( tmp = LBGET(lp)) != 0 ) { lp++; if (tmp == ';') break; } i--; } if (!tmp) return(0); /* copy over path */ while ( ( tmp = LBGET(lp) ) != 0) { if ( tmp != ';' ) { LBSET(dp++, tmp); last = tmp; lp++; } else break; } /* see if extra slash */ /* is needed */ if ( (last != '\\') && (last != ':') ) LBSET(dp++, '\\'); /* append file name */ strcpy((char *) dp, pname); /* make whichone refer */ /* to next path */ return(whichone+1); }
WORD LLSTRCMP(LONG l1, LONG l2) { BYTE b; b = LBGET(l1++); while (b) { if (b != LBGET(l2++)) return (FALSE); else b = LBGET(l1++); } return (!LBGET(l2)); }
VOID LLSTRCPY(LONG src, LONG dest) { BYTE b; do { b = LBGET(src++); LBSET(dest++, b); } while (b); }
WORD ins_latoi(LONG st_ad) { WORD retval; BYTE ch; retval = 0; while ((ch = LBGET(st_ad)) != '\0') { retval = retval*10 + ch - '0'; st_ad += 1; } return(retval); }
/* * Search for a particular string in the DOS environment and return * a long pointer to the character after the string if it is found. * Otherwise, return a NULLPTR */ void sh_envrn(BYTE **ppath, const BYTE *psrch) { BYTE *lp; WORD len, findend; BYTE last, tmp, loc1[10], loc2[10]; len = strlencpy(loc2, psrch); len--; loc1[len] = NULL; lp = ad_envrn; findend = FALSE; tmp = NULL; do { last = tmp; tmp = LBGET(lp); lp++; if ( (findend) && (tmp == NULL) ) { findend = FALSE; tmp = 0xFF; } else { if (((last == NULL) || (last == -1)) && (tmp == loc2[0])) { LBCOPY(ADDR(&loc1[0]), lp, len); if ( strcmp(&loc1[0], &loc2[1])==0 ) { lp += len; break; } } else findend = TRUE; } } while( tmp ); if (!tmp) lp = 0x0L; *ppath = lp; }