static int load_module(void) { announce_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); if (!announce_tech.capabilities) { return AST_MODULE_LOAD_DECLINE; } record_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); if (!record_tech.capabilities) { return AST_MODULE_LOAD_DECLINE; } ast_format_cap_append_by_type(announce_tech.capabilities, AST_MEDIA_TYPE_UNKNOWN); ast_format_cap_append_by_type(record_tech.capabilities, AST_MEDIA_TYPE_UNKNOWN); if (ast_channel_register(&announce_tech)) { ast_log(LOG_ERROR, "Unable to register channel technology %s(%s).\n", announce_tech.type, announce_tech.description); cleanup_capabilities(); return AST_MODULE_LOAD_DECLINE; } if (ast_channel_register(&record_tech)) { ast_log(LOG_ERROR, "Unable to register channel technology %s(%s).\n", record_tech.type, record_tech.description); cleanup_capabilities(); return AST_MODULE_LOAD_DECLINE; } return AST_MODULE_LOAD_SUCCESS; }
static int load_module(void) { announce_tech.capabilities = ast_format_cap_alloc(0); if (!announce_tech.capabilities) { return AST_MODULE_LOAD_DECLINE; } record_tech.capabilities = ast_format_cap_alloc(0); if (!record_tech.capabilities) { return AST_MODULE_LOAD_DECLINE; } ast_format_cap_add_all(announce_tech.capabilities); ast_format_cap_add_all(record_tech.capabilities); if (ast_channel_register(&announce_tech)) { ast_log(LOG_ERROR, "Unable to register channel technology %s(%s).\n", announce_tech.type, announce_tech.description); cleanup_capabilities(); return AST_MODULE_LOAD_DECLINE; } if (ast_channel_register(&record_tech)) { ast_log(LOG_ERROR, "Unable to register channel technology %s(%s).\n", record_tech.type, record_tech.description); cleanup_capabilities(); return AST_MODULE_LOAD_DECLINE; } return AST_MODULE_LOAD_SUCCESS; }
static int unload_module(void) { ast_channel_unregister(&announce_tech); ast_channel_unregister(&record_tech); cleanup_capabilities(); return 0; }
int main(int argc, char **argv) { int c; char *domain = NULL; char *uri = "xen"; char *file = NULL; bool xml = false; bool cap = false; struct domain *dominfo = NULL; struct capabilities *capsinfo = NULL; struct cap_domain_info *capgdinfo = NULL; int ret; static struct option lopts[] = { {"domain", 1, 0, 'd'}, {"uri", 1, 0, 'u'}, {"xml", 0, 0, 'x'}, {"file", 1, 0, 'f'}, {"cap", 0, 0, 'c'}, {"help", 0, 0, 'h'}, {0, 0, 0, 0}}; while (1) { int optidx = 0; c = getopt_long(argc, argv, "d:u:f:xch", lopts, &optidx); if (c == -1) break; switch (c) { case 'd': domain = optarg; break; case 'u': uri = optarg; break; case 'f': file = optarg; break; case 'x': xml = true; break; case 'c': cap = true; break; case '?': case 'h': usage(); return c == '?'; }; } if (file != NULL) ret = dominfo_from_file(file, &dominfo); else if (domain != NULL) ret = dominfo_from_dom(uri, domain, &dominfo); else { printf("Need a data source (--domain or --file)\n"); return 1; } if (ret == 0) { printf("Unable to get dominfo\n"); return 2; } if (xml) print_domxml(dominfo, stdout); else { print_dominfo(dominfo, stdout); print_devices(dominfo, stdout); } if (cap && file == NULL) { ret = capinfo_for_dom(uri, dominfo, &capsinfo); if (ret == 0) { printf("Unable to get capsinfo\n"); return 3; } else { print_capabilities(capsinfo, stdout); const char *os_type = get_ostype(dominfo); const char *dom_type = get_domaintype(dominfo); const char *def_arch = get_default_arch(capsinfo, os_type); fprintf(stdout, "-- KVM is used: %s\n\n", (use_kvm(capsinfo)?"true":"false")); fprintf(stdout, "-- For all following default OS type=%s\n", os_type); fprintf(stdout, "-- Default Arch : %s\n", def_arch); fprintf(stdout, "-- Default Machine for arch=NULL : %s\n", get_default_machine(capsinfo, os_type, NULL, NULL)); fprintf(stdout, "-- Default Machine for arch=%s and domain type=NULL : %s\n", def_arch, get_default_machine(capsinfo, os_type, def_arch, NULL)); fprintf(stdout, "-- Default Machine for arch=%s and domain type=%s : %s\n", def_arch, dom_type, get_default_machine(capsinfo, os_type, def_arch, dom_type)); fprintf(stdout, "-- Default Machine for arch=NULL and domain type=%s : %s\n", dom_type, get_default_machine(capsinfo, os_type, NULL, dom_type)); fprintf(stdout, "-- Default Emulator for arch=NULL : %s\n", get_default_emulator(capsinfo, os_type, NULL, NULL)); fprintf(stdout, "-- Default Emulator for arch=%s and domain type=NULL : %s\n", def_arch, get_default_emulator(capsinfo, os_type, def_arch, NULL)); fprintf(stdout, "-- Default Emulator for arch=%s and domain type=%s : %s\n", def_arch, dom_type, get_default_emulator(capsinfo, os_type, def_arch, dom_type)); fprintf(stdout, "-- Default Emulator for arch=NULL and domain type=%s : %s\n", dom_type, get_default_emulator(capsinfo, os_type, NULL, dom_type)); fprintf(stdout, "\n-- Default Domain Search for: \n" "guest type=hvm - guest arch=* - guest domain type=kvm\n"); capgdinfo = findDomainInfo(capsinfo, "hvm", NULL, "kvm"); print_cap_domain_info(capgdinfo, stdout); fprintf(stdout, "-- Default Domain Search for: \n" "guest type=* - guest arch=* - guest domain type=*\n"); capgdinfo = findDomainInfo(capsinfo, NULL, NULL, NULL); print_cap_domain_info(capgdinfo, stdout); cleanup_capabilities(&capsinfo); } } else if (cap) { printf("Need a data source (--domain) to get default capabilities\n"); return 4; } cleanup_dominfo(&dominfo); return 0; }