diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2011-07-04 11:24:04 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2011-07-04 11:24:04 +0200 |
commit | 4598557192c46e43edc5cc09b89c30045aacdb33 (patch) | |
tree | fc29e0cc3954658bf74b3493ee7e39881cb82916 /grammar/utils.c | |
parent | 25cd9f59ad3a0daa2662e44b2e844116ad487450 (diff) | |
download | rsyslog-4598557192c46e43edc5cc09b89c30045aacdb33.tar.gz rsyslog-4598557192c46e43edc5cc09b89c30045aacdb33.tar.bz2 rsyslog-4598557192c46e43edc5cc09b89c30045aacdb33.zip |
milestone: support for include files added
support for directories will be added during rsyslog integration
Diffstat (limited to 'grammar/utils.c')
-rw-r--r-- | grammar/utils.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/grammar/utils.c b/grammar/utils.c index d09a34a9..4e93c26c 100644 --- a/grammar/utils.c +++ b/grammar/utils.c @@ -11,13 +11,23 @@ void readConfFile(FILE *fp, es_str_t **str) { char ln[10240]; + char buf[512]; + int lenBuf; + int bWriteLineno = 0; int len, i; int start; /* start index of to be submitted text */ int bContLine = 0; + int lineno = 0; *str = es_newStr(4096); while(fgets(ln, sizeof(ln), fp) != NULL) { + ++lineno; + if(bWriteLineno) { + bWriteLineno = 0; + lenBuf = sprintf(buf, "PreprocFileLineNumber(%d)\n", lineno); + es_addBuf(str, buf, lenBuf); + } len = strlen(ln); /* if we are continuation line, we need to drop leading WS */ if(bContLine) { @@ -33,13 +43,15 @@ readConfFile(FILE *fp, es_str_t **str) --i; bContLine = 1; } else { + if(bContLine) /* write line number if we had cont line */ + bWriteLineno = 1; bContLine = 0; } /* add relevant data to buffer */ es_addBuf(str, ln+start, i+1 - start); - if(!bContLine) - es_addChar(str, '\n'); } + if(!bContLine) + es_addChar(str, '\n'); } /* indicate end of buffer to flex */ es_addChar(str, '\0'); |