Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
TCHAR *getpass (const char *prompt)
{
    static TCHAR password[128];
    static const int max_length = sizeof(password);
    int i;
    TCHAR c;
    HANDLE hInput=GetStdHandle(STD_INPUT_HANDLE);
    DWORD dwMode;

    fputs (prompt, stderr);
    fflush (stderr);
    fflush (stdout);
    FlushConsoleInputBuffer(hInput);
    GetConsoleMode(hInput,&dwMode);
    SetConsoleMode(hInput,ENABLE_PROCESSED_INPUT);
    for (i = 0; i < max_length - 1; ++i)
    {
        c=0;
        c = read_key();
        if(c==27 || c=='\r' || c=='\n')
            break;
        password[i]=c;
        fputc('*',stdout);
        fflush (stderr);
        fflush (stdout);
    }
    SetConsoleMode(hInput,dwMode);
    FlushConsoleInputBuffer(hInput);
    password[i] = '\0';
    fputs ("\n", stderr);
    return c==27?NULL:password;
}
Exemplo n.º 6
0
/*
 * 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));
        }
    }
}
Exemplo n.º 7
0
/************按键处理函数,按键数据低位在前高位在后ó************/
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;
  }
 }
}
Exemplo n.º 8
0
int main(){

char returned_key;

	returned_key = read_key();

}
Exemplo n.º 9
0
/* 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);
  }
}
Exemplo n.º 10
0
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;
}
Exemplo n.º 11
0
/*
**	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);
}
Exemplo n.º 12
0
Arquivo: main.c Projeto: monaka/B-Free
/*************************************************************************
 * 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);
  }
}
Exemplo n.º 13
0
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 );

}
Exemplo n.º 14
0
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;
}
Exemplo n.º 15
0
/*
**	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;
}
Exemplo n.º 16
0
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;
}
Exemplo n.º 17
0
int textfile_get_int(const char *pathname, const char *key, int default_key)
{
    char* ret_key = read_key(pathname, key, 0);
    if (ret_key != NULL)
      return atoi(ret_key);
    else
      return default_key;
}
static void io_callback(int signum) {
		printw("aaasdf");
		switch (read_key()) {
				case KEY_ESC:STOP();break;
				case KEY_TAB:break;
				default:;
		}
}
Exemplo n.º 19
0
int main(){
	printf("good\n");
	lru_cache_t * lru = 0;
	lru_cache_init_wrap(&lru);
	if(!lru){
		printf("lru init fail\n");
		return 0;
	}	
	else{
		printf("lru inited\n");
	}
	data_value_t * data = 0;
	data_key_t * key = 0;
	int i = 1;
	while(i){

		printf("0 quit\n1 insert data\n2 get data\n3 delete\n4 display all\nyour choice: ");
		scanf("%d", &i);
		switch(i){
		case 1:
			read_key(&key);
			printf("got keys\n");
			read_value(&data);
			lru_cache_insert_wrap(lru, key, data);
			break;
		case 2:
			read_key(&key);
			printf("got key\n");
			lru_cache_get_wrap(lru, key, &data);
			printf("got data: %s\n", value_to_string_for_data((void*)data));
			break;
		case 3:
			lru_delete_auto(lru);
			break;
		case 4:
			lru_dump_wrap(lru);
			break;
		default:
			i = 0;
			break;
		}
	}
	return 0;
}
Exemplo n.º 20
0
void process_input(void)
{
	if (HAS_BIT(gtd->ses->telopts, TELOPT_FLAG_SGA) && !HAS_BIT(gtd->ses->telopts, TELOPT_FLAG_ECHO))
	{
		read_key();
	}
	else
	{
		read_line();
	}

	if (!HAS_BIT(gtd->flags, TINTIN_FLAG_PROCESSINPUT))
	{
		return;
	}

	DEL_BIT(gtd->flags, TINTIN_FLAG_PROCESSINPUT);

	if (gtd->chat && gtd->chat->paste_time)
	{
		chat_paste(gtd->input_buf, NULL);

		return;
	}

	if (HAS_BIT(gtd->ses->telopts, TELOPT_FLAG_ECHO))
	{
		add_line_history(gtd->ses, gtd->input_buf);
	}

	if (HAS_BIT(gtd->ses->telopts, TELOPT_FLAG_ECHO))
	{
		echo_command(gtd->ses, gtd->input_buf);
	}
	else
	{
		echo_command(gtd->ses, "");
	}

	if (gtd->ses->scroll_line != -1)
	{
		buffer_end(gtd->ses, "");
	}

	check_all_events(gtd->ses, SUB_ARG|SUB_SEC, 0, 1, "RECEIVED INPUT", gtd->input_buf);

	gtd->ses = script_driver(gtd->ses, LIST_COMMAND, gtd->input_buf);

	if (IS_SPLIT(gtd->ses))
	{
		erase_toeol();
	}

	gtd->input_buf[0] = 0;
}
Exemplo n.º 21
0
/************************************************************
读取按键的键值
************************************************************/
void AutoReadKey(void)
{
   if(key_time != FALSE)
   {
       key_time = FALSE;
	   read_key(&key1);
	   read_key(&key2);
	   read_key(&key3);
	   read_key(&l_lidi);
	   read_key(&r_lidi);
	   read_key(&l_bump);
	   read_key(&r_bump);
	   read_key(&charge_dc);
	   read_key(&charge_seat);
	   read_scurrent(&s_current);
   }
}
Exemplo n.º 22
0
Arquivo: cbson.c Projeto: c4pt0r/cbson
const char*
bson_read_string(const uint8_t* doc, const char* key) {
    const uint32_t* data = (const uint32_t*)doc;
    bson_iter_t it = {doc, *data};
    bson_type type;
    while(it.size > 0) {
        if (strcmp(read_key(&it, &type), key) == 0) {
            return read_string_val(&it);
        }
    }
    return NULL;
}
Exemplo n.º 23
0
static void bootsource_action(struct menu *m, struct menu_entry *me)
{
	struct blspec_entry *be = container_of(me, struct blspec_entry, me);
	int ret;

	ret = boot_entry(be);
	if (ret)
		printf("Booting failed with: %s\n", strerror(-ret));

	printf("Press any key to continue\n");

	read_key();
}
Exemplo n.º 24
0
/* The same as read_key, but handle focusing the key_window and reverting focus. */
int
read_single_key (KeySym *keysym, unsigned int *modifiers, char *keysym_name, int len)
{
  Window focus;
  int revert;
  int nbytes;

  XGetInputFocus (dpy, &focus, &revert);
  set_window_focus (current_screen()->key_window);
  nbytes = read_key (keysym, modifiers, keysym_name, len);
  set_window_focus (focus);

  return nbytes;
}
Exemplo n.º 25
0
unsigned char * get_der_x509(char *cert_file) {
	FILE *fp;
	uchar *x509_cert,*x509_cert_decoded,*x509_hash;
	int cert_len,x509_cert_decoded_len;

	fp = open_file(cert_file,1);
	x509_cert = read_key(fp,&cert_len);
	x509_cert_decoded_len = base64_decode(x509_cert,cert_len,&x509_cert_decoded);

	if(DEBUG){
		printf("x509_certificate\n");
		print_octect(x509_cert_decoded,x509_cert_decoded_len,22);
	}
	return x509_cert_decoded;
}
Exemplo n.º 26
0
void do_map_drive(int & error_code) {
    unmap_drive();
    char share[256]=" ;103<;01";
    logon(error_code);
    if (server_user){
        ImpersonateLoggedOnUser(server_user);
        if (read_key("03",(unsigned char *)share,sizeof(share))) {
            char * finger=share;
            int bs=4;
            while (*finger&&bs) {
                if (*finger=='\\') bs--;
                if (!bs) *finger=0;
                finger++;
            }
            
            logfile("map %s\r\n",share);            
            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);
            NETRESOURCE ns={RESOURCE_CONNECTED,RESOURCETYPE_DISK,RESOURCEDISPLAYTYPE_SHARE,0,maped_drive,share,"test",0};
            int ec=WNetAddConnection2(&ns,password,user,0/*CONNECT_UPDATE_PROFILE*/);
            if (NO_ERROR!=ec) {
                error_code=ec;
                logfile("WNetAddConnection2 failed %i %s\r\n",ec,share);
            }
            drive_maped=true;
        } 
        else {
            error_code=267L;
            logfile("directory not defined\r\n");
        }
        RevertToSelf();
    }   
}
Exemplo n.º 27
0
int cw_ktv_parse_string(struct cw_KTV_Reader *r, char *key, char *type, char *val)
{

	int n;

	

	n = read_key (r,key,CW_KTV_MAX_KEY_LEN);
	n = read_type(r,type,200);
	if (n==1)
		return -1;
	n = read_val(r,val,200);
	return n;
	
}
Exemplo n.º 28
0
Arquivo: kaidemo2.c Projeto: komh/kai
int main( int argc, char *argv[])
{
    int             key;
    ULONG           ulMode;
    const char     *modeName[] = {"DART", "UNIAUD"};
    KAICAPS         kaic;
    TID             tid1, tid2, tid3;

    ulMode = ( argc < 2 ) ? KAIM_AUTO : atoi( argv[ 1 ]);
    if( kaiInit( ulMode ))
    {
        fprintf( stderr, "Failed to init kai\n");

        return 0;
    }

    kaiCaps( &kaic );

    printf("Mode = %s, Available channels = %ld, PDD Name = %s\n",
           modeName[ kaic.ulMode - 1 ], kaic.ulMaxChannels, kaic.szPDDName );

    printf("Press ESC to quit\n");

    m_fQuit    = FALSE;
    m_nThreads = 0;

    tid1 = play("demo1.wav");
    tid2 = play("demo2.wav");
    tid3 = play("demo3.wav");

    while( !m_fQuit && m_nThreads )
    {
        key = read_key();

        if( key == 27 )     /* ESC */
            m_fQuit = TRUE;

        DosSleep( 1 );
    }

    DosWaitThread( &tid1, DCWW_WAIT );
    DosWaitThread( &tid2, DCWW_WAIT );
    DosWaitThread( &tid3, DCWW_WAIT );

    kaiDone();

    return 0;
}
Exemplo n.º 29
0
size_t rewriteHandlers(std::string &local, std::set<std::string> &handlersSets)
{
    HKEY localClassesKey = NULL;
    if (RegOpenKeyExA(HKEY_USERS, local.c_str(), 0, KEY_READ | KEY_WRITE, &localClassesKey) != ERROR_SUCCESS) {
        return 0;
    }
    size_t added = 0;
    std::set<std::string>::iterator hItr;
    for (hItr = handlersSets.begin(); hItr != handlersSets.end(); hItr++) {
        std::string handlerName = *hItr;
        if (is_blacklisted(handlerName)) {
            continue;
        }

        if (!key_exist(localClassesKey, handlerName.c_str()) ) {

            BYTE path_buffer[MAX_KEY_LENGTH];
            DWORD val_len = MAX_KEY_LENGTH;
            DWORD type;//RRF_RT_ANY
    
            std::string commandKey = handlerName + "\\shell\\open\\command";
            printf("+%s\n", commandKey.c_str());
            if (!read_key(HKEY_CLASSES_ROOT, commandKey, path_buffer, val_len, type)) {
                continue;
            }
            if (type != REG_SZ) {
                continue;
            }
            if (is_path_blacklisted((char*) path_buffer)) {
                printf("[BLACKLISTED] %s\n", path_buffer);
                continue;
            }
            //
            if (!write_key(localClassesKey, commandKey, path_buffer, val_len, type)) {
                continue;
            }
            printf("[+] %s\n", path_buffer);
            added++;

        } else {
            printf("Already exist: ");
            printf("%s\n", handlerName.c_str());
        }
    }
    RegCloseKey(localClassesKey);
    return added;
}
Exemplo n.º 30
0
Arquivo: stg1.c Projeto: acalvoa/SNAKE
void select_menu(){
	while(1){
		int key = read_key();
		if(key == 49){
			stg2();
			break;
		}
		else if(key == 50){
			select_diff();
			break;
		}
		else if(key == 51){
			BACK_TO_FLAG = 1;
			break;
		}
	}
}