Lines Matching refs:file
111 static char *getattrib (struct rnndb *db, char *file, int line, xmlAttr *attr) {
115 rnn_err(db, "%s:%d: unknown attribute child \"%s\" in attribute \"%s\"\n", file, line, chain->name, attr->name);
124 static int getboolattrib (struct rnndb *db, char *file, int line, xmlAttr *attr) {
125 char *c = getattrib(db, file, line, attr);
130 rnn_err(db, "%s:%d: invalid boolean value \"%s\" in attribute \"%s\"\n", file, line, c, attr->name);
134 static uint64_t getnum(struct rnndb *db, char *file, int line, xmlAttr *attr, char *c)
143 rnn_err(db, "%s:%d: invalid numeric value \"%s\" in attribute \"%s\"\n", file, line, c, attr->name);
148 static uint64_t getnumattrib (struct rnndb *db, char *file, int line, xmlAttr *attr) {
149 char *c = getattrib(db, file, line, attr);
150 return getnum(db, file, line, attr, c);
153 static int trytop (struct rnndb *db, char *file, xmlNode *node);
155 static int trydoc (struct rnndb *db, char *file, xmlNode *node) {
164 static struct rnnvalue *parsevalue(struct rnndb *db, char *file, xmlNode *node);
165 static struct rnnbitfield *parsebitfield(struct rnndb *db, char *file, xmlNode *node);
167 static int trytypetag (struct rnndb *db, char *file, xmlNode *node, struct rnntypeinfo *ti) {
169 struct rnnvalue *val = parsevalue(db, file, node);
174 struct rnnbitfield *bf = parsebitfield(db, file, node);
181 static int trytypeattr (struct rnndb *db, char *file, xmlNode *node, xmlAttr *attr, struct rnntypeinfo *ti) {
183 ti->shr = getnumattrib(db, file, node->line, attr);
186 ti->min = getnumattrib(db, file, node->line, attr);
190 ti->max = getnumattrib(db, file, node->line, attr);
194 ti->align = getnumattrib(db, file, node->line, attr);
198 ti->name = strdup(getattrib(db, file, node->line, attr));;
201 ti->radix = getnumattrib(db, file, node->line, attr);
205 ti->high = ti->low = getnumattrib(db, file, node->line, attr);
208 ti->low = getnumattrib(db, file, node->line, attr);
211 ti->high = getnumattrib(db, file, node->line, attr);
214 ti->addvariant = getboolattrib(db, file, node->line, attr);
220 static struct rnnvalue *parsevalue(struct rnndb *db, char *file, xmlNode *node) {
222 val->file = file;
226 val->name = strdup(getattrib(db, file, node->line, attr));
228 val->value = getnumattrib(db, file, node->line, attr);
231 val->varinfo.varsetstr = strdup(getattrib(db, file, node->line, attr));
233 val->varinfo.variantsstr = strdup(getattrib(db, file, node->line, attr));
235 rnn_err(db, "%s:%d: wrong attribute \"%s\" for value\n", file, node->line, attr->name);
242 } else if (!trytop(db, file, chain) && !trydoc(db, file, chain)) {
243 rnn_err(db, "%s:%d: wrong tag in %s: <%s>\n", file, chain->line, node->name, chain->name);
248 rnn_err(db, "%s:%d: nameless value\n", file, node->line);
255 static void parsespectype(struct rnndb *db, char *file, xmlNode *node) {
257 res->file = file;
262 res->name = strdup(getattrib(db, file, node->line, attr));
263 } else if (!trytypeattr(db, file, node, attr, &res->typeinfo)) {
264 rnn_err(db, "%s:%d: wrong attribute \"%s\" for spectype\n", file, node->line, attr->name);
269 rnn_err(db, "%s:%d: nameless spectype\n", file, node->line);
274 rnn_err(db, "%s:%d: duplicated spectype name %s\n", file, node->line, res->name);
281 } else if (!trytypetag(db, file, chain, &res->typeinfo) && !trytop(db, file, chain) && !trydoc(db, file, chain)) {
282 rnn_err(db, "%s:%d: wrong tag in spectype: <%s>\n", file, chain->line, chain->name);
288 static void parseenum(struct rnndb *db, char *file, xmlNode *node) {
299 name = getattrib(db, file, node->line, attr);
301 bare = getboolattrib(db, file, node->line, attr);
303 isinline = getboolattrib(db, file, node->line, attr);
305 prefixstr = strdup(getattrib(db, file, node->line, attr));
307 varsetstr = strdup(getattrib(db, file, node->line, attr));
309 variantsstr = strdup(getattrib(db, file, node->line, attr));
311 rnn_err(db, "%s:%d: wrong attribute \"%s\" for enum\n", file, node->line, attr->name);
316 rnn_err(db, "%s:%d: nameless enum\n", file, node->line);
330 rnn_err(db, "%s:%d: merge fail for enum %s\n", file, node->line, node->name);
340 cur->file = file;
347 struct rnnvalue *val = parsevalue(db, file, chain);
350 } else if (!trytop(db, file, chain) && !trydoc(db, file, chain)) {
351 rnn_err(db, "%s:%d: wrong tag in enum: <%s>\n", file, chain->line, chain->name);
357 static struct rnnbitfield *parsebitfield(struct rnndb *db, char *file, xmlNode *node) {
359 bf->file = file;
364 bf->name = strdup(getattrib(db, file, node->line, attr));
366 bf->varinfo.varsetstr = strdup(getattrib(db, file, node->line, attr));
368 bf->varinfo.variantsstr = strdup(getattrib(db, file, node->line, attr));
369 } else if (!trytypeattr(db, file, node, attr, &bf->typeinfo)) {
370 rnn_err(db, "%s:%d: wrong attribute \"%s\" for bitfield\n", file, node->line, attr->name);
377 } else if (!trytypetag(db, file, chain, &bf->typeinfo) && !trytop(db, file, chain) && !trydoc(db, file, chain)) {
378 rnn_err(db, "%s:%d: wrong tag in %s: <%s>\n", file, chain->line, node->name, chain->name);
383 rnn_err(db, "%s:%d: nameless bitfield\n", file, node->line);
386 rnn_err(db, "%s:%d: bitfield has wrong placement\n", file, node->line);
393 static void parsebitset(struct rnndb *db, char *file, xmlNode *node) {
404 name = getattrib(db, file, node->line, attr);
406 bare = getboolattrib(db, file, node->line, attr);
408 isinline = getboolattrib(db, file, node->line, attr);
410 prefixstr = strdup(getattrib(db, file, node->line, attr));
412 varsetstr = strdup(getattrib(db, file, node->line, attr));
414 variantsstr = strdup(getattrib(db, file, node->line, attr));
416 rnn_err(db, "%s:%d: wrong attribute \"%s\" for bitset\n", file, node->line, attr->name);
421 rnn_err(db, "%s:%d: nameless bitset\n", file, node->line);
435 rnn_err(db, "%s:%d: merge fail for bitset %s\n", file, node->line, node->name);
445 cur->file = file;
452 struct rnnbitfield *bf = parsebitfield(db, file, chain);
455 } else if (!trytop(db, file, chain) && !trydoc(db, file, chain)) {
456 rnn_err(db, "%s:%d: wrong tag in bitset: <%s>\n", file, chain->line, chain->name);
462 static struct rnndelem *trydelem(struct rnndb *db, char *file, xmlNode *node) {
465 res->file = file;
470 res->name = strdup(getattrib(db, file, node->line, attr));
472 rnn_err(db, "%s:%d: wrong attribute \"%s\" for %s\n", file, node->line, attr->name, node->name);
477 rnn_err(db, "%s:%d: nameless use-group\n", file, node->line);
487 res->file = file;
491 res->name = strdup(getattrib(db, file, node->line, attr));
493 res->offset = getnumattrib(db, file, node->line, attr);
495 char *str = strdup(getattrib(db, file, node->line, attr));
498 uint64_t offset = getnum(db, file, node->line, attr, tok);
503 fprintf(stderr, "%s:%d: invalid offsets: %s\n", file, node->line, str);
507 res->doffset = strdup(getattrib(db, file, node->line, attr));
510 char *str = strdup(getattrib(db, file, node->line, attr));
518 fprintf(stderr, "%s:%d: invalid offsets: %s\n", file, node->line, str);
521 res->length = getnumattrib(db, file, node->line, attr);
523 res->stride = getnumattrib(db, file, node->line, attr);
525 res->varinfo.prefixstr = strdup(getattrib(db, file, node->line, attr));
527 res->varinfo.varsetstr = strdup(getattrib(db, file, node->line, attr));
529 res->varinfo.variantsstr = strdup(getattrib(db, file, node->line, attr));
531 const char *enumname = getattrib(db, file, node->line, attr);
534 rnn_err(db, "%s:%d: invalid enum name \"%s\"\n", file, node->line, enumname);
537 rnn_err(db, "%s:%d: wrong attribute \"%s\" for %s\n", file, node->line, attr->name, node->name);
545 } else if ((delem = trydelem(db, file, chain))) {
547 } else if (!trytop(db, file, chain) && !trydoc(db, file, chain)) {
548 rnn_err(db, "%s:%d: wrong tag in %s: <%s>\n", file, chain->line, node->name, chain->name);
555 fprintf(stderr, "%s: Array %s's stride is undefined. Aborting.\n", file, res->name);
573 res->file = file;
583 res->name = strdup(getattrib(db, file, node->line, attr));
585 res->offset = getnumattrib(db, file, node->line, attr);
587 res->length = getnumattrib(db, file, node->line, attr);
589 res->stride = getnumattrib(db, file, node->line, attr);
591 res->varinfo.varsetstr = strdup(getattrib(db, file, node->line, attr));
593 res->varinfo.variantsstr = strdup(getattrib(db, file, node->line, attr));
595 char *str = getattrib(db, file, node->line, attr);
603 fprintf (stderr, "%s:%d: wrong access type \"%s\" for register\n", file, node->line, str);
604 } else if (!trytypeattr(db, file, node, attr, &res->typeinfo)) {
605 rnn_err(db, "%s:%d: wrong attribute \"%s\" for register\n", file, node->line, attr->name);
612 } else if (!trytypetag(db, file, chain, &res->typeinfo) && !trytop(db, file, chain) && !trydoc(db, file, chain)) {
613 rnn_err(db, "%s:%d: wrong tag in %s: <%s>\n", file, chain->line, node->name, chain->name);
618 rnn_err(db, "%s:%d: nameless register\n", file, node->line);
625 static void parsegroup(struct rnndb *db, char *file, xmlNode *node) {
631 name = getattrib(db, file, node->line, attr);
633 rnn_err(db, "%s:%d: wrong attribute \"%s\" for group\n", file, node->line, attr->name);
638 rnn_err(db, "%s:%d: nameless group\n", file, node->line);
656 } else if ((delem = trydelem(db, file, chain))) {
658 } else if (!trytop(db, file, chain) && !trydoc(db, file, chain)) {
659 rnn_err(db, "%s:%d: wrong tag in group: <%s>\n", file, chain->line, chain->name);
665 static void parsedomain(struct rnndb *db, char *file, xmlNode *node) {
676 name = getattrib(db, file, node->line, attr);
678 bare = getboolattrib(db, file, node->line, attr);
680 size = getnumattrib(db, file, node->line, attr);
682 width = getnumattrib(db, file, node->line, attr);
684 prefixstr = strdup(getattrib(db, file, node->line, attr));
686 varsetstr = strdup(getattrib(db, file, node->line, attr));
688 variantsstr = strdup(getattrib(db, file, node->line, attr));
690 rnn_err(db, "%s:%d: wrong attribute \"%s\" for domain\n", file, node->line, attr->name);
695 rnn_err(db, "%s:%d: nameless domain\n", file, node->line);
711 rnn_err(db, "%s:%d: merge fail for domain %s\n", file, node->line, node->name);
725 cur->file = file;
732 } else if ((delem = trydelem(db, file, chain))) {
734 } else if (!trytop(db, file, chain) && !trydoc(db, file, chain)) {
735 rnn_err(db, "%s:%d: wrong tag in domain: <%s>\n", file, chain->line, chain->name);
741 static void parsecopyright(struct rnndb *db, char *file, xmlNode *node) {
746 unsigned firstyear = getnumattrib(db, file, node->line, attr);
750 rnn_err(db, "%s:%d: wrong attribute \"%s\" for copyright\n", file, node->line, attr->name);
772 author->name = strdup(getattrib(db, file, chain->line, authorattr));
774 author->email = strdup(getattrib(db, file, chain->line, authorattr));
776 rnn_err(db, "%s:%d: wrong attribute \"%s\" for author\n", file, chain->line, authorattr->name);
787 nickname = strdup(getattrib(db, file, authorchild->line, nickattr));
789 rnn_err(db, "%s:%d: wrong attribute \"%s\" for nick\n", file, authorchild->line, nickattr->name);
794 rnn_err(db, "%s:%d: missing \"name\" attribute for nick\n", file, authorchild->line);
798 rnn_err(db, "%s:%d: wrong tag in author: <%s>\n", file, authorchild->line, authorchild->name);
804 rnn_err(db, "%s:%d: wrong tag in copyright: <%s>\n", file, chain->line, chain->name);
810 static int trytop (struct rnndb *db, char *file, xmlNode *node) {
812 parseenum(db, file, node);
815 parsebitset(db, file, node);
818 parsegroup(db, file, node);
821 parsedomain(db, file, node);
824 parsespectype(db, file, node);
830 if (!strcmp(attr->name, "file")) {
831 subfile = getattrib(db, file, node->line, attr);
833 rnn_err(db, "%s:%d: wrong attribute \"%s\" for import\n", file, node->line, attr->name);
838 rnn_err(db, "%s:%d: missing \"file\" attribute for import\n", file, node->line);
844 parsecopyright(db, file, node);
858 FILE *file = find_in_path(file_orig, rnn_path, &fname);
859 if (!file) {
860 fprintf (stderr, "%s: couldn't find database file. Please set the env var RNN_PATH.\n", file_orig);
863 fclose(file);
898 rnn_err(db, "%s: couldn't find database file. Please set the env var RNN_PATH.\n", schema_name);
933 rnn_err(db, "%s: couldn't open database file. Please set the env var RNN_PATH.\n", fname);
944 rnn_err(db, "%s: database file has errors\n", fname);
960 static struct rnnvalue *copyvalue (struct rnnvalue *val, char *file) {
966 res->file = file;
970 static struct rnnbitfield *copybitfield (struct rnnbitfield *bf, char *file);
973 static void copytypeinfo (struct rnntypeinfo *dst, struct rnntypeinfo *src, char *file) {
984 ADDARRAY(dst->vals, copyvalue(src->vals[i], file));
986 ADDARRAY(dst->bitfields, copybitfield(src->bitfields[i], file));
989 static struct rnnbitfield *copybitfield (struct rnnbitfield *bf, char *file) {
993 res->file = file;
994 copytypeinfo(&res->typeinfo, &bf->typeinfo, file);
998 static struct rnndelem *copydelem (struct rnndelem *elem, char *file) {
1008 res->file = file;
1009 copytypeinfo(&res->typeinfo, &elem->typeinfo, file);
1012 ADDARRAY(res->subelems, copydelem(elem->subelems[i], file));
1156 static void preptypeinfo(struct rnndb *db, struct rnntypeinfo *ti, char *prefix, struct rnnvarinfo *vi, char *file) {
1167 ADDARRAY(ti->vals, copyvalue(en->vals[j], file));
1177 ADDARRAY(ti->bitfields, copybitfield(bs->bitfields[j], file));
1238 preptypeinfo(db, &bf->typeinfo, bf->fullname, &bf->varinfo, bf->file);
1254 ADDARRAY(elem->subelems, copydelem(gr->subelems[i], elem->file));
1274 preptypeinfo(db, &elem->typeinfo, elem->name?elem->fullname:prefix, &elem->varinfo, elem->file);
1315 preptypeinfo(db, &st->typeinfo, st->name, 0, st->file); // XXX doesn't exactly make sense...