当前位置: 首页>>代码示例>>C++>>正文


C++ read_input函数代码示例

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


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


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