void ClassBuffer::SearchFile (const char* path, struct stat&) { InputFile* f = InputFile::open(path); if (f == nil) { return; } const char* buf; int len = f->read(buf); if (len <= 0) { return; } if (_verbose) { printf("searching file %s (%d)\n", path, len); } /* * stupid regular expression requires writable strings to guarantee * null-termination */ char* tbuf = new char[len + 1]; Memory::copy(buf, tbuf, len); tbuf[len] = '\0'; TextBuffer textbuf(tbuf, len, len); SearchTextBuffer(&textbuf, path); delete tbuf; f->close(); delete f; }
int main(int argc, const char** argv){ #ifdef WIN32 setneuronhome(argv[0]); #endif if (!neuronhome()) { printf("no NEURONHOME\n"); return 1; } // printf("started hel2mos\n"); char buf[256]; sprintf(buf, "%s/lib/helpdict", neuronhome()); String sf(buf); InputFile* f = InputFile::open(sf); if (f == nil) { printf("Can't open %s\n", sf.string()); return 1; } const char* st; int flen = f->read(st); shelp = new CopyString(st, flen); f->close(); nrnbbs_connect(); nrnbbs_post("ochelp running"); start(); nrnbbs_notify("ochelp", help); #ifdef WIN32 nrnbbs_notify("neuron closed", help); #else nrnbbs_notify("neuron closed", quit); #endif help(""); nrnbbs_wait(&quit_); stop(); nrnbbs_take("ochelp running"); nrnbbs_disconnect(); return 0; }