1 /*-------------------------------------------------------*/
2 /* stuff.c ( NTHU CS MapleBBS Ver 2.36 ) */
3 /*-------------------------------------------------------*/
4 /* target : utility routines */
5 /* create : 1995/03/29 */
6 /* update : 2009/12/18 from sob_pack Dopin: ��������� */
7 /*-------------------------------------------------------*/
8
9 #include <sys/param.h>
10 #include <string.h>
11
12 #include "bbs.h"
13
14 /* ----------------------------------------------------- */
15 /* �r���ഫ�ˬd��� */
16 /* ----------------------------------------------------- */
17
18 /* Case Independent strncmp */
19
str_lower(t,s)20 void str_lower(t, s)
21 char *t, *s;
22 {
23 register uschar ch;
24
25 do
26 {
27 ch = *s++;
28 *t++ = char_lower(ch);
29 } while (ch);
30 }
31
trim(buf)32 void trim(buf) /* remove trailing space */
33 char *buf;
34 {
35 char *p = buf;
36
37 while (*p)
38 p++;
39 while (--p >= buf)
40 {
41 if (*p == ' ')
42 *p = '\0';
43 else
44 break;
45 }
46 }
47
48 /* ----------------------------------------------------- */
49 /* �r���ˬd��ơG�^��B�Ʀr�B�ɦW�BE-mail address */
50 /* ----------------------------------------------------- */
51
52 #ifdef BIT8
isprint2(ch)53 int isprint2(ch)
54 char ch;
55 {
56 return ((ch & 0x80) ? 1 : isprint(ch));
57 }
58 #endif
59
not_alpha(ch)60 int not_alpha(ch)
61 register char ch;
62 {
63 return (ch < 'A' || (ch > 'Z' && ch < 'a') || ch > 'z');
64 }
65
66 /* ----------------------------------------------------- */
67 /* �ɮ��ˬd��ơG�ɮסB�ؿ��B�ݩ� */
68 /* ----------------------------------------------------- */
69
dashf(fname)70 int dashf(fname)
71 char *fname;
72 {
73 struct stat st;
74
75 return (stat(fname, &st) == 0 && S_ISREG(st.st_mode));
76 }
77
dashd(fname)78 int dashd(fname)
79 char *fname;
80 {
81 struct stat st;
82
83 return (stat(fname, &st) == 0 && S_ISDIR(st.st_mode));
84 }
85
pressanykey()86 void pressanykey()
87 {
88 int ch;
89
90 outmsg("[37;45;1m �� �� [33m(Space/Return)"
91 "[37m �~�� �� [0m");
92
93 do {
94 ch = igetkey();
95 } while ((ch != ' ') && (ch != KEY_LEFT) && (ch != '\r') && (ch != '\n'));
96
97 move(b_lines, 0);
98 clrtoeol();
99
100 refresh();
101 }
102
stand_title(title)103 void stand_title(title)
104 char *title;
105 {
106 clear();
107 prints("[1;37;46m�i %s �j[0m\n", title);
108 }
109
110 /* opus : cursor position */
111
more(char * fpath,int i)112 more(char* fpath, int i) {
113 FILE* fp;
114 char buf[100];
115
116 clear();
117
118 if(fp = fopen(fpath, "r")) {
119 for(i = 0; i < 20 && fgets(buf, 100, fp); i++) outs(buf);
120
121 fclose(fp);
122 }
123 }
124
setuserfile(char * fpath,char * fname)125 setuserfile(char* fpath, char* fname) {
126 char *getenv();
127 char *dir = getenv("HOME");
128
129 dir = dir ? dir : "/tmp";
130
131 sprintf(fpath, "%s/.ve_%s", dir, fname);
132 }
133