summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Meckelein <mmeckelein@hq.adiscon.com>2004-11-11 15:39:49 +0000
committerMichael Meckelein <mmeckelein@hq.adiscon.com>2004-11-11 15:39:49 +0000
commitf938f366a53edb590e5ccd5cd09631ac1a1f1a10 (patch)
treece32fc52fb7da9b6da0a6e08897b4c499b853f0d
parent30d73c4ec8e1033ef1f520926f745709d3e640fe (diff)
downloadrsyslog-f938f366a53edb590e5ccd5cd09631ac1a1f1a10.tar.gz
rsyslog-f938f366a53edb590e5ccd5cd09631ac1a1f1a10.tar.xz
rsyslog-f938f366a53edb590e5ccd5cd09631ac1a1f1a10.zip
syslog
-rw-r--r--Makefile8
-rw-r--r--syslogd.c54
2 files changed, 51 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 6507e0a0..fb62a954 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,8 @@
CC= gcc
#CFLAGS= -g -DSYSV -Wall
#LDFLAGS= -g
-CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce
+#CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce
+CFLAGS= $(RPM_OPT_FLAGS) -O3 -DSYSV -fomit-frame-pointer -Wall -fno-strength-reduce -DWITH_DB
LDFLAGS= -s
# Look where your install program is.
@@ -11,6 +12,9 @@ INSTALL = /usr/bin/install
BINDIR = /usr/sbin
MANDIR = /usr/man
+# Uncommenting the following to use mysql.
+LIBS = -lmysqlclient #/var/lib/mysql/mysql
+
# There is one report that under an all ELF system there may be a need to
# explicilty link with libresolv.a. If linking syslogd fails you may wish
# to try uncommenting the following define.
@@ -70,7 +74,7 @@ syslog_tst: syslog_tst.o
${CC} ${LDFLAGS} -o syslog_tst syslog_tst.o
tsyslogd: syslogd.c version.h
- $(CC) $(CFLAGS) -g -DTESTING $(SYSLOGD_FLAGS) -o tsyslogd syslogd.c
+ $(CC) $(CFLAGS) -g -DTESTING $(SYSLOGD_FLAGS) -o tsyslogd syslogd.c $(LIBS)
tklogd: klogd.c syslog.c ksym.c ksym_mod.c version.h
$(CC) $(CFLAGS) -g -DTESTING $(KLOGD_FLAGS) -o tklogd klogd.c syslog.c ksym.c ksym_mod.c
diff --git a/syslogd.c b/syslogd.c
index cc5411d7..0e3908a8 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -524,7 +524,6 @@ static char sccsid[] = "@(#)rsyslogd.c 0.1 (Adiscon) 11/08/2004";
* a patch.
*/
-
#define MAXLINE 1024 /* maximum line length */
#define DEFUPRI (LOG_USER|LOG_NOTICE)
#define DEFSPRI (LOG_KERN|LOG_CRIT)
@@ -930,6 +929,8 @@ void writeMySQL(register struct filed *f);
void closeMySQL(register struct filed *f);
#endif
+int getSubString(char **pSrc, char *pDst, char cSep, int len);
+
#ifdef SYSLOG_UNIXAF
static int create_inet_socket();
#endif
@@ -3018,7 +3019,7 @@ void cfline(line, f)
char *line;
register struct filed *f;
{
- register char *p;
+ char *p;
register char *q;
register int i, i2;
char *bp;
@@ -3026,9 +3027,12 @@ void cfline(line, f)
int singlpri = 0;
int ignorepri = 0;
int syncfile;
+ int iErr;
#ifdef SYSLOG_INET
struct hostent *hp;
#endif
+#ifdef WITH_DB
+#endif
char buf[MAXLINE];
char xbuf[200];
@@ -3250,11 +3254,29 @@ void cfline(line, f)
dprintf("p is: %s\n", p);
f->f_type = F_MYSQL;
initMySQL(f);
- /* TODO: Add actual code! */
p++;
- while (*p == '\t' || *p == ' ')
- p++;
-
+ dprintf("p is: %s\n", p);
+
+ iErr = getSubString(&p, f->f_dbsrv, ',', 1);
+ iErr = getSubString(&p, f->f_dbname, ',', 1);
+ iErr = getSubString(&p, f->f_dbuid, ',', 1);
+ iErr = getSubString(&p, f->f_dbpwd, ',', 1);
+ dprintf("f->f_dbsrv is: %s\n", f->f_dbsrv);
+ dprintf("f->f_dbname is: %s\n", f->f_dbname);
+ dprintf("f->f_dbuid is: %s\n", f->f_dbuid);
+ dprintf("f->f_dbpwd is: %s\n", f->f_dbpwd);
+
+ /* pLine = f->f_dbsrv;
+ while (*p != ',' || *p == '\0') {
+ *pLine = *p;
+ dprintf("pLine is: %s\n", pLine);
+ pLine++; p++;
+ }
+ pLine = '\0';
+ dprintf("p is: %s\n", p);
+ dprintf("pLine is: %s\n", pLine);
+ dprintf("f->f_dbsrv is: %s\n", f->f_dbsrv);
+ */
break;
#endif /* #ifdef WITH_DB */
@@ -3423,10 +3445,10 @@ void closeMySQL(register struct filed *f)
*/
void writeMySQL(register struct filed *f)
{
- char sql_command[MAXSVLINE+1048];
+ char sql_command[MAXLINE+1048];
printf("in writeMySQL()\n");
-
- snprintf(sql_command, sizeof(sql_command), "INSERT INTO myTable VALUES (1,'%s')", f->f_prevline);
+ /* TODO: Insert useful values */
+ snprintf(sql_command, sizeof(sql_command), "INSERT INTO myTable VALUES (1,'test')");
/* query */
if(mysql_query(&f->f_hmysql, sql_command)) {
@@ -3440,6 +3462,20 @@ void writeMySQL(register struct filed *f)
#endif /* #ifdef WITH_DB */
/*
+ * getSubString
+ */
+int getSubString(char **ppSrc, char *pDst, char cSep, int len)
+{
+ char *pSrc = *ppSrc;
+ while(*pSrc != cSep && *pSrc != '\0') {
+ *pDst++ = *(pSrc)++;
+ }
+ *ppSrc=pSrc+1;
+ *pDst = '\0';
+ return len;
+}
+
+/*
* Local variables:
* c-indent-level: 8
* c-basic-offset: 8