Exemplo n.º 1
0
Arquivo: tina.c Projeto: jrg94/EECS338
/**
 * Overrides the askForCookies function
 * which is used to differentiate between
 * the two separate client processes
 */
int askForCookies(CLIENT *c) {
	
	struct CookieStruct cs = {0, TINA};

	int* result = get_me_my_cookie_1(&cs, c);
	
	return *result;
}
Exemplo n.º 2
0
//request a cookie from mom
void request_cookie(CLIENT *client) {

    // create the request object
    struct cookie_request request = {0, 1};

    // request the cookie
    int *cookie = get_me_my_cookie_1(&request, client);

    // if there are no more cookies then stop asking
    if (*cookie == -2) {
        printf("No more cookies for Tina...\n");
        printf("At least I got %d cookies\n", cookies);

        done_with_cookies_1(&request, client);
        clnt_destroy(client);
        exit(EXIT_SUCCESS);
    } else {
        cookies++;
        printf("I got a cookie!\n\t Tina has gotten %d cookies\n", cookies);
    }
}
Exemplo n.º 3
0
// request a cookie from mom
int request_cookie(CLIENT *client) {

    // create the request object
    struct cookie_request request = {0, 0};

    // request the cookie
    int *cookie = get_me_my_cookie_1(&request, client);

    // if there are no more cookies then stop asking
    if (*cookie == -2) {
        printf("No more cookies for Judy...\n");
        printf("\tAt least I got %d cookies\n", cookies);

        done_with_cookies_1(&request, client);
        clnt_destroy(client);
        exit(EXIT_SUCCESS);
    } else if (*cookie == -1) {
        printf("\tI have to wait for Tina, NOT FAIR\n");
    } else {
        cookies++;
        printf("\tI got a cookie! I have gotten %d cookies now!\n", cookies);
    }
}