/ * Csp.c
Wang Jiabao CSP.C
Create: Shenyang, 1997.11.22 * / # include "dos.h" #include "conoe.h" #include "ctype.h" #include "string.h" #include "dir.h"
#define ESC 27 / * Find a file * / # define file_attrib fa_rdonly | fa_hidden | fa_rdonly | fa_direc / * Defines the maximum space of the array of scan strings * / # Define strmaxlen 129enum uicolorindex {FINDSTRCOLOR, / * Find string Displayed as bright green * / DigitColor, / * Digital display as cyan * / normalfileattr, hiddenreadonlyfileattr, hiddenfileattr, / * hidden files with dark gray display * / readonlyfileattr, / * read-only file to show * / Dir_normal_attr, / * directory Show * / DIR_HIDDEN_RDONLY_ATTR, DIR_HIDDEN_ATTR, DIR_RDONLY_ATTR, NORMVIDEO / * General Document in the Default Show * /}; unsigned char uicolor [] = {0x0a, 0x0b, 0x07,04,04,0 x0c, 0x70,0x74,0x78, 0x7c, 0x07}; char * keywords [11] = { "CSP", "tARGETSTRING", "DIGITAL", "NORMALFILE", "HIDDEN & READONLYFILE", "HIDDENFILE", "READONLYFILE", "NORMALDIRECTORY", "HIDDEN & READONLYDIRECTORY", " HiddENDIRECTORY "," ReadonlyDirectory "}; char * help =" Color Search Plus v1.2 / / r / nwritten by Wangjiabao, 1997.11.22 @ Shenyang / / R / Nusage: CSP [
[-S]] / / r / n searchString target string / / r / n -s Turn Screen Search On / / R / N / / R / NCSP Based on The Direct Full Screen Search Technology.it Can Exact Find The / / / / / r / nstring that you have specified on command line, the target string either / / r / non screen or file in the current directory./ / r / nWhen CSP found the target string, it will indicates it with markedness color, / / r / nand when you find string in a directory, all files with read only and hidden / / r / nproperty in the directory will also markedness with specifically color./ / r / n / / r / nCSP defined such property colors in user interface: / / R / N targetString the Found Target String / / R / N Digital Digit / / R / N Normalfile Normal File / / R / N Hidden & Readonlyfile Hidden & Read All File / / R / N Hiddenfile Hidden File / / R / N Readonlyfile Read Only File / / / R / N NormalDirectory Normal Directory / / R / N Hidden & ReadonlyDirectory Hidde N & read Only Directory / / R / N HiddEndirectory Hiddirectory Read Only Directory / "; / * To find strings * / char far findstr [strMaxlen]; / * Find string functions, return value Founded target string number * / int chguicolor (int top, int / * column file directory function * / void DirfileSearch (void);
Main (int Argc, char * argv []) {textattr (uicolor [normvideo]); if (argc> 1) STRCPY (FindStr, Strupr (Argv [1])); Else {/ * If you do not specify a lookup character, display Tip information * / int TMPI = 11; CPRINTF ("% s", help); while (tmpi -) {structure (FindStr, Strupr (keywords [tmpi]); uicolor [0] = TMPI> 1? Uicolor [ TMPI-1]: lightgreen; chguicolor (wherey () - 24, wherey ());} exit (0);} if (! strcmp (strupr (Argv [2]), "- s")) {/ * Find * / int num = chguicolor (0,25); textattr (uicolor [normvideo]); cprintf ("// _ // _ csp saarched [% d] targets on screen screen.Any key back....... _ / ", num); getch ();} else / * look up files containing specified strings in the current directory * / DirfileSearch ();
INT chguicolor (int topstrlen = Strlen (FindStr); INT I, FOUND = 0, IncludedIgit; Char * Strtmp, * Mark = "/ 1", Mark1 = '/ 2'; Unsigned Char ch, ScannedStr [STRMAXLEN]; unsigned Buf = 0xB800, BufOffset, Start, DigitStart, ScanStrStart; topy * = 160; bottomy * = 160; for (BufOffset = topy; BufOffset 1, uicolor [DigitColor] | (PEEKB (BUF, BUFOFFSET 1) & 0xF0));} while (isdigit ((ch = peekb (buf, bufoffset = 2)) && bufoffset void DirFileSearch (void) {struct ffblk DTA; int LineCount = 0, Top; unsigned long Files = 0, FullScreen = 0; findfirst ( ". * *", & DTA, FILE_ATTRIB); textattr (UiColor [Dir_NORMAL_Attr]); cprintf ( "% -13s", DTA.ff_name); LineCount ; Files ; While (! FindNext (& DTA)) {files ; Textattr (uicolor [normalfileattr]); if (linecount == 23 * 6) {/ * file list Screen * / fullscreen ; linecount = 0; if (chguicolor (2, 25)) {/ * find the target character is pause * / cprintf ("/ r / n // _ // _ esc quit, other key continue. [% D ] files scanned _ / _ / _ / ", files); if (getch () == ESC) {CPRINTF (" / r // _ // _ csp interrupt by user. [% d] files scanned already _ / _ / ", FILES) EXIT (0);}} cprintf ("/ r / n");} if (linecount% 6 == 0) CPrintf ("/ r / n"); / * list full line Fold * / LineCount ; if (DTA.ff_attrib & FA_DIREC) {textattr (UiColor [Dir_NORMAL_Attr]); / * Common directory * / if (DTA.ff_attrib & FA_RDONLY) / * read-only attribute directory * / textattr (UiColor [Dir_RDONLY_Attr]); if (DTA.ff_attrib & FA_HIDDEN) / * Hide property directory * / textattr (uicolor [dir_hidden_attr]); if (DTA .ff_attrib & FA_HIDDEN && DTA.ff_attrib & FA_RDONLY) textattr (UiColor [Dir_HIDDEN_RDONLY_Attr]); / * read-only & hidden attribute directory * / cprintf ( "% - 13s", DTA.ff_name); continue;} if (DTA.ff_attrib & FA_HIDDEN && DTA. ff_attrib & FA_RDONLY) {textattr (UiColor [HiddenReadOnlyFileAttr]); cprintf ( "% - 13s", DTA.ff_name); continue;} if (DTA.ff_attrib & FA_HIDDEN) {/ * Hide document * / textattr (UiColor [HiddenFileAttr]); cprintf ( "% -13s", DTA.ff_name); Continue;} IF (DTA.ff_attrib &