Prep for new extension system
This commit is contained in:
parent
ef68f9c378
commit
fa8e81e288
@ -1,6 +0,0 @@
|
||||
#ifndef EXEC_H
|
||||
#define exec_h
|
||||
#include "types.h"
|
||||
|
||||
struct line runextension(struct line *data, char *filename, size_t n);
|
||||
#endif
|
8
include/extension.h
Normal file
8
include/extension.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef EXTENSION_H
|
||||
#define EXTENSION_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
struct filedata runfilter(struct filedata *f);
|
||||
|
||||
#endif // EXTENSION_H
|
4
include/server.h
Normal file
4
include/server.h
Normal file
@ -0,0 +1,4 @@
|
||||
#ifndef SERVER_H
|
||||
#define SERVER_H
|
||||
|
||||
#endif // SERVER_H
|
5
src/extension/filter.c
Normal file
5
src/extension/filter.c
Normal file
@ -0,0 +1,5 @@
|
||||
#include "extension.h"
|
||||
#include "types.h"
|
||||
#include "util.h"
|
||||
|
||||
struct filedata runfilter(struct filedata *f) { return *f; }
|
@ -1,14 +0,0 @@
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "arg.h"
|
||||
#include "types.h"
|
||||
#include "util.h"
|
||||
|
||||
struct line runextension(struct line *data, char *filename, size_t n) {
|
||||
// TODO: Implement as unix socket
|
||||
return *data;
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "arg.h"
|
||||
#include "exec.h"
|
||||
#include "extension.h"
|
||||
#include "file.h"
|
||||
#include "process.h"
|
||||
#include "types.h"
|
||||
@ -53,6 +53,10 @@ void run(FILE *fp, char *filename, bool tty) {
|
||||
struct filedata f;
|
||||
f = readfile(fp, conf.isstdin);
|
||||
|
||||
if (conf.extension != NULL) {
|
||||
f = runfilter(&f);
|
||||
}
|
||||
|
||||
if (conf.pager) {
|
||||
st = popen("less", "w");
|
||||
err = st;
|
||||
@ -91,9 +95,6 @@ void run(FILE *fp, char *filename, bool tty) {
|
||||
free(padding);
|
||||
}
|
||||
|
||||
if (conf.extension != NULL) {
|
||||
f.lines[i] = runextension(&f.lines[i], filename, i + 1);
|
||||
}
|
||||
fwrite(f.lines[i].buf, 1, f.lines[i].len, st);
|
||||
fprintf(st, "\n");
|
||||
linecount++;
|
||||
|
Loading…
Reference in New Issue
Block a user