Fosdccf.blog.chinaunix.net
sdccf
全部博文(19283)
Linux酷软(214)
tmp(0)
PostgreSQL(93)
Solaris(383)
AIX(173)
SCOUNIX(575)
DB2(1005)
Shell(386)
C/C++(1187)
MySQL(1750)
Sybase(465)
Oracle(3695)
Informix(548)
HP-UX(0)
IBM AIX(2)
Sun Solaris(0)
BSD(1)
Linux(8597)
SCO UNIX(23)
2011年(1)
2009年(125)
2008年(19094)
2007年(63)
clifford
linky521
曾德标
fengzhan
leon_yu
mcuflowe
yt200902
guanyuji
GY123456
snow888
carlos94
丸喵喵
sean229
cxunix
可怜的猪
cqxc413
xzzgege
wb123456
分类: C/C++
2008-04-17 20:30:42
//SimpSed.h#ifndef SIMP_SED#define SIMP_SED#include <stdio.h>//#include #include "SedScript.h"#define PATTERN_SPACE_SIZE 0x100000#define HOLD_SPACE_SIZE 0x100000#define LINE_SIZE 0x100#define MSG_FILE_NOT_OPEN "Cannot open file %s.\n"typedef struct TSimpSed { FILE *_file; int _lineNumber; char _line[LINE_SIZE]; char *_holdSpace; char *_patternSpace; SedScript *scriptList; void (*parseScript)(struct TSimpSed *self, char *script); void (*runScript)(struct TSimpSed *self); /** sed commands, such as x,d,h,g,p and so on. */ int (*next)(struct TSimpSed *self); // n, returns -1, 0, 1 int (*nextA)(struct TSimpSed *self); // N, returns -1, 0, 1 void (*exchange)(struct TSimpSed *self); // x void (*delete)(struct TSimpSed *self); // d void (*hold)(struct TSimpSed *self); // h void (*holdA)(struct TSimpSed *self); // H void (*get)(struct TSimpSed *self); // g void (*getA)(struct TSimpSed *self); // G void (*print)(struct TSimpSed *self); // p void (*destroy)(struct TSimpSed *self); // public.. void (*exec)(struct TSimpSed *, char *script, char *fileName);} SimpSed; SimpSed getSed();#endif
//SedScript.h#ifndef SED_SCRIPT#define SED_SCRIPT#include "SedAddress.h"// CMD Types#define SED_CMD_PRINT 1#define SED_CMD_NEXT 2#define SED_CMD_NEXTA 3#define SED_CMD_HOLD 4#define SED_CMD_HOLDA 5#define SED_CMD_GET 6#define SED_CMD_GETA 7#define SED_CMD_DELETE 8#define SED_CMD_EXCHANGE 9typedef struct TSedScript { SedAddress address; char cmd; char *params; int (*getCmdType)(struct TSedScript *self);} SedScript;SedScript getSedScript(char *address, char cmd, char *params);#endif
//SedAddress.h#ifndef SED_ADDRESS#define SED_ADDRESS// ADDR TYPES ( $ not included )#define SED_ADDR_NUMBER 1#define SED_ADDR_NUMBER_RANGE 2#define SED_ADDR_PATTERN 3#define SED_ADDR_PATTERN_RANGE 4typedef struct TSedAddress { int type; int startLine; int stopLine; char *startPattern; char *stopPattern; int rangeFlag; int (*inRange)(struct TSedAddress *self);} SedAddress;SedAddress getSedAddress(char *addr);#endif
上一篇:利用ACE信号处理解决unix中的僵尸进程
下一篇:c语言调用gawk
登录 注册