29static stralloc line = {0};
30static stralloc outline = {0};
35static char inbuf[256];
39 scan_ulong(line.s,&
when);
41 if (!stralloc_copyb(&outline,date,
date822fmt(date,&
dt) - 1))
43 if (!stralloc_cats(&outline,
": "))
die_nomem();
44 if (!stralloc_catb(&outline,line.s,line.len - 1))
die_nomem();
45 if (
subwrite(outline.s,outline.len) == -1)
46 logmsg(
WHO,111,FATAL,B(
"ERR_WRITE :",
"output"));
66 unsigned char *cpsearch;
69 unsigned char *cplast, *cpline;
70 unsigned int searchlen;
76 const char *table = (
char *) 0;
77 const char **ptable = &table;
78 unsigned long *lengths;
80 if (!search) search = (
char *)
"";
81 searchlen = str_len(search);
82 case_lowerb(search,searchlen);
83 cps = (
unsigned char *) search;
84 while ((ch = *(cps++))) {
85 if (ch >=
'a' && ch <=
'z')
continue;
86 if (ch >=
'0' && ch <=
'9')
continue;
87 if (ch ==
'.' || ch ==
'_')
continue;
97 if (!stralloc_cats(&line,
"/Log"))
die_nomem();
100 fd = open_read(line.s);
103 logmsg(
WHO,111,FATAL,B(
"ERR_OPEN :",line.s));
105 logmsg(
WHO,100,FATAL,line.s,
"ERR_NOEXIST");
115 cpline = (
unsigned char *) line.s - 1;
116 cplast = cpline + line.len - searchlen;
117 while ((
cp = ++cpline) <= cplast) {
118 cpsearch = (
unsigned char *) search;
123 if (y <= (
unsigned char) (
'Z' -
'A')) y +=
'a';
else y +=
'A';
124 if (x != y && x !=
'_')
break;
126 if (!x) { lineout(
subwrite);
break; }
139 if (!stralloc_cats(&line,
"SELECT CONCAT(FROM_UNIXTIME(UNIX_TIMESTAMP(tai)),"
140 "'-0000: ',UNIX_TIMESTAMP(tai),' ',edir,etype,' ',address,' ',"
142 if (!stralloc_cats(&line,table))
die_nomem();
143 if (!stralloc_cats(&line,
"_slog "))
die_nomem();
145 if (!stralloc_cats(&line,
"WHERE fromline LIKE '%"))
die_nomem();
146 if (!stralloc_cats(&line,search))
die_nomem();
147 if (!stralloc_cats(&line,
"%' OR address LIKE '%"))
die_nomem();
148 if (!stralloc_cats(&line,search))
die_nomem();
149 if (!stralloc_cats(&line,
"%'"))
die_nomem();
151 if (!stralloc_cats(&line,
" ORDER by tai"))
die_nomem();
153 if (mysql_real_query(
mysql,line.s,line.len))
156 if (!(result = mysql_use_result(
mysql)))
159 while ((row = mysql_fetch_row(result))) {
160 if (!(lengths = mysql_fetch_lengths(result)))
165 if (!mysql_eof(result))
168 mysql_free_result(result);
Error messages. If you translate these, I would urge you to keep the English version as well....
const char * opensql(const char *dir, const char **table)
void searchlog(const char *dir, char *search, int subwrite())
unsigned int date822fmt(char *s, const struct datetime *dt)
void datetime_tai(struct datetime *dt, datetime_sec t)
int subwrite(char *s, unsigned int l)
const char * logmsg(const char *dir, unsigned long num, unsigned long listno, unsigned long subs, int done)