• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ read_input函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中read_input函数的典型用法代码示例。如果您正苦于以下问题:C++ read_input函数的具体用法?C++ read_input怎么用?C++ read_input使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了read_input函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: fopen

char *test_read_input()
{
        FILE *f;

        /* open, read and parse some invalid xml */
        f = fopen("test.invalid.xml", "r");
        mu_assert("read invalid xml", read_input(f) == 0);
        fclose(f);
        mu_assert("parse invalid xml", xml_parse(buf) == XML_STATUS_INVALID);

        /* open, read and parse some valid xml */
        f = fopen("test.xml", "r");
        mu_assert("read valid xml", read_input(f) == 0);
        fclose(f);
        mu_assert("buffer contains request", strncmp(buf,"<request>", 9) == 0);
        mu_assert("parse some valid xml", xml_parse(buf) == XML_STATUS_OK);

        /* fetch value of an element */
        char *value = xml_element("//username");
        mu_assert("perform xpath search for element", value != NULL);
        mu_assert("get value of xml element", strcmp(value, "iamauser") == 0);
        xml_free(value);

        xml_cleanup();

        return 0;
}
开发者ID:brettsheffield,项目名称:gladd,代码行数:27,代码来源:tests.c


示例2: main

int main(int argc, char **path, char ** envp) {
	struct stat st = { 0 };
	char *home = getenv("HOME");
	char *conf_path = (char *) malloc(sizeof(char) * (strlen(home)));
	strcpy(conf_path, home);
	strcat(conf_path, "/.shell");
	if (stat(conf_path, &st) == -1) {
		mkdir(conf_path, 0700);
	}
	history_path = (char *) malloc(sizeof(char) * (strlen(conf_path) + 7));
	log_path = (char *) malloc(sizeof(char) * (strlen(conf_path) + 4));
	strcpy(history_path, conf_path);
	strcat(history_path, "/history");
	strcpy(log_path, conf_path);
	strcat(log_path, "/log");
	signal(SIGCHLD, handle_signal);
	fill_env_var(envp);
	fill_bin_paths();
	if (argc == 1) {
		read_input(INTERACTIVE, "");
	} else if (argc == 2) {
		read_input(BATCH, path[1]);
	} else {
		fprintf(stderr, "too much arguments\n");
	}
	free_args();
	free(line);
	printf("\n");
	return 0;
}
开发者ID:MagedMilad,项目名称:Shell,代码行数:30,代码来源:shell.c


示例3: event_play_profile

static void event_play_profile(char* infile) {
  FILE* in, * datain;
  char filename[4096], buffer[4096];
  unsigned limit, data_read, amt;

  limit = 16*1024*1024;
  if (getenv("CHISTKA_PREREAD"))
    limit = atoi(getenv("CHISTKA_PREREAD"))*1024*1024;

  data_read = 0;

  if (in = fopen(infile, "r")) {
    while (data_read < limit && fgets(filename, sizeof(filename), in)) {
      read_input();
      if (!filename[0]) continue;
      /* Remove trailing newline */
      filename[strlen(filename)-1] = 0;
      dbgprintf(stderr, "daemon: replaying profile event: %s\n", filename);

      if (datain = fopen(filename, "r")) {
        do {
          read_input();
          amt = fread(buffer, 1, sizeof(buffer), datain);
          data_read += amt;
        } while (amt == sizeof(buffer) && data_read < limit);
        fclose(datain);
      }
    }
    fclose(in);
  }

  /* Done reading those files, now open the profile output. */
  profile_output = fopen(infile, "w");
}
开发者ID:AltSysrq,项目名称:libchistka,代码行数:34,代码来源:daemon.c


示例4: make_request

/**
* Tworzy żądanie, prosząc o odpowienie wpisy użytkownika.
* Zwraca -1 jeśli nastąpił błąd lub 0 - jeśli proces przebiegł pomyślnie.
*/
int make_request(int *auth){
  if(!*auth){  // autoryzuje do skutku
    char name[60], password[30];
    printf("Imię: ");
    read_input(61,name);
    strcpy(tmp.message, name);
    strcat(tmp.message,"_");
    printf("Nazwisko: ");
    read_input(60,name);
    strcat(tmp.message,name);
    printf("Hasło(jeśli puste wpisz \"\")[max. 30 zn]: ");
    read_input(30, password);
    if(strcmp(password,"\"\"") == 0)
      strcpy(password,"");
    strcat(tmp.message, ";");
    strcat(tmp.message, password);
	printf("%s\n",tmp.message);
    tmp.command_type = 1;
    return 0;
  }
  printf("Command: ");
  int cmd = -1;
  char tab[40];
  read_input(40,tab);
  cmd = parse_comand(tab);
  request_details(&cmd,auth);  // tworzymy żądanie
  if(cmd < 0 || cmd > 14){
    return -1;
  }
    tmp.command_type = cmd;
  return 0;
}
开发者ID:adowsky,项目名称:client-server,代码行数:36,代码来源:client.c


示例5: login_auth

int login_auth()
{
    char user_name[16]={0};
    char password[16]={0};
    int ret;

    printf_to_fd(fd_pty_slave, "login:");
READ_USER_NAME:
    
    ret=read_input(0);
    if (ret<0) return -1;
    if (ret!=1) goto READ_USER_NAME;
    memcpy(user_name, shell_buf, 15);
    shell_buf_cur_len = 0;

    printf_to_fd(fd_pty_slave, "password:");
READ_PASSWORD:
    ret=read_input(1);
    if (ret<0) return -1;
    if (ret!=1) goto READ_PASSWORD;
    memcpy(password, shell_buf, 15);
    shell_buf_cur_len = 0;

    if (strcmp(user_name, "admin")==0 &&
        strcmp(user_name, "admin")==0)
    {
        printf_to_fd(fd_pty_slave, "login success\n");
        return 0;
    }

          printf_to_fd(fd_pty_slave, "username or password wrong\n");
        return 1;
}
开发者ID:mikephp,项目名称:linux-dev-framework,代码行数:33,代码来源:telnetd4dbg.c


示例6: main

	int main(int argc, char* argv[]){
		printf("Welcome to Title Case! Please enter your exceptions within square brackets, each word in single quotes, then enter your desired sentence, again in square brackets and single quotes\n"); 
		struct value* exceptions = read_input(stdin);
		struct value* sentence = read_input(stdin);
		
		title_case(sentence, exceptions);
		return 0;
	}
开发者ID:arcturus611,项目名称:dailyprogrammer,代码行数:8,代码来源:c76e_title_case.c


示例7: printf

bool DataFlashFileReader::update(char type[5])
{
    uint8_t hdr[3];
    if (read_input(hdr, 3) != 3) {
        return false;
    }
    if (hdr[0] != HEAD_BYTE1 || hdr[1] != HEAD_BYTE2) {
        printf("bad log header\n");
        return false;
    }

    if (hdr[2] == LOG_FORMAT_MSG) {
        struct log_Format f;
        memcpy(&f, hdr, 3);
        if (read_input(&f.type, sizeof(f)-3) != sizeof(f)-3) {
            return false;
        }
        memcpy(&formats[f.type], &f, sizeof(formats[f.type]));
        strncpy(type, "FMT", 3);
        type[3] = 0;

        message_count++;
        return handle_log_format_msg(f);
    }

    if (!done_format_msgs) {
        done_format_msgs = true;
        end_format_msgs();
    }

    const struct log_Format &f = formats[hdr[2]];
    if (f.length == 0) {
        // can't just throw these away as the format specifies the
        // number of bytes in the message
        ::printf("No format defined for type (%d)\n", hdr[2]);
        exit(1);
    }

    uint8_t msg[f.length];

    memcpy(msg, hdr, 3);
    if (read_input(&msg[3], f.length-3) != f.length-3) {
        return false;
    }

    strncpy(type, f.name, 4);
    type[4] = 0;

    message_count++;
    return handle_msg(f,msg);
}
开发者ID:chenjiawei,项目名称:ardupilot,代码行数:51,代码来源:DataFlashFileReader.cpp


示例8: handle_lasikbd_event

static u8 handle_lasikbd_event(unsigned long hpa)
{
        u8 status_keyb,status_mouse,scancode,id;
        extern void handle_at_scancode(int); /* in drivers/char/keyb_at.c */
        
        /* Mask to get the base address of the PS/2 controller */
        id = gsc_readb(hpa+LASI_ID) & 0x0f;
        
        if (id==1) 
		hpa -= LASI_PSAUX_OFFSET; 
	
        status_keyb = read_status(hpa);
        status_mouse = read_status(hpa+LASI_PSAUX_OFFSET);

        while ((status_keyb|status_mouse) & LASI_STAT_RBNE){
           
		while (status_keyb & LASI_STAT_RBNE) {
	      
		scancode = read_input(hpa);

	        /* XXX don't know if this is a valid fix, but filtering
	         * 0xfa avoids 'unknown scancode' errors on, eg, capslock
	         * on some keyboards.
	         */
	      	      
		if (scancode == AUX_REPLY_ACK) 
			cmd_status=0;
			
		else if (scancode == AUX_RESEND)
			cmd_status=1;
		else 
			handle_at_scancode(scancode); 
	      
		status_keyb =read_status(hpa);
		}
	   
#ifdef CONFIG_PSMOUSE
		while (status_mouse & LASI_STAT_RBNE) {
			scancode = read_input(hpa+LASI_PSAUX_OFFSET);
			handle_mouse_scancode(scancode);
			status_mouse = read_status(hpa+LASI_PSAUX_OFFSET);
		}
		status_mouse = read_status(hpa+LASI_PSAUX_OFFSET);
#endif /* CONFIG_PSMOUSE */
		status_keyb = read_status(hpa);
        }

        tasklet_schedule(&keyboard_tasklet);
        return (status_keyb|status_mouse);
}
开发者ID:GunioRobot,项目名称:MI424WR_GEN2_Rev_E-F,代码行数:50,代码来源:hp_psaux.c


示例9: line_input

//read input
int line_input(char *line_str)
{

	if (get_buffer(line_str)) {
		return 1;

	} else if (check_input()) {

		read_input();

		if (get_buffer(line_str)) {
			return 1;

		} else if (read_end == LINE_INPUT_MAX_CHAR) {

			memcpy(line_str, buffer, LINE_INPUT_MAX_CHAR - 1);
			line_str[LINE_INPUT_MAX_CHAR - 1] = '\0';
			buffer[0] = buffer[LINE_INPUT_MAX_CHAR - 1];

			read_end = 1;
			return 1;

		} else {
			return 0;
		}

	} else {
		return 0;
	}
}
开发者ID:Chaozz,项目名称:happygg,代码行数:31,代码来源:pipe.cpp


示例10: main

int main(void) {

    time_t t;
    int val, ans[7], sumof, ret;
    srand((int) time(&t));

    while (1) {    
        for (val=0; val<6; val++) {
            ans[val] = (rand() % 6 + 1);
            write(ans[val]);
        }

        count_pairs(ans); 
        sumof = count(ans);
        printf("Sum of all dices: %i\n", sumof);
        ret = read_input();
    
        if (ret == 1) {
            continue;
        }
        else {
            break;
        }
    }
    return 0;
}
开发者ID:el-tillias,项目名称:mdh,代码行数:26,代码来源:2.c


示例11: interact

// INTERACT WITH USER AND SERVER IN ORDER TO CHOOSE ACTION
void interact(int socket) {
	printf("---MENU---\n1: SHELL\n2: SCREENSHOT\n3: UPDATE\n---FIN---\n");
	
	char *input;
	int choix = 0; 
	int i;
	// GET INPUT FROM USER AND TRANSFORM IT TO AN INT
	while(choix == 0) {
		input = read_input();
		for(i = 0; i < 4; i++)
			if(strchr(input, i + '0') != NULL)
				choix = i;
	}
	// TELL TO SERVER OUR CHOICE			
	write(socket, input, BUF_SIZE); 
	free(input); 
	
	switch(choix) {
		case 1 : 
			handle_shell(socket);
		break;
		case 2: 
			get_screenshot(socket);
		break;
		case 3:
			send_update(socket);
		break;
	}
	// WE'RE DONE, BYE
	close(socket);
}
开发者ID:pamartn,项目名称:Tiny-Rat,代码行数:32,代码来源:client.c


示例12: part2

void part2(){
  int r[4] = {0, 0, 1, 0};
  Vector v = read_input();
  run(v, r);
  printf("%d\n", r['a' - 'a']);
  Vector_free(v);
}
开发者ID:Jassob,项目名称:advent_of_code_2016,代码行数:7,代码来源:day12.c


示例13: main

int main(int argc, char *argv[])
{
	const char *outfilename = "tinyL.out";
	char *input;
	FILE *infile;

	printf("------------------------------------------------\n");
	printf("CS314 compiler for tinyL\n      Spring 2014\n");
	printf("------------------------------------------------\n");
	if (argc != 2) {
		ERROR("Use of command:\n  compile <tinyL file>\n");
		exit(EXIT_FAILURE);
	}
	infile = fopen(argv[1], "r");
	if (!infile) {
		ERROR("Cannot open input file \"%s\"\n", argv[1]);
		exit(EXIT_FAILURE);
	}
	outfile = fopen(outfilename, "w");
	if (!outfile) {
		ERROR("Cannot open output file \"%s\"\n", outfilename);
		exit(EXIT_FAILURE);
	}
	input = read_input(infile);
	buffer = input;
	program();
	printf("\nCode written to file \"%s\".\n\n", outfilename);
	free(input);
	fclose(infile);
	fclose(outfile);
	return EXIT_SUCCESS;
}
开发者ID:T-G-P,项目名称:TinyDawg,代码行数:32,代码来源:Compiler.c


示例14: read_username_password

void read_username_password (char *pword, int flag)
{
	int i = 0;
	int ch;
	while ((ch = read_input()) != '\n') {

		if (IS_BACK_SPACE(ch))  {
			if(pword[0] == '\0')
				continue;
			if (i > 0) {
				i--;
				pword[i] = '\0';
				if (flag)
					write_string ("\b \b");
			}
		}
		else {
			pword[i++] = (char)ch;
			if (flag)
				write_input_on_screen (ch);

		}
	}

	pword[i] = '\0';

	return;
}
开发者ID:ArunRamadoss,项目名称:Layer3Switch,代码行数:28,代码来源:login.c


示例15: main

int main(int argc, char * argv[])
{	
	char current_path[] = "0:/";
	
	printf(SHELL_BANNER",%s,v%d。\n", __DATE__, SHELL_VERSION);
	printf("输入help获取帮助.\n");
	
	/* Loop to get char */
	while(1)
	{
		int ch;

		/* 获取当前路径 */

		/* 打印提示符 */
		printf("[%s]#", current_path);
		ch = read_input(line_buffer, MAX_LINE_SIZE);
		printf("\n");
 
		/* 回车键则执行命令 */
		if (ch == SHELL_KEY_ENTER)
		{
			execute_cmd(line_buffer);	
		}		
	}

	return 0;
}
开发者ID:LastRitter,项目名称:GridOS,代码行数:28,代码来源:main.c


示例16: irc_input_cb_ssl

static void irc_input_cb_ssl(gpointer data, PurpleSslConnection *gsc,
		PurpleInputCondition cond)
{

	PurpleConnection *gc = data;
	struct irc_conn *irc = gc->proto_data;
	int len;

	if(!g_list_find(purple_connections_get_all(), gc)) {
		purple_ssl_close(gsc);
		return;
	}

	if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) {
		irc->inbuflen += IRC_INITIAL_BUFSIZE;
		irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen);
	}

	len = purple_ssl_read(gsc, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1);

	if (len < 0 && errno == EAGAIN) {
		/* Try again later */
		return;
	} else if (len < 0) {
		purple_connection_error(gc, _("Read error"));
		return;
	} else if (len == 0) {
		purple_connection_error(gc, _("Server has disconnected"));
		return;
	}

	read_input(irc, len);
}
开发者ID:arminius2,项目名称:apolloim,代码行数:33,代码来源:irc.c


示例17: decipher

static int decipher(struct sc_pkcs15_object *obj)
{
	u8 buf[1024], out[1024];
	int r, c, len;

	if (opt_input == NULL) {
		fprintf(stderr, "No input file specified.\n");
		return 2;
	}
	c = read_input(buf, sizeof(buf));
	if (c < 0)
		return 2;

	len = sizeof(out);
	if (!((struct sc_pkcs15_prkey_info *) obj->data)->native) {
                fprintf(stderr, "Deprecated non-native key detected! Upgrade your smart cards.\n");
		return SC_ERROR_NOT_SUPPORTED;
	}

	r = sc_pkcs15_decipher(p15card, obj, opt_crypt_flags & SC_ALGORITHM_RSA_PAD_PKCS1, buf, c, out, len);
	if (r < 0) {
		fprintf(stderr, "Decrypt failed: %s\n", sc_strerror(r));
		return 1;
	}
	r = write_output(out, r);

	return 0;
}
开发者ID:andyvand,项目名称:OpenSC,代码行数:28,代码来源:pkcs15-crypt.c


示例18: run

static void run(tool_options_t &opts)
{
	netlist_tool_t nt;
	osd_ticks_t t = osd_ticks();

	nt.m_opts = &opts;
	nt.init();
	nt.read_netlist(filetobuf(opts.opt_file()), opts.opt_name());

	plist_t<input_t> *inps = read_input(&nt, opts.opt_inp());

	double ttr = opts.opt_ttr();

	printf("startup time ==> %5.3f\n", (double) (osd_ticks() - t) / (double) osd_ticks_per_second() );
	printf("runnning ...\n");
	t = osd_ticks();

	unsigned pos = 0;
	netlist::netlist_time nlt = netlist::netlist_time::zero;

	while (pos < inps->size() && (*inps)[pos].m_time < netlist::netlist_time::from_double(ttr))
	{
		nt.process_queue((*inps)[pos].m_time - nlt);
		(*inps)[pos].setparam();
		nlt = (*inps)[pos].m_time;
		pos++;
	}
	nt.process_queue(netlist::netlist_time::from_double(ttr) - nlt);
	nt.stop();
	pfree(inps);

	double emutime = (double) (osd_ticks() - t) / (double) osd_ticks_per_second();
	printf("%f seconds emulation took %f real time ==> %5.2f%%\n", ttr, emutime, ttr/emutime*100.0);
}
开发者ID:matthewbauer,项目名称:mame,代码行数:34,代码来源:nltool.c


示例19: main

int main(int argc, char *argv[])
{
    FILE *input = NULL;
    FILE *output = NULL;
    Edges edges = {0, NULL} ;
    double *shapley = NULL;
    long kernel_time = 0;
    long summary_time = 0;
    int n;
    Adjacency *adjacency;

    input = safeFopen(argv[1], "r");
    output = safeFopen(argv[2], "w");

    read_input(input, &edges);

    n = number_of_vertices(&edges);
    shapley = (double *) safeMalloc(n * sizeof(double));

    adjacency = createAdjacency(n, &edges, n);
    compute_shapley(adjacency, n, shapley, function, &kernel_time, &summary_time);
    
    write_output(n, shapley, output);

    print_time("kernel", kernel_time);
    print_time("summary", summary_time);

    releaseAdjacency(adjacency);
    free(shapley);
    free(edges.list);
    fclose(input);
    fclose(output);

    return 0;
}
开发者ID:piotyrus,项目名称:Shapley,代码行数:35,代码来源:main.c


示例20: main

int main(int argc, char ** argv) {
	//create_dummy_vol_file(); exit(0);
	holger_time_start(0, "Main");	
	holger_time(0, "OpenCL initialization");
	read_input(
		"C:\\Master Holger\\Franks thumb drive\\UL\\Nevro_Spine\\SpineData\\ultrasoundSample5.mhd",
		"C:\\Master Holger\\Franks thumb drive\\UL\\Nevro_Spine\\SpineData\\ultrasoundSample5.pos",
		"C:\\Master Holger\\Franks thumb drive\\UL\\Nevro_Spine\\SpineData\\ultrasoundSample5.tim",
		"C:\\Master Holger\\Franks thumb drive\\UL\\Nevro_Spine\\SpineData\\ultrasoundSample5.msk",
		//"C:\\Master Holger\\Simple test input\\Lines\\lines.vol",
		"C:\\Master Holger\\Franks thumb drive\\UL\\Nevro_Spine\\SpineData\\ultrasoundSample5.vol",
		"C:\\Master Holger\\Franks thumb drive\\UL\\Nevro_Spine\\calibration_files\\M12L.cal"
	);
	holger_time(0, "Read input files");
	#pragma omp parallel num_threads(2)
	{
		int thread_idx = omp_get_thread_num();
		if (thread_idx == 0) {
			printf("Reconstruct thread\n");
			reconstruct();
		} else if (thread_idx == 1) {
			printf("GUI thread\n");
			gui(argc, argv);
		}
	}

	gui(argc, argv);
	holger_time(0, "Reconstruction");
	holger_time_print(0);
	exit(0);
}
开发者ID:Guokr1991,项目名称:thunder-ultrasound,代码行数:31,代码来源:main.cpp



注:本文中的read_input函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ read_int32函数代码示例发布时间:2022-05-30
下一篇:
C++ read_inode函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap