当前位置: 首页>>代码示例>>C++>>正文


C++ OE::open方法代码示例

本文整理汇总了C++中OE::open方法的典型用法代码示例。如果您正苦于以下问题:C++ OE::open方法的具体用法?C++ OE::open怎么用?C++ OE::open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OE的用法示例。


在下文中一共展示了OE::open方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:26,代码来源:test_funtokenizer.c

示例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;
	}
}
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:30,代码来源:opentest.c

示例3: test_listen

static int test_listen(OE oe) {
  uint fd = 0;
  oe->open("listen 2020",&fd);
	if (!fd) {
		oe->p("Unable to listen on port 2020");
		return 0;
	}
	else {
		oe->p("Accepting connections on 2020");
		return 1;
	}
}
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:12,代码来源:opentest.c

示例4: test_open_file

static int test_open_file(OE oe) {
  uint fd = 0;
  oe->open("file C:\\Users\\rwl\\test.txt",&fd);

	if (!fd) {
		oe->p("unable to open file test.txt");
		return 0;
	}
	else {
		oe->p("test.txt successfully opened");
		oe->close(fd);
		return 1;
	}
}
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:14,代码来源:opentest.c

示例5: 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;
	}
}
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:15,代码来源:opentest.c

示例6: test_write

static int test_write(OE oe) {
	byte buf[] = { "Rasmus Zakarias" };
	uint lbuf = sizeof(buf);
	uint fd = 0;
	oe->open("file .\\test.txt",&fd);
	if (oe->write(fd, buf, &lbuf) == RC_OK && lbuf == sizeof(buf)) {
		oe->p("Successfully wrote test.txt");
		oe->close(fd);
		return 1;
	}	else{
		oe->p("Failed to write to test.txt");
		oe->close(fd);
		return 0;
	}
}
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:15,代码来源:opentest.c

示例7: 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;
}
开发者ID:AarhusCrypto,项目名称:EmpiricalZeroKnowledge,代码行数:41,代码来源:test_inputgatevisitor.c

示例8: main

int main(int c, char **s) {
  OE oe = OperatingEnvironment_New();
  uint ltext = 120, lcode = 256, nplayers = 2;
  MiniMacsEnc encoder = 0;
  MiniMacsTripleRep ** triples = 0;
  MiniMacsRep ** singles = 0;
  MiniMacsRep *** pairs = 0;
  BitDecomposedTriple ** t = 0;
  MiniMacsRep * compat = 0;
  uint ltriples=1, lsingles=1, lpairs=1, lbtriples=1;
  byte * buf = 0;
  uint lbuf = 0;
  init_polynomial();

  encoder = MiniMacsEnc_MatrixNew(oe,lcode, ltext);
  
  compat = minimacs_fake_setup(oe, encoder, 
                               ltext, nplayers, lcode, 
                               &triples, ltriples, 
                               &singles, lsingles, 
                               &pairs, lpairs,0);
  minimacs_fake_bdt( oe, encoder, compat, &t, lbtriples);
  
  

  printf("Save/Load BitDecomposedTriples\n");

  write_bdt(t[0], lbtriples, &buf, &lbuf);
  {
    BitDecomposedTriple * loaded_bdt = 0;
    uint lloaded_bdt = 0;
    DerRC rc = 0;
    uint i = 0;

    rc = read_bdt(buf, lbuf, &loaded_bdt, &lloaded_bdt);
    if (rc != DER_OK) {
      printf("Oh crap \n");
      exit(-1);
    }

    if (!loaded_bdt) {
      printf("Oh crap nothing there\n");
      return -2;
    }

    if (lloaded_bdt ==1 ){
      printf("Yes we loaded one\n");
    } else {
      printf("Oh, no this failes\n");
    }

    
    for (i = 0;i < lloaded_bdt;++i) {
      int j = 0;
      if (loaded_bdt[i]->a == 0) {
        printf("[%u] has no a\n",i);
      }

      if (loaded_bdt[i]->b == 0) {
        printf("[%u] has no b\n",i);
      }

      if (loaded_bdt[i]->c == 0) {
        printf("[%u] has no c\n",i);
      }

      for(j = 0;j < 8;++j) {
       
        if (loaded_bdt[i]->abits[j] == 0) {
          printf("[%u] has no abits[%u]\n",i,j);
        }

        if (loaded_bdt[i]->bbits[j] == 0) {
          printf("[%u] has no abits[%u]\n",i,j);
        }

      }
    }
  }

  {
    FD fd = 0;
    oe->open("file bdt.fat", &fd);
    oe->write(fd, buf, &lbuf);
    oe->close(fd);

  }
  
  //  minimacs_fake_bdt(oe, encoder, 
  
  return 0;

  
  

}
开发者ID:AarhusCrypto,项目名称:MiniAES,代码行数:96,代码来源:loadreps.c


注:本文中的OE::open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。