// Minimal dlsym() check for the jetc_api_ route-metadata export added // alongside jetc_render_ in --shared mode (see JetCodegen.cpp). Proves // a host can discover a compiled module's declared routes purely from the // .jtc itself, with no separate manifest file - the actual point of putting // routing metadata in an exported symbol instead of a sidecar file. #include #include #include struct JetApiRoute { const char *method; const char *path; }; typedef const JetApiRoute *(*ApiFn)(int *count); int main(int argc, char **argv) { if (argc < 3) { std::cerr << "usage: api_test " << std::endl; return 1; } void *handle = dlopen(argv[1], RTLD_NOW); if (!handle) { std::cerr << "dlopen failed: " << dlerror() << std::endl; return 1; } dlerror(); ApiFn api = (ApiFn)dlsym(handle, argv[2]); const char *err = dlerror(); if (err) { std::cerr << "dlsym failed: " << err << std::endl; return 1; } int count = -1; const JetApiRoute *routes = api(&count); std::cout << count << " route(s):" << std::endl; for (int i = 0; i < count; ++i) std::cout << " " << routes[i].method << " " << routes[i].path << std::endl; dlclose(handle); return 0; }