本文整理汇总了C++中check_stdin函数的典型用法代码示例。如果您正苦于以下问题:C++ check_stdin函数的具体用法?C++ check_stdin怎么用?C++ check_stdin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_stdin函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: read_stdin
void read_stdin(t_lemin *l)
{
int i;
char *line;
char *prev;
i = 0;
line = NULL;
prev = NULL;
l->listrooms = NULL;
l->listtubes = NULL;
while (get_next_line(0, &line))
{
if (line[0] != '#')
{
check_stdin(l, line, prev, i);
i++;
}
prev = line;
}
link_rooms(l);
define_rooms_weight(l);
handle_stdout(l);
lemin_loop(l);
}
开发者ID:NormanSchilling,项目名称:lemin,代码行数:25,代码来源:handle_stdin.c
示例2: conf_askvalue
static int conf_askvalue(struct symbol *sym, const char *def)
{
enum symbol_type type = sym_get_type(sym);
if (!sym_has_value(sym))
printf(_("(NEW) "));
line[0] = '\n';
line[1] = 0;
if (!sym_is_changable(sym)) {
printf("%s\n", def);
line[0] = '\n';
line[1] = 0;
return 0;
}
switch (input_mode) {
case ask_new:
case ask_silent:
if (sym_has_value(sym)) {
printf("%s\n", def);
return 0;
}
check_stdin();
case ask_all:
fflush(stdout);
if (NULL == fgets(line, 128, stdin)) { //BRCM: check ret val to fix compiler warning
printf("fgets failed, exiting\n");
exit(2);
}
if (feof(stdin)) {
printf("\nEOF on std input -- exiting\n");
exit(2);
}
return 1;
default:
break;
}
switch (type) {
case S_INT:
case S_HEX:
case S_STRING:
printf("%s\n", def);
return 1;
default:
;
}
printf("%s", line);
return 1;
}
开发者ID:antonywcl,项目名称:AR-5315u_PLD,代码行数:52,代码来源:conf.c
示例3: conf_askvalue
static int conf_askvalue(struct symbol *sym, const char *def)
{
enum symbol_type type = sym_get_type(sym);
if (!sym_has_value(sym))
printf(_("(NEW) "));
line[0] = '\n';
line[1] = 0;
if (!sym_is_changable(sym)) {
printf("%s\n", def);
line[0] = '\n';
line[1] = 0;
return 0;
}
switch (input_mode) {
case oldconfig:
case silentoldconfig:
if (sym_has_value(sym)) {
printf("%s\n", def);
return 0;
}
check_stdin();
/* fall through */
case oldaskconfig:
fflush(stdout);
xfgets(line, 128, stdin);
if (!tty_stdio)
printf("\n");
return 1;
default:
break;
}
switch (type) {
case S_INT:
case S_HEX:
case S_STRING:
printf("%s\n", def);
return 1;
default:
;
}
printf("%s", line);
return 1;
}
开发者ID:JS-Wang,项目名称:linux-testing,代码行数:48,代码来源:conf.c
示例4: conf_askvalue
static int conf_askvalue(struct symbol *sym, const char *def)
{
char *ret;
enum symbol_type type = sym_get_type(sym);
if (!sym_has_value(sym))
printf("(NEW) ");
line[0] = '\n';
line[1] = 0;
if (!sym_is_changable(sym)) {
printf("%s\n", def);
line[0] = '\n';
line[1] = 0;
return 0;
}
switch (input_mode) {
case ask_new:
case ask_silent:
if (sym_has_value(sym)) {
printf("%s\n", def);
return 0;
}
check_stdin();
case ask_all:
fflush(stdout);
ret = fgets(line, 128, stdin);
(void)ret;
return 1;
default:
break;
}
switch (type) {
case S_INT:
case S_HEX:
case S_STRING:
printf("%s\n", def);
return 1;
default:
;
}
printf("%s", line);
return 1;
}
开发者ID:32bitmicro,项目名称:xvisor,代码行数:47,代码来源:conf.c
示例5: conf_choice
static int conf_choice(struct menu *menu)
{
struct symbol *sym, *def_sym;
struct menu *child;
bool is_new;
sym = menu->sym;
is_new = !sym_has_value(sym);
if (sym_is_changable(sym)) {
conf_sym(menu);
sym_calc_value(sym);
switch (sym_get_tristate_value(sym)) {
case no:
return 1;
case mod:
return 0;
case yes:
break;
}
} else {
switch (sym_get_tristate_value(sym)) {
case no:
return 1;
case mod:
printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
return 0;
case yes:
break;
}
}
while (1) {
int cnt, def;
printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
def_sym = sym_get_choice_value(sym);
cnt = def = 0;
line[0] = 0;
for (child = menu->list; child; child = child->next) {
if (!menu_is_visible(child))
continue;
if (!child->sym) {
printf("%*c %s\n", indent, '*', _(menu_get_prompt(child)));
continue;
}
cnt++;
if (child->sym == def_sym) {
def = cnt;
printf("%*c", indent, '>');
} else
printf("%*c", indent, ' ');
printf(" %d. %s", cnt, _(menu_get_prompt(child)));
if (child->sym->name)
printf(" (%s)", child->sym->name);
if (!sym_has_value(child->sym))
printf(_(" (NEW)"));
printf("\n");
}
printf(_("%*schoice"), indent - 1, "");
if (cnt == 1) {
printf("[1]: 1\n");
goto conf_childs;
}
printf("[1-%d", cnt);
if (menu_has_help(menu))
printf("?");
printf("]: ");
switch (input_mode) {
case oldconfig:
case silentoldconfig:
if (!is_new) {
cnt = def;
printf("%d\n", cnt);
break;
}
check_stdin();
/* fall through */
case oldaskconfig:
fflush(stdout);
xfgets(line, 128, stdin);
strip(line);
if (line[0] == '?') {
print_help(menu);
continue;
}
if (!line[0])
cnt = def;
else if (isdigit(line[0]))
cnt = atoi(line);
else
continue;
break;
default:
break;
}
conf_childs:
for (child = menu->list; child; child = child->next) {
if (!child->sym || !menu_is_visible(child))
continue;
//.........这里部分代码省略.........
开发者ID:LGaljo,项目名称:android_kernel_samsung_s3ve3g,代码行数:101,代码来源:conf.c
示例6: conf_askvalue
static void conf_askvalue(struct symbol *sym, const char *def)
{
enum symbol_type type = sym_get_type(sym);
tristate val;
if (!sym_has_value(sym))
printf("(NEW) ");
line[0] = '\n';
line[1] = 0;
if (!sym_is_changable(sym)) {
printf("%s\n", def);
line[0] = '\n';
line[1] = 0;
return;
}
switch (input_mode) {
case set_no:
case set_mod:
case set_yes:
case set_random:
if (sym_has_value(sym)) {
printf("%s\n", def);
return;
}
break;
case ask_new:
case ask_silent:
if (sym_has_value(sym)) {
printf("%s\n", def);
return;
}
check_stdin();
case ask_all:
fflush(stdout);
fgets(line, 128, stdin);
return;
case set_default:
printf("%s\n", def);
return;
default:
break;
}
switch (type) {
case S_INT:
case S_HEX:
case S_STRING:
printf("%s\n", def);
return;
default:
;
}
switch (input_mode) {
case set_yes:
if (sym_tristate_within_range(sym, yes)) {
line[0] = 'y';
line[1] = '\n';
line[2] = 0;
break;
}
case set_mod:
if (type == S_TRISTATE) {
if (sym_tristate_within_range(sym, mod)) {
line[0] = 'm';
line[1] = '\n';
line[2] = 0;
break;
}
} else {
if (sym_tristate_within_range(sym, yes)) {
line[0] = 'y';
line[1] = '\n';
line[2] = 0;
break;
}
}
case set_no:
if (sym_tristate_within_range(sym, no)) {
line[0] = 'n';
line[1] = '\n';
line[2] = 0;
break;
}
case set_random:
do {
val = (tristate)(random() % 3);
} while (!sym_tristate_within_range(sym, val));
switch (val) {
case no: line[0] = 'n'; break;
case mod: line[0] = 'm'; break;
case yes: line[0] = 'y'; break;
}
line[1] = '\n';
line[2] = 0;
break;
default:
break;
//.........这里部分代码省略.........
开发者ID:0x6e3078,项目名称:toybox,代码行数:101,代码来源:conf.c
示例7: conf_choice
static int conf_choice(struct menu *menu)
{
struct symbol *sym, *def_sym;
struct menu *child;
int type;
bool is_new;
sym = menu->sym;
type = sym_get_type(sym);
is_new = !sym_has_value(sym);
if (sym_is_changable(sym)) {
conf_sym(menu);
sym_calc_value(sym);
switch (sym_get_tristate_value(sym)) {
case no:
return 1;
case mod:
return 0;
case yes:
break;
}
} else {
switch (sym_get_tristate_value(sym)) {
case no:
return 1;
case mod:
printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
return 0;
case yes:
break;
}
}
while (1) {
int cnt, def;
printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
def_sym = sym_get_choice_value(sym);
cnt = def = 0;
line[0] = 0;
for (child = menu->list; child; child = child->next) {
if (!menu_is_visible(child))
continue;
if (!child->sym) {
printf("%*c %s\n", indent, '*', menu_get_prompt(child));
continue;
}
cnt++;
if (child->sym == def_sym) {
def = cnt;
printf("%*c", indent, '>');
} else
printf("%*c", indent, ' ');
printf(" %d. %s", cnt, menu_get_prompt(child));
if (child->sym->name)
printf(" (%s)", child->sym->name);
if (!sym_has_value(child->sym))
printf(" (NEW)");
printf("\n");
}
printf("%*schoice", indent - 1, "");
if (cnt == 1) {
printf("[1]: 1\n");
goto conf_childs;
}
printf("[1-%d", cnt);
if (sym->help)
printf("?");
printf("]: ");
switch (input_mode) {
case ask_new:
case ask_silent:
if (!is_new) {
cnt = def;
printf("%d\n", cnt);
break;
}
check_stdin();
case ask_all:
fflush(stdout);
fgets(line, 128, stdin);
strip(line);
if (line[0] == '?') {
printf("\n%s\n", menu->sym->help ?
menu->sym->help : nohelp_text);
continue;
}
if (!line[0])
cnt = def;
else if (isdigit(line[0]))
cnt = atoi(line);
else
continue;
break;
case set_random:
def = (random() % cnt) + 1;
case set_default:
case set_yes:
case set_mod:
case set_no:
//.........这里部分代码省略.........
开发者ID:0x6e3078,项目名称:toybox,代码行数:101,代码来源:conf.c
示例8: main
int main(int argc, char **argv)
{
/* setup up space to pass stuff around in */
control *c;
if ((c = malloc(sizeof(control))) == NULL) {
check_errors("Control structure: Not allocated enough memory", __LINE__);
}
timeseries *ts;
if ((ts = malloc(sizeof(timeseries))) == NULL) {
check_errors("Timeseries structure: Not allocated enough memory", __LINE__);
}
meta *m;
if ((m = malloc(sizeof(meta))) == NULL) {
check_errors("Meta structure: Not allocated enough memory", __LINE__);
}
output_options *o;
if ((o = malloc(sizeof(output_options))) == NULL) {
check_errors("Output_options structure: Not allocated enough memory", __LINE__);
}
/* setup initial junk */
setup_initial_conditions(c, ts, o);
/* send sweep along the command line */
clparse(argc, argv, c, ts, o);
/* check the input file is on the stdin? */
check_stdin(__LINE__);
/* read data in from stdin */
read_input_file(argv, c, ts, o);
/* setup space for working arrays and other misc stuff */
allocate_working_environment(c, ts);
/* calculate lomb periodgram for raw time-series */
spectrum_wrapper(c, ts, ts->x, ts->y, ts->frq, ts->gxx);
/* Calculate red noise bias and correct periodgram
- need to generate a seed ONCE */
srand (time(NULL));
rednoise_bias_wrapper(c, ts, o);
/* dump out what you need */
print_outputs(c, ts, o);
/* tidy up */
free_array_double(ts->gxx);
free_array_double(ts->frq);
free_array_double(ts->red);
free_array_double(ts->grr);
free_array_double(ts->grrsum);
free_array_double(ts->gredth);
free_array_double(ts->corr);
free_array_double(ts->gxxc);
free_array_double(ts->grravg);
free_array_double(ts->x);
free_array_double(ts->y);
free(c);
free(ts);
free(m);
free(o);
return (0);
}
开发者ID:mdekauwe,项目名称:Lomb_Scargle,代码行数:68,代码来源:lombscargle.c
示例9: main
// Main program. Open a window. Continuously read commands from the
// command line interface and draw frames with 60Hz onto the
// screen. Commands for multiple frames can be cached within a ring
// buffer, so that a consistent frame rate can be maintained even if
// the control program doesn't respond within 16ms. The control
// program is written in Common Lisp and a 16ms time granularity cannot
// always be maintained, due to the time a garbage collection may
// take.
int
main(int argc,char**argv)
{
// make sure frame rate update cycle is phase locked to vertical
// refresh of screen. On Nvidia hardware this can be done by setting
// the following environment variable.
setenv("__GL_SYNC_TO_VBLANK","1",1);
if(!glfwInit())
exit(EXIT_FAILURE);
int width=1280,height=1024;
if(argc==3){
width=atoi(argv[1]);
height=atoi(argv[2]);
}
if(!glfwOpenWindow(width,height,8,8,8,
0,0,0,
GLFW_WINDOW
)){
glfwTerminate();
exit(EXIT_FAILURE);
}
printf("lcos started %dx%d\n",width,height);
fflush(stdout);
glfwSetWindowTitle("LCoS");
//glfwSetWindowPos(-8,-31);
// use glfw method to sync to vertical refresh
glfwSwapInterval(1);
glfwSetKeyCallback(keyhandler);
init_matrix();
glMatrixMode(GL_PROJECTION);
glOrtho(0,1280,1024,0,-1,1);
glMatrixMode(GL_MODELVIEW);
while(running){
while(check_stdin()>0){
char*s=malloc(CMDLEN);
char*line=fgets(s,CMDLEN,stdin);
if(line!=s)
printf("fgets error\n");
parse_line(line);
}
glClear(GL_COLOR_BUFFER_BIT);
glLoadMatrixf(m);
frame_count++;
// run all commands which have been stored in the queue
while(!emptyp()){
char*cmd=pop();
if(0==strncmp(cmd,"swap",4)){
struct timeval tv;
gettimeofday(&tv,0);
printf("q swap frame-count=%d sec=%lu usec=%lu\n",
frame_count,tv.tv_sec,tv.tv_usec);
free(cmd);
goto nextframe;
}
parse_line(cmd);
printf("q cread=%5d cwrite=%5d cmd=%s\n",circread,circwrite,cmd);
fflush(stdout);
free(cmd);
}
nextframe:
if(show_calibration_stripes){
float v = 100+20*(frame_count%10);
glRectf(v,0,v+2,400);
}
glfwSleep(1./72);
glfwSwapBuffers();
}
glfwCloseWindow();
glfwTerminate();
exit(EXIT_SUCCESS);
}
开发者ID:plops,项目名称:glfw,代码行数:94,代码来源:glfw.c
示例10: main
int main(int ac, char **av)
{
check_stdin(ac, av);
}
开发者ID:pmclaugh,项目名称:push_swap,代码行数:4,代码来源:checkmain.c
示例11: conf_choice
static int conf_choice(struct menu *menu)
{
struct symbol *sym, *def_sym;
struct menu *child;
// int type; backported future linux patch to 2.6.30 to fix gcc4.6 compiler warning
bool is_new;
sym = menu->sym;
// type = sym_get_type(sym); see backported comment above
is_new = !sym_has_value(sym);
if (sym_is_changable(sym)) {
conf_sym(menu);
sym_calc_value(sym);
switch (sym_get_tristate_value(sym)) {
case no:
return 1;
case mod:
return 0;
case yes:
break;
}
} else {
switch (sym_get_tristate_value(sym)) {
case no:
return 1;
case mod:
printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
return 0;
case yes:
break;
}
}
while (1) {
int cnt, def;
printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
def_sym = sym_get_choice_value(sym);
cnt = def = 0;
line[0] = 0;
for (child = menu->list; child; child = child->next) {
if (!menu_is_visible(child))
continue;
if (!child->sym) {
printf("%*c %s\n", indent, '*', _(menu_get_prompt(child)));
continue;
}
cnt++;
if (child->sym == def_sym) {
def = cnt;
printf("%*c", indent, '>');
} else
printf("%*c", indent, ' ');
printf(" %d. %s", cnt, _(menu_get_prompt(child)));
if (child->sym->name)
printf(" (%s)", child->sym->name);
if (!sym_has_value(child->sym))
printf(_(" (NEW)"));
printf("\n");
}
printf(_("%*schoice"), indent - 1, "");
if (cnt == 1) {
printf("[1]: 1\n");
goto conf_childs;
}
printf("[1-%d", cnt);
if (menu_has_help(menu))
printf("?");
printf("]: ");
switch (input_mode) {
case ask_new:
case ask_silent:
if (!is_new) {
cnt = def;
printf("%d\n", cnt);
break;
}
check_stdin();
case ask_all:
fflush(stdout);
if (NULL == fgets(line, 128, stdin)) { //BRCM: check ret val to fix compiler warning
printf("fgets failed, exiting\n");
exit(2);
}
strip(line);
if (line[0] == '?') {
printf("\n%s\n", get_help(menu));
continue;
}
if (!line[0])
cnt = def;
else if (isdigit(line[0]))
cnt = atoi(line);
else
continue;
break;
default:
break;
}
//.........这里部分代码省略.........
开发者ID:antonywcl,项目名称:AR-5315u_PLD,代码行数:101,代码来源:conf.c
注:本文中的check_stdin函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论