Esempio n. 1
0
int main()
{
	int n,t;  
	char x;
	//check connection
	while(create_connection(5500,"127.0.0.1")==FAIL){
		printf("Ban co muon thu ket noi lai?[y]\n");
        x=getchar();
        while(getchar()!='\n');
        if (x=='y'||x=='Y')continue;
        else return 0;
	}
	protocol p;
	while(1){
		// bien t de check trang thai cua signup
		
		in_menu();
		scanf("%d",&n);
		while(getchar()!='\n');
		if(n==3) break;
		switch(n){
			case 1: c_login(&p);
					break;
			case 2: t=c_signup(&p);
					break;
		}
		if(t==SIGNUP_FAIL) continue; // k trung pass

		send(sockfd,&p,sizeof(protocol),0);
		recv(sockfd,&p,sizeof(protocol),0);
		switch(p.flag){
			case SUCCESS: printf("\nLogin success!!\n"); start(p); break;
			case NO_ACCOUNT: printf("\n%s",LOGIN_ERROR);
							 break; 
			case LOGIN_FAIL: printf("\n%s",LOGIN_ERROR);
							 break; 
			case SIGNUP_FAIL: printf("\n%s",SIGNUP_ERROR2);
		}
	}
	close(sockfd);
}
Esempio n. 2
0
int main()
{
    create_connection(5500,"127.0.0.1");
    int n,t;
    protocol p;
    while(1) {
        // bien t de check trang thai cua signup
        t=-1;
        in_menu();
        scanf("%d",&n);
        while(getchar()!='\n');
        if(n==3) break;
        switch(n) {
        case 1:
            c_login(&p);
            break;
        case 2:
            t=c_signup(&p);
            break;
        }
        if(t==SIGNUP_FAIL) continue;
        send(sockfd,&p,sizeof(protocol),0);
        recv(sockfd,&p,sizeof(protocol),0);
        switch(p.flag) {
        case SUCCESS:
            printf("\nLogin success!!\n");
            start(p);
            break;
        case NO_ACCOUNT:
            printf("\n%s",LOGIN_ERROR);
            break;
        case LOGIN_FAIL:
            printf("\n%s",LOGIN_ERROR);
            break;
        case SIGNUP_FAIL:
            printf("\n%s",SIGNUP_ERROR2);
        }
    }
}
Esempio n. 3
0
VOID edit_str(LONG tree, WORD sobj)
{
	LONG	obspec; 
	WORD	where, type, exitobj, ok;
	GRECT	p;
	WORD	min_width, neww, len; 
	BYTE	text[73], name[9]; 

	get_fields(tree, sobj, &type, &obspec, &p);
	len = (WORD)LSTRLEN(LLGET(obspec));
	if (len <= 72)
	{
		ini_tree(&tree, STRDIAL);
		where = set_obname(tree, STRNAME, name, ad_view, sobj);
		set_text(tree, OSTRITEM, (LONG)ADDR(&text[0]), 73);
		LLSTRCPY(LLGET(obspec), (LONG)ADDR(&text[0]));
		if ( rcs_state == ALRT_STATE )
			hide_obj( tree, STRNAME);
		if (!text[0])
			text[0] = '@';
		do {
			exitobj = hndl_dial(tree, OSTRITEM, &p);
			desel_obj(tree, exitobj);
			ok = DEFAULT & GET_FLAGS(tree, exitobj);
		} while ( ok && !name_ok(name, where, TRUE));

		if (ok)
		{
			rcs_edited = TRUE;
			get_obname(name, ad_view, sobj);
			if (text[0] == '@')
				text[0] = '\0';

			if (rcs_state == ALRT_STATE)
			{		
				if (strlen(text) > 40 )
				{
					hndl_alert(1, string_addr(STOOLONG));
					text[40] = '\0';
				}
				update_if(obspec, &text[0]);
				fix_alert(ad_view);
				unhide_obj(tree, STRNAME);
			}
			else
			{
				neww = (WORD)(gl_wchar * strlen(text));
				if (rcs_state == MENU_STATE)
				{
					if (type == G_TITLE)
					{
						if (!newsize_obj(ad_view, sobj, neww,gl_hchar, TRUE))
							text[len] = '\0';
						fix_menu_bar(ad_view);
					}
					else if (in_which_menu(ad_view, sobj) == 1
						&& in_menu(ad_view, sobj) == 1
						&& strlen(text) > 20 )
		    		{
						hndl_alert(1, string_addr(STOOLONG));	
						text[20] = '\0';
					}
					else  if(!newsize_obj(ad_view, sobj, neww,gl_hchar, FALSE))
						text[len] = '\0';
				}
				else if (type == G_STRING || type == G_BUTTON )
				{
					min_width = GET_WIDTH(ad_view, sobj);
					if( neww > min_width )
						if(!newsize_obj(ad_view, sobj, neww,gl_hchar, FALSE))
							text[len] = '\0';
				}
			}
			if( rcs_state != ALRT_STATE)
				update_if(obspec, &text[0]);
		}
	}
}