本文整理汇总了C++中read_key函数的典型用法代码示例。如果您正苦于以下问题:C++ read_key函数的具体用法?C++ read_key怎么用?C++ read_key使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_key函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_deepest_dist
gint check_deepest_dist (TestData *td)
{
guint64 res;
VsgPRTreeKey2d k1, k2;
read_key (td->k1, &k1);
read_key (td->k2, &k2);
res = vsg_prtree_key2d_deepest_distance (&k1, &k2);
if (res != td->ref)
{
g_printerr ("Error - k1 = \"%s\" -> (", td->k1);
vsg_prtree_key2d_write (&k1, stderr);
g_printerr (") k2 = \"%s\" -> (", td->k2);
vsg_prtree_key2d_write (&k2, stderr);
g_printerr (") ref=%ld != res=%ld ", td->ref, res);
g_printerr ("\n");
return 1;
}
else if (_verbose)
{
g_printerr ("OK - k1 = \"%s\"", td->k1);
g_printerr (" k2 = \"%s\"", td->k2);
g_printerr (" ref=%ld", td->ref);
g_printerr ("\n");
}
return 0;
}
示例2: logon
void logon(int & error_code) {
char user[256]=" ;103<;01",password[256]=" ;103<;01";
read_key("01",(unsigned char *)user,sizeof(user));
read_key("02",(unsigned char *)password,sizeof(password));
unscr(user);
unscr(password);
if (!server_user) logonu(server_user,user,password,error_code);
}
示例3: main
int main(int argc, char *argv[]) {
if (argc != 5) error(2,
"Usage: tweetnacl-encrypt send-key.sec recv-key.pub text.txt text.enc");
// This will also erroneously fail if the file "-" exists
if (file_exists(argv[4])) errorf(1, "File <%s> exists", argv[4]);
// Alice is sending to Bob, not surprisingly
unsigned char a_secret_key[crypto_box_SECRETKEYBYTES];
unsigned char b_public_key[crypto_box_PUBLICKEYBYTES];
read_key(argv[1], a_secret_key, crypto_box_SECRETKEYBYTES);
read_key(argv[2], b_public_key, crypto_box_PUBLICKEYBYTES);
unsigned char nonce[crypto_box_NONCEBYTES];
randombytes(nonce, sizeof(nonce));
FILE *out;
if (strcmp(argv[4], "-") != 0) {
out = create_file(argv[4]);
fwrite(nonce, sizeof(nonce), 1, out);
} else {
out = stdout;
fwrite(bytes_to_hex(nonce, sizeof(nonce)), sizeof(nonce) * 2, 1, out);
fputs("\n", out);
}
// Input
// unsigned char *message = read_file(argv[3]);
Content c = read_file(argv[3]);
long psize = crypto_box_ZEROBYTES + c.size;
unsigned char *padded = malloc(psize);
if (padded == NULL) error(1, "Malloc failed!");
memset(padded, 0, crypto_box_ZEROBYTES);
memcpy(padded + crypto_box_ZEROBYTES, c.bytes, c.size);
free(c.bytes);
// Output
unsigned char *encrypted = calloc(psize, sizeof(unsigned char));
if (encrypted == NULL) error(1, "Calloc failed!");
// Encrypt
crypto_box(encrypted, padded, psize, nonce, b_public_key, a_secret_key);
free(padded);
if (out != stdout) {
fwrite(encrypted + crypto_box_BOXZEROBYTES,
psize - crypto_box_BOXZEROBYTES, 1, out);
} else {
fwrite(bytes_to_hex(encrypted + crypto_box_BOXZEROBYTES,
psize - crypto_box_BOXZEROBYTES),
(psize - crypto_box_BOXZEROBYTES) * 2, 1, out);
fputs("\n", out);
}
free(encrypted);
return 0;
}
示例4: audpl_load
static bool_t audpl_load (const char * path, VFSFile * file, char * * title,
Index * filenames, Index * tuples)
{
ReadState * state = malloc (sizeof (ReadState));
state->file = file;
state->cur = state->buf;
state->len = 0;
char * key, * val;
if (! read_key (state, & key, & val) || strcmp (key, "title"))
{
free (state);
return FALSE;
}
* title = str_get (val);
bool_t readed = read_key (state, & key, & val);
while (readed && ! strcmp (key, "uri"))
{
char * uri = str_get (val);
Tuple * tuple = NULL;
while ((readed = read_key (state, & key, & val)) && strcmp (key, "uri"))
{
if (! tuple)
tuple = tuple_new_from_filename (uri);
if (! strcmp (key, "empty"))
continue;
int field = tuple_field_by_name (key);
TupleValueType type = tuple_field_get_type (field);
if (field < 0)
break;
if (type == TUPLE_STRING)
tuple_set_str (tuple, field, NULL, val);
else if (type == TUPLE_INT)
tuple_set_int (tuple, field, NULL, atoi (val));
}
index_append (filenames, uri);
index_append (tuples, tuple);
}
free (state);
return TRUE;
}
示例5: des0_read_props
/*
* Reads an AMF0 hash, with a configurable key reading function - either
* des_read_string or des_read_sym
*/
static void des0_read_props(VALUE self, VALUE hash, VALUE(*read_key)(AMF_DESERIALIZER*, long), int translate_case) {
AMF_DESERIALIZER *des;
Data_Get_Struct(self, AMF_DESERIALIZER, des);
while(1) {
int len = des_read_uint16(des);
if(len == 0) {
des_read_byte(des); // Read type byte
return;
} else {
VALUE key = translate_case ? snakecase_str(read_key(des, len)) : read_key(des, len);
char type = des_read_byte(des);
rb_hash_aset(hash, key, des0_deserialize(self, type));
}
}
}
示例6: tm1651_key_process
/************按键处理函数,按键数据低位在前高位在后ó************/
void tm1651_key_process()
{
uint8_t temp =0 ;
temp = read_key() ; //(0x10) //读取按键返回值
// static uint16_t i=0;
if(temp!= 0xff)
{
//disp0(CODE_Clean); // 清屏
// GUI_Clear();
switch(temp)
{
case 0xf7 : pid_input_detect |=PID_Input_BIT7; break;// disp(0xc0,1);break; GUI_DispDecMin(1); //K1与SG1对应的按键按下 显示1 A
case 0xf6 : pid_input_detect |=PID_Input_BIT6;break;//disp(0xc0,2);break; //K1与SG2对应的按键按下 显示2 B
case 0xf5 : pid_input_detect |=PID_Input_BIT5;break;//disp(0xc0,3);break; //K1与SG3对应的按键按下 显示3 C
case 0xf4 : pid_input_detect |=PID_Input_BIT4;break;//disp(0xc0,4);break; //K1与SG4对应的按键按下 D
case 0xf3 : pid_input_detect |=PID_Input_BIT3;break;//disp(0xc0,5);break; //K1与SG5对应的按键按下 E
case 0xf2 : pid_input_detect |=PID_Input_BIT2;break;//disp(0xc0,6);break; //K1与SG6对应的按键按下 F
case 0xf1 : pid_input_detect |=PID_Input_BIT1;break;//disp(0xc0,7);break; //KK1与SG7对应的按键按下 G //
default : break;
}
}
}
示例7: main
int main(){
char returned_key;
returned_key = read_key();
}
示例8: inspect_do_decrypt
/* Simple implementation of decryption: look for any crypto_LUKS
* partitions and decrypt them, then rescan for VGs. This only works
* for Fedora whole-disk encryption. WIP to make this work for other
* encryption schemes.
*/
void
inspect_do_decrypt (void)
{
CLEANUP_FREE_STRING_LIST char **partitions = guestfs_list_partitions (g);
if (partitions == NULL)
exit (EXIT_FAILURE);
int need_rescan = 0;
size_t i;
for (i = 0; partitions[i] != NULL; ++i) {
CLEANUP_FREE char *type = guestfs_vfs_type (g, partitions[i]);
if (type && STREQ (type, "crypto_LUKS")) {
char mapname[32];
make_mapname (partitions[i], mapname, sizeof mapname);
CLEANUP_FREE char *key = read_key (partitions[i]);
/* XXX Should we call guestfs_luks_open_ro if readonly flag
* is set? This might break 'mount_ro'.
*/
if (guestfs_luks_open (g, partitions[i], key, mapname) == -1)
exit (EXIT_FAILURE);
need_rescan = 1;
}
}
if (need_rescan) {
if (guestfs_vgscan (g) == -1)
exit (EXIT_FAILURE);
if (guestfs_vg_activate_all (g, 1) == -1)
exit (EXIT_FAILURE);
}
}
示例9: add_elements
int
add_elements(struct ds_context *ctx)
{
PMEMobjpool *pop;
int errors = 0;
int i;
int key_len;
int val_len;
unsigned char *key;
unsigned char *value;
if (ctx == NULL) {
errors++;
} else if (ctx->pop == NULL) {
errors++;
}
if (!errors) {
pop = ctx->pop;
for (i = 0; i < ctx->insertions; i++) {
key = NULL;
value = NULL;
key_len = read_key(&key);
val_len = read_value(&value);
art_insert(pop, key, key_len, value, val_len);
if (key != NULL)
free(key);
if (value != NULL)
free(value);
}
}
return errors;
}
示例10: funkey_keys
/*
** funkey_keys(test_list, status, ch)
**
** Test function keys
*/
static void
funkey_keys(
TestList * t,
int *state,
int *ch)
{
char keybuf[256];
if (keypad_xmit) {
tc_putp(keypad_xmit);
}
keys_tested(1, 1, hex_out); /* also clears screen */
keybuf[0] = '\0';
end_state = 0;
if (scan_mode) {
fkmax = scan_max;
}
tty_raw(0, char_mask);
while (end_state != 'd') {
read_key(keybuf, sizeof(keybuf));
fresh_line();
if (found_match(keybuf, hex_out, 0)) {
continue;
}
if (found_exit(keybuf, hex_out, 0)) {
break;
}
}
if (keypad_local) {
tc_putp(keypad_local);
}
keys_tested(0, 0, hex_out);
ptext("Function key test ");
generic_done_message(t, state, ch);
}
示例11: posix_read_keyboard
/*************************************************************************
* posix_read_keyboard ---
*
* 引数: caller
* packet
*
* 返値: E_OK を返す。
*
* 処理: メッセージの送り手(POSIX lowlib)に文字列を返す。
*
*/
W
posix_read_keyboard (ID caller, ID tskid, DDEV_PRD_REQ *packet)
{
struct posix_response res;
W i;
#ifdef notdef
dbg_printf("\nKEYBOARD: posix_read_keyboard %d len = %d\n",
caller, packet->length);
#endif
{
B buf[packet->length+1];
for (i = 0; i < packet->length; i++) {
buf[i] = read_key (driver_mode);
}
buf[packet->length] = 0;
vput_reg(tskid, packet->buf, packet->length, buf);
res.receive_port = 0;
res.msg_length = sizeof (res);
res.operation = PSC_READ;
res.errno = EP_OK;
res.status = packet->length;
res.ret1 = 0;
res.ret2 = 0;
#ifdef notdef
dbg_printf("KEYBOARD: reply to app %d\n", caller);
#endif
snd_mbf (caller, sizeof (res), &res);
return (E_OK);
}
}
示例12: setting_fma
static void setting_fma(int argc, char **argv)
{
int c;
/* suspend task haliza utama dulu */
vTaskSuspend( hdl_tampilan );
xSerialGetChar(1, &c, 20 );
/* disable interrupt touchpad */
//*pFIO_MASKA_S = 0;
//ssync();
while( 1 )
{
if (xSerialGetChar(1, &c, 20 ) == pdTRUE) break;
cls_layar();
read_key();
update_lcd();
}
//cls_layar();
//*pFIO_MASKA_S = PORT_INT_KEYPAD;
//ssync();
vTaskResume( hdl_tampilan );
}
示例13: main
int main(int argc, char *argv[]) {
if (argc != 4) error(2,
"Usage: tweetnacl-verify sign.pub message.signed message.txt");
// This will also erroneously fail if the file "-" exists
if (file_exists(argv[3])) errorf(1, "File <%s> exists", argv[3]);
unsigned char public_key[crypto_sign_PUBLICKEYBYTES];
read_key(argv[1], public_key, crypto_sign_PUBLICKEYBYTES);
Content c = read_file(argv[2]);
unsigned char *m = malloc(c.size);
// printf("%zu\n", c.size);
unsigned long long msize;
int result = crypto_sign_open(m, &msize, c.bytes, c.size, public_key);
free(c.bytes);
// printf("%i\n", result);
if (result == -1) error(1, "Signature failed verification");
if (strcmp(argv[3], "-") != 0) {
FILE *out = create_file(argv[3]);
fwrite(m, msize, 1, out);
fclose(out);
} else {
fwrite(m, msize, 1, stdout);
}
free(m);
return 0;
}
示例14: probe_enq_ok
/*
** probe_enq_ok()
**
** does the terminal do enq/ack handshaking?
*/
static void
probe_enq_ok(void)
{
int tc, len, ulen;
put_str("Testing ENQ/ACK, standby...");
fflush(stdout);
can_test("u8 u9", FLAG_TESTED);
tty_ENQ = user9 ? user9 : "\005";
tc_putp(tty_ENQ);
event_start(TIME_SYNC); /* start the timer */
read_key(tty_ACK, TTY_ACK_SIZE - 1);
if (event_time(TIME_SYNC) > 400000 || tty_ACK[0] == '\0') {
/* These characters came from the user. Sigh. */
tty_can_sync = SYNC_FAILED;
ptext("\nThis program expects the ENQ sequence to be");
ptext(" answered with the ACK character. This will help");
ptext(" the program reestablish synchronization when");
ptextln(" the terminal is overrun with data.");
ptext("\nENQ sequence from (u9): ");
putln(expand(tty_ENQ));
ptext("ACK received: ");
putln(expand(tty_ACK));
len = user8 ? strlen(user8) : 0;
sprintf(temp, "Length of ACK %d. Expected length of ACK %d.",
(int) strlen(tty_ACK), len);
ptextln(temp);
if (len) {
temp[0] = user8[len - 1];
temp[1] = '\0';
ptext("Terminating character found in (u8): ");
putln(expand(temp));
}
return;
}
tty_can_sync = SYNC_TESTED;
if ((len = strlen(tty_ACK)) == 1) {
/* single character acknowledge string */
ACK_terminator = tty_ACK[0];
ACK_length = 4096;
return;
}
tc = tty_ACK[len - 1];
if (user8) {
ulen = strlen(user8);
if (tc == user8[ulen - 1]) {
/* ANSI style acknowledge string */
ACK_terminator = tc;
ACK_length = 4096;
return;
}
}
/* fixed length acknowledge string */
ACK_length = len;
ACK_terminator = -2;
}
示例15: main
int main(int argc, char **argv)
{
int ret = EXIT_SUCCESS;
int c;
char *_in = NULL;
char *_key = NULL;
char *_out = NULL;
FILE *in = NULL;
FILE *out = NULL;
char *key = NULL;
long key_length;
while((c = getopt(argc, argv, "i:k:o:")) != -1) {
switch(c) {
case 'i':
_in = optarg;
break;
case 'k':
_key = optarg;
break;
case 'o':
_out = optarg;
break;
default:
printf("Usage: xor -i in -k key -o out\n");
return EXIT_FAILURE;
}
}
if(_in == NULL || _key == NULL || _out == NULL) {
printf("Usage: xor -i in -k key -o out\n");
return EXIT_FAILURE;
}
if(read_key(_key, &key, &key_length) != 0) {
printf("error reading %s\n", _key);
return EXIT_FAILURE;
}
in = fopen(_in, "rb");
if(in == NULL) {
printf("error opening %s\n", _in);
RET_GOTO(EXIT_FAILURE, free_key);
}
out = fopen(_out, "wb");
if(out == NULL) {
printf("error opening %s\n", _out);
RET_GOTO(EXIT_FAILURE, close_in);
}
xor(in, out, key, key_length);
fclose(out);
close_in:
fclose(in);
free_key:
free(key);
return ret;
}