static unsigned int adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts, int isreq) { Id id, name, marker; const char *n, *f, *k; const char **a; n = f = k = 0; marker = isreq ? -SOLVABLE_PREREQMARKER : 0; for (a = atts; *a; a += 2) { if (!strcmp(*a, "name")) n = a[1]; else if (!strcmp(*a, "flags")) f = a[1]; else if (!strcmp(*a, "kind")) k = a[1]; else if (isreq && !strcmp(*a, "pre") && a[1][0] == '1') marker = SOLVABLE_PREREQMARKER; } if (!n) return olddeps; if (k && !strcmp(k, "package")) k = 0; if (k) { int l = strlen(k) + 1 + strlen(n) + 1; if (l > pd->acontent) { pd->content = sat_realloc(pd->content, l + 256); pd->acontent = l + 256; } sprintf(pd->content, "%s:%s", k, n); name = str2id(pool, pd->content, 1); } else name = str2id(pool, (char *)n, 1); if (f) { Id evr = makeevr_atts(pool, pd, atts); int flags; for (flags = 0; flags < 6; flags++) if (!strcmp(f, flagtab[flags])) break; flags = flags < 6 ? flags + 1 : 0; id = rel2id(pool, name, evr, flags, 1); } else id = name; #if 0 fprintf(stderr, "new dep %s%s%s\n", id2str(pool, d), id2rel(pool, d), id2evr(pool, d)); #endif return repo_addid_dep(pd->common.repo, olddeps, id, marker); }
static void doquery(Pool *pool, Repo *repo, const char *query) { Id id, type = 0; char qbuf[256]; const char *qp; Dataiterator di; qp = strchr(query, ':'); if (qp) { type = strn2id(pool, query, qp - query, 0); if (!type) exit(0); qp++; } else qp = query; snprintf(qbuf, sizeof(qbuf), "repository:repomd:%s", qp); id = str2id(pool, qbuf, 0); if (!id) exit(0); dataiterator_init(&di, pool, repo, SOLVID_META, id, 0, 0); dataiterator_prepend_keyname(&di, REPOSITORY_REPOMD); while (dataiterator_step(&di)) { if (type) { dataiterator_setpos_parent(&di); if (pool_lookup_id(pool, SOLVID_POS, REPOSITORY_REPOMD_TYPE) != type) continue; } switch (di.key->type) { case REPOKEY_TYPE_ID: case REPOKEY_TYPE_CONSTANTID: printf("%s\n", id2str(pool, di.kv.id)); break; case REPOKEY_TYPE_STR: printf("%s\n", di.kv.str); break; case REPOKEY_TYPE_NUM: printf("%d\n", di.kv.num); break; case REPOKEY_TYPE_SHA1: printf("sha1:%s\n", repodata_chk2str(di.data, di.key->type, (unsigned char *)di.kv.str)); break; case REPOKEY_TYPE_SHA256: printf("sha256:%s\n", repodata_chk2str(di.data, di.key->type, (unsigned char *)di.kv.str)); break; default: break; } } dataiterator_free(&di); }
VirtualStream * virtual_stream_find(char * id) { LINK * l; unsigned n = 0; if (str2id(id, &n)) { for (l = streams.next; l != &streams; l = l->next) { VirtualStream * stream = all2stream(l); if (stream->id == n && !stream->deleted) return stream; } } errno = ERR_INV_CONTEXT; return NULL; }
static unsigned int adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, Id marker) { char *name; Id id; while ((name = splitword(&line)) != 0) { /* Hack, as the content file adds 'package:' for package dependencies sometimes. */ if (!strncmp (name, "package:", 8)) name += 8; id = str2id(pool, name, 1); if (*line == '<' || *line == '>' || *line == '=') /* rel follows */ { char *rel = splitword(&line); char *evr = splitword(&line); int flags; if (!rel || !evr) { pool_debug(pool, SAT_FATAL, "repo_content: bad relation '%s %s'\n", name, rel); exit(1); } for (flags = 0; flags < 6; flags++) if (!strcmp(rel, flagtab[flags])) break; if (flags == 6) { pool_debug(pool, SAT_FATAL, "repo_content: unknown relation '%s'\n", rel); exit(1); } id = rel2id(pool, id, str2id(pool, evr, 1), flags + 1, 1); } olddeps = repo_addid_dep(pd->repo, olddeps, id, marker); } return olddeps; }
void sparql_parser::do_parse(vector<string>& token_vec){ if(!valid) return ; remove_header(token_vec); if(!valid) return ; replace_prefix(token_vec); if(!valid) return ; if(token_vec.size()%4!=0){ cout<<"[error token number] "<<endl; valid=false; return ; } int iter=0; while(iter<token_vec.size()){ string strs[3]={token_vec[iter+0],token_vec[iter+1],token_vec[iter+2]}; int ids[3]; if(token_vec[iter+3]=="<-"){ swap(strs[0],strs[2]); } for(int i=0;i<3;i++){ ids[i]=str2id(strs[i]); } if(token_vec[iter+3]=="." || token_vec[iter+3]=="->"){ req_template.cmd_chains.push_back(ids[0]); req_template.cmd_chains.push_back(ids[1]); req_template.cmd_chains.push_back(direction_out); req_template.cmd_chains.push_back(ids[2]); iter+=4; } else if(token_vec[iter+3]=="<-"){ req_template.cmd_chains.push_back(ids[0]); req_template.cmd_chains.push_back(ids[1]); req_template.cmd_chains.push_back(direction_in); req_template.cmd_chains.push_back(ids[2]); iter+=4; } else { cout<<"[error seperator] "<<endl; valid=false; return ; } } for(int i=0;i<req_template.cmd_chains.size();i++){ if(req_template.cmd_chains[i]==place_holder){ req_template.place_holder_position.push_back(i); return ; } } }
static StreamClient * find_client(char * s, Channel * c) { unsigned id = 0; if (str2id(s, &id)) { unsigned h = get_client_hash(id, c); LINK * l = handle_hash[h].next; while (l != &handle_hash[h]) { StreamClient * client = hash2client(l); if (client->stream->id == id && client->channel == c) return client; l = l->next; } } errno = set_fmt_errno(ERR_OTHER, "No such stream: %s", s); return NULL; }
static StreamClient * find_client(char * s, Channel * c) { unsigned id = 0; if (str2id(s, &id)) { unsigned h = get_client_hash(id, c); LINK * l = handle_hash[h].next; while (l != &handle_hash[h]) { StreamClient * client = hash2client(l); if (client->stream->id == id && client->channel == c) return client; l = l->next; } } errno = ERR_INV_CONTEXT; return NULL; }
void langdemo(Pool *pool) { Id screenid, p, pp; screenid = str2id(pool, "3ddiag", 1); static const char *languages[] = {"es", "de"}; pool_set_languages(pool, languages, 2); FOR_PROVIDES(p, pp, screenid) { unsigned int medianr; Id chktype = 0; char *loc = solvable_get_location(pool->solvables + p, &medianr); const char *chksum; chksum = solvable_lookup_checksum(pool->solvables + p, SOLVABLE_CHECKSUM, &chktype); printf("%s: %s\n%s[%d] %s:%s\n", solvable2str(pool, pool->solvables + p), solvable_lookup_str_poollang(pool->solvables + p, SOLVABLE_DESCRIPTION), loc, medianr, id2str(pool, chktype), chksum); printf("DE: %s\n", solvable_lookup_str_lang(pool->solvables + p, SOLVABLE_DESCRIPTION, "de", 1)); }
static gid_t str2gid(const char *grnam) { struct group *grp = getgrnam(grnam); gid_t res; if (grp == NULL) { res = (gid_t)str2id(grnam); if (res == (gid_t)-1) { (void) fprintf(stderr, "%s: %s: unknown group" " or bad gid\n", command, grnam); exit(1); } } else { res = grp->gr_gid; } return (res); }
static int FUNC_TEST_CMD(struct cmd_data *data) { int cmd = str2id(data->id); switch (cmd) { case SEGFAULT: { int *p = NULL; *p = 0; break; } case DEADLOCK: { DEBUG("Enter deadlock"); while (1) sleep(1); DEBUG("Exit deadlock"); } default: ERROR("cmd %s not supported", data->id); return 1; } return 0; }
static Solvable * select_solvable(Solver *solv, Pool *pool, Repo *repo, char *name) { Id id; Queue plist; int i, end; Solvable *s; id = str2id(pool, name, 1); queue_init(&plist); i = repo ? repo->start : 1; end = repo ? repo->end : pool->nsolvables; for (; i < end; i++) { s = pool->solvables + i; if (repo && s->repo != repo) continue; if (!pool_installable(pool, s)) continue; if (s->name == id) queue_push(&plist, i); } prune_best_arch_name_version(solv, pool, &plist); if (plist.count == 0) { printf("unknown package '%s'\n", name); exit(1); } id = plist.elements[0]; queue_free(&plist); return pool->solvables + id; }
static void XMLCALL endElement(void *userData, const char *name) { //fprintf(stderr,"-tag: %s\n", name); struct parsedata *pd = userData; Pool *pool = pd->common.pool; Solvable *s = pd->solvable; Repo *repo = pd->common.repo; Id handle = pd->handle; Id id; char *p; if (pd->depth != pd->statedepth) { pd->depth--; // printf("back from unknown %d %d %d\n", pd->state, pd->depth, pd->statedepth); return; } /* ignore patterns & metadata */ if (pd->state == STATE_START && !strcmp(name, "patterns")) return; if (pd->state == STATE_START && !strcmp(name, "products")) return; //if (pd->state == STATE_START && !strcmp(name, "metadata")) // return; if (pd->state == STATE_SOLVABLE && !strcmp(name, "format")) return; pd->depth--; pd->statedepth--; switch (pd->state) { case STATE_SOLVABLE: if (pd->kind && !s->name) /* add namespace in case of NULL name */ s->name = str2id(pool, join2(pd->kind, ":", ""), 1); if (!s->arch) s->arch = ARCH_NOARCH; if (!s->evr) s->evr = ID_EMPTY; /* some patterns have this */ if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) s->provides = repo_addid_dep(repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); s->supplements = repo_fix_supplements(repo, s->provides, s->supplements, pd->freshens); s->conflicts = repo_fix_conflicts(repo, s->conflicts); pd->freshens = 0; pd->kind = 0; break; case STATE_NAME: if (pd->kind) s->name = str2id(pool, join2(pd->kind, ":", pd->content), 1); else s->name = str2id(pool, pd->content, 1); break; case STATE_ARCH: s->arch = str2id(pool, pd->content, 1); break; case STATE_VENDOR: s->vendor = str2id(pool, pd->content, 1); break; case STATE_RPM_GROUP: repodata_set_poolstr(pd->data, handle, SOLVABLE_GROUP, pd->content); break; case STATE_RPM_LICENSE: repodata_set_poolstr(pd->data, handle, SOLVABLE_LICENSE, pd->content); break; case STATE_CHECKSUM: { Id type, index; type = sat_chksum_str2type(pd->tmpattr); if (!type) { fprintf(stderr, "Unknown checksum type: %d: %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), pd->tmpattr); exit(1); } if (strlen(pd->content) != 2 * sat_chksum_len(type)) { fprintf(stderr, "Invalid checksum length: %d: for %s\n", (unsigned int)XML_GetCurrentLineNumber(*pd->parser), pd->tmpattr); exit(1); } repodata_set_checksum(pd->data, handle, SOLVABLE_CHECKSUM, type, pd->content); /* we save the checksum to solvable id relationship for extended metadata */ index = stringpool_str2id(&pd->cspool, pd->content, 1 /* create it */); if (index >= pd->ncscache) { pd->cscache = sat_zextend(pd->cscache, pd->ncscache, index + 1 - pd->ncscache, sizeof(Id), 255); pd->ncscache = index + 1; } /* add the checksum to the cache */ pd->cscache[index] = s - pool->solvables; break; } case STATE_FILE: #if 0 id = str2id(pool, pd->content, 1); s->provides = repo_addid_dep(repo, s->provides, id, SOLVABLE_FILEMARKER); #endif if ((p = strrchr(pd->content, '/')) != 0) { *p++ = 0; if (pd->lastdir && !strcmp(pd->lastdirstr, pd->content)) { id = pd->lastdir; } else { int l; id = repodata_str2dir(pd->data, pd->content, 1); l = strlen(pd->content) + 1; if (l > pd->lastdirstrl) { pd->lastdirstrl = l + 128; pd->lastdirstr = sat_realloc(pd->lastdirstr, pd->lastdirstrl); } strcpy(pd->lastdirstr, pd->content); pd->lastdir = id; } } else { p = pd->content; id = 0; } if (!id) id = repodata_str2dir(pd->data, "/", 1); repodata_add_dirstr(pd->data, handle, SOLVABLE_FILELIST, id, p); break; case STATE_SUMMARY: repodata_set_str(pd->data, handle, langtag(pd, SOLVABLE_SUMMARY, pd->tmplang), pd->content); break; case STATE_DESCRIPTION: set_description_author(pd->data, handle, pd->content, pd); break; case STATE_CATEGORY: repodata_set_str(pd->data, handle, langtag(pd, SOLVABLE_CATEGORY, pd->tmplang), pd->content); break; case STATE_DISTRIBUTION: repodata_set_poolstr(pd->data, handle, SOLVABLE_DISTRIBUTION, pd->content); break; case STATE_URL: if (pd->content[0]) repodata_set_str(pd->data, handle, SOLVABLE_URL, pd->content); break; case STATE_PACKAGER: if (pd->content[0]) repodata_set_poolstr(pd->data, handle, SOLVABLE_PACKAGER, pd->content); break; case STATE_SOURCERPM: set_sourcerpm(pd->data, s, handle, pd->content); break; case STATE_RELNOTESURL: if (pd->content[0]) { repodata_add_poolstr_array(pd->data, pd->handle, PRODUCT_URL, pd->content); repodata_add_idarray(pd->data, pd->handle, PRODUCT_URL_TYPE, str2id(pool, "releasenotes", 1)); } break; case STATE_UPDATEURL: if (pd->content[0]) { repodata_add_poolstr_array(pd->data, pd->handle, PRODUCT_URL, pd->content); repodata_add_idarray(pd->data, pd->handle, PRODUCT_URL_TYPE, str2id(pool, "update", 1)); } break; case STATE_OPTIONALURL: if (pd->content[0]) { repodata_add_poolstr_array(pd->data, pd->handle, PRODUCT_URL, pd->content); repodata_add_idarray(pd->data, pd->handle, PRODUCT_URL_TYPE, str2id(pool, "optional", 1)); } break; case STATE_FLAG: if (pd->content[0]) repodata_set_poolstr(pd->data, handle, PRODUCT_FLAGS, pd->content); break; case STATE_EULA: if (pd->content[0]) repodata_set_str(pd->data, handle, langtag(pd, SOLVABLE_EULA, pd->tmplang), pd->content); break; case STATE_KEYWORD: if (pd->content[0]) repodata_add_poolstr_array(pd->data, pd->handle, SOLVABLE_KEYWORDS, pd->content); break; case STATE_DISKUSAGE: if (pd->ndirs) commit_diskusage(pd, pd->handle); break; case STATE_ORDER: if (pd->content[0]) repodata_set_str(pd->data, pd->handle, SOLVABLE_ORDER, pd->content); default: break; } pd->state = pd->sbtab[pd->state]; pd->docontent = 0; // fprintf(stderr, "back from known %d %d %d\n", pd->state, pd->depth, pd->statedepth); }
static Id makeevr_atts(Pool *pool, struct parsedata *pd, const char **atts) { const char *e, *v, *r, *v2; char *c; int l; e = v = r = 0; for (; *atts; atts += 2) { if (!strcmp(*atts, "epoch")) e = atts[1]; else if (!strcmp(*atts, "ver")) v = atts[1]; else if (!strcmp(*atts, "rel")) r = atts[1]; } if (e && !strcmp(e, "0")) e = 0; if (v && !e) { for (v2 = v; *v2 >= '0' && *v2 <= '9'; v2++) ; if (v2 > v && *v2 == ':') e = "0"; } l = 1; if (e) l += strlen(e) + 1; if (v) l += strlen(v); if (r) l += strlen(r) + 1; if (l > pd->acontent) { pd->content = sat_realloc(pd->content, l + 256); pd->acontent = l + 256; } c = pd->content; if (e) { strcpy(c, e); c += strlen(c); *c++ = ':'; } if (v) { strcpy(c, v); c += strlen(c); } if (r) { *c++ = '-'; strcpy(c, r); c += strlen(c); } *c = 0; if (!*pd->content) return 0; #if 0 fprintf(stderr, "evr: %s\n", pd->content); #endif return str2id(pool, pd->content, 1); }
void request_name( Request *t, const char *name, int what ) { queue_push( &(t->queue), what|SOLVER_SOLVABLE_NAME ); queue_push( &(t->queue), str2id( t->pool, name, 1 )); }
enum AVCodecID ff_guess_image2_codec(const char *filename) { return str2id(ff_img_tags, filename); }
void repo_add_content(Repo *repo, FILE *fp, int flags) { Pool *pool = repo->pool; char *line, *linep; int aline; Solvable *s; struct parsedata pd; Repodata *data; Id handle = 0; int contentstyle = 0; char *descrdir = 0; char *datadir = 0; char *defvendor = 0; int i = 0; /* architectures we use the first architecture in BASEARCHS or noarch for the product. At the end we create (clone) the product for each one of the remaining architectures we allow max 4 archs */ unsigned int numotherarchs = 0; Id *otherarchs = 0; memset(&pd, 0, sizeof(pd)); line = sat_malloc(1024); aline = 1024; pd.repo = repo; linep = line; s = 0; data = repo_add_repodata(repo, flags); for (;;) { char *key, *value; /* read line into big-enough buffer */ if (linep - line + 16 > aline) { aline = linep - line; line = sat_realloc(line, aline + 512); linep = line + aline; aline += 512; } if (!fgets(linep, aline - (linep - line), fp)) break; linep += strlen(linep); if (linep == line || linep[-1] != '\n') continue; while ( --linep > line && ( linep[-1] == ' ' || linep[-1] == '\t' ) ) ; /* skip trailing ws */ *linep = 0; linep = line; /* expect "key value" lines */ value = line; key = splitword(&value); if (key) { #if 0 fprintf (stderr, "key %s, value %s\n", key, value); #endif #define istag(x) (!strcmp (key, x)) #define code10 (contentstyle == 10) #define code11 (contentstyle == 11) if (istag ("CONTENTSTYLE")) { if (contentstyle) pool_debug(pool, SAT_ERROR, "repo_content: 'CONTENTSTYLE' must be first line of 'content'\n"); contentstyle = atoi(value); continue; } if (!contentstyle) contentstyle = 10; /* repository tags */ /* we also replicate some of them into the product solvables * to be backward compatible */ if (istag ("REPOID")) { repodata_add_poolstr_array(data, SOLVID_META, REPOSITORY_REPOID, value); continue; } if (istag ("DESCRDIR")) { if (descrdir) free(descrdir); else repo_set_str(repo, SOLVID_META, SUSETAGS_DESCRDIR, value); if (s) repo_set_str(repo, s - pool->solvables, SUSETAGS_DESCRDIR, value); descrdir = strdup(value); continue; } if (istag ("DATADIR")) { if (datadir) free(datadir); else repo_set_str(repo, SOLVID_META, SUSETAGS_DATADIR, value); if (s) repo_set_str(repo, s - pool->solvables, SUSETAGS_DATADIR, value); datadir = strdup(value); continue; } if (istag ("VENDOR")) { if (defvendor) free(defvendor); else repo_set_poolstr(repo, SOLVID_META, SUSETAGS_DEFAULTVENDOR, value); if (s) s->vendor = str2id(pool, value, 1); defvendor = strdup(value); continue; } if (istag ("META") || istag ("HASH") || istag ("KEY")) { char *checksumtype, *checksum; Id fh, type; int l; if ((checksumtype = splitword(&value)) == 0) continue; if ((checksum = splitword(&value)) == 0) continue; if (!*value) continue; if (!strcasecmp(checksumtype, "sha") || !strcasecmp(checksumtype, "sha1")) l = SIZEOF_SHA1 * 2, type = REPOKEY_TYPE_SHA1; else if (!strcasecmp(checksumtype, "sha256")) l = SIZEOF_SHA256 * 2, type = REPOKEY_TYPE_SHA256; else if (!strcasecmp(checksumtype, "md5")) l = SIZEOF_MD5 * 2, type = REPOKEY_TYPE_MD5; else { fprintf(stderr, "Unknown checksum type: %s: %s\n", value, checksumtype); exit(1); } if (strlen(checksum) != l) { fprintf(stderr, "Invalid checksum length: %s: for %s\n", value, checksum); exit(1); } fh = repodata_new_handle(data); repodata_set_poolstr(data, fh, SUSETAGS_FILE_TYPE, key); repodata_set_str(data, fh, SUSETAGS_FILE_NAME, value); repodata_set_checksum(data, fh, SUSETAGS_FILE_CHECKSUM, type, checksum); repodata_add_flexarray(data, SOLVID_META, SUSETAGS_FILE, fh); continue; } /* product tags */ if ((code10 && istag ("PRODUCT")) || (code11 && istag ("NAME"))) { if (s && !s->name) { /* this solvable was created without seeing a PRODUCT entry, just set the name and continue */ s->name = str2id(pool, join(&pd, "product", ":", value), 1); continue; } if (s) { /* finish old solvable */ if (!s->arch) s->arch = ARCH_NOARCH; if (!s->evr) s->evr = ID_EMPTY; if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) s->provides = repo_addid_dep(repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); if (code10) s->supplements = repo_fix_supplements(repo, s->provides, s->supplements, 0); } /* create new solvable */ s = pool_id2solvable(pool, repo_add_solvable(repo)); repodata_extend(data, s - pool->solvables); handle = s - pool->solvables; s->name = str2id(pool, join(&pd, "product", ":", value), 1); if (datadir) repo_set_str(repo, s - pool->solvables, SUSETAGS_DATADIR, datadir); if (descrdir) repo_set_str(repo, s - pool->solvables, SUSETAGS_DESCRDIR, descrdir); if (defvendor) s->vendor = str2id(pool, defvendor, 1); continue; } /* Sometimes PRODUCT/NAME is not the first entry, but we need a solvable from here on. */ if (!s) { s = pool_id2solvable(pool, repo_add_solvable(repo)); repodata_extend(data, s - pool->solvables); handle = s - pool->solvables; } if (istag ("VERSION")) pd.tmpvers = strdup(value); else if (istag ("RELEASE")) pd.tmprel = strdup(value); else if (code11 && istag ("DISTRIBUTION")) repo_set_str(repo, s - pool->solvables, SOLVABLE_DISTRIBUTION, value); else if (istag ("UPDATEURLS")) add_multiple_urls(data, handle, value, str2id(pool, "update", 1)); else if (istag ("EXTRAURLS")) add_multiple_urls(data, handle, value, str2id(pool, "extra", 1)); else if (istag ("OPTIONALURLS")) add_multiple_urls(data, handle, value, str2id(pool, "optional", 1)); else if (istag ("RELNOTESURL")) add_multiple_urls(data, handle, value, str2id(pool, "releasenotes", 1)); else if (istag ("SHORTLABEL")) repo_set_str(repo, s - pool->solvables, PRODUCT_SHORTLABEL, value); else if (istag ("LABEL")) /* LABEL is the products SUMMARY. */ repo_set_str(repo, s - pool->solvables, SOLVABLE_SUMMARY, value); else if (!strncmp (key, "LABEL.", 6)) repo_set_str(repo, s - pool->solvables, pool_id2langid(pool, SOLVABLE_SUMMARY, key + 6, 1), value); else if (istag ("FLAGS")) add_multiple_strings(data, handle, PRODUCT_FLAGS, value); else if (istag ("VENDOR")) /* actually already handled above */ s->vendor = str2id(pool, value, 1); else if (istag ("BASEARCHS")) { char *arch; if ((arch = splitword(&value)) != 0) { s->arch = str2id(pool, arch, 1); while ((arch = splitword(&value)) != 0) { otherarchs = sat_extend(otherarchs, numotherarchs, 1, sizeof(Id), 7); otherarchs[numotherarchs++] = str2id(pool, arch, 1); } } } /* * Every tag below is Code10 only * */ if (code10 && istag ("DISTPRODUCT")) /* DISTPRODUCT is for registration and Yast, not for the solver. */ repo_set_str(repo, s - pool->solvables, PRODUCT_DISTPRODUCT, value); else if (code10 && istag ("DISTVERSION")) /* DISTVERSION is for registration and Yast, not for the solver. */ repo_set_str(repo, s - pool->solvables, PRODUCT_DISTVERSION, value); else if (code10 && istag ("ARCH")) /* Theoretically we want to have the best arch of the given modifiers which still is compatible with the system arch. We don't know the latter here, though. */ s->arch = ARCH_NOARCH; else if (code10 && istag ("PREREQUIRES")) s->requires = adddep(pool, &pd, s->requires, value, SOLVABLE_PREREQMARKER); else if (code10 && istag ("REQUIRES")) s->requires = adddep(pool, &pd, s->requires, value, -SOLVABLE_PREREQMARKER); else if (code10 && istag ("PROVIDES")) s->provides = adddep(pool, &pd, s->provides, value, 0); else if (code10 && istag ("CONFLICTS")) s->conflicts = adddep(pool, &pd, s->conflicts, value, 0); else if (code10 && istag ("OBSOLETES")) s->obsoletes = adddep(pool, &pd, s->obsoletes, value, 0); else if (code10 && istag ("RECOMMENDS")) s->recommends = adddep(pool, &pd, s->recommends, value, 0); else if (code10 && istag ("SUGGESTS")) s->suggests = adddep(pool, &pd, s->suggests, value, 0); else if (code10 && istag ("SUPPLEMENTS")) s->supplements = adddep(pool, &pd, s->supplements, value, 0); else if (code10 && istag ("ENHANCES")) s->enhances = adddep(pool, &pd, s->enhances, value, 0); /* FRESHENS doesn't seem to exist. */ else if (code10 && istag ("TYPE")) repo_set_str(repo, s - pool->solvables, PRODUCT_TYPE, value); /* XXX do something about LINGUAS and ARCH? * <ma>: Don't think so. zypp does not use or propagate them. */ #undef istag } else pool_debug(pool, SAT_ERROR, "repo_content: malformed line: %s\n", line); } if (datadir) free(datadir); if (descrdir) free(descrdir); if (defvendor) free(defvendor); if (s) { if (!s->name) { pool_debug(pool, SAT_FATAL, "repo_content: 'content' incomplete, no product solvable created!\n"); exit(1); } if (pd.tmprel) s->evr = makeevr(pool, join(&pd, pd.tmpvers, "-", pd.tmprel)); else s->evr = makeevr(pool, pd.tmpvers); pd.tmpvers = sat_free((void *)pd.tmpvers); pd.tmprel = sat_free((void *)pd.tmprel); if (!s->arch) s->arch = ARCH_NOARCH; if (!s->evr) s->evr = ID_EMPTY; if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) s->provides = repo_addid_dep(repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); if (code10) s->supplements = repo_fix_supplements(repo, s->provides, s->supplements, 0); /* now for every other arch, clone the product except the architecture */ for (i = 0; i < numotherarchs; ++i) { Solvable *p = pool_id2solvable(pool, repo_add_solvable(repo)); repodata_extend(data, p - pool->solvables); p->name = s->name; p->evr = s->evr; p->vendor = s->vendor; p->arch = otherarchs[i]; /* self provides */ if (s->name && p->arch != ARCH_SRC && p->arch != ARCH_NOSRC) p->provides = repo_addid_dep(repo, p->provides, rel2id(pool, p->name, p->evr, REL_EQ, 1), 0); /* now merge the attributes */ repodata_merge_attrs(data, p - pool->solvables, s - pool->solvables); } } if (pd.tmp) sat_free(pd.tmp); sat_free(line); sat_free(otherarchs); join_freemem(); if (!(flags & REPO_NO_INTERNALIZE)) repodata_internalize(data); }
static void initcred(void) { struct passwd *pwd; if ((groups = malloc(ngroups_max * sizeof (gid_t))) == NULL) { (void) perr("malloc"); exit(1); } if (login != NULL) { pwd = getpwnam(login); if (pwd == NULL) { (void) fprintf(stderr, "%s: %s: unknown user\n", command, login); exit(1); } uid = pwd->pw_uid; gid = pwd->pw_gid; groups[0] = gid; ngrp = _getgroupsbymember(login, groups, (int)ngroups_max, 1); } if (user != NULL) { pwd = getpwnam(user); if (pwd == NULL) { uid = (uid_t)str2id(user); if (uid == (uid_t)-1) { (void) fprintf(stderr, "%s: %s: unknown user" " or bad uid\n", command, user); exit(1); } } else { uid = pwd->pw_uid; } } if (group != NULL) gid = str2gid(group); if (grplst != NULL) { char *cgrp; ngrp = 0; while ((cgrp = strtok(grplst, ",")) != NULL) { if (ngrp >= ngroups_max) { (void) fprintf(stderr, "%s: Too many groups\n", command); exit(1); } groups[ngrp++] = str2gid(cgrp); /* For iterations of strtok */ grplst = NULL; } } }
static void XMLCALL endElement(void *userData, const char *name) { struct parsedata *pd = userData; Solvable *s = pd->solvable; #if 0 fprintf(stderr, "end: [%d]%s\n", pd->state, name); #endif if (pd->depth != pd->statedepth) { pd->depth--; #if 0 fprintf(stderr, "back from unknown %d %d %d\n", pd->state, pd->depth, pd->statedepth); #endif return; } pd->depth--; pd->statedepth--; switch (pd->state) { case STATE_PRODUCT: /* product done, finish solvable */ if (pd->ctime) repodata_set_num(pd->data, pd->handle, SOLVABLE_INSTALLTIME, pd->ctime); if (pd->basename) repodata_set_str(pd->data, pd->handle, PRODUCT_REFERENCEFILE, pd->basename); /* this is where <productsdir>/baseproduct points to */ if (pd->currentproduct == pd->baseproduct) repodata_set_str(pd->data, pd->handle, PRODUCT_TYPE, "base"); if (pd->tmprel) { if (pd->tmpvers) s->evr = makeevr(pd->pool, join2(pd->tmpvers, "-", pd->tmprel)); else { fprintf(stderr, "Seen <release> but no <version>\n"); } } else if (pd->tmpvers) s->evr = makeevr(pd->pool, pd->tmpvers); /* just version, no release */ pd->tmpvers = sat_free((void *)pd->tmpvers); pd->tmprel = sat_free((void *)pd->tmprel); if (!s->arch) s->arch = ARCH_NOARCH; if (!s->evr) s->evr = ID_EMPTY; if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) s->provides = repo_addid_dep(pd->repo, s->provides, rel2id(pd->pool, s->name, s->evr, REL_EQ, 1), 0); pd->solvable = 0; break; case STATE_VENDOR: s->vendor = str2id(pd->pool, pd->content, 1); break; case STATE_NAME: s->name = str2id(pd->pool, join2("product", ":", pd->content), 1); break; case STATE_VERSION: pd->tmpvers = strdup(pd->content); break; case STATE_RELEASE: pd->tmprel = strdup(pd->content); break; case STATE_ARCH: s->arch = str2id(pd->pool, pd->content, 1); break; case STATE_PRODUCTLINE: repodata_set_str(pd->data, pd->handle, PRODUCT_PRODUCTLINE, pd->content); break; case STATE_UPDATEREPOKEY: /** obsolete **/ break; case STATE_SUMMARY: repodata_set_str(pd->data, pd->handle, langtag(pd, SOLVABLE_SUMMARY, pd->tmplang), pd->content); pd->tmplang = sat_free((void *)pd->tmplang); break; case STATE_SHORTSUMMARY: repodata_set_str(pd->data, pd->handle, PRODUCT_SHORTLABEL, pd->content); break; case STATE_DESCRIPTION: repodata_set_str(pd->data, pd->handle, langtag(pd, SOLVABLE_DESCRIPTION, pd->tmplang), pd->content ); pd->tmplang = sat_free((void *)pd->tmplang); break; case STATE_URL: if (pd->tmpurltype) { repodata_add_poolstr_array(pd->data, pd->handle, PRODUCT_URL, pd->content); repodata_add_idarray(pd->data, pd->handle, PRODUCT_URL_TYPE, str2id(pd->pool, pd->tmpurltype, 1)); } pd->tmpurltype = sat_free((void *)pd->tmpurltype); break; case STATE_TARGET: repodata_set_str(pd->data, pd->handle, PRODUCT_REGISTER_TARGET, pd->content); break; case STATE_REGRELEASE: repodata_set_str(pd->data, pd->handle, PRODUCT_REGISTER_RELEASE, pd->content); break; case STATE_CPEID: if (pd->content) repodata_set_str(pd->data, pd->handle, SOLVABLE_CPEID, pd->content); default: break; } pd->state = pd->sbtab[pd->state]; pd->docontent = 0; #if 0 fprintf(stderr, "end: [%s] -> %d\n", name, pd->state); #endif }