Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc518c41

Browse files
Start moving blobstamper code into separate files
1 parent756fc74 commitc518c41

File tree

9 files changed

+182
-145
lines changed

9 files changed

+182
-145
lines changed

‎Makefile‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,24 @@ ifeq ($(origin CC),default)
66
CC = gcc
77
endif
88

9+
BLOB_STAMPER_OBJ = blobstamper/blob.o blobstamper/helpers.o
10+
911
.PHONY: all
10-
all: test test_pg_op_wrappers test_libblobstamper
12+
all:blob-stamper-alltest test_pg_op_wrappers test_libblobstamper
1113
@echo All done!
1214

15+
.PHONY: blob-stamper-all
16+
blob-stamper-all:
17+
$(MAKE) -C blobstamper
1318

1419
test:$(LIB_OBJS) test.o
1520
$(CC)$(LDFLAGS)$^ -o$@$(LDLIBS)
1621

17-
test_pg_op_wrappers:$(LIB_OBJS) test_pg_op_wrappers.o libblobstamper.o pg_op_wrappers.o
18-
$(CXX)$(LDFLAGS)$^ -o$@$(LDLIBS)
22+
test_pg_op_wrappers:blob-stamper-all$(LIB_OBJS) test_pg_op_wrappers.olibblobstamper.o pg_op_wrappers.o
23+
$(CXX)$(LDFLAGS)$@.o -o$@$(LDLIBS)$(BLOB_STAMPER_OBJ) libblobstamper.o pg_op_wrappers.o
1924

20-
test_libblobstamper:$(LIB_OBJS) libblobstamper.o test_libblobstamper.o
21-
$(CXX)$(LDFLAGS)$^ -o$@$(LDLIBS)
25+
test_libblobstamper:$(LIB_OBJS) libblobstamper.o test_libblobstamper.o blob-stamper-all
26+
$(CXX)$(LDFLAGS)$@.o -o$@$(LDLIBS)$(BLOB_STAMPER_OBJ) libblobstamper.o
2227

2328

2429

@@ -28,7 +33,12 @@ test_libblobstamper: $(LIB_OBJS) libblobstamper.o test_libblobstamper.o
2833
%.o:%.c$(DEPS)
2934
$(CC) -c -g$(CXXFLAGS)$<
3035

31-
.PHONY: clean
32-
clean:
36+
.PHONY: blob-stamper-clean
37+
38+
blob-stamper-clean:
39+
$(MAKE) -C blobstamper clean
40+
41+
.PHONY: clean
42+
clean: blob-stamper-clean
3343
rm -f*.otest test_pg_op_wrappers test_libblobstamper
3444
@echo Clean done!

‎blobstamper/Makefile‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
ALL_OBJS = blob.o helpers.o
3+
4+
%.o:%.cpp$(DEPS)
5+
$(CXX) -c -g$(CFLAGS)$<
6+
7+
%.o:%.c$(DEPS)
8+
$(CC) -c -g$(CXXFLAGS)$<
9+
10+
11+
all:$(ALL_OBJS)
12+
13+
.PHONY: clean
14+
clean:
15+
rm -f*.o

‎blobstamper/blob.cpp‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include"blob.h"
2+
#include"helpers.h"
3+
4+
#include"../libblobstamper.h"/*FIXME remove this*/
5+
6+
Blob::Blob (char * data_in,int size_in)
7+
{
8+
data = data_in;
9+
size = size_in;
10+
begin =0;
11+
end = size -1;/* i.e. size=1 means begin=0 && end=0*/
12+
}
13+
14+
bool
15+
Blob::isEmpty ()
16+
{
17+
if (! data)returntrue;
18+
returnfalse;
19+
}
20+
21+
void
22+
Blob::Dump()
23+
{
24+
int length = end - begin +1 ;
25+
hexdump(data + begin, length);
26+
}
27+
28+
Blob
29+
Blob::ShiftBytes(size_t n)
30+
{
31+
if (begin + n > end)
32+
{
33+
Blobempty(NULL, -1);
34+
return empty;/* not enough data*/
35+
}
36+
37+
Blobnew_blob(data, size);
38+
39+
new_blob.begin = begin;/* FIXME this should go private once*/
40+
new_blob.end = begin + n -1;
41+
42+
begin += n;
43+
44+
return new_blob;
45+
}
46+
47+
void *
48+
Blob::ShiftSingleStampBin(StampGeneric& stmp)
49+
{
50+
return stmp.Extract(*this);
51+
}
52+
53+
std::string
54+
Blob::ShiftSingleStampStr(StampGeneric& stmp)
55+
{
56+
return stmp.ExtractStr(*this);
57+
}
58+

‎blobstamper/blob.h‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
#ifndef BLOB_H
3+
#defineBLOB_H
4+
5+
#include<string>
6+
7+
classStampGeneric;
8+
9+
classBlob
10+
{
11+
private:
12+
public:
13+
Blob(char * data,int size);
14+
boolisEmpty ();
15+
voidDump();
16+
BlobShiftBytes(size_t n);
17+
18+
void *ShiftSingleStampBin(StampGeneric &stmp);
19+
std::stringShiftSingleStampStr(StampGeneric &stmp);
20+
21+
char* data;/*FIXME потом сделать private*/
22+
int size;
23+
int begin;
24+
int end;
25+
};
26+
27+
#endif/*BLOB_H*/

‎blobstamper/helpers.cpp‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
2+
#include<stdio.h>
3+
#include<ctype.h>
4+
5+
/* Borrowed from http://www.stahlworks.com/dev/index.php?tool=csc01*/
6+
/* Code is not nice for support, better rewrite it*/
7+
8+
voidhexdump(void *pAddressIn,long lSize)
9+
{
10+
char szBuf[100];
11+
long lIndent =1;
12+
long lOutLen, lIndex, lIndex2, lOutLen2;
13+
long lRelPos;
14+
struct {char *pData;unsignedlong lSize; } buf;
15+
unsignedchar *pTmp,ucTmp;
16+
unsignedchar *pAddress = (unsignedchar *)pAddressIn;
17+
18+
buf.pData = (char *)pAddress;
19+
buf.lSize = lSize;
20+
21+
while (buf.lSize >0)
22+
{
23+
pTmp = (unsignedchar *)buf.pData;
24+
lOutLen = (int)buf.lSize;
25+
if (lOutLen >16)
26+
lOutLen =16;
27+
28+
// create a 64-character formatted output line:
29+
sprintf(szBuf," >"
30+
""
31+
" %08lX", pTmp-pAddress);
32+
lOutLen2 = lOutLen;
33+
34+
for(lIndex =1+lIndent, lIndex2 =53-15+lIndent, lRelPos =0;
35+
lOutLen2;
36+
lOutLen2--, lIndex +=2, lIndex2++
37+
)
38+
{
39+
ucTmp = *pTmp++;
40+
41+
sprintf(szBuf + lIndex,"%02X", (unsignedshort)ucTmp);
42+
if(!isprint(ucTmp)) ucTmp ='.';// nonprintable char
43+
szBuf[lIndex2] = ucTmp;
44+
45+
if (!(++lRelPos &3))// extra blank after 4 bytes
46+
{ lIndex++; szBuf[lIndex+2] =''; }
47+
}
48+
49+
if (!(lRelPos &3)) lIndex--;
50+
51+
szBuf[lIndex ] ='\t';
52+
szBuf[lIndex+1] ='\t';
53+
54+
printf("%s\n", szBuf);
55+
56+
buf.pData += lOutLen;
57+
buf.lSize -= lOutLen;
58+
}
59+
}
60+

‎blobstamper/helpers.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
voidhexdump(void*pAddressIn,longlSize);

‎libblobstamper.cpp‎

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -8,116 +8,6 @@
88
#include"libblobstamper.h"
99

1010

11-
Blob::Blob (char * data_in,int size_in)
12-
{
13-
data = data_in;
14-
size = size_in;
15-
begin =0;
16-
end = size -1;/* i.e. size=1 means begin=0 && end=0*/
17-
}
18-
19-
bool
20-
Blob::isEmpty ()
21-
{
22-
if (! data)returntrue;
23-
returnfalse;
24-
}
25-
26-
/* Borrowed from http://www.stahlworks.com/dev/index.php?tool=csc01*/
27-
/* Code is not nice for support, better rewrite it*/
28-
29-
voidhexdump(void *pAddressIn,long lSize)
30-
{
31-
char szBuf[100];
32-
long lIndent =1;
33-
long lOutLen, lIndex, lIndex2, lOutLen2;
34-
long lRelPos;
35-
struct {char *pData;unsignedlong lSize; } buf;
36-
unsignedchar *pTmp,ucTmp;
37-
unsignedchar *pAddress = (unsignedchar *)pAddressIn;
38-
39-
buf.pData = (char *)pAddress;
40-
buf.lSize = lSize;
41-
42-
while (buf.lSize >0)
43-
{
44-
pTmp = (unsignedchar *)buf.pData;
45-
lOutLen = (int)buf.lSize;
46-
if (lOutLen >16)
47-
lOutLen =16;
48-
49-
// create a 64-character formatted output line:
50-
sprintf(szBuf," >"
51-
""
52-
" %08lX", pTmp-pAddress);
53-
lOutLen2 = lOutLen;
54-
55-
for(lIndex =1+lIndent, lIndex2 =53-15+lIndent, lRelPos =0;
56-
lOutLen2;
57-
lOutLen2--, lIndex +=2, lIndex2++
58-
)
59-
{
60-
ucTmp = *pTmp++;
61-
62-
sprintf(szBuf + lIndex,"%02X", (unsignedshort)ucTmp);
63-
if(!isprint(ucTmp)) ucTmp ='.';// nonprintable char
64-
szBuf[lIndex2] = ucTmp;
65-
66-
if (!(++lRelPos &3))// extra blank after 4 bytes
67-
{ lIndex++; szBuf[lIndex+2] =''; }
68-
}
69-
70-
if (!(lRelPos &3)) lIndex--;
71-
72-
szBuf[lIndex ] ='\t';
73-
szBuf[lIndex+1] ='\t';
74-
75-
printf("%s\n", szBuf);
76-
77-
buf.pData += lOutLen;
78-
buf.lSize -= lOutLen;
79-
}
80-
}
81-
82-
83-
void
84-
Blob::Dump()
85-
{
86-
int length = end - begin +1 ;
87-
hexdump(data + begin, length);
88-
}
89-
90-
Blob
91-
Blob::ShiftBytes(size_t n)
92-
{
93-
if (begin + n > end)
94-
{
95-
Blobempty(NULL, -1);
96-
return empty;/* not enough data*/
97-
}
98-
99-
Blobnew_blob(data, size);
100-
101-
new_blob.begin = begin;/* FIXME this should go private once*/
102-
new_blob.end = begin + n -1;
103-
104-
begin += n;
105-
106-
return new_blob;
107-
}
108-
109-
void *
110-
Blob::ShiftSingleStampBin(StampGeneric& stmp)
111-
{
112-
return stmp.Extract(*this);
113-
}
114-
115-
std::string
116-
Blob::ShiftSingleStampStr(StampGeneric& stmp)
117-
{
118-
return stmp.ExtractStr(*this);
119-
}
120-
12111
/*************************************************************************************/
12212

12313
std::list<std::string>StampList::ExtractStrList(Blob &blob)

‎libblobstamper.h‎

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,7 @@
44
#include<string>
55
#include<list>
66

7-
classStampGeneric;
8-
9-
classBlob
10-
{
11-
private:
12-
public:
13-
Blob(char * data,int size);
14-
boolisEmpty ();
15-
voidDump();
16-
BlobShiftBytes(size_t n);
17-
18-
void *ShiftSingleStampBin(StampGeneric &stmp);
19-
std::stringShiftSingleStampStr(StampGeneric &stmp);
20-
21-
char* data;/*FIXME потом сделать private*/
22-
int size;
23-
int begin;
24-
int end;
25-
};
7+
#include"blobstamper/blob.h"
268

279
classStampGeneric
2810
{
@@ -86,12 +68,3 @@ class StampStrPgPolygon: public StampList
8668
StampStrPgPolygon() : StampList(actual_stamp) {}
8769
std::stringExtractStr(Blob &blob)override;
8870
};
89-
90-
91-
92-
BlobwflShiftN(Blob &blob,size_t n);
93-
std::stringwflShiftDouble(Blob &blob);
94-
std::stringwflShiftPgPoint(Blob &blob);
95-
std::stringwflShiftPgPath(Blob &blob);
96-
97-
voidhexdump(void *pAddressIn,long lSize);

‎test_libblobstamper.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include"libblobstamper.h"
44

5+
#include"blobstamper/helpers.h"
6+
57
char my_data[]="1234567890ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyzАБВГДитд.___";
68

79
int

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp