Edge* Node::getSuccessorEdge(Node* Y) { if(NOTFOUND(mOutMap, Y)) cerr << "Successor node "<<Y->getName()<<" not found for node "<<getName()<<endl; assert(!NOTFOUND(mOutMap, Y)); return mOutMap[Y]; }
struct Result binary_search(size_t n, char *b) { size_t first = 0; size_t last = n; if (n == 0) { return NOTFOUND(0); } else if (strcmp(table[0], b) == 1) { return NOTFOUND(0); } else if (strcmp(table[n - 1], b) == -1) { return NOTFOUND(n); } while (first < last) { size_t mid = first + (last - first) / 2; if (strcmp(table[mid], b) == 1 || strcmp(table[mid], b) == 0) last = mid; else first = mid + 1; } if (strcmp(table[last], b) == 0) { return FOUND(last); } else { return NOTFOUND(last); } }
Node* Node::getCalleeDuplicateNode(unsigned idx) { assert(!NOTFOUND(mDuplicatesMap, idx)); return mDuplicatesMap[idx]; //assert(idx < mDuplicatesVec.size()); //return mDuplicatesVec[idx]; }
static void *doit(void *a){ FCGX_Request request; int rc; char *filename; UNUSED(a); FCGX_InitRequest(&request, 0, /* FCGI_FAIL_ACCEPT_ON_INTR */ 0); while(1){ int fd; //Some platforms require accept() serialization, some don't. The documentation claims it to be thread safe // static pthread_mutex_t accept_mutex = PTHREAD_MUTEX_INITIALIZER; // pthread_mutex_lock(&accept_mutex); rc = FCGX_Accept_r(&request); // pthread_mutex_unlock(&accept_mutex); if(rc < 0) break; //get the filename if((filename = FCGX_GetParam("SCRIPT_FILENAME", request.envp)) == NULL){ FORBIDDEN(request.out); //don't try to open directories }else if(filename[strlen(filename)-1] == '/'){ FORBIDDEN(request.out); //open the file }else if((fd = open(filename, O_RDONLY)) == -1){ NOTFOUND(request.out, filename); //no error, serve it }else{ SENDFILE(request.out, filename); close(fd); } FCGX_Finish_r(&request); } return NULL; }
void Node::addNode2BSet(Node* Y) { if(NOTFOUND(mJohnsonBSet, Y)) mJohnsonBSet.insert(Y); }
void * object_open(const char *filename, void * (*opencb)(const char *, const void *), const void * user_data) { /* Dictionary data directory path cache -- per-thread storage. */ static TLS char *path_found; char *completename = NULL; void *fp = NULL; char *data_dir = NULL; const char **path = NULL; if (NULL == filename) { /* Invalidate the dictionary data directory path cache. */ char *pf = path_found; path_found = NULL; free(pf); return NULL; } if (NULL == path_found) { data_dir = dictionary_get_data_dir(); if (verbosity_level(D_USER_FILES)) { char cwd[MAX_PATH_NAME]; char *cwdp = getcwd(cwd, sizeof(cwd)); prt_error("Debug: Current directory: %s\n", NULL == cwdp ? "NULL": cwdp); prt_error("Debug: Last-resort data directory: %s\n", data_dir ? data_dir : "NULL"); } } /* Look for absolute filename. * Unix: starts with leading slash. * Windows: starts with C:\ except that the drive letter may differ. */ if ((filename[0] == '/') #ifdef _WIN32 || ((filename[1] == ':') && ((filename[2] == '\\') || (filename[2] == '/'))) || (filename[0] == '\\') /* UNC path */ #endif /* _WIN32 */ ) { /* opencb() returns NULL if the file does not exist. */ fp = opencb(filename, user_data); lgdebug(D_USER_FILES, "Debug: Opening file %s%s\n", filename, NOTFOUND(fp)); } else { /* A path list in which to search for dictionaries. * path_found, data_dir or DEFAULTPATH may be NULL. */ const char *dictpath[] = { path_found, ".", "." DIR_SEPARATOR "data", "..", ".." DIR_SEPARATOR "data", data_dir, DEFAULTPATH, }; size_t i = sizeof(dictpath)/sizeof(dictpath[0]); for (path = dictpath; i-- > 0; path++) { if (NULL == *path) continue; free(completename); completename = join_path(*path, filename); fp = opencb(completename, user_data); lgdebug(D_USER_FILES, "Debug: Opening file %s%s\n", completename, NOTFOUND(fp)); if ((NULL != fp) || (NULL != path_found)) break; } } if (NULL == fp) { fp = opencb(filename, user_data); lgdebug(D_USER_FILES, "Debug: Opening file %s%s\n", filename, NOTFOUND(fp)); } else if (NULL == path_found) { char *pfnd = strdup((NULL != completename) ? completename : filename); if ((0 < verbosity) && (dict_file_open == opencb)) prt_error("Info: Dictionary found at %s\n", pfnd); for (size_t i = 0; i < 2; i++) { char *root = strrchr(pfnd, DIR_SEPARATOR[0]); if (NULL != root) *root = '\0'; } path_found = pfnd; } free(data_dir); free(completename); return fp; }