/* ------------------------------------------------------------------- lsh_klist - ------------------------------------------------------------------- */ LONG KL_CALLTYPE KL_EXPORT lsh_klist (HANDLE hListBox, TICKETINFO FAR * lpti) { LPSTR lp1 ; // clear out list box SendMessage (hListBox, LB_RESETCONTENT, 0, 0L) ; // only list if we have a NetID if (lpFt->bAuthenticated == FALSE) return (0) ; // note: ctime() can't take a FAR pointer, so use the struct "directly" // append expired time, due to funky way ctime() works. Unfortunately, I can't // put this in 1 wsprintf() statement. Dooh! wsprintf (lpszTemp, "%s\t", (LPSTR)ctime(&ft.lTimeAcquired)) ; _fstrcat (lpszTemp, (LPSTR)ctime(&ft.lTimeExpires)) ; _fstrcat (lpszTemp, (LPSTR)"\t") ; _fstrcat (lpszTemp, lpFt->szNetID) ; // remove '\n' from ctime output if ((lp1 = _fstrchr(lpszTemp, '\n')) != NULL) { *lp1 = ' ' ; lp1++ ; if ((lp1 = _fstrchr(lpszTemp, '\n')) != NULL) *lp1 = ' ' ; } SendMessage (hListBox, LB_ADDSTRING, 0, (LPARAM)(LPCSTR)lpszTemp) ; return (0) ; }
/* change all cr/lf chars in input text to spaces */ void gtab_delcr(LPSTR ptext) { LPSTR chp; if (ptext == NULL) { return; } for(chp = ptext; (chp = _fstrchr(chp, '\r')) != NULL; ) { *chp = ' '; } for(chp = ptext; (chp = _fstrchr(chp, '\n')) != NULL; ) { *chp = ' '; } }
//--------------------------------------------------------------------------- // LoadIncludeFile // // This function uses the callback loader to load in a new file, into a new // FILEINFO structure in lpFI. Scanning/parsing then resumes from this newly // loaded include file. // // RETURNS: Nothing //--------------------------------------------------------------------------- VOID NEAR LoadIncludeFile () { LPSTR tok, newfile; // If there's no room for another include file, tell the user so... //----------------------------------------------------------------------- if ((CUR_FILE.nDepth == MAXINC) || (nFileAvail == MAXSF)) { ScanError (SCN_INCDEEP); return; } // Get the script file name. We just get the next token (which had best // be the opening ' mark), and then null-terminate the file name at the // closing ' mark (which had best be there). //----------------------------------------------------------------------- NextToken(); if (curtok[0] != '\'') { ScanError (SCN_INCERR); return; } newfile = szLine + idx; tok = _fstrchr (newfile, '\''); if (!tok) { ScanError (SCN_INCERR); return; } *tok = 0; iEnd = idx + _fstrlen (newfile) + 1; // Ask the callback loader to load the file we need and give us a pointer // to it //----------------------------------------------------------------------- AVAIL_FILE.lpText = CBLoader (newfile, CUR_FILE.nDepth + 1, nFileAvail, TRUE, AVAIL_FILE.szName); if (!AVAIL_FILE.lpText) { ScanError (SCN_INCFILE); return; } // The file is loaded. Finish the initialization of this FI entry, and // the scanner is ready to start taking its input from the new file. //----------------------------------------------------------------------- AVAIL_FILE.nLineNo = 0; AVAIL_FILE.pIfStack = pIfStack; AVAIL_FILE.nParent = nFileIdx; AVAIL_FILE.nDepth = CUR_FILE.nDepth + 1; AVAIL_FILE.fLoaded = TRUE; nFileIdx = nFileAvail++; lpCurFI = (lpFI + nFileIdx); }
void TestSearchF( void ) { char buf[] = "The quick brown fox jumped over the lazy dogs."; char __far *ptr; ptr = _fstrchr( buf, '!' ); /* try to find a '!' */ VERIFY( ptr == NULL ); ptr = _fstrchr( buf, 0x00 ); /* try to find the NULL */ VERIFY( ptr == buf+strlen(buf) ); ptr = _fstrchr( buf, 'k' ); /* try to find a 'k' */ VERIFY( ptr == buf+8 ); ptr = _fstrrchr( buf, '!' ); /* try to find a '!' */ VERIFY( ptr == NULL ); ptr = _fstrrchr( buf, 0x00 ); /* try to find the NULL */ VERIFY( ptr == buf+strlen(buf) ); ptr = _fstrrchr( buf, 'k' ); /* try to find a 'k' */ VERIFY( ptr == buf+8 ); }
void gtab_paintcell(HWND hwnd, HDC hdc, lpTable ptab, int line, int cell) { lpLineData pline; lpCellData cd; lpCellPos ppos; RECT rc, rcbox; int cx, x, y, tabwidth; UINT align; LPSTR chp, tabp; DWORD fcol, bkcol; HFONT hfont; TEXTMETRIC tm; HBRUSH hbr; fcol = 0; bkcol = 0; /* eliminate spurious diagnostic, generate worse code */ hfont = 0; /* eliminate spurious diagnostic, generate worse code */ /* init pointers to cell text and properties */ pline = &ptab->pdata[line]; cd = &pline->pdata[cell]; ppos = &ptab->pcellpos[cell]; /* clip all output to this rectangle */ rc.top = pline->linepos.clipstart; rc.bottom = pline->linepos.clipend; rc.left = ppos->clipstart; rc.right = ppos->clipend; /* check cell properties and colours */ if (cd->props.valid & P_ALIGN) { align = cd->props.alignment; } else { align = P_LEFT; } if (cd->props.valid & P_FONT) { hfont = SelectObject(hdc, cd->props.hFont); GetTextMetrics(hdc, &tm); tabwidth = tm.tmAveCharWidth * ptab->tabchars; } else { tabwidth = ptab->avewidth * ptab->tabchars; } /* set colours if not default */ if (cd->props.valid & P_FCOLOUR) { fcol = SetTextColor(hdc, cd->props.forecolour); } if (cd->props.valid & P_BCOLOUR) { /* there is a non-default background colour. * create a brush and fill the entire cell with it */ hbr = CreateSolidBrush(cd->props.backcolour); FillRect(hdc, &rc, hbr); DeleteObject(hbr); /* also set colour as background colour for the text */ bkcol = SetBkColor(hdc, cd->props.backcolour); } /* calc offset of text within cell for right-align or centering */ if (align == P_LEFT) { cx = ptab->avewidth/2; } else { if (cd->ptext == NULL) { cx = 0; } else { cx = LOWORD(GetTextExtent(hdc, cd->ptext, lstrlen(cd->ptext))); } if (align == P_CENTRE) { cx = (ppos->size - cx) / 2; } else { cx = ppos->size - cx - (ptab->avewidth/2); } } cx += ppos->start; /* expand tabs on output */ x = 0; y = pline->linepos.start; for (chp = cd->ptext; ((chp != NULL) && ((tabp = _fstrchr(chp, '\t')) != NULL)); ) { /* perform output upto tab char */ ExtTextOut(hdc, x+cx, y, ETO_CLIPPED, &rc, chp, tabp-chp, NULL); /* advance past the tab */ x += LOWORD(GetTextExtent(hdc, chp, tabp - chp)); x = ( (x + tabwidth) / tabwidth) * tabwidth; chp = ++tabp; } /*no more tabs - output rest of string */ if (chp != NULL) { ExtTextOut(hdc, x+cx, y, ETO_CLIPPED, &rc, chp, lstrlen(chp), NULL); } /* reset colours to original if not default */ if (cd->props.valid & P_FCOLOUR) { SetTextColor(hdc, fcol); } if (cd->props.valid & P_BCOLOUR) { SetBkColor(hdc, bkcol); } if (cd->props.valid & P_FONT) { SelectObject(hdc, hfont); } /* now box cell if marked */ if (cd->props.valid & P_BOX) { if (cd->props.box != 0) { rcbox.top = pline->linepos.start; rcbox.bottom = rcbox.top + pline->linepos.size; rcbox.left = ppos->start; rcbox.right = ppos->start + ppos->size; gtab_boxcell(hwnd, hdc, &rcbox, &rc, cd->props.box); } } }
/* * create a slm object for the given directory. The pathname may include * a filename component. * If the directory is not enlisted in a SLM library, this will return NULL. * * Check that the directory is valid, and that we can open slm.ini, and * build a UNC path to the master source library before declaring everything * valid. */ SLMOBJECT SLM_New(LPSTR pathname) { SLMOBJECT pslm; char slmpath[MAX_PATH]; HFILE fh; BOOL bOK; LPSTR pfinal = NULL; pslm = (SLMOBJECT) gmem_get(hHeap, sizeof(struct _slmobject)); if (pslm == NULL) { return(NULL); } if (pathname == NULL) { pathname = "."; } /* * find the directory portion of the path. */ if (dir_isvaliddir(pathname)) { /* * its a valid directory as it is. */ lstrcpy(pslm->CurDir, pathname); } else { /* it's not a valid directory, perhaps because it has a filename on * the end. remove the final element and try again. */ pfinal = _fstrrchr(pathname, '\\'); if (pfinal == NULL) { /* * there is no backslash in this name and it is not a directory * - it can only be valid if it is a file in the current dir. * so create a current dir of '.' */ lstrcpy(pslm->CurDir, "."); // remember the final element in case it was a wild card pfinal = pathname; } else { /* * pfinal points to the final backslash. */ _fstrncpy(pslm->CurDir, pathname, pfinal - pathname); } } /* * look for slm.ini in the specified directory */ lstrcpy(slmpath, pslm->CurDir); if (pslm->CurDir[lstrlen(pslm->CurDir) -1] != '\\') { lstrcat(slmpath, "\\"); } lstrcat(slmpath, "slm.ini"); fh = _lopen(slmpath, 0); if (fh != -1) { bOK = SLM_ReadIni(pslm, fh); /* * if pfinal is not null, then it might be a *.* wildcard pattern * at the end of the path - if so, we should append it to the masterpath. */ if (pfinal && (_fstrchr(pfinal, '*') || _fstrchr(pfinal, '?'))) { if ( (pslm->MasterPath[lstrlen(pslm->MasterPath)-1] != '\\') && (pfinal[0] != '\\')) { lstrcat(pslm->MasterPath, "\\"); } lstrcat(pslm->MasterPath, pfinal); } _lclose(fh); } else { bOK = FALSE; } if (!bOK) { gmem_free(hHeap, (LPSTR) pslm, sizeof(struct _slmobject)); return(NULL); } else { return(pslm); } }