예제 #1
0
int main(void)
{
	union uKeyRoster scan;
    init();    

    while (1)
    {
		wait_for_press();
		// Result is stored in prev_keys & keys and hopefully keys2

		SET_LED_1();
		scan = pack_array( keys );
		build_key_list   ( keys );

		if (isConfigured(MODE_SEND_ROSTER)==0)		{
			can_prep_button_roster_msg( &msg1, scan );
			can_send_msg_no_wait( CAN_TRANSMIT_CHANNEL1, &msg1 );
		}
		if (isConfigured(MODE_SEND_PRESSED)==0)		{
			can_prep_button_pressed_msg( &msg2 );
			can_send_msg_no_wait( CAN_TRANSMIT_CHANNEL2, &msg2 );
	    }
		RESET_LED_1();
    }
    return(0);
} 
예제 #2
0
    void crypto_asym::set_signatories(const std::vector<std::string> & signatories)
    {
#if GPGME_SUPPORT
	gpgme_key_t *signatories_key = NULL;

	if(signatories.empty())
	{
	    gpgme_signers_clear(context);
	    has_signatories = false;
	}
	else
	{
	    build_key_list(signatories, signatories_key, true);
	    try
	    {
		gpgme_signers_clear(context);
		gpgme_key_t *ptr = signatories_key;
		gpgme_error_t err;

		if(ptr == NULL)
		    throw SRC_BUG;  // build_key_list failed
		while(*ptr != NULL)
		{
		    err = gpgme_signers_add(context, *ptr);
		    switch(gpgme_err_code(err))
		    {
		    case GPG_ERR_NO_ERROR:
			break;
		    default:
			throw Erange("crypto_asym::encrypt", string(gettext("Unexpected error reported by GPGME: ")) + tools_gpgme_strerror_r(err));
		    }
		    ++ptr;
		}
	    }
	    catch(...)
	    {
		release_key_list(signatories_key);
		gpgme_signers_clear(context);
		has_signatories = false;
		throw;
	    }
	    release_key_list(signatories_key);
	    has_signatories = true;
	}
#else
	throw Efeature("Asymetric Strong encryption algorithms using GPGME");
#endif
    }
예제 #3
0
파일: hotspares.c 프로젝트: andreiw/polaris
static int
get_hsp(
	void			*d,
	int			mode
)
{
	hot_spare_pool_t	*hsp;
	get_hsp_t		*ghsp;
	size_t			size;
	set_t			setno;
	int			err = 0;
	md_i_get_t		*migp = (md_i_get_t *)d;


	setno = migp->md_driver.md_setno;

	mdclrerror(&migp->mde);

	/* Scan the hot spare pool list */
	hsp = find_hot_spare_pool(setno, migp->id);
	if (hsp == NULL) {
		return (mdhsperror(&migp->mde, MDE_INVAL_HSP,
			migp->id));
	}

	size = (sizeof (ghsp->ghsp_hs_keys[0]) * (hsp->hsp_nhotspares - 1)) +
	    sizeof (get_hsp_t);

	if (migp->size == 0) {
		migp->size = (int)size;
		return (0);
	}

	if (migp->size < size)
		return (EFAULT);

	ghsp = kmem_alloc(size, KM_SLEEP);

	ghsp->ghsp_id = hsp->hsp_self_id;
	ghsp->ghsp_refcount = hsp->hsp_refcount;
	ghsp->ghsp_nhotspares = hsp->hsp_nhotspares;
	build_key_list(setno, hsp, ghsp->ghsp_hs_keys);
	if (ddi_copyout(ghsp, (caddr_t)(uintptr_t)migp->mdp, size, mode))
		err = EFAULT;
	kmem_free(ghsp, size);
	return (err);
}
예제 #4
0
    void crypto_asym::encrypt(const vector<string> & recipients_email, generic_file & clear, generic_file & ciphered)
    {
#if GPGME_SUPPORT
	gpgme_key_t *ciphering_keys = NULL;

	build_key_list(recipients_email, ciphering_keys, false);
	try
	{
	    generic_file_overlay_for_gpgme o_clear = &clear;
	    generic_file_overlay_for_gpgme o_ciphered = &ciphered;
	    gpgme_error_t err;

	    if(!has_signatories)
		err = gpgme_op_encrypt(context,
				       ciphering_keys,
				       (gpgme_encrypt_flags_t)(GPGME_ENCRYPT_NO_ENCRYPT_TO|GPGME_ENCRYPT_ALWAYS_TRUST),
				       o_clear.get_gpgme_handle(),
				       o_ciphered.get_gpgme_handle());
	    else
		err = gpgme_op_encrypt_sign(context,
					    ciphering_keys,
					    (gpgme_encrypt_flags_t)(GPGME_ENCRYPT_NO_ENCRYPT_TO|GPGME_ENCRYPT_ALWAYS_TRUST),
					    o_clear.get_gpgme_handle(),
					    o_ciphered.get_gpgme_handle());
	    switch(gpgme_err_code(err))
	    {
	    case GPG_ERR_NO_ERROR:
		break;
	    case GPG_ERR_INV_VALUE:
		throw SRC_BUG;
	    case GPG_ERR_UNUSABLE_PUBKEY:
		throw Erange("crypto_asym::encrypt", gettext("Key found but users are not all trusted"));
	    default:
		throw Erange("crypto_asym::encrypt", string(gettext("Unexpected error reported by GPGME: ")) + tools_gpgme_strerror_r(err));
	    }
	}
	catch(...)
	{
	    release_key_list(ciphering_keys);
	    throw;
	}
	release_key_list(ciphering_keys);
#else
	throw Efeature("Asymetric Strong encryption algorithms using GPGME");
#endif
    }
예제 #5
0
void
trkproperties_fill_meta (GtkListStore *store, DB_playItem_t **tracks, int numtracks) {
    gtk_list_store_clear (store);
    if (!tracks) {
        return;
    }

    const char **keys = NULL;
    int nkeys = build_key_list (&keys, 0, tracks, numtracks);

    int k;

    // add "standard" fields
    for (int i = 0; types[i]; i += 2) {
        add_field (store, types[i], _(types[i+1]), 0, tracks, numtracks);
    }

    // add all other fields
    for (int k = 0; k < nkeys; k++) {
        int i;
        for (i = 0; types[i]; i += 2) {
            if (!strcasecmp (keys[k], types[i])) {
                break;
            }
        }
        if (types[i]) {
            continue;
        }

        char title[MAX_GUI_FIELD_LEN];
        if (!types[i]) {
            snprintf (title, sizeof (title), "<%s>", keys[k]);
        }
        add_field (store, keys[k], title, 0, tracks, numtracks);
    }
    if (keys) {
        free (keys);
    }
}
예제 #6
0
void
trkproperties_fill_metadata (void) {
    if (!trackproperties) {
        return;
    }
    trkproperties_modified = 0;
    deadbeef->pl_lock ();

    trkproperties_fill_meta (store, tracks, numtracks);
    gtk_list_store_clear (propstore);

    // hardcoded properties
    for (int i = 0; hc_props[i]; i += 2) {
        add_field (propstore, hc_props[i], _(hc_props[i+1]), 1, tracks, numtracks);
    }
    // properties
    const char **keys = NULL;
    int nkeys = build_key_list (&keys, 1, tracks, numtracks);
    for (int k = 0; k < nkeys; k++) {
        int i;
        for (i = 0; hc_props[i]; i += 2) {
            if (!strcasecmp (keys[k], hc_props[i])) {
                break;
            }
        }
        if (hc_props[i]) {
            continue;
        }
        char title[MAX_GUI_FIELD_LEN];
        snprintf (title, sizeof (title), "<%s>", keys[k]+1);
        add_field (propstore, keys[k], title, 1, tracks, numtracks);
    }
    if (keys) {
        free (keys);
    }

    deadbeef->pl_unlock ();
}
예제 #7
0
int main(int argc , char ** argv) {
  install_SIGNALS();
  {
    bool           report_only     = false;
    bool           list_mode       = false;
    bool           include_restart = true;
    bool           print_header    = true;
    int            arg_offset      = 1;

#ifdef ERT_HAVE_GETOPT
    if (argc == 1)
      print_help_and_exit();
    else {

      static struct option long_options[] = {
        {"no-restart"  , 0 , 0 , 'n'} ,
        {"list"        , 0 , 0 , 'l'} ,
        {"report-only" , 0 , 0 , 'r'} ,
        {"no-header"   , 0 , 0 , 'x'} ,
        {"help"        , 0 , 0 , 'h'} ,
        { 0            , 0 , 0 ,   0} };

      while (1) {
        int c;
        int option_index = 0;

        c = getopt_long (argc, argv, "nlRrx", long_options, &option_index);
        if (c == -1)
          break;

        switch (c) {
        case 'n':
          include_restart = false;
          break;
        case 'r':
          report_only = true;
          break;
        case 'l':
          list_mode = true;
          break;
        case 'x':
          print_header = false;
          break;
        case 'h':
          print_help_and_exit();
          break;
        case '?':
          printf("Hmmm - unrecognized option???");
          break;
        }
      }
      arg_offset = optind;  /* External static variable in the getopt scope*/
    }
#endif

    if (arg_offset >= argc)
      print_help_and_exit();

    {
      char         * data_file = argv[arg_offset];
      ecl_sum_type * ecl_sum;
      int            num_keys  = argc - arg_offset - 1;
      const char  ** arg_list  = (const char **) &argv[arg_offset + 1];


      ecl_sum = ecl_sum_fread_alloc_case__( data_file , ":" , include_restart);
      /** If no keys have been presented the function will list available keys. */
      if (num_keys == 0)
        list_mode = true;

      if (ecl_sum != NULL) {
        if (list_mode) {
          /*
             The program is called in list mode, we only print the
             (matching) keys in a table on stdout. If no arguments
             have been given on the commandline, all internalized keys
             will be printed.
          */

          stringlist_type * keys = stringlist_alloc_new();
          if (num_keys == 0) {
            ecl_sum_select_matching_general_var_list( ecl_sum , "*" , keys);
            stringlist_sort(keys , NULL );
          } else
            build_key_list( ecl_sum , keys , num_keys , arg_list);

          {
            int columns = 5;
            int i;
            for (i=0; i< stringlist_get_size( keys );  i++) {
              printf("%-24s ",stringlist_iget( keys , i ));
              if ((i % columns) == 4)
                printf("\n");
            }
            printf("\n");
          }
          stringlist_free( keys );
        } else {
          /* Normal operation print results for the various keys on stdout. */
          ecl_sum_fmt_type fmt;
          stringlist_type * key_list = stringlist_alloc_new( );
          build_key_list( ecl_sum , key_list , num_keys , arg_list);

          if (print_header)
            ecl_sum_fmt_init_summary_x(ecl_sum , &fmt );
          else
            fmt.print_header = false;

          ecl_sum_fprintf(ecl_sum , stdout , key_list , report_only , &fmt);

          stringlist_free( key_list );
        }
        ecl_sum_free(ecl_sum);
      } else
        fprintf(stderr,"summary.x: No summary data found for case:%s\n", data_file );
    }
  }
}