mirror of
https://codeberg.org/1414codeforge/ubgpsuite.git
synced 2025-06-05 21:29:11 +02:00
[lonetic/bufio,lonetix/bgp,tools/bgpgrep,tools/peerindex] Add support for buffered input
This commit is contained in:
@@ -316,8 +316,10 @@ static void Bgpgrep_OpenMrtDump(const char *filename)
|
||||
S.filename = filename;
|
||||
if (strcmp(S.filename, "-") == 0) {
|
||||
// Direct read from stdin - assume uncompressed.
|
||||
S.inf = STM_FILDES(CON_FILDES(STDIN));
|
||||
S.infOps = Stm_NcFildesOps;
|
||||
Bufio_RdInit(&S.infBuf, STM_FILDES(CON_FILDES(STDIN)), Stm_NcFildesOps);
|
||||
|
||||
S.inf = &S.infBuf;
|
||||
S.infOps = Stm_NcRdBufOps;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -352,8 +354,10 @@ static void Bgpgrep_OpenMrtDump(const char *filename)
|
||||
|
||||
} else {
|
||||
// Assume uncompressed file
|
||||
S.inf = STM_FILDES(fh);
|
||||
S.infOps = Stm_FildesOps;
|
||||
Bufio_RdInit(&S.infBuf, STM_FILDES(fh), Stm_FildesOps);
|
||||
|
||||
S.inf = &S.infBuf;
|
||||
S.infOps = Stm_RdBufOps;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include "bgp/mrt.h"
|
||||
#include "bgp/patricia.h"
|
||||
#include "bgp/vm.h"
|
||||
#include "bufio.h"
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
@@ -113,6 +114,7 @@ struct BgpgrepState {
|
||||
const char *filename; // current file being processed
|
||||
void *inf; // NOTE: may be NULL even in a file is open
|
||||
const StmOps *infOps; // if NULL no file is open
|
||||
Stmrdbuf infBuf; // input buffer in case we're reading from uncompressed source
|
||||
|
||||
// Miscellaneous global flags and data
|
||||
Boolean8 noColor;
|
||||
|
Reference in New Issue
Block a user