summaryrefslogtreecommitdiffstats
path: root/util/writemoney.c
blob: 0db8d99d4636a88038bb9bc17b86634b9e468c41 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* $Id$ */
/*  SHM 銝剔 money 券典神 .PASSWDS */
#define _UTIL_C_
#include "bbs.h"

time4_t now;
extern SHM_t   *SHM;

int invalid(char *userid) {
    int i;
    
    if(!isalpha(userid[0]))
    return 1;
    
    for(i = 1; i < IDLEN && userid[i]; i++)
    if(!isalpha(userid[i]) && !isdigit(userid[i]))
        return 1;
    return 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;
}