void session::start(int flags, settings_pack const& pack, io_service* ios) { bool const internal_executor = ios == nullptr; if (internal_executor) { // the user did not provide an executor, we have to use our own m_io_service = boost::make_shared<io_service>(); ios = m_io_service.get(); } m_impl = boost::make_shared<session_impl>(boost::ref(*ios)); *static_cast<session_handle*>(this) = session_handle(m_impl.get()); #ifndef TORRENT_DISABLE_EXTENSIONS if (flags & add_default_plugins) { add_extension(create_ut_pex_plugin); add_extension(create_ut_metadata_plugin); add_extension(create_smart_ban_plugin); } #else TORRENT_UNUSED(flags); #endif m_impl->start_session(pack); if (internal_executor) { // start a thread for the message pump m_thread = std::make_shared<std::thread>( [&]() { m_io_service->run(); }); } }
void session::init(std::pair<int, int> listen_range, char const* listen_interface , fingerprint const& id, int flags, boost::uint32_t alert_mask TORRENT_LOGPATH_ARG) { m_impl.reset(new session_impl(listen_range, id, listen_interface, alert_mask TORRENT_LOGPATH)); #ifdef TORRENT_MEMDEBUG start_malloc_debug(); #endif #ifndef TORRENT_DISABLE_EXTENSIONS if (flags & add_default_plugins) { add_extension(create_ut_pex_plugin); add_extension(create_ut_metadata_plugin); add_extension(create_lt_trackers_plugin); add_extension(create_smart_ban_plugin); } #endif m_impl->start_session(); if (flags & start_default_features) { start_upnp(); start_natpmp(); #ifndef TORRENT_DISABLE_DHT start_dht(); #endif start_lsd(); } }
void torrent_handle::add_extension( boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> const& ext , void* userdata) { INVARIANT_CHECK; TORRENT_FORWARD(add_extension(ext, userdata)); }
void get_file_name (char *name, char *extension) { get_parameter (name); add_extension (name, extension); if (echo_name) printf ("File name : %s.\n", name); }
static void peas_extension_set_constructed (GObject *object) { PeasExtensionSet *set = PEAS_EXTENSION_SET (object); GList *plugins, *l; if (set->priv->engine == NULL) set->priv->engine = peas_engine_get_default (); g_object_ref (set->priv->engine); plugins = (GList *) peas_engine_get_plugin_list (set->priv->engine); for (l = plugins; l; l = l->next) add_extension (set, (PeasPluginInfo *) l->data); set->priv->load_handler_id = g_signal_connect_data (set->priv->engine, "load-plugin", G_CALLBACK (add_extension), set, NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED); set->priv->unload_handler_id = g_signal_connect_data (set->priv->engine, "unload-plugin", G_CALLBACK (remove_extension), set, NULL, G_CONNECT_SWAPPED); G_OBJECT_CLASS (peas_extension_set_parent_class)->constructed (object); }
static void decompile() { if (!has_extension(sOutputFile, ".rdef")) add_extension(sOutputFile, ".rdef"); rdef_decompile(sOutputFile); }
static void compile() { if (!has_extension(sOutputFile, ".rsrc")) add_extension(sOutputFile, ".rsrc"); rdef_compile(sOutputFile); }
void init(){ terminal_extension_id = add_extension(&terminal_extension); infofs_register("TERMS", &terms_infofs); init_device(); terminals=new vterm_list(); cons_backend=new console_backend(); uint64_t id=terminals->create_terminal(cons_backend); terminals->get(id)->sync(); cons_backend->switch_terminal(id); default_terminal=id; }
void session::start(int flags, settings_pack const& pack, io_service* ios) { #if defined _MSC_VER && defined TORRENT_DEBUG // workaround for microsofts // hardware exceptions that makes // it hard to debug stuff ::_set_se_translator(straight_to_debugger); #endif bool internal_executor = ios == NULL; if (internal_executor) { // the user did not provide an executor, we have to use our own m_io_service = boost::make_shared<io_service>(); ios = m_io_service.get(); } m_impl = boost::make_shared<session_impl>(boost::ref(*ios)); *static_cast<session_handle*>(this) = session_handle(m_impl.get()); #ifndef TORRENT_DISABLE_EXTENSIONS if (flags & add_default_plugins) { add_extension(create_ut_pex_plugin); add_extension(create_ut_metadata_plugin); add_extension(create_smart_ban_plugin); } #else TORRENT_UNUSED(flags); #endif m_impl->start_session(pack); if (internal_executor) { // start a thread for the message pump m_thread = boost::make_shared<thread>(boost::bind(&io_service::run , m_io_service.get())); } }
void session::start(int flags) { #ifndef TORRENT_DISABLE_EXTENSIONS if (flags & add_default_plugins) { add_extension(create_ut_pex_plugin); //add_extension(create_ut_metadata_plugin); add_extension(create_lt_trackers_plugin); //add_extension(create_smart_ban_plugin); } #endif m_impl->start_session(); if (flags & start_default_features) { start_upnp(); start_natpmp(); #ifndef TORRENT_DISABLE_DHT start_dht(); #endif start_lsd(); } }
CFileClassifier::CFileClassifier() { const char **p; const char *ext1[] = { "mpeg", "mpg", "avi", "dat", "asf", "ogm", "vob", "m2v", "wmv", "mkv", 0 }; const char *ext2[] = { "mp3", "wav", "au", "aif", "aiff", "ogg", "mpc", "flac", "fla", "ape", "wma", "ra", "rm", "vqf", "ac3", 0 }; const char *ext3[] = { "txt", "rtf", "doc", "htm", "html", "pdf", "ps", "djv", "djvu", "chm", 0 }; const char *ext4[] = { "bmp", "gif", "jpeg", "jpg", "pbm", "pcx", "png", "pnm", "ppm", "psd", "tiff", "tif", "xbm", "xpm", 0 }; const char *ext5[] = { "rpm", "deb", "spec", "ebuild", "patch", 0 }; const char *ext7[] = { "bin", "iso", "mdf", "bwt", "cdi", "nrg", 0 }; const char *ext8[] = { "mds", "ccd", "cue", 0 }; const char *ext9[] = { "arj", "zip", "rar", "arc", "lha", "lzh", "ace", "tar", "gz", "gzip", "bz2", "tgz", "tbz2", "zoo", "cab", "jar", "7z", "z", 0 }; const char *ext10[] = { "exe", "dll", 0 }; for (p = ext1; *p != 0; p++) { add_extension(RES_TYPE_MOVIE, *p); } for (p = ext2; *p != 0; p++) { add_extension(RES_TYPE_MUSIC, *p); } for (p = ext3; *p != 0; p++) { add_extension(RES_TYPE_DOC, *p); } for (p = ext4; *p != 0; p++) { add_extension(RES_TYPE_PICTURE, *p); } for (p = ext5; *p != 0; p++) { add_extension(RES_TYPE_UNIX_FILE, *p); } for (p = ext7; *p != 0; p++) { add_extension(RES_TYPE_CD_IMAGE, *p); } for (p = ext8; *p != 0; p++) { add_extension(RES_TYPE_CD_INDEX, *p); } for (p = ext9; *p != 0; p++) { add_extension(RES_TYPE_ARCHIVE, *p); } for (p = ext10; *p != 0; p++) { add_extension(RES_TYPE_WIN_EXE, *p); } }
static int ca_sign(hx509_context context, hx509_ca_tbs tbs, hx509_private_key signer, const AuthorityKeyIdentifier *ai, const Name *issuername, hx509_cert *certificate) { heim_octet_string data; Certificate c; TBSCertificate *tbsc; size_t size; int ret; const AlgorithmIdentifier *sigalg; time_t notBefore; time_t notAfter; unsigned key_usage; sigalg = _hx509_crypto_default_sig_alg; memset(&c, 0, sizeof(c)); /* * Default values are: Valid since 24h ago, valid one year into * the future, KeyUsage digitalSignature and keyEncipherment set, * and keyCertSign for CA certificates. */ notBefore = tbs->notBefore; if (notBefore == 0) notBefore = time(NULL) - 3600 * 24; notAfter = tbs->notAfter; if (notAfter == 0) notAfter = time(NULL) + 3600 * 24 * 365; key_usage = tbs->key_usage; if (key_usage == 0) { KeyUsage ku; memset(&ku, 0, sizeof(ku)); ku.digitalSignature = 1; ku.keyEncipherment = 1; key_usage = KeyUsage2int(ku); } if (tbs->flags.ca) { KeyUsage ku; memset(&ku, 0, sizeof(ku)); ku.keyCertSign = 1; ku.cRLSign = 1; key_usage |= KeyUsage2int(ku); } /* * */ tbsc = &c.tbsCertificate; if (tbs->flags.key == 0) { ret = EINVAL; hx509_set_error_string(context, 0, ret, "No public key set"); return ret; } /* * Don't put restrictions on proxy certificate's subject name, it * will be generated below. */ if (!tbs->flags.proxy) { if (tbs->subject == NULL) { hx509_set_error_string(context, 0, EINVAL, "No subject name set"); return EINVAL; } if (hx509_name_is_null_p(tbs->subject) && tbs->san.len == 0) { hx509_set_error_string(context, 0, EINVAL, "NULL subject and no SubjectAltNames"); return EINVAL; } } if (tbs->flags.ca && tbs->flags.proxy) { hx509_set_error_string(context, 0, EINVAL, "Can't be proxy and CA " "at the same time"); return EINVAL; } if (tbs->flags.proxy) { if (tbs->san.len > 0) { hx509_set_error_string(context, 0, EINVAL, "Proxy certificate is not allowed " "to have SubjectAltNames"); return EINVAL; } } /* version [0] Version OPTIONAL, -- EXPLICIT nnn DEFAULT 1, */ tbsc->version = calloc(1, sizeof(*tbsc->version)); if (tbsc->version == NULL) { ret = ENOMEM; hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } *tbsc->version = rfc3280_version_3; /* serialNumber CertificateSerialNumber, */ if (tbs->flags.serial) { ret = der_copy_heim_integer(&tbs->serial, &tbsc->serialNumber); if (ret) { hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } } else { tbsc->serialNumber.length = 20; tbsc->serialNumber.data = malloc(tbsc->serialNumber.length); if (tbsc->serialNumber.data == NULL){ ret = ENOMEM; hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } /* XXX diffrent */ RAND_bytes(tbsc->serialNumber.data, tbsc->serialNumber.length); ((unsigned char *)tbsc->serialNumber.data)[0] &= 0x7f; } /* signature AlgorithmIdentifier, */ ret = copy_AlgorithmIdentifier(sigalg, &tbsc->signature); if (ret) { hx509_set_error_string(context, 0, ret, "Failed to copy sigature alg"); goto out; } /* issuer Name, */ if (issuername) ret = copy_Name(issuername, &tbsc->issuer); else ret = hx509_name_to_Name(tbs->subject, &tbsc->issuer); if (ret) { hx509_set_error_string(context, 0, ret, "Failed to copy issuer name"); goto out; } /* validity Validity, */ tbsc->validity.notBefore.element = choice_Time_generalTime; tbsc->validity.notBefore.u.generalTime = notBefore; tbsc->validity.notAfter.element = choice_Time_generalTime; tbsc->validity.notAfter.u.generalTime = notAfter; /* subject Name, */ if (tbs->flags.proxy) { ret = build_proxy_prefix(context, &tbsc->issuer, &tbsc->subject); if (ret) goto out; } else { ret = hx509_name_to_Name(tbs->subject, &tbsc->subject); if (ret) { hx509_set_error_string(context, 0, ret, "Failed to copy subject name"); goto out; } } /* subjectPublicKeyInfo SubjectPublicKeyInfo, */ ret = copy_SubjectPublicKeyInfo(&tbs->spki, &tbsc->subjectPublicKeyInfo); if (ret) { hx509_set_error_string(context, 0, ret, "Failed to copy spki"); goto out; } /* issuerUniqueID [1] IMPLICIT BIT STRING OPTIONAL */ if (tbs->issuerUniqueID.length) { tbsc->issuerUniqueID = calloc(1, sizeof(*tbsc->issuerUniqueID)); if (tbsc->issuerUniqueID == NULL) { ret = ENOMEM; hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } ret = der_copy_bit_string(&tbs->issuerUniqueID, tbsc->issuerUniqueID); if (ret) { hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } } /* subjectUniqueID [2] IMPLICIT BIT STRING OPTIONAL */ if (tbs->subjectUniqueID.length) { tbsc->subjectUniqueID = calloc(1, sizeof(*tbsc->subjectUniqueID)); if (tbsc->subjectUniqueID == NULL) { ret = ENOMEM; hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } ret = der_copy_bit_string(&tbs->subjectUniqueID, tbsc->subjectUniqueID); if (ret) { hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } } /* extensions [3] EXPLICIT Extensions OPTIONAL */ tbsc->extensions = calloc(1, sizeof(*tbsc->extensions)); if (tbsc->extensions == NULL) { ret = ENOMEM; hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } /* Add the text BMP string Domaincontroller to the cert */ if (tbs->flags.domaincontroller) { data.data = rk_UNCONST("\x1e\x20\x00\x44\x00\x6f\x00\x6d" "\x00\x61\x00\x69\x00\x6e\x00\x43" "\x00\x6f\x00\x6e\x00\x74\x00\x72" "\x00\x6f\x00\x6c\x00\x6c\x00\x65" "\x00\x72"); data.length = 34; ret = add_extension(context, tbsc, 0, &asn1_oid_id_ms_cert_enroll_domaincontroller, &data); if (ret) goto out; } /* add KeyUsage */ { KeyUsage ku; ku = int2KeyUsage(key_usage); ASN1_MALLOC_ENCODE(KeyUsage, data.data, data.length, &ku, &size, ret); if (ret) { hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } if (size != data.length) _hx509_abort("internal ASN.1 encoder error"); ret = add_extension(context, tbsc, 1, &asn1_oid_id_x509_ce_keyUsage, &data); free(data.data); if (ret) goto out; } /* add ExtendedKeyUsage */ if (tbs->eku.len > 0) { ASN1_MALLOC_ENCODE(ExtKeyUsage, data.data, data.length, &tbs->eku, &size, ret); if (ret) { hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } if (size != data.length) _hx509_abort("internal ASN.1 encoder error"); ret = add_extension(context, tbsc, 0, &asn1_oid_id_x509_ce_extKeyUsage, &data); free(data.data); if (ret) goto out; } /* add Subject Alternative Name */ if (tbs->san.len > 0) { ASN1_MALLOC_ENCODE(GeneralNames, data.data, data.length, &tbs->san, &size, ret); if (ret) { hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } if (size != data.length) _hx509_abort("internal ASN.1 encoder error"); ret = add_extension(context, tbsc, 0, &asn1_oid_id_x509_ce_subjectAltName, &data); free(data.data); if (ret) goto out; } /* Add Authority Key Identifier */ if (ai) { ASN1_MALLOC_ENCODE(AuthorityKeyIdentifier, data.data, data.length, ai, &size, ret); if (ret) { hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } if (size != data.length) _hx509_abort("internal ASN.1 encoder error"); ret = add_extension(context, tbsc, 0, &asn1_oid_id_x509_ce_authorityKeyIdentifier, &data); free(data.data); if (ret) goto out; } /* Add Subject Key Identifier */ { SubjectKeyIdentifier si; unsigned char hash[SHA_DIGEST_LENGTH]; { EVP_MD_CTX *ctx; ctx = EVP_MD_CTX_create(); EVP_DigestInit_ex(ctx, EVP_sha1(), NULL); EVP_DigestUpdate(ctx, tbs->spki.subjectPublicKey.data, tbs->spki.subjectPublicKey.length / 8); EVP_DigestFinal_ex(ctx, hash, NULL); EVP_MD_CTX_destroy(ctx); } si.data = hash; si.length = sizeof(hash); ASN1_MALLOC_ENCODE(SubjectKeyIdentifier, data.data, data.length, &si, &size, ret); if (ret) { hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } if (size != data.length) _hx509_abort("internal ASN.1 encoder error"); ret = add_extension(context, tbsc, 0, &asn1_oid_id_x509_ce_subjectKeyIdentifier, &data); free(data.data); if (ret) goto out; } /* Add BasicConstraints */ { BasicConstraints bc; int aCA = 1; unsigned int path; memset(&bc, 0, sizeof(bc)); if (tbs->flags.ca) { bc.cA = &aCA; if (tbs->pathLenConstraint >= 0) { path = tbs->pathLenConstraint; bc.pathLenConstraint = &path; } } ASN1_MALLOC_ENCODE(BasicConstraints, data.data, data.length, &bc, &size, ret); if (ret) { hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } if (size != data.length) _hx509_abort("internal ASN.1 encoder error"); /* Critical if this is a CA */ ret = add_extension(context, tbsc, tbs->flags.ca, &asn1_oid_id_x509_ce_basicConstraints, &data); free(data.data); if (ret) goto out; } /* add Proxy */ if (tbs->flags.proxy) { ProxyCertInfo info; memset(&info, 0, sizeof(info)); if (tbs->pathLenConstraint >= 0) { info.pCPathLenConstraint = malloc(sizeof(*info.pCPathLenConstraint)); if (info.pCPathLenConstraint == NULL) { ret = ENOMEM; hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } *info.pCPathLenConstraint = tbs->pathLenConstraint; } ret = der_copy_oid(&asn1_oid_id_pkix_ppl_inheritAll, &info.proxyPolicy.policyLanguage); if (ret) { free_ProxyCertInfo(&info); hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } ASN1_MALLOC_ENCODE(ProxyCertInfo, data.data, data.length, &info, &size, ret); free_ProxyCertInfo(&info); if (ret) { hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } if (size != data.length) _hx509_abort("internal ASN.1 encoder error"); ret = add_extension(context, tbsc, 0, &asn1_oid_id_pkix_pe_proxyCertInfo, &data); free(data.data); if (ret) goto out; } if (tbs->crldp.len) { ASN1_MALLOC_ENCODE(CRLDistributionPoints, data.data, data.length, &tbs->crldp, &size, ret); if (ret) { hx509_set_error_string(context, 0, ret, "Out of memory"); goto out; } if (size != data.length) _hx509_abort("internal ASN.1 encoder error"); ret = add_extension(context, tbsc, FALSE, &asn1_oid_id_x509_ce_cRLDistributionPoints, &data); free(data.data); if (ret) goto out; } ASN1_MALLOC_ENCODE(TBSCertificate, data.data, data.length,tbsc, &size, ret); if (ret) { hx509_set_error_string(context, 0, ret, "malloc out of memory"); goto out; } if (data.length != size) _hx509_abort("internal ASN.1 encoder error"); ret = _hx509_create_signature_bitstring(context, signer, sigalg, &data, &c.signatureAlgorithm, &c.signatureValue); free(data.data); if (ret) goto out; ret = hx509_cert_init(context, &c, certificate); if (ret) goto out; free_Certificate(&c); return 0; out: free_Certificate(&c); return ret; }
/** * Allocate a SIP User-Agent * * @param uap Pointer to allocated User-Agent object * @param aor SIP Address-of-Record (AOR) * * @return 0 if success, otherwise errorcode */ int ua_alloc(struct ua **uap, const char *aor) { struct ua *ua; int err; if (!aor) return EINVAL; ua = mem_zalloc(sizeof(*ua), ua_destructor); if (!ua) return ENOMEM; MAGIC_INIT(ua); list_init(&ua->calls); #if HAVE_INET6 ua->af = uag.prefer_ipv6 ? AF_INET6 : AF_INET; #else ua->af = AF_INET; #endif /* Decode SIP address */ err = account_alloc(&ua->acc, aor); if (err) goto out; /* generate a unique contact-user, this is needed to route incoming requests when using multiple useragents */ err = re_sdprintf(&ua->cuser, "%r-%p", &ua->acc->luri.user, ua); if (err) goto out; if (ua->acc->sipnat) { ua_printf(ua, "Using sipnat: `%s'\n", ua->acc->sipnat); } if (ua->acc->mnat) { ua_printf(ua, "Using medianat `%s'\n", ua->acc->mnat->id); if (0 == str_casecmp(ua->acc->mnat->id, "ice")) add_extension(ua, "ice"); } if (ua->acc->menc) { ua_printf(ua, "Using media encryption `%s'\n", ua->acc->menc->id); } /* Register clients */ if (str_isset(uag.cfg->uuid)) add_extension(ua, "gruu"); if (0 == str_casecmp(ua->acc->sipnat, "outbound")) { size_t i; add_extension(ua, "path"); add_extension(ua, "outbound"); if (!str_isset(uag.cfg->uuid)) { warning("ua: outbound requires valid UUID!\n"); err = ENOSYS; goto out; } for (i=0; i<ARRAY_SIZE(ua->acc->outbound); i++) { if (ua->acc->outbound[i] && ua->acc->regint) { err = reg_add(&ua->regl, ua, (int)i+1); if (err) break; } } } else if (ua->acc->regint) { err = reg_add(&ua->regl, ua, 0); } if (err) goto out; list_append(&uag.ual, &ua->le, ua); if (ua->acc->regint) { err = ua_register(ua); } if (!uag_current()) uag_current_set(ua); out: if (err) mem_deref(ua); else if (uap) { *uap = ua; ua->uap = uap; } return err; }
/* called when we click ok */ static void mkrcp_ok_cb( GtkWidget *widget, gpointer dialog) { GtkWidget *window; struct gui_star_list *gsl; struct wcs *wcs; char *fn, *fn2, *comment, *target, *seq; int w = 0, h = 0; int flags; struct stf *rcp; FILE *rfp; char qu[1024]; struct image_channel *i_ch; GList *stars; window = g_object_get_data(G_OBJECT(dialog), "im_window"); g_return_if_fail(window != NULL); i_ch = g_object_get_data(G_OBJECT(window), "i_channel"); if (i_ch != NULL && i_ch->fr != NULL) { w = i_ch->fr->w; h = i_ch->fr->h; } wcs = g_object_get_data(G_OBJECT(window), "wcs_of_window"); if (wcs == NULL) { err_printf_sb2(window, "Cannot create a recipe without a wcs"); error_beep(); return; } gsl = g_object_get_data(G_OBJECT(window), "gui_star_list"); if (gsl == NULL || gsl->sl == NULL) { err_printf_sb2(window, "No stars to put in recipe"); error_beep(); return; } fn = named_entry_text(dialog, "recipe_file_entry"); if (fn == NULL || fn[0] == 0) { err_printf_sb2(window, "Please enter a recipe file name"); error_beep(); if (fn != NULL) g_free(fn); return; } fn2 = add_extension(fn, "rcp"); if (fn2 == NULL) fn2 = fn; else g_free(fn); if ((rfp = fopen(fn2, "r")) != NULL) { /* file exists */ snprintf(qu, 1023, "File %s exists\nOverwrite?", fn2); if (!modal_yes_no(qu, "gcx: file exists")) { free(fn2); fclose(rfp); return; } else { fclose(rfp); } } rfp = fopen(fn2, "w"); if (rfp == NULL) { err_printf_sb2(window, "Cannot create file %s (%s)", fn2, strerror(errno)); free(fn2); return; } comment = named_entry_text(dialog, "comments_entry"); target = named_entry_text(dialog, "tgt_entry"); seq = named_entry_text(dialog, "seq_entry"); flags = get_recipe_flags(dialog); rcp = create_recipe(gsl->sl, wcs, flags, comment, target, seq, w, h); if (rcp == NULL) { err_printf_sb2(window, "%s", last_err()); } else { g_object_set_data_full(G_OBJECT(window), "recipe", rcp, (GDestroyNotify)stf_free_all); stf_fprint(rfp, rcp, 0, 0); stars = stf_find_glist(rcp, 0, SYM_STARS); info_printf_sb2(window, "recipe", 10000, "Wrote %d star(s) to %s\n", g_list_length(stars), fn2); } fclose(rfp); free(fn2); g_free(comment); g_free(target); g_free(seq); if (rcp != NULL) gtk_widget_hide(dialog); }
static void parse_options(int argc, char *argv[]) { int32 args_left = argc - 1; // ToDo: use getopt_long() for (int32 i = 1; i < argc; ++i) { if (strcmp(argv[i], "-o") == 0 || strcmp(argv[i], "--output") == 0) { if (i + 1 >= argc) error("%s should be followed by a file name", argv[i]); strcpy(sOutputFile, argv[i + 1]); argv[i] = NULL; argv[i + 1] = NULL; ++i; args_left -= 2; } else if (strcmp(argv[i], "-I") == 0 || strcmp(argv[i], "--include") == 0) { if (i + 1 >= argc) error("%s should be followed by a directory name", argv[i]); rdef_add_include_dir(argv[i + 1], true); argv[i] = NULL; argv[i + 1] = NULL; ++i; args_left -= 2; } else if (strcmp(argv[i], "-d") == 0 || strcmp(argv[i], "--decompile") == 0) { sDecompile = true; argv[i] = NULL; --args_left; } else if (strcmp(argv[i], "-m") == 0 || strcmp(argv[i], "--merge") == 0) { sFlags |= RDEF_MERGE_RESOURCES; argv[i] = NULL; --args_left; } else if (strcmp(argv[i], "--auto-names") == 0) { sFlags |= RDEF_AUTO_NAMES; argv[i] = NULL; --args_left; } else if (strcmp(argv[i], "-q") == 0 || strcmp(argv[i], "--quiet") == 0) { sQuiet = true; argv[i] = NULL; --args_left; } else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { usage(); } else if (strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) { version(); } else if (!strcmp(argv[i], "-")) { // stdin input file break; } else if (argv[i][0] == '-') { error("unknown option %s", argv[i]); argv[i] = NULL; --args_left; } } if (args_left < 1) { error("no input files"); usage(); } for (int i = 1; i < argc; ++i) { if (argv[i] == NULL) continue; if (sFirstInputFile == NULL) sFirstInputFile = argv[i]; rdef_add_input_file(argv[i]); } if (sOutputFile[0] == '\0') { // no output file name was given, use the name of the // first source file as base strlcpy(sOutputFile, sFirstInputFile, sizeof(sOutputFile)); cut_extension(sOutputFile, sDecompile ? ".rsrc" : ".rdef"); add_extension(sOutputFile, sDecompile ? ".rdef" : ".rsrc"); } }
void ICMPExtensionsStructure::add_extension(MPLS& mpls) { ICMPExtension extension(1, 1); extension.payload(mpls.serialize()); add_extension(extension); }
int set_extension (ASN1_TYPE asn, const char *root, const char *ext_id, const gnutls_datum_t * ext_data, unsigned int critical) { int result; int k, len; char name[ASN1_MAX_NAME_SIZE], name2[ASN1_MAX_NAME_SIZE]; char extnID[128]; /* Find the index of the given extension. */ k = 0; do { k++; if (root[0] != 0) snprintf (name, sizeof (name), "%s.?%u", root, k); else snprintf (name, sizeof (name), "?%u", k); len = sizeof (extnID) - 1; result = asn1_read_value (asn, name, extnID, &len); /* move to next */ if (result == ASN1_ELEMENT_NOT_FOUND) { break; } do { _gnutls_str_cpy (name2, sizeof (name2), name); _gnutls_str_cat (name2, sizeof (name2), ".extnID"); len = sizeof (extnID) - 1; result = asn1_read_value (asn, name2, extnID, &len); if (result == ASN1_ELEMENT_NOT_FOUND) { gnutls_assert (); break; } else if (result != ASN1_SUCCESS) { gnutls_assert (); return _gnutls_asn2err (result); } /* Handle Extension */ if (strcmp (extnID, ext_id) == 0) { /* extension was found */ return overwrite_extension (asn, root, k, ext_data, critical); } } while (0); } while (1); if (result == ASN1_ELEMENT_NOT_FOUND) { return add_extension (asn, root, ext_id, ext_data, critical); } else { gnutls_assert (); return _gnutls_asn2err (result); } return 0; }