int st_query(int a, int b) { if (is_parent(a, b)) { return a; } if (is_parent(b, a)) { return b; } for (int i = len - 1; i >= 0; i--) { if (!is_parent(up[i][a], b)) { a = up[i][a]; } } return up[0][a]; }
//XXX:carefull, the dentry type is not supported by all fs static void dir_parse(i parent_fd) { ++depth; u8 dirents[DIRENTS_BUF_SZ]; while(1){ l r=getdents64(parent_fd,dirents,DIRENTS_BUF_SZ); if(ISERR(r)){ PERR("ERROR(%ld):getdents error\n",r); exit(-1); } if(!r) break; l j=0; while(j<r){ struct dirent64 *d=(struct dirent64*)(dirents+j); dout(d); if(d->type==DT_DIR&&!is_current(d->name)&&!is_parent(d->name)){ i dir_fd; do dir_fd=(i)openat(parent_fd,d->name,RDONLY|NONBLOCK); while(dir_fd==-EINTR); if(ISERR(dir_fd)) PERR("ERROR(%d):unable to open subdir:%s\n",dir_fd,d->name); else{ dir_parse(dir_fd); l r1; do r1=close(dir_fd); while(r1==-EINTR); } } j+=d->rec_len; } } depth--; }
Note::Note(std::string n, std::string dir) : Node(p), _name(n); Org_Bot::Org_Bot(): Node Note::Note(std::string n, Note* p) : Node(p), _name(n) { if (p != NULL) { p->make_parent(); //may already be parent, then line will do nada dir = p->path(); } else ERROR("Creating note with NULL parent. (Must give parent or directory)"); } Note::make_parent() {//Ignores request if already parent if (! is_parent()) { system(("rm "+path()).c_str()); system(("mkdir "+path()).c_str()); // Note* nt = new Note("note.a", this); // nt->msg = msg; // I'd like to do this without creating a new Note } } }
void Fl_Type::write_properties() { int level = 0; for (Fl_Type* p = parent; p; p = p->parent) level++; // repeat this for each attribute: if (!label().empty()) { write_indent(level+1); write_word("label"); write_word(label()); } if (!user_data().empty()) { write_indent(level+1); write_word("user_data"); write_word(user_data()); if (!user_data_type().empty()) { write_word("user_data_type"); write_word(user_data_type()); } } if (!callback().empty()) { write_indent(level+1); write_word("callback"); write_word(callback()); } if (is_parent() && open_) write_word("open"); if (selected) write_word("selected"); if (!tooltip().empty()) { write_indent(level+1); write_word("tooltip"); write_word(tooltip()); } }
int main(void) { int p,c,x,y; int result; while (1) { if (scanf("%s %s", buf1, buf2) != 2) { printf("unexpected\n"); exit(0); } if (strcmp(buf1,"no.child")==0) break; c = lookup(buf1); p = lookup(buf2); parent[c] = p; children[p][num_children[p]] = c; num_children[p]++; } while (1) { if (scanf("%s %s", buf1, buf2) != 2) { exit(0); } x = lookup(buf1); y = lookup(buf2); result = is_parent(x, y); if (result) { print_grand(result, "child"); continue; } result = is_parent(y, x); if (result) { print_grand(result, "parent"); continue; } if (parent[x] && (parent[x] == parent[y])) { printf("sibling\n"); continue; } if (check_cousins(x, y)) continue; printf("no relation\n"); } }
void init(bool exit_parent, boost::function0<bool> child_init_func) { daemon_impl_.fork_(child_init_func); if(exit_parent && is_parent()) { exit(EXIT_SUCCESS); } }
void handle_signal(int sigtype) { if (SIGINT == sigtype) { dump("Received SIGINT signal"); running = false; if (is_parent()) { send_signal(SIGTERM, false); } } else if (SIGTERM == sigtype) { dump("Received SIGTERM signal"); running = false; if (is_parent()) { send_signal(SIGTERM, false); } } else { dump("Received unknown signal. Ignoring it"); } }
/* * is_parent: returns True iff parent is a parent class of child, or if * parent and child are the same class. * Class id #s are compared to see if two classes are equal. */ int is_parent(class_type parent, class_type child) { if (child->class_id->idnum == parent->class_id->idnum) return True; if (child->superclass == NULL) return False; return is_parent(parent, child->superclass); }
string materialize (url u, string filter) { // Combines resolve and concretize url r= resolve (u, filter); if (!(is_rooted (r) || is_here (r) || is_parent (r))) { failed_error << "u= " << u << LF; FAILED ("url could not be resolved"); } return concretize (r); }
url operator * (url u1, url u2) { //cout << "concat " << u1->t << " * " << u2->t << "\n"; if (is_root (u2) || (is_concat (u2) && is_root (u2[1]))) { if (is_concat (u1) && is_root_web (u1[1])) { if (is_root (u2, "default") || (is_concat (u2) && is_root (u2[1], "default"))) { url v= u1[2]; while (is_concat (v)) v= v[1]; if (is_root (u2)) return u1[1] * v; return u1[1] * v * u2[2]; } if (is_root (u2, "blank") || (is_concat (u2) && is_root (u2[1], "blank"))) return reroot (u2, u1[1][1]->t->label); } return u2; } if (is_here (u1) || (u1->t == "")) return u2; if (is_here (u2)) return u1; if (is_none (u1)) return url_none (); if (is_none (u2)) return url_none (); if (u2 == url_parent ()) { if (is_root (u1)) return u1; if (is_pseudo_atomic (u1) && (!is_parent (u1))) return url_here (); if (is_semi_root (u1)) return u1; } if (is_concat (u2) && (u2[1] == url_parent ())) { if (is_root (u1)) return u1 * u2[2]; if (is_pseudo_atomic (u1) && (!is_parent (u1))) return u2[2]; if (is_semi_root (u1)) return u1 * u2[2]; } if (is_concat (u1)) return u1[1] * (u1[2] * u2); return as_url (tuple ("concat", u1->t, u2->t)); }
// write a widget and all it's children: void Fl_Type::write() { int level = 0; for (Fl_Type* p = parent; p; p = p->parent) level++; write_indent(level); write_word(type_name()); write_word(name()); write_open(level); write_properties(); write_close(level); if (!is_parent()) return; // now do children: write_open(level); Fl_Type *child; for (child = first_child; child; child = child->next_brother) child->write(); write_close(level); }
string concretize (url u) { // This routine transforms a resolved url into a system file name. // In the case of distant files from the web, a local copy is created. if (is_rooted (u, "default") || is_rooted (u, "file") || is_rooted (u, "blank")) return as_string (reroot (u, "default")); if (is_rooted_web (u)) return concretize (get_from_web (u)); if (is_rooted_tmfs (u)) return concretize (get_from_server (u)); if (is_ramdisc (u)) return concretize (get_from_ramdisc (u)); if (is_here (u)) return as_string (url_pwd ()); if (is_parent (u)) return as_string (url_pwd () * url_parent ()); if (is_wildcard (u, 1)) return u->t[1]->label; std_warning << "Couldn't concretize " << u->t << LF; // failed_error << "u= " << u << LF; // FAILED ("url has no root"); return "xxx"; }
static struct header *find_parent (ATTACHPTR **idx, short idxlen, struct body *cur, short nattach) { short i; struct header *parent = NULL; if (cur) { for (i = 0; i < idxlen; i++) { if (mutt_is_message_type (idx[i]->content->type, idx[i]->content->subtype) && is_parent (i, idx, idxlen, cur)) parent = idx[i]->content->hdr; if (idx[i]->content == cur) break; } } else if (nattach) parent = find_common_parent (idx, idxlen, nattach); return parent; }
class_type make_class_signature(id_type class_id, id_type superclass_id) { list_type l; id_type old_id; class_type c = (class_type) SafeMalloc(sizeof(class_struct)); c->superclass = NULL; /* Will be set for real below */ c->class_id = class_id; /* Class name must not have appeared before */ old_id = lookup_id(class_id); switch(class_id->type) { case I_MISSING: /* The class has been referenced in a function call, but not declared anywhere * We should use the existent class # and remove the id from the missing list */ if (class_id->source != I_CLASS) { action_error("Class %s was referenced elsewhere with different type", class_id->name); break; } /* Insert directly into global table to preserve id # */ class_id->type = I_CLASS; class_id->source = COMPILE; table_insert(st.globalvars, (void *) class_id, id_hash, id_compare); /* Remove from missing list */ table_delete_item(st.missingvars, class_id, id_hash, id_compare); break; case I_UNDEFINED: /* New class name--continue normally */ add_identifier(class_id, I_CLASS); break; case I_CLASS: /* We are recompiling a previously existing class. This is rather ugly, since * we want to replace all the old class's data with our new data. However, to give * previously compiled subclasses a chance of working with the new version, we * should try to match class numbers, message #s, etc. with the old class. * At this point, all the old class's data have been inserted into our hash * tables. The new class will be inserted into st.globalvars. We must remove the old class * from the class list. */ /* If class is given twice in source files, that's an error */ if (class_id->source == COMPILE) action_error("Class %s is given twice", class_id->name); else /* Change the existent class id to reflect the fact that the class has now * been recompiled. */ old_id->source = COMPILE; class_id->source = COMPILE; /* Delete self from list of existent classes. Give warnings for subclasses. */ for (l = st.classes; l != NULL; l = l->next) if (is_parent(c, (class_type) l->data)) { if (((class_type) l->data)->class_id->idnum == c->class_id->idnum) st.classes = list_delete_item(st.classes, l->data, class_compare); else /* Don't give warning if deleted self from list */ { recompile_type recompile_info = (recompile_type) SafeMalloc(sizeof(recompile_struct)); recompile_info->class_id = ((class_type) (l->data))->class_id; recompile_info->superclass = c->class_id; /* Only add to list if it isn't already there */ if (list_find_item(st.recompile_list, recompile_info->class_id, recompile_compare) == NULL) st.recompile_list = list_add_item(st.recompile_list, (void *) recompile_info); } } break; default: action_error("Duplicate identifier %s", class_id->name); } /* Delete this class from list of those that need to be recompiled */ st.recompile_list = list_delete_item(st.recompile_list, (void *) c->class_id, recompile_compare); c->resources = NULL; c->properties = NULL; c->messages = NULL; c->is_new = True; /* We should generate code for this class */ /* Superclass must be defined, if one is given */ if (superclass_id != NULL) { lookup_id(superclass_id); if (superclass_id->type != I_CLASS) action_error("Can't find superclass %s", superclass_id->name); else if (class_id->idnum == superclass_id->idnum) action_error("Can't subclass from self", superclass_id->name); else { /* Find superclass's data and store a pointer to it. */ for (l = st.classes; l != NULL; l = l->next) if (superclass_id->idnum == ((class_type) (l->data))->class_id->idnum) { c->superclass = (class_type) l->data; break; } if (c->superclass == NULL) action_error("Unable to find superclass %s", superclass_id->name); } } else c->superclass = NULL; st.curclass = class_id->idnum; /* Now add superclasses' properties to our own property table, but delete * them from our property list. This way the table will hold all properties * that can be referenced in the class, but the property list will only * hold those that were declared in this class (need to know this for code gen) */ add_parent_properties(c, c->superclass); /* Similarly, add superclasses' classvars. This must be done AFTER adding the properties, * since some properties in a superclass could be overriding classvars in a superclass */ add_parent_classvars(NULL, c, c->superclass); /* Add to list of classes */ st.classes = list_add_item(st.classes, (void *) c); return c; }