summaryrefslogtreecommitdiffstats
path: root/mbbsd/kaede.c
blob: 252984bef15b50c891403e1cde85159684be7b10 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* $Id: kaede.c,v 1.10 2002/07/21 09:26:02 in2 Exp $ */
#include "bbs.h"

char           *
Ptt_prints(char *str, int mode)
{
    char           *po, strbuf[256];

    while ((po = strstr(str, "\033*s"))) {
    po[0] = 0;
    sprintf(strbuf, "%s%s%s", str, cuser.userid, po + 3);
    strcpy(str, strbuf);
    }
    while ((po = strstr(str, "\033*t"))) {

    po[0] = 0;
    sprintf(strbuf, "%s%s", str, Cdate(&now));
    strcat(strbuf, po + 3);
    strcpy(str, strbuf);
    }
    while ((po = strstr(str, "\033*u"))) {
    int             attempts;

    attempts = SHM->UTMPnumber;
    po[0] = 0;
    sprintf(strbuf, "%s%d%s", str, attempts, po + 3);
    strcpy(str, strbuf);
    }
    while ((po = strstr(str, "\033*b"))) {
    po[0] = 0;
    sprintf(strbuf, "%s%d/%d%s", str, cuser.month, cuser.day, po + 3);
    strcpy(str, strbuf);
    }
    while ((po = strstr(str, "\033*l"))) {
    po[0] = 0;
    sprintf(strbuf, "%s%d%s", str, cuser.numlogins, po + 3);
    strcpy(str, strbuf);
    }
    while ((po = strstr(str, "\033*p"))) {
    po[0] = 0;
    sprintf(strbuf, "%s%d%s", str, cuser.numposts, po + 3);
    strcpy(str, strbuf);
    }
    while ((po = strstr(str, "\033*n"))) {
    po[0] = 0;
    sprintf(strbuf, "%s%s%s", str, cuser.username, po + 3);
    strcpy(str, strbuf);
    }
    while ((po = strstr(str, "\033*m"))) {
    po[0] = 0;
    sprintf(strbuf, "%s%d%s", str, cuser.money, po + 3);
    strcpy(str, strbuf);
    }
    strip_ansi(str, str, mode);
    return str;
}

int
Rename(char *src, char *dst)
{
    char            buf[256];
    if (rename(src, dst) == 0)
    return 0;
    if (!strchr(src, ';') && !strchr(dst, ';'))
    //Ptt  黎ㄔ膨`指令
    {
    sprintf(buf, "/bin/mv %s %s", src, dst);
    system(buf);
    }
    return -1;
}

int
Link(char *src, char *dst)
{
    char            cmd[200];

    if (strcmp(src, BBSHOME "/home") == 0)
    return 1;
    if (symlink(dst, src) == 0)
    return 0;

    sprintf(cmd, "/bin/cp -R %s %s", src, dst);
    return system(cmd);
}

char           *
my_ctime(const time_t * t)
{
    struct tm      *tp;
    static char     ans[100];

    tp = localtime(t);
    sprintf(ans, "%02d/%02d/%02d %02d:%02d:%02d", (tp->tm_year % 100),
      tp->tm_mon + 1, tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec);
    return ans;
}