int qldap_get_mailstore(qldap *q, stralloc *hd, stralloc *ms) { int r; /* * get and check the mailstores. * Both homedir and maildir are set from the three * values ~control/ldapmessagestore, homedirectory * and mailmessagestore. * ms is only filled with a value if both homedir * and maildir is used. */ r = qldap_get_attr(q, LDAP_HOMEDIR, hd, SINGLE_VALUE); if (r == NOSUCH) { if (!stralloc_copys(hd, "")) return ERRNO; } else if (r != OK) return r; if (0 < hd->len) { if (hd->s[0] != '/' || check_paths(hd->s) == 0) { /* probably some log warning would be good */ return ILLVAL; } } r = qldap_get_attr(q, LDAP_MAILSTORE, ms, SINGLE_VALUE); if (r == NOSUCH) { if (!stralloc_copys(ms, "")) return ERRNO; } else if (r != OK) return r; if (ms->len > 0) if (check_paths(ms->s) == 0) { /* probably some log warning would be good */ return ILLVAL; } if (hd->len > 0 && ms->len > 0) return OK; if (hd->len > 0) return OK; if (ms->len > 0) { if (ms->s[0] != '/') { if (default_messagestore.s == 0 || default_messagestore.len == 0) return ILLVAL; if (!stralloc_cat(hd, &default_messagestore)) return ERRNO; } if (!stralloc_cat(hd, ms)) return ERRNO; if (!stralloc_copys(ms, "")) return ERRNO; return OK; } return NEEDED; }
int main(int argc, char **argv) { int mount; uid_t uid; /* Get program name */ { char *ch = strrchr(argv[0], '/'); if (ch) { argv[0] = ch + 1; } mount = argv[0][0]!='u'; } /* Check arguments */ #ifdef DEFAULT_DIR if (argc!=1+mount && argc!=2+mount) { fputs("usage: mountiso image.iso [ directory ]\n" " umountiso [ image.iso | directory ]\n", stderr); return 1; } #else if (argc!=2+mount) { fputs("usage: mountiso image.iso directory\n" " umountiso image.iso | directory\n", stderr); return 1; } #endif if ((uid = getuid())) { int ret; /* Became root */ if (setuid(0)) { fprintf(stderr, "%s: setuid: %s\n", argv[0], strerror(errno)); return 1; } /* Check paths */ ret = check_paths(argc, argv, uid, mount); if (ret) { return ret; } } /* Mount */ #ifdef DEFAULT_DIR argv[argc] = (char*)DEFAULT_DIR; #endif if (mount) { execl(MOUNT, MOUNT, "-o", mnt_opts(uid), "--", argv[1], argv[2], (const char *)0); } else { execl(UMOUNT, UMOUNT, "--", argv[1], (const char *)0); } fprintf(stderr, "%s: %s: %s\n", argv[0], mount ? MOUNT : UMOUNT, strerror(errno)); return 1; }
int main(int argc, char** argv) { // use smaller mmap chunks for testing. qio_mmap_chunk_iobufs = 1; // use smaller qbytes_iobuf_size for testing qbytes_iobuf_size = 4*1024; check_paths(); check_channels(); return 0; }
/* * validate_args -- (internal) check whether passed arguments are valid */ static int validate_args(struct pool_set *set_in, struct pool_set *set_out) { LOG(3, "set_in %p, set_out %p", set_in, set_out); if (set_in->directory_based) { ERR("transform of directory poolsets is not supported"); errno = EINVAL; return -1; } /* * check if all parts in the target poolset are large enough * (now replication works only for pmemobj pools) */ if (replica_check_part_sizes(set_out, PMEMOBJ_MIN_POOL)) { ERR("part sizes check failed"); return -1; } /* * check if all directories for part files exist and if part files * do not reoccur in the poolset */ if (check_paths(set_out)) return -1; /* * check if set_out has enough size, i.e. if the target poolset * structure has enough capacity to accommodate the effective size of * the source poolset */ ssize_t master_pool_size = replica_get_pool_size(set_in, 0); if (master_pool_size < 0) { ERR("getting pool size from master replica failed"); return -1; } if (set_out->poolsize < (size_t)master_pool_size) { ERR("target poolset is too small"); errno = EINVAL; return -1; } return 0; }
//connects libraries with address bool get_replace(char complete_list[], char curLib[],char* custname) { char path[5000]; bool check; check = check_paths(custname); // if end of array has been reached and no library has been found if(check == false){ //we look into "LD_curLib_PATH" if(getenv("LD_curLib_PATH") != NULL) { strcpy(path,getenv("LD_curLib_PATH")); strcat(path,"/"); strcat(path,curLib); if(checkfile(path) == 0){ strcat(complete_list,curLib); strcat(complete_list," => "); strcat(path,"\n"); strcat(complete_list,path); check = true; } } } // if previous test still doesnt link if(check == false) { strcpy(path,""); strcat(path,"/"); // look here strcat(path,"usr/lib/"); strcat(path,curLib); if(checkfile(path) == 0){ strcat(complete_list,curLib); strcat(complete_list," => "); strcat(path,"\n"); strcat(complete_list,path); check = true; } } // return status return check; }
int main(int argc, char** argv) { if( argc != 1 ) verbose = 1; // use smaller mmap chunks for testing. qio_mmap_chunk_iobufs = 1; // use smaller qbytes_iobuf_size for testing qbytes_iobuf_size = 4*1024; check_paths(); check_channels(); printf("qio_test PASS\n"); return 0; }
bool Target::track(const cv::Mat &prev, const cv::Mat &curr, double stamp) { // TODO: 应该根据轨迹的方向扩展搜索范围 ... // FIXME: 简单的四周扩展 ... // 第一次得到的特征点,总有部分不在活动目标上,所以应该在N帧之后,扔掉这些点,让“跟踪点”真正落在目标上 ... int exp = 60; // 不知道这个距离是否合理 ... cv::Rect search_roi = last_rc_; search_roi.x -= exp; search_roi.y -= exp; search_roi.width += 2 * exp; search_roi.height += 2 * exp; search_roi &= outer_; PTS last_pts = layers_.back(), curr_pts, last_pts2; g2l(last_pts, search_roi.tl()); //cv::Mat status, err, status2, err2; std::vector<unsigned char> status, err, status2, err2; //cv::calcOpticalFlowPyrLK(prev(search_roi), curr(search_roi), last_pts, curr_pts, status, err); calcLKOpticalFlow(prev(search_roi), curr(search_roi), last_pts, curr_pts, status); //#define REVERSE_FIND #ifdef REVERSE_FIND //cv::calcOpticalFlowPyrLK(curr(search_roi), prev(search_roi), curr_pts, last_pts2, status2, err2); // 反向查找 .. calcLKOpticalFlow(curr(search_roi), prev(search_roi), curr_pts, last_pts2, status2); // 反向查找 .. #endif // //for (int r = 0; r < status.rows; r++) { // // 标记找错的 // if (status.at<uchar>(r, 0) != 1) { // curr_pts[r].x = -10000; // } //} for (int r = 0; r < status.size(); r++) { // 标记找错的 if (status[r] != 1) { curr_pts[r].x = -10000; } } #ifdef REVERSE_FIND /// 比较 last_pts 与 last_pts2,如果比较接近,说明反向查找成功 ... for (int i = 0; i < (int)last_pts.size(); i++) { if (::distance(last_pts[i], last_pts2[i]) > 5.0) { curr_pts[i].x = -10000; } } #endif /// 删除错误点对应的轨迹 ... PTS valid_pts; for (int i = (int)curr_pts.size() - 1; i >= 0; i--) { if (curr_pts[i].x < -5000) { remove_path(i); } else { valid_pts.push_back(curr_pts[i]); } } if ((int)valid_pts.size() < min_pts_) { return false; } std::reverse(valid_pts.begin(), valid_pts.end()); // 需要反序 ... l2g(valid_pts, search_roi.tl()); layers_.push_back(valid_pts); last_rc_ = cv::boundingRect(valid_pts); brc_ |= last_rc_; return check_paths(stamp); }