公司要求做socat源代码二次开发的时候,花了一周时间通读代码,写上了注释,添加了-M参数用于在端口无法打开的时候超时退出(不影响其他功能),在linux操作系统上编译通过,并做了测试
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-09-02 09:29 socat
文件 3064 2014-08-30 04:45 socatxiowrite.o
文件 35096 2014-09-02 01:38 socatxio-socket.o
文件 16384 2014-08-22 05:40 socat.socat.c.swp
文件 746 2014-08-22 05:40 socatBUGREPORTS
文件 38153 2014-08-22 05:40 socatCHANGES
文件 18092 2014-08-22 05:40 socatCOPYING
文件 6279 2014-08-22 05:40 socatCOPYING.OpenSSL
文件 7011 2014-08-22 05:40 socatDEVELOPMENT
文件 16861 2014-08-22 05:40 socatEXAMPLES
文件 3919 2014-08-22 05:40 socatFAQ
文件 2763 2014-08-22 05:40 socatFILES
文件 6525 2014-08-22 05:43 socatMakefile
文件 6488 2014-08-22 05:40 socatMakefile.in
文件 3095 2014-08-22 05:40 socatPORTING
文件 11535 2014-08-22 05:40 socatREADME
文件 2655 2014-08-22 05:40 socatREADME.FIPS
文件 1849 2014-08-22 05:40 socatSECURITY
文件 12 2014-08-22 05:40 socatVERSION
文件 16430 2014-08-22 05:40 socatcompat.h
文件 14879 2014-08-22 05:40 socatconfig.h
文件 13679 2014-08-22 05:40 socatconfig.h.in
文件 850426 2014-08-22 05:43 socatconfig.log
文件 32516 2014-08-22 05:43 socatconfig.status
文件 344843 2014-08-22 05:40 socatconfigure
文件 53122 2014-08-22 05:40 socatconfigure.in
文件 872 2014-08-22 05:40 socatdaemon.sh
文件 5164 2014-08-22 05:40 socatdalan.c
文件 949 2014-08-22 05:40 socatdalan.h
文件 4436 2014-08-30 04:45 socatdalan.o
文件 8208 2014-08-22 05:40 socaterror.c
............此处省略230个文件信息
/* source: dalan.c */
/* Copyright Gerhard Rieger 2001-2008 */
/* Published under the GNU General Public License V.2 see file COPYING */
/* idea of a low level data description language. currently only a most
primitive subset exists. */
#include
#include
#include
#include “dalan.h“
/* test structure to find maximal alignment */
static struct {
char a;
long double b;
} maxalign;
/* test structure to find minimal alignment */
static struct {
char a;
char b;
} minalign;
/* test union to find kind of byte ordering */
static union {
char a[2];
short b;
} byteorder = { “01“ };
struct dalan_opts_s dalan_opts = {
sizeof(int)
sizeof(short)
sizeof(long)
sizeof(char)
sizeof(float)
sizeof(double)
} ;
/* fill the dalan_opts structure with machine dependent defaults values. */
static void _dalan_dflts(struct dalan_opts_s *dlo) {
dlo->c_int = sizeof(int);
dlo->c_short = sizeof(short);
dlo->c_long = sizeof(long);
dlo->c_char = sizeof(char);
dlo->c_float = sizeof(float);
dlo->c_double = sizeof(double);
dlo->maxalign = (char *)&maxalign.b-&maxalign.a;
dlo->minalign = &minalign.b-&minalign.a;
dlo->byteorder = (byteorder.b!=7711);
}
/* allocate a new dalan_opts structure fills it with machine dependent
defaults values and returns the pointer. */
struct dalan_opts_s *dalan_props(void) {
struct dalan_opts_s *dlo;
dlo = malloc(sizeof(struct dalan_opts_s));
if (dlo == NULL) {
return NULL;
}
_dalan_dflts(dlo);
return dlo;
}
void dalan_init(void) {
_dalan_dflts(&dalan_opts);
}
/* read data description from line write result to data; do not write
so much data that *p exceeds n !
p must be initialized to 0.
return 0 on success
-1 if the data was cut due to n limit
1 if a syntax error occurred
*p is a global data counter; especially it must be used when calculating
alignment. On successful return from the function *p must be actual!
*/
int dalan(const char *line char *data size_t *p size_t n) {
int align mask i x;
size_t p1 = *p;
char c;
/*fputs(line stderr); fputc(‘
‘ stderr);*/
while (c = *line++) {
switch (c) {
case ‘ ‘:
case ‘ ‘:
case ‘
‘:
case ‘
‘:
break;
case ‘‘:
align = 2;
while (*line == ‘‘) {
align <<= 1;
++line;
}
mask = align - 1; /* create the bitmask */
i = (align - (p1 & mask)) & mask;
while (i && p1 if (i) { *p = p1; return -1; }
break;
case ‘;‘:
align = dalan_opts.c_int;
mask = align - 1;
i = (align - (p1 & mask)) & mask;
while (i && p1 if (i) { *p = p1; return -1; }
break;
case ‘“‘:
while (1) {
switch (c = *line++) {
case ‘ ‘: fputs(“unterminated string
“ stderr);
return 1;
case ‘“‘:
break;
case ‘\‘:
if (!(c = *line++)) {
fputs(“continuation line not implemented
“ stderr);
return 1;
}
s
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-09-02 09:29 socat
文件 3064 2014-08-30 04:45 socatxiowrite.o
文件 35096 2014-09-02 01:38 socatxio-socket.o
文件 16384 2014-08-22 05:40 socat.socat.c.swp
文件 746 2014-08-22 05:40 socatBUGREPORTS
文件 38153 2014-08-22 05:40 socatCHANGES
文件 18092 2014-08-22 05:40 socatCOPYING
文件 6279 2014-08-22 05:40 socatCOPYING.OpenSSL
文件 7011 2014-08-22 05:40 socatDEVELOPMENT
文件 16861 2014-08-22 05:40 socatEXAMPLES
文件 3919 2014-08-22 05:40 socatFAQ
文件 2763 2014-08-22 05:40 socatFILES
文件 6525 2014-08-22 05:43 socatMakefile
文件 6488 2014-08-22 05:40 socatMakefile.in
文件 3095 2014-08-22 05:40 socatPORTING
文件 11535 2014-08-22 05:40 socatREADME
文件 2655 2014-08-22 05:40 socatREADME.FIPS
文件 1849 2014-08-22 05:40 socatSECURITY
文件 12 2014-08-22 05:40 socatVERSION
文件 16430 2014-08-22 05:40 socatcompat.h
文件 14879 2014-08-22 05:40 socatconfig.h
文件 13679 2014-08-22 05:40 socatconfig.h.in
文件 850426 2014-08-22 05:43 socatconfig.log
文件 32516 2014-08-22 05:43 socatconfig.status
文件 344843 2014-08-22 05:40 socatconfigure
文件 53122 2014-08-22 05:40 socatconfigure.in
文件 872 2014-08-22 05:40 socatdaemon.sh
文件 5164 2014-08-22 05:40 socatdalan.c
文件 949 2014-08-22 05:40 socatdalan.h
文件 4436 2014-08-30 04:45 socatdalan.o
文件 8208 2014-08-22 05:40 socaterror.c
............此处省略230个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)