static jint setAddresses(JNIEnv *env, jobject thiz, jstring jName,
        jstring jAddresses)
{
    const char *name = NULL;
    const char *addresses = NULL;
    int count = -1;

    name = jName ? env->GetStringUTFChars(jName, NULL) : NULL;
    if (!name) {
        jniThrowNullPointerException(env, "name");
        goto error;
    }
    addresses = jAddresses ? env->GetStringUTFChars(jAddresses, NULL) : NULL;
    if (!addresses) {
        jniThrowNullPointerException(env, "addresses");
        goto error;
    }
    count = set_addresses(name, addresses);
    if (count < 0) {
        throwException(env, count, "Cannot set address");
        count = -1;
    }

error:
    if (name) {
        env->ReleaseStringUTFChars(jName, name);
    }
    if (addresses) {
        env->ReleaseStringUTFChars(jAddresses, addresses);
    }
    return count;
}
示例#2
0
TH1F* get_pid_count_hist(const TString filename, const TString histname, const int counter) 
{
    // counter 5, look at the numbers at the beam pipe
    // const int counter = 5; 
    // TString filename = "../../output/final_900M/final_st_Copper_0.5mm_deg_Air_5mm.root";
    TH1F* hist = make_hist(histname);
    TFile* file = new TFile(filename, "READ");
    TTree* tree = (TTree*) file->Get("t");
    
    in_branch branch; 
    set_addresses(tree, branch);
    
    const int n_entries = tree->GetEntries();
    // const int n_entries = 100;
    for (int entry = 0; entry < n_entries; ++entry)
    { // Loop over all the entries
        tree->GetEntry(entry);
        for (int hit = 0; hit < branch.n_hits; ++hit)
        { // Loop over the hits and fill the histograms
            
            // Skip anything that's not at the correct counter or the first step
            if ( branch.counter[hit] != counter) continue;
            if (!branch.first_step)              continue; // don't double count
            // Translate the PDG id into a bin number (needs cast)
            const int bin_num = get_bin_number((pdg_id) branch.pdgid[hit]);
            // get_bin_number returns -1 if not a charged particle
            if (bin_num == BIN_ERROR) continue;
            hist->Fill(bin_num);
        }
    }
    
    file->Close();
    return hist;
}
示例#3
0
static void re_cb(GDHCPClient *dhcp_client, gpointer user_data)
{
    struct connman_dhcpv6 *dhcp = user_data;
    uint16_t status;
    int ret;

    ret = set_addresses(dhcp_client, dhcp);

    status = g_dhcpv6_client_get_status(dhcp_client);

    DBG("dhcpv6 cb msg %p ret %d status %d", dhcp, ret, status);

    if (ret < 0) {
        if (dhcp->callback != NULL)
            dhcp->callback(dhcp->network, FALSE);
        return;
    }

    if (status  == G_DHCPV6_ERROR_BINDING) {
        /* RFC 3315, 18.1.8 */
        dhcpv6_request(dhcp, FALSE);
    } else {
        if (dhcp->callback != NULL)
            dhcp->callback(dhcp->network,
                           status == 0 ? TRUE : FALSE);
    }
}
示例#4
0
文件: main.c 项目: rhaamo/xpudpng
PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
{


	strcpy(outName, "XPUDPng " VERSION);
	strcpy(outSig, "li.rhaamo.xpudpng");
	strcpy(outDesc, "Send simuator data to an XPUDPNG-compliant application using UDP.");

	/* Initialize status variables */
	plugin_enabled = 0; /* set to 1 if the plugin is enabled from the menu. 0 otherwise */
	send_enabled = 1;   /* set to 1 if socket is open and preferences window is not shown. 0 otherwise */
	recv_enabled = 1;   /* set to 1 if socket is open and preferences window is not shown. 0 otherwise */
	recv_socket_open = 0;

	XPLMDebugString("XPUDPNG: Plugin " VERSION "\n");


	/* Create socket and addresses */
	receiverSocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);

	(void)set_addresses();
	(void)create_menu();

	/* Flag to tell us if the widget is being displayed */
	gMenuItem = 0;
	return 1;
}
示例#5
0
static void solicitation_cb(GDHCPClient *dhcp_client, gpointer user_data)
{
    /* We get here if server supports rapid commit */
    struct connman_dhcpv6 *dhcp = user_data;

    DBG("dhcpv6 solicitation msg %p", dhcp);

    clear_timer(dhcp);

    set_addresses(dhcp_client, dhcp);
}
示例#6
0
static int populate_ifaddrs(struct ifaddrs* ifaddr, ifaddrmsg* msg, void* bytes,
		     size_t len) {
	if (set_ifname(ifaddr, msg->ifa_index) != 0) {
		return -1;
	}
	if (set_flags(ifaddr) != 0) {
		return -1;
	}
	if (set_addresses(ifaddr, msg, bytes, len) != 0) {
		return -1;
	}
	if (make_prefixes(ifaddr, msg->ifa_family, msg->ifa_prefixlen) != 0) {
		return -1;
	}
	return 0;
}
OM_uint32
_gsskrb5_create_ctx(
        OM_uint32 * minor_status,
	gss_ctx_id_t * context_handle,
 	const gss_channel_bindings_t input_chan_bindings,
 	enum gss_ctx_id_t_state state)
{
    krb5_error_code kret;
    gsskrb5_ctx ctx;

    *context_handle = NULL;

    ctx = malloc(sizeof(*ctx));
    if (ctx == NULL) {
	*minor_status = ENOMEM;
	return GSS_S_FAILURE;
    }
    ctx->auth_context		= NULL;
    ctx->source			= NULL;
    ctx->target			= NULL;
    ctx->state			= state;
    ctx->flags			= 0;
    ctx->more_flags		= 0;
    ctx->service_keyblock	= NULL;
    ctx->ticket			= NULL;
    krb5_data_zero(&ctx->fwd_data);
    ctx->lifetime		= GSS_C_INDEFINITE;
    ctx->order			= NULL;
    HEIMDAL_MUTEX_init(&ctx->ctx_id_mutex);

    kret = krb5_auth_con_init (_gsskrb5_context, &ctx->auth_context);
    if (kret) {
	*minor_status = kret;
	_gsskrb5_set_error_string ();

	HEIMDAL_MUTEX_destroy(&ctx->ctx_id_mutex);
		
	return GSS_S_FAILURE;
    }

    kret = set_addresses(ctx->auth_context, input_chan_bindings);
    if (kret) {
	*minor_status = kret;

	HEIMDAL_MUTEX_destroy(&ctx->ctx_id_mutex);

	krb5_auth_con_free(_gsskrb5_context, ctx->auth_context);

	return GSS_S_BAD_BINDINGS;
    }

    /*
     * We need a sequence number
     */

    krb5_auth_con_addflags(_gsskrb5_context,
			   ctx->auth_context,
			   KRB5_AUTH_CONTEXT_DO_SEQUENCE |
			   KRB5_AUTH_CONTEXT_CLEAR_FORWARDED_CRED,
			   NULL);

    *context_handle = (gss_ctx_id_t)ctx;

    return GSS_S_COMPLETE;
}