main(void) { FILE * finput, *foutput; char line[BUFSIZ*4]; char fname[BUFSIZ],inpname[BUFSIZ], outname[BUFSIZ]; int rval; long freemem = 0; long nwords = 0; long nhits = 0; char * p; fprintf(stderr,"use stdout? "); gets(line); if(line[0] == 'y' ) { fprintf(stderr,"type in forms\n"); strcpy(outname,"out.morph"); finput = stdin; } else { if((finput=MorphFopen(NOMINDEX,"r")) == NULL) { fprintf(stderr,"cannot find [%s]!\n", NOMINDEX); exit(-1); } /* fprintf(stderr,"word file? "); gets(fname); strcpy(inpname,fname); strcat(inpname,".words"); strcpy(outname,fname); strcat(outname,".morph"); if((finput=fopen(inpname,"r")) == NULL) { fprintf(stderr,"cannot find [%s]!\n", inpname); exit(-1); } */ } if( (foutput=fopen("stem.t","w")) == NULL) { fprintf(stderr,"cannot find [%s]!\n", outname); exit(-1); } while(fgets(line,(int)sizeof line,finput)) { if(isdigit(line[0]) || line[0] == '*') continue; trimwhite(line); trimdigit(line); p = line; /* while(*p&&!isspace(*p)) p++; if(*p) *p++ = 0; */ checkcmpstem(line,p,foutput); nwords++; if( rval ) { nhits++; } if(! ( nwords % 10) ) fprintf(stderr,"%ld %ld %0.2f %s %d\n", nwords , nhits, 100* ((float)nhits/(float)nwords) , line , rval ); } if( finput != stdin ) fclose(finput); fclose(foutput); }
int main (int argc, char *argv []) { iObjectRegistry* object_reg = csInitializer::CreateEnvironment (argc, argv); if (!object_reg) return -1; if (!csInitializer::SetupConfigManager (object_reg, 0)) { csPrintfErr ("couldn't setup config!\n"); return 1; } if (!csInitializer::RequestPlugins (object_reg, CS_REQUEST_VFS, CS_REQUEST_END)) return -1; VFS = csQueryRegistry<iVFS> (object_reg); if (!VFS) { csPrintfErr ("Cannot load iVFS plugin\n"); return -1; } Cfg = csQueryRegistry<iConfigManager> (object_reg); if (!Cfg) { csPrintfErr ("Cannot load iConfigManager plugin\n"); return -1; } VFS->MountRoot ("native"); csPrintf ("Welcome to Virtual Shell\n" "Type \"help\" to get a short description of commands\n" "\n"); while (!ShutDown) { char command [999]; csPrintf (CS_ANSI_TEXT_BOLD_ON CS_ANSI_FM "%s " CS_ANSI_TEXT_BOLD_OFF CS_ANSI_FG "#" CS_ANSI_RST " ", VFS->GetCwd ()); fflush (stdout); if (!fgets (command, sizeof(command), stdin)) { csPrintf ("\r\n"); ShutDown = true; } else { char* s = command; trimwhite(s); if (s != 0 && !execute (s)) csPrintfErr ("vsh: unknown command: [%s]\n", s); } } Cfg = 0; VFS = 0; csInitializer::DestroyApplication (object_reg); return 0; }