Example #1
0
int
passwd_sync_query(int num, userec_t * buf)
{
    if (passwd_query(num, buf) < 0)
	return -1;

    buf->money = moneyof(num);

    if (num == usernum)
	cuser.money = moneyof(num);

    return 0;
}
Example #2
0
int
pwcuDeMoney	(int money)
{
    deumoney(usernum, money);
    cuser.money = moneyof(usernum);
    return 0;
}
Example #3
0
int
passwd_sync_update(int num, userec_t * buf)
{
    if (num < 1 || num > MAX_USERS)
	return -1;

    // money update should be done before everything.
    buf->money = moneyof(num);
    if (passwd_update(num, buf) != 0)
	return -1;

    if (num == usernum)
	cuser.money = moneyof(num);

    return 0;
}
Example #4
0
int main()
{
    int num, pwdfd, money;
    userec_t u;

    attach_SHM();

    if ((pwdfd = open(fn_passwd, O_WRONLY)) < 0)
        exit(1);
    for (num=1; num <= SHM->number; num++) {
        lseek(pwdfd, sizeof(userec_t) * (num - 1) +
              ((char *)&u.money - (char *)&u), SEEK_SET);
        money = moneyof(num);
        write(pwdfd, &money, sizeof(int));
    }
    close(pwdfd);

    return 0;
}
Example #5
0
int
pwcuReloadMoney ()
{
    cuser.money=moneyof(usernum);
    return 0;
}