/* Helper for unit tests: populate the ed25519 keys without saving or * loading */ void init_mock_ed_keys(const crypto_pk_t *rsa_identity_key) { routerkeys_free_all(); #define MAKEKEY(k) \ k = tor_malloc_zero(sizeof(*k)); \ if (ed25519_keypair_generate(k, 0) < 0) { \ log_warn(LD_BUG, "Couldn't make a keypair"); \ goto err; \ } MAKEKEY(master_identity_key); MAKEKEY(master_signing_key); MAKEKEY(current_auth_key); #define MAKECERT(cert, signing, signed_, type, flags) \ cert = tor_cert_create(signing, \ type, \ &signed_->pubkey, \ time(NULL), 86400, \ flags); \ if (!cert) { \ log_warn(LD_BUG, "Couldn't make a %s certificate!", #cert); \ goto err; \ } MAKECERT(signing_key_cert, master_identity_key, master_signing_key, CERT_TYPE_ID_SIGNING, CERT_FLAG_INCLUDE_SIGNING_KEY); MAKECERT(auth_key_cert, master_signing_key, current_auth_key, CERT_TYPE_SIGNING_AUTH, 0); if (generate_ed_link_cert(get_options(), time(NULL), 0) < 0) { log_warn(LD_BUG, "Couldn't make link certificate"); goto err; } rsa_ed_crosscert_len = tor_make_rsa_ed25519_crosscert( &master_identity_key->pubkey, rsa_identity_key, time(NULL)+86400, &rsa_ed_crosscert); return; err: routerkeys_free_all(); tor_assert_nonfatal_unreached(); }
static irqreturn_t h3600_micro_power_isr(int irq, void *dev_id, struct pt_regs *regs) { int down = (GPLR & GPIO_H3600_NPOWER_BUTTON) ? 0 : 1; if (dev_id != h3600_micro_power_isr) return IRQ_NONE; h3600_hal_keypress( MAKEKEY( 11, down ) ); return IRQ_HANDLED; }
bool raconf_getboolEx(raconf rc, const char *section, const char *fallback_section, const char *key, bool _default){ char keystr[SECTION_LEN + VARNAME_LEN + 1 + 1]; struct conf_value *v; MAKEKEY(keystr, section, key); v = strdb_get(rc->db, keystr); if(v == NULL){ MAKEKEY(keystr, fallback_section, key); v = strdb_get(rc->db, keystr); if(v == NULL){ return _default; }else{ return v->bval; } }else{ return v->bval; } }//end: raconf_getboolEx()
const char* raconf_getstr(raconf rc, const char *section, const char *key, const char *_default){ char keystr[SECTION_LEN + VARNAME_LEN + 1 + 1]; struct conf_value *v; MAKEKEY(keystr, section, key); v = strdb_get(rc->db, keystr); if(v == NULL) return _default; else return v->strval; }//end: raconf_getstr()
void FASTCALL UpdateBlinkBitmaps( void ) { LPBLINKENTRY lpbe; for( lpbe = lpbeFirst; lpbe; lpbe = lpbe->lpbeNext ) { CMDREC cmd; int index; int c; WORD wDefKey; WORD wMyKey; wDefKey = 0; wMyKey = 0; /* Next, create an entry in the command table unless it is * the Custom or Full entry. */ cmd.iCommand = lpbe->iCommandID; cmd.iDisabledString = 0; cmd.lpszTooltipString = lpbe->szName; cmd.iToolButton = TB_BLINK; if( cmd.iCommand == IDM_CUSTOMBLINK ) { cmd.lpszString = GS( IDS_CUSTOMBLINK ); cmd.lpszCommand = GS( IDS_CUSTOMBLINK ); cmd.wCategory = CAT_FILE_MENU; } else { cmd.lpszString = lpbe->szName; cmd.lpszCommand = lpbe->szName; cmd.wCategory = CAT_BLINKS; } if( CTree_GetCommandKey( lpbe->szName, &wMyKey ) ) cmd.wDefKey = wMyKey; else if( strcmp( lpbe->szName, "Full" ) == 0 ) { if( wMyKey == 0 ) wDefKey = MAKEKEY(HOTKEYF_CONTROL,'T'); } else cmd.wDefKey = wDefKey; cmd.iActiveMode = WIN_ALL; cmd.hLib = NULL; cmd.wNewKey = 0; cmd.wKey = 0; cmd.nScheduleFlags = NSCHF_CANSCHEDULE; /* Set blink button bitmap. */ if( cmd.iCommand != IDM_CUSTOMBLINK ) { index = fNewButtons ? 31 : 0; for( c = 0; c < maxBlinkButtonArray; ++c ) if( strcmp( BlinkButtonArray[ c ].pszBlinkName, lpbe->szName ) == 0 ) { index = fNewButtons ? BlinkButtonArray[ c ].iBmpIndex + 28 : BlinkButtonArray[ c ].iBmpIndex; break; } SetCommandCustomBitmap( &cmd, BTNBMP_GRID, index ); } else { cmd.iToolButton = TB_CUSTOMBLINK; // strcpy( lpbe->szName, GS( IDS_CUSTOMBLINK ) ); } CTree_PutCommand( &cmd ); CTree_ChangeKey( cmd.iCommand, cmd.wDefKey ); } }
/* This function reads all blink manager entries into a locally * linked list. */ void FASTCALL LoadBlinkList( void ) { LPSTR lpsz; INITIALISE_PTR(lpsz); /* First create the Blink menu. */ hBlinkMenu = GetSubMenu( GetSubMenu( hMainMenu, 0 ), 12 ); /* Get the list of blink manager entries and * install them into the command table. */ if( fNewMemory( &lpsz, 8000 ) ) { UINT c; Amuser_GetPPString( szBlinkman, NULL, "", lpsz, 8000 ); for( c = 0; lpsz[ c ]; ++c ) { char szBtnBmpFilename[ 64 ]; LPCSTR pszBtnBmpFilename; char szConnCard[ 40 ]; DWORD dwBlinkFlags; LPBLINKENTRY lpbe; RASDATA rd2; int index; LPSTR lp; /* Read the configuration setting */ Amuser_GetPPString( szBlinkman, &lpsz[ c ], "", lpTmpBuf, LEN_TEMPBUF ); lp = lpTmpBuf; /* Set the default RAS settings */ rd2 = rdDef; /* Parse blink flags value. */ lp = IniReadLong( lp, &dwBlinkFlags ); lp = IniReadText( lp, szConnCard, sizeof(szConnCard)-1 ); if( *lp ) { lp = IniReadInt( lp, &rd2.fUseRAS ); if( rd2.fUseRAS ) { char szRASPassword[ 80 ]; lp = IniReadText( lp, rd2.szRASEntryName, RAS_MaxEntryName ); lp = IniReadText( lp, rd2.szRASUserName, UNLEN ); lp = IniReadText( lp, szRASPassword, PWLEN ); DecodeLine64( szRASPassword, rd2.szRASPassword, PWLEN ); } } /* Get button bitmap details. */ lp = IniReadText( lp, szBtnBmpFilename, sizeof(szBtnBmpFilename) ); lp = IniReadInt( lp, &index ); /* Convert to proper filename or index. */ pszBtnBmpFilename = szBtnBmpFilename; if( '\0' == *pszBtnBmpFilename ) pszBtnBmpFilename = BTNBMP_GRID; /* Store the settings. */ if( *szConnCard == '\0' ) strcpy( szConnCard, szCIXConnCard ); if( strcmp( &lpsz[ c ], "Custom" ) == 0 ) lpbe = AddBlinkToList( &lpsz[ c ], dwBlinkFlags, szConnCard, IDM_CUSTOMBLINK, FALSE ); else { WORD wDefKey; wDefKey = 0; if( strcmp( &lpsz[ c ], "Full" ) == 0 ) wDefKey = MAKEKEY(HOTKEYF_CONTROL,'T'); lpbe = AddBlinkToCommandTable( &lpsz[ c ], dwBlinkFlags, szConnCard, wDefKey, FALSE ); } /* Store RAS settings. */ if( NULL != lpbe ) lpbe->rd = rd2; c += strlen( &lpsz[ c ] ); } FreeMemory( &lpsz ); } /* If no blink entries, install some defaults. */ if( NULL == lpbeFirst ) { AddBlinkToCommandTable( "Full", BF_FULLCONNECT, szCIXConnCard, 0, TRUE ); AddBlinkToList( "Custom", BF_POSTCIX|BF_GETCIX, szCIXConnCard, IDM_CUSTOMBLINK, TRUE ); if( fUseInternet ) AddBlinkToCommandTable( "Mail Only", BF_GETIPMAIL|BF_POSTIPMAIL, szCIXConnCard, 0, TRUE ); AddBlinkToCommandTable( "Upload Only", BF_POSTIPMAIL|BF_POSTIPNEWS|BF_POSTCIX, szCIXConnCard, 0, TRUE ); AddBlinkToCommandTable( "CIX Forums Only", BF_POSTCIX|BF_GETCIX, szCIXConnCard, 0, TRUE ); if( fUseInternet ) AddBlinkToCommandTable( "Internet Only", BF_IPFLAGS, szCIXConnCard, 0, TRUE ); fBlinkListLoaded = FALSE; } else { /* Always make sure we have a Default blink * command. */ if( 0 == GetBlinkCommandID( "Full" ) ) AddBlinkToCommandTable( "Full", BF_FULLCONNECT, szCIXConnCard, MAKEKEY(HOTKEYF_CONTROL,'T'), TRUE ); fBlinkListLoaded = TRUE; } }