コード例 #1
0
ファイル: swaplabel.c プロジェクト: dankamongmen/util-linux
int main(int argc, char *argv[])
{
	blkid_probe pr = NULL;
	char *uuid = NULL, *label = NULL, *devname;
	int c, rc = -1;

	static const struct option longopts[] = {
	    { "help",      0, 0, 'h' },
	    { "version",   0, 0, 'V' },
	    { "label",     1, 0, 'L' },
	    { "uuid",      1, 0, 'U' },
	    { NULL,        0, 0, 0 }
	};

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
	atexit(close_stdout);

	while ((c = getopt_long(argc, argv, "hVL:U:", longopts, NULL)) != -1) {
		switch (c) {
		case 'h':
			usage(stdout);
			break;
		case 'V':
			printf(UTIL_LINUX_VERSION);
			return EXIT_SUCCESS;
		case 'L':
			label = optarg;
			break;
		case 'U':
#ifdef HAVE_LIBUUID
			uuid = optarg;
#else
			warnx(_("ignore -U (UUIDs are unsupported)"));
#endif
			break;
		default:
			usage(stderr);
			break;
		}
	}

	if (optind == argc)
		usage(stderr);

	devname = argv[optind];
	pr = get_swap_prober(devname);
	if (pr) {
		if (uuid || label)
			rc = change_info(devname, label, uuid);
		else
			rc  = print_info(pr);
		blkid_free_probe(pr);
	}
	return rc ? EXIT_FAILURE : EXIT_SUCCESS;
}
コード例 #2
0
int find(st_info *buf_head,const int flag_num)
{
	char check[21];
	st_info *p1 = buf_head,*p2 = NULL,*p3 = NULL;
	find_link *q1,*q2,*find_head=NULL;
	unsigned int flag_find = 0;
	system("cls");
	switch (flag_num)
	{
	case 0:print_tips("  查询学生体检信息  ");break;
	case 2:print_tips("  修改学生体检信息  ");break;
	case 1:print_tips("  删除学生体检信息  ");break;
	}
	if(buf_head->next == NULL)
	{
		printf("\n Error!-----没有数据可供查询!请录入!");
		return 0;
	}
	printf("\n\n\n\n Tips:-----请输入姓名或者学号:");
	fflush(stdin);
	scanf("%20s",check);
	print_star();
	printf(menu_print);
	while (p1->next)
	{
		p2 = p1;
		p1 = p1->next;
		if(strcmp(p1->name,check) == 0 || strcmp(p1->num,check) == 0)
		{
			++flag_find;
			if(flag_find == 1)
			{
				find_head = (find_link *)malloc(M);
				q1 = (find_link *)malloc(M);
				find_head->next = q1;
			}
			q1->buf_find = p2;
			q2 = q1;
			q1 = (find_link *)malloc(M); 
			q2->next = q1;
		}
	}
	if(flag_find != 0)
	{
		free(q1);
		q2->next = NULL;
	}
	printf("\n\n");
	if(flag_find > 10)
	{
		free_find(find_head);
		printf("\n\n Warning!-----系统检测到您的查询结果已超过10个,数据文件可能存在问题!请检查!");
		return 0;
	}
	find_print(find_head,flag_find);
	if(find_head == NULL)
	{
		return 0;
	}
	switch (flag_num)
	{
	case 0:free_find(find_head);break;
	case 1:del_info(find_head,flag_find);free_find(find_head);break;
	case 2:change_info(find_head,flag_find);free_find(find_head);break;
	}
	return 1;
}
コード例 #3
0
ファイル: newuser.c プロジェクト: cafuego/monolith
static void
newuser_registration(user_t * user)
{
    char p[RGurlLEN];
    int ret;

    cprintf("\1f\1g");
    more(BBSDIR "/share/newuser/registration", 0);

    cprintf("Please enter your real name.\n");
    do {
	cprintf("\n* FULL REAL name: ");
	xgetline(user->RGname, RGnameLEN, 1);
    }
    while (strlen(user->RGname) <= 6);

    cprintf("\nNext, enter your address (street name, and number).\n\n");
    do {
	cprintf("* Address:        ");
	xgetline(user->RGaddr, RGaddrLEN, 1);
    } while (strlen(user->RGaddr) < 3);

    do {
	cprintf("* City/Suburb:    ");
	xgetline(user->RGcity, RGcityLEN, 1);
    } while (strlen(user->RGcity) < 2);

    do {
	cprintf("* Zip code:       ");
	xgetline(user->RGzip, RGzipLEN, 1);
    } while (strlen(user->RGzip) < 3);

	cprintf("  State/Province: ");
	strcpy( user->RGstate, "" ); /* initialise, or get garbage */
	xgetline(user->RGstate, RGstateLEN, 1);

    do {
	cprintf("* Country:        ");
	xgetline(user->RGcountry, RGcountryLEN, 1);
    } while (strlen(user->RGcountry) < 3);

	cprintf("  Phone number:   ");
	strcpy( user->RGphone, "" ); /* initialise or get garbage! */
	xgetline(user->RGphone, RGphoneLEN, 1);

    more(BBSDIR "/share/newuser/email", 0);

    cprintf("\n\1f\1gPlease enter your e-mail address in the form: \[email protected]\n");
    fflush(stdout);
    sleep(3);

    do {
	cprintf("\n\n* Email address:  ");
	xgetline(user->RGemail, RGemailLEN, 1);
    }
    while ((strlen(user->RGemail) < 7)
	   || (is_allowed_email(user->RGemail) == FALSE));

    cprintf("\nYou can enter a homepage address (URL) if you wish.\n");
    cprintf("Enter it in the form: host.machine.edu/directory\n");
    cprintf("If you don't have a homepage, or don't understand this ");
    cprintf("just press return.\n\n");

    fflush(stdout);

    cprintf("\n\nURL:              http://");
    xgetline(p, RGurlLEN - 7, 1);
    if (strlen(p) < 5) {
	strcpy(user->RGurl, "");
	cprintf("URL left blank.\n");
    } else {
        strremcol( p );
	sprintf(user->RGurl, "http://%s", p);
    }

    ret = mono_sql_u_update_registration( usersupp->usernum,
        usersupp->RGname, usersupp->RGaddr, usersupp->RGzip, usersupp->RGcity,
        usersupp->RGstate, usersupp->RGcountry, usersupp->RGphone );
    if ( ret == -1 ) fprintf( stderr, "Problems saving registration info.\n" );
    ret = mono_sql_u_update_email( usersupp->usernum, usersupp->RGemail );
    if ( ret == -1 ) fprintf( stderr, "Problems saving email.\n" );
    ret = mono_sql_u_update_url( usersupp->usernum, usersupp->RGurl );
    if ( ret == -1 ) fprintf( stderr, "Problems saving URL.\n" );

    cprintf("\n\1f\1gYou have entered the following information:\n\n");
    dis_regis(user, TRUE);

    cprintf("\n\1wPlease check that it is correct!\n");
    fflush(stdout);
    sleep(3);

    cprintf("\1f\1g\n\nIs the information correct so far? \1w(\1ry\1w/\1rn\1w) ");
    if (yesno() == NO)
	change_info(user, TRUE);	/* so they can edit their name */
    return;
}
コード例 #4
0
ファイル: ncurses_func.c プロジェクト: nakulrk95/cprojects
/*Description - Prints the menu tht appears after login in a new window using ncurses library*/
void login_menu() {
	system("clear");
	WINDOW *menu_win;
	int highlight = 1;
	int choice = 0;
	int c;
	initscr();
	clear();
	noecho();
	cbreak();	/* Line buffering disabled. pass on everything */
	startx = (80 - WIDTH) / 2;
	starty = (24 - HEIGHT) / 2;
	menu_win = newwin(HEIGHT, WIDTH, starty, startx);
	keypad(menu_win, TRUE);
	mvprintw(0, 20, "***************WELCOME****************");
	mvprintw(2, 7, "Use arrow keys to go up and down, Press enter to select a choice");
	refresh();
	print_menu2(menu_win, highlight);
	while(1)
	{	c = wgetch(menu_win);
		switch(c)
		{	case KEY_UP:
				if(highlight == 1)
					highlight = n_choices2;
				else
					--highlight;
				break;
			case KEY_DOWN:
				if(highlight == n_choices2)
					highlight = 1;
				else 
					++highlight;
				break;
			case 10:
				choice = highlight;
				break;
			default:
				mvprintw(24, 0, "Charcter pressed is = %3d Hopefully it can be printed as '%c'", c, c);
				refresh();
				break;
		}
		print_menu2(menu_win, highlight);
		if(choice != 0)	/* User did a choice come out of the infinite loop */
			break;
	}
	clrtoeol();
	endwin();
	switch(choice) {
		case 1: /*Guide*/
			guide();
			login_menu();
			break;
		case 2: /*Play Game*/
			play_game();
			break;
		case 3: /*Buy*/
			buy_chips();
			login_menu();
			break;
		case 4: /*Sell*/
			sell_chips();
			login_menu();
			break;
		case 5: /*Check bal*/
			disp_bal();
			login_menu();
			break;
		case 6: /*Change_info*/
			change_info();
			login_menu();
			break;
		case 7: /*Log out*/
			logout();
			menu();
			break;
		default:
			login_menu();
			break;
	}
}