本文整理汇总了C++中OE::read方法的典型用法代码示例。如果您正苦于以下问题:C++ OE::read方法的具体用法?C++ OE::read怎么用?C++ OE::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OE
的用法示例。
在下文中一共展示了OE::read方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tokenize_file
static int tokenize_file(OE oe) {
uint lbuffer = 1060365;
uint ands = 0, xors = 0, invs = 0, nums = 0, tokens = 0;
Tokenizer tk = 0;
Token tok = {0};
byte * buffer = oe->getmem(lbuffer);
uint fp = 0;
oe->open("file ../test/AES",&fp);
oe->read(fp,buffer,&lbuffer);
oe->close(fp);
tk = FunCallTokenizer_New(oe);
tk->start(buffer,lbuffer);
do {
tk->nextToken(&tok);
if (tok.type == INV) invs += 1;
if (tok.type == AND) ands +=1;
if (tok.type == XOR) xors += 1;
if (tok.type == NUM) nums += 1;
tokens++;
} while(tok.type != DONE);
DBG_P(oe,"\nANDS: %u\nXORS: %u\nINVS: %u\nNUMS: %u\nTOKENS: %u\n",ands,xors,invs,nums,tokens);
oe->putmem(buffer);
return ands == 6800 && xors == 24448 && nums == 139136 && tokens == 172076 && invs == 1691;
}
示例2: openip
static int openip(OE oe) {
byte buf[64] = { 0 };
uint lbuf = sizeof(buf);
uint fd = 0;
RC rc = RC_OK;
oe->open("ip 87.104.238.146 80",&fd);
if (!fd) {
oe->p("Failed to connect to IP-address 87.104.238.146 on port 80.");
return 0;
} else {
uint written = 19;
oe->write(fd, (byte*)"GET / HTTP/1.0\n\n\n", &written);
if (written != 19) {
oe->p("Failed to write 19 bytes to server at 87.104.238.146 port 80.");
return 0;
}
rc = oe->read(fd, buf, &lbuf);
oe->close(fd);
if (rc != RC_OK) {
if (lbuf != sizeof(buf)) {
oe->p("Read too few bytes.");
return 0;
}
}
return 1;
}
}
示例3: test_read
static int test_read(OE oe) {
byte buf[10] = { 0 };
uint lbuf = sizeof(buf);
uint fd = 0;
oe->open("file .\\test.txt",&fd);
if (oe->read(fd, buf, &lbuf) == RC_OK && lbuf == sizeof(buf)) {
oe->p("Successfully read 10 bytes");
oe->close(fd);
return 1;
} else {
oe->p("Failed to read 10 bytes from test.txt");
oe->close(fd);
return 0;
}
}
示例4: test_large_file
static int test_large_file(OE oe) {
_Bool ok = 1;
uint lbuffer = 1060365;
uint ands = 0, xors = 0, nums = 0, tokens = 0;
Tokenizer tk = 0;CircuitParser cp = 0;
List ast = 0;
byte * buffer = oe->getmem(lbuffer);
uint fp = 0, i = 0;
CircuitVisitor cv = 0;
Map input_gates = 0;
List aoig = 0;
DateTime clock = 0;
ull start = 0;
oe->open("file ../test/AES",&fp);
cv = InputGateVisitor_New(oe);
clock = DateTime_New(oe);
start = clock->getMicroTime();
oe->read(fp,buffer,&lbuffer);
oe->close(fp);
DBG_P(oe,"reading file took %u microseconds",clock->getMicroTime()-start);
tk = FunCallTokenizer_New(oe);
cp = CircuitParser_New(oe,tk);
start = clock->getMicroTime();
ast = cp->parseSource(buffer,lbuffer);
DBG_P(oe,"parsing circuit took %u microseconds.",clock->getMicroTime()-start);
oe->putmem(buffer);
start = clock->getMicroTime();
input_gates = cv->visit(ast);
AssertTrue(input_gates != 0)
aoig = input_gates->get_keys();
if (aoig) {
DBG_P(oe,"#Input: %u analysis took %u microseconds",aoig->size(),clock->getMicroTime()-start);
}
AssertTrue( aoig != 0 );
test_end:
return ok;
}