int doFingerprints(char *file, char *mapfile){ FILE *output; char tampon[256]; struct utsname uts; time_t timeval; struct tm *ptr_tm; printf("[+] Begin Generating Fingerprints in %s\n\n", file); if((output = fopen(file, "w")) == NULL){ perror("fopen :"); return -1; } uname(&uts); (void)time(&timeval); ptr_tm = localtime(&timeval); strftime(tampon, 256, "%A %d %B %Y, %I:%S %p", ptr_tm); fprintf(output,"[BEGIN]\n"); fprintf(output,"[DATE %s]\n", tampon); fprintf(output,"[INFO %s %s %s]\n", uts.sysname, uts.machine, uts.release); fprintf(output,"[BEGIN SYSCALLS]\n"); writeSyscallsMemory(output, mapfile); fprintf(output,"[END SYSCALLS]\n"); fprintf(output,"[BEGIN IDT]\n"); writeIdtMemory(output, mapfile); fprintf(output,"[END IDT]\n"); fprintf(output,"[BEGIN SYMBOLS]\n"); writeSymbols(output, mapfile); fprintf(output,"[END SYMBOLS]\n"); fprintf(output,"[BEGIN BINFMT]\n"); writeBinfmt(output, mapfile); fprintf(output,"[END BINFMT]\n"); fprintf(output,"[END]\n"); printf("[+] End Generating Fingerprints in %s\n", file); fclose(output); return 0; }
int Project::syncDB() { if (mPendingDirtyFiles.isEmpty() && mPendingData.isEmpty()) return -1; StopWatch watch; // for (Map<uint32_t, shared_ptr<IndexData> >::iterator it = mPendingData.begin(); it != mPendingData.end(); ++it) { // writeErrorSymbols(mSymbols, mErrorSymbols, it->second->errors); // } if (!mPendingDirtyFiles.isEmpty()) { RTags::dirtySymbols(mSymbols, mPendingDirtyFiles); RTags::dirtySymbolNames(mSymbolNames, mPendingDirtyFiles); RTags::dirtyUsr(mUsr, mPendingDirtyFiles); mPendingDirtyFiles.clear(); } Set<uint32_t> newFiles; for (Map<uint32_t, shared_ptr<IndexData> >::iterator it = mPendingData.begin(); it != mPendingData.end(); ++it) { const shared_ptr<IndexData> &data = it->second; addDependencies(data->dependencies, newFiles); addFixIts(data->dependencies, data->fixIts); writeSymbols(data->symbols, mSymbols); writeUsr(data->usrMap, mUsr, mSymbols); writeReferences(data->references, mSymbols); writeSymbolNames(data->symbolNames, mSymbolNames); } for (Set<uint32_t>::const_iterator it = newFiles.begin(); it != newFiles.end(); ++it) { const Path path = Location::path(*it); const Path dir = path.parentDir(); if (dir.isEmpty()) { error() << "Got empty parent dir for" << path << *it; } else if (mWatchedPaths.insert(dir)) { mWatcher.watch(dir); } } mPendingData.clear(); if (Server::instance()->options().options & Server::Validate) { shared_ptr<ValidateDBJob> validate(new ValidateDBJob(static_pointer_cast<Project>(shared_from_this()), mPreviousErrors)); Server::instance()->startQueryJob(validate); } return watch.elapsed(); }