void check_common(dbref obj) { printf("\nObject %s\n", unparse_object(me, obj)); printf("Name: %s\n", uncompress(DBFETCH(obj)->name)); if (GETDESC(obj)) printf("Desc: %s\n", uncompress(GETDESC(obj))); printf("Loc: #%s\n", unparse_object(me, DBFETCH(obj)->location)); printf("Owner: #%d\n", unparse_object(me, DBFETCH(obj)->owner)); printf("First contents: #%d\n", unparse_object(me, DBFETCH(obj)->contents)); printf("Next item: #%d\n", unparse_object(me, DBFETCH(obj)->next)); printf("Key: %s\n", unparse_boolexp(me, GETLOCK(obj)), 1); if (GETFAIL(obj)) printf("Fail: %s\n", uncompress(GETFAIL(obj))); if (GETSUCC(obj)) printf("Succ: %s\n", uncompress(GETSUCC(obj))); if (GETDROP(obj)) printf("Drop: %s\n", uncompress(GETDROP(obj))); if (GETOFAIL(obj)) printf("Ofail: %s\n", uncompress(GETOFAIL(obj))); if (GETOSUCC(obj)) printf("Osucc: %s\n", uncompress(GETOSUCC(obj))); if (GETODROP(obj)) printf("Odrop: %s\n", uncompress(GETODROP(obj))); printf("Properties:\n"); check_properties("/", obj); printf("End of properties.\n"); }
int main(int argc, char *argv[]) { int input_val; while(1) { printf("please enter a number, or 0 to exit\n"); scanf("%d",&input_val); if (input_val == 0) break; else { if (rootptr == NULL) { rootptr = (struct tree_node*)malloc(sizeof(*rootptr)); rootptr->val = input_val; rootptr->left = NULL; rootptr->right = NULL; rootptr->height = -1; rootptr->color = BLACK; } else { insert(&rootptr, input_val); check_properties(&rootptr, NULL); height(&rootptr, NULL); pretty_print(rootptr); } } } free_tree(rootptr); return 0; }
void check_properties(const char *dir, dbref obj) { int val; char *buf, *prop; PropPtr pptr; PropPtr pref; char name[BUFFER_LEN]; pref = first_prop(obj, dir, &pptr, name); while (pref > 0) { buf = (char *) malloc(strlen(dir) + strlen(name) + 2); (void) strcat(strcpy(buf, dir), name); if (prop = (char *) get_property_class(obj, buf)) printf("%s%c%s\n", buf + 1, PROP_DELIMITER, uncompress(prop)); else if (val = get_property_value(obj, buf)) printf("%s%c^%d\n", buf + 1, PROP_DELIMITER, val); if (is_propdir(obj, buf)) check_properties((char *) strcat(buf, "/"), obj); free(buf); pref = next_prop(pptr, pref, name); } }
int main(int argc, char** argv) { if (argc < 2) { return print_usage(argv[0], true); } int a = 1; for (; a < argc && argv[a][0] == '-'; ++a) { if (argv[a][1] == 'l') { one_line_errors = true; } else if (argv[a][1] == 'v') { return print_version(); } else { fprintf(stderr, "%s: Unknown option `%s'\n", argv[0], argv[a]); return print_usage(argv[0], true); } } SordWorld* world = sord_world_new(); SordModel* model = sord_new(world, SORD_SPO|SORD_OPS, false); SerdEnv* env = serd_env_new(&SERD_NODE_NULL); SerdReader* reader = sord_new_reader(model, env, SERD_TURTLE, NULL); for (; a < argc; ++a) { const uint8_t* input = (const uint8_t*)argv[a]; uint8_t* in_path = absolute_path(serd_uri_to_path(input)); if (!in_path) { fprintf(stderr, "Skipping file %s\n", input); continue; } SerdURI base_uri; SerdNode base_uri_node = serd_node_new_file_uri( in_path, NULL, &base_uri, false); serd_env_set_base_uri(env, &base_uri_node); const SerdStatus st = serd_reader_read_file(reader, in_path); if (st) { fprintf(stderr, "error reading %s: %s\n", in_path, serd_strerror(st)); } serd_node_free(&base_uri_node); free(in_path); } serd_reader_free(reader); serd_env_free(env); #define URI(prefix, suffix) \ uris.prefix##_##suffix = sord_new_uri(world, NS_##prefix #suffix) URIs uris; URI(foaf, Document); URI(owl, AnnotationProperty); URI(owl, Class); URI(owl, DatatypeProperty); URI(owl, FunctionalProperty); URI(owl, InverseFunctionalProperty); URI(owl, ObjectProperty); URI(owl, OntologyProperty); URI(owl, Restriction); URI(owl, Thing); URI(owl, cardinality); URI(owl, equivalentClass); URI(owl, minCardinality); URI(owl, onDatatype); URI(owl, onProperty); URI(owl, someValuesFrom); URI(owl, withRestrictions); URI(rdf, PlainLiteral); URI(rdf, Property); URI(rdf, first); URI(rdf, rest); URI(rdf, type); URI(rdfs, Class); URI(rdfs, Literal); URI(rdfs, Resource); URI(rdfs, domain); URI(rdfs, label); URI(rdfs, range); URI(rdfs, subClassOf); URI(xsd, anyURI); URI(xsd, decimal); URI(xsd, maxInclusive); URI(xsd, minInclusive); URI(xsd, pattern); URI(xsd, string); #ifndef HAVE_PCRE fprintf(stderr, "warning: Built without PCRE, datatypes not checked.\n"); #endif const int prop_st = check_properties(model, &uris); const int inst_st = check_instances(model, &uris); printf("Found %d errors among %d files (checked %d restrictions)\n", n_errors, argc - 1, n_restrictions); sord_free(model); sord_world_free(world); return prop_st || inst_st; }
void verify_updates(void) { if (!check_properties()) { printf("Property failed! Aborting...\n"); exit(1); } else printf("Property passed.\n"); }