本文整理汇总了C++中dump函数的典型用法代码示例。如果您正苦于以下问题:C++ dump函数的具体用法?C++ dump怎么用?C++ dump使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dump函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: mc
////////////////////////////////////////////////////////////////////////////////
/// @brief 動き補償 (小ブロック単位)
///
/// TODO: メモリアクセスの出力
///
/// @param SF [in] 画素差分データ
/// @param b [in] ブロック番号
///
int mc(int SF[8][8], int b)
{
int p[8][8];
int mixf = 1 - (fptr[0][mb_y][mb_x] & 1);
if(pic_coding_type == 1) mixf = 0;
dump_header(dump_mv);
dump(dump_mv, "mbx mby intra pat", " %2d %2d %d %d",
mb_x, mb_y, mb_intra, (mb_pattern >> (5 - b)) & 1);
if(!mb_mo_fw) mv[0][0][0] = mv[0][0][1] = 0;
if(mb_intra)
{
dumpx_mc_fetch("# no fetch (mb_intra=1)\n");
}
else
{
uint32_t fetch_a[9][5];
uint8_t fetch_d[9][10];
int ivx = mv[0][0][0];
int ivy = mv[0][0][1];
dump(dump_mv, "mvx mvy", " %5d %5d", ivx, ivy);
if(b & 4) { ivx /= 2; ivy /= 2; } // 絶対値の小さい方へ丸め
int halfx = ivx & 1;
int halfy = ivy & 1;
ivx = (ivx & ~1) / 2;
ivy = (ivy & ~1) / 2;
int oddx = ivx & 1;
dump(dump_mv, "ivx halfx", " %3d %d", ivx, halfx);
dump(dump_mv, "ivy halfy", " %3d %d", ivy, halfy);
ivx += (b < 4) ? (mb_x * 16 + (b & 1) * 8) : (mb_x * 8);
ivy += (b < 4) ? (mb_y * 16 + (b & 2) * 4) : (mb_y * 8);
dump(dump_mv, "ox oy", " %3d %3d", ivx, ivy);
dumpx_mc_fetch("# ivx=%d,halfx=%d,ivy=%d,halfy=%d\n",
ivx, halfx, ivy, halfy);
// フェッチアドレス計算
if(b < 4)
{
for(int y = 0; y < 9; ++y) for(int x = 0; x < 10; x += 2)
{
int ivx2 = x + ivx;
int ivy2 = y + ivy;
int f = fptr[0][(ivy2 >> 4) & MBY_MASK][(ivx2 >> 4) & MBX_MASK] & 1;
fetch_a[y][x >> 1] =
FBAGEN(b, f, (ivx2 >> 4), (ivx2 & 14) >> 1, (ivy2 >> 4), (ivy2 & 15));
}
}
else
{
for(int y = 0; y < 9; ++y) for(int x = 0; x < 10; x += 2)
{
int ivx2 = x + ivx;
int ivy2 = y + ivy;
int f = fptr[0][(ivy2 >> 3) & MBY_MASK][(ivx2 >> 3) & MBX_MASK] & 1;
fetch_a[y][x >> 1] =
FBAGEN(b, f, (ivx2 >> 3), (ivx2 & 14), (ivy2 >> 3), (ivy2 & 7) << 1);
}
}
// フェッチ実行
for(int y = 0; y < 9; ++y) for(int x = 0; x < 10; x += 2)
{
uint32_t a = fetch_a[y][x >> 1];
fetch_d[y][x + 0] = fbuf[a + 0];
fetch_d[y][x + 1] = fbuf[a + 1];
dumpx_mc_fetch("%06x %02x%02x\n",
fetch_a[y][x >> 1], fetch_d[y][x + 1], fetch_d[y][x + 0]);
}
// 整数画素・半画素合成
for(int y = 0; y < 8; ++y) for(int x = 0; x < 8; ++x)
{
int ym = y + halfy;
p[y][x] = (fetch_d[y][x + oddx] + fetch_d[y][x + oddx + halfx] +
fetch_d[ym][x + oddx] + fetch_d[ym][x + oddx + halfx] + 2) / 4;
dumpx_mc_fetch("%s %2x%s",
x == 0 ? "#" : "", p[y][x], x == 7 ? "\n" : "");
}
dumpx_mc_fetch("#------------------------\n");
// memset(p, 0, sizeof(p));
}
开发者ID:kimushu,项目名称:m2v_dec_eval,代码行数:98,代码来源:mc.c
示例2: main
int main(int argc, char **argv)
{
enum {
NNP = CHAR_MAX + 1,
RUID,
EUID,
RGID,
EGID,
REUID,
REGID,
CLEAR_GROUPS,
KEEP_GROUPS,
INIT_GROUPS,
GROUPS,
INHCAPS,
AMBCAPS,
LISTCAPS,
CAPBSET,
SECUREBITS,
PDEATHSIG,
SELINUX_LABEL,
APPARMOR_PROFILE
};
static const struct option longopts[] = {
{ "dump", no_argument, NULL, 'd' },
{ "nnp", no_argument, NULL, NNP },
{ "no-new-privs", no_argument, NULL, NNP },
{ "inh-caps", required_argument, NULL, INHCAPS },
{ "ambient-caps", required_argument, NULL, AMBCAPS },
{ "list-caps", no_argument, NULL, LISTCAPS },
{ "ruid", required_argument, NULL, RUID },
{ "euid", required_argument, NULL, EUID },
{ "rgid", required_argument, NULL, RGID },
{ "egid", required_argument, NULL, EGID },
{ "reuid", required_argument, NULL, REUID },
{ "regid", required_argument, NULL, REGID },
{ "clear-groups", no_argument, NULL, CLEAR_GROUPS },
{ "keep-groups", no_argument, NULL, KEEP_GROUPS },
{ "init-groups", no_argument, NULL, INIT_GROUPS },
{ "groups", required_argument, NULL, GROUPS },
{ "bounding-set", required_argument, NULL, CAPBSET },
{ "securebits", required_argument, NULL, SECUREBITS },
{ "pdeathsig", required_argument, NULL, PDEATHSIG, },
{ "selinux-label", required_argument, NULL, SELINUX_LABEL },
{ "apparmor-profile", required_argument, NULL, APPARMOR_PROFILE },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 }
};
static const ul_excl_t excl[] = {
/* keep in same order with enum definitions */
{CLEAR_GROUPS, KEEP_GROUPS, INIT_GROUPS, GROUPS},
{0}
};
int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
int c;
struct privctx opts;
struct passwd *pw = NULL;
int dumplevel = 0;
int total_opts = 0;
int list_caps = 0;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
atexit(close_stdout);
memset(&opts, 0, sizeof(opts));
while ((c = getopt_long(argc, argv, "+dhV", longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
total_opts++;
switch (c) {
case 'd':
dumplevel++;
break;
case NNP:
if (opts.nnp)
errx(EXIT_FAILURE,
_("duplicate --no-new-privs option"));
opts.nnp = 1;
break;
case RUID:
if (opts.have_ruid)
errx(EXIT_FAILURE, _("duplicate ruid"));
opts.have_ruid = 1;
pw = get_passwd(optarg, &opts.ruid, _("failed to parse ruid"));
if (pw) {
passwd_copy(&opts.passwd, pw);
opts.have_passwd = 1;
}
break;
case EUID:
if (opts.have_euid)
errx(EXIT_FAILURE, _("duplicate euid"));
opts.have_euid = 1;
opts.euid = get_user(optarg, _("failed to parse euid"));
//.........这里部分代码省略.........
开发者ID:Webster-WXH,项目名称:util-linux,代码行数:101,代码来源:setpriv.c
示例3: insert
bool ConfigManager::initialize()
{
if (isInitialized())
{
std::cerr << "CONFIG WARNING: The configuration framework is already initialized!" << std::endl;
return true;
}
if (Getopt::instance().paramOptPresent("configfile"))
{
// Read the configuration file.
icl_core::String filename = Getopt::instance().paramOpt("configfile");
if (!load(filename))
{
std::cerr << "CONFIG ERROR: The configuration file '" << filename << "' could not be loaded!"
<< std::endl;
return false;
}
insert(CONFIGFILE_CONFIG_KEY, filename);
notify(CONFIGFILE_CONFIG_KEY);
}
// Check for registered parameters.
for (ConfigParameterList::const_iterator it = m_parameter_list.begin(); it != m_parameter_list.end(); ++it)
{
if (it->configKey() != "")
{
// Fill the configuration parameter from the commandline.
if (Getopt::instance().paramOptPresent(it->option()))
{
insert(it->configKey(), Getopt::instance().paramOpt(it->option()));
notify(it->configKey());
}
// If the parameter is still not present but has a default value, then set it.
else if (!hasKey(it->configKey()) && it->hasDefaultValue())
{
insert(it->configKey(), it->defaultValue());
notify(it->configKey());
}
}
}
// Check for registered positional parameters.
for (ConfigPositionalParameterList::const_iterator it = m_postional_parameter_list.begin(); it != m_postional_parameter_list.end(); ++it)
{
if (it->configKey() != "")
{
// Fill the configuration parameter from the commandline.
if (Getopt::instance().paramOptPresent(it->name()))
{
insert(it->configKey(), Getopt::instance().paramOpt(it->name()));
notify(it->configKey());
}
// If the parameter is still not present but has a default value, then set it.
else if (!hasKey(it->configKey()) && it->hasDefaultValue())
{
insert(it->configKey(), it->defaultValue());
notify(it->configKey());
}
}
}
// Check for option parameters.
Getopt::KeyValueList option_params = Getopt::instance().paramPrefixOpt("config-option");
for (Getopt::KeyValueList::const_iterator it = option_params.begin(); it != option_params.end(); ++it)
{
insert(it->m_key, it->m_value);
notify(it->m_key);
}
// Optionally dump the configuration.
if (Getopt::instance().paramOptPresent("dump-config"))
{
dump();
}
m_initialized = true;
return true;
}
开发者ID:HumaRobotics,项目名称:fzi_icl_core,代码行数:79,代码来源:ConfigManager.cpp
示例4: dump
void ConsumerBase::dump(String8& result) const {
char buffer[1024];
dump(result, "", buffer, 1024);
}
开发者ID:Proshivalskiy,项目名称:MT6582_kernel_source,代码行数:4,代码来源:ConsumerBase.cpp
示例5: toString
string toString() { ostringstream oss; dump(oss); return oss.str(); }
开发者ID:jterweeme,项目名称:wincore,代码行数:1,代码来源:dd.cpp
示例6: switch
void AsiMS2000::selectCommand(int commandNum)
{
switch(commandNum)
{
case 0:
accel();
break;
case 1:
aalign();
break;
case 2:
afcont();
break;
case 3:
aflim();
break;
case 4:
afocus();
break;
case 5:
afset();
break;
case 6:
afmove();
break;
case 7:
ahome();
break;
case 8:
aij();
break;
case 9:
array();
break;
case 10:
azero();
break;
case 11:
backlash();
break;
case 12:
bcustom();
break;
case 13:
benable();
break;
case 14:
build();
break;
case 15:
cdate();
break;
case 16:
cnts();
break;
case 17:
customa();
break;
case 18:
customb();
break;
case 19:
dack();
break;
case 20:
dump();
break;
case 21:
ensync();
break;
case 22:
epolarity();
break;
case 23:
error();
break;
case 24:
halt();
break;
case 25:
here();
break;
case 26:
home();
break;
case 27:
info();
break;
case 28:
joystick();
break;
case 29:
jsspd();
break;
case 30:
kadc();
break;
case 31:
kd();
break;
//.........这里部分代码省略.........
开发者ID:AllenBurnham,项目名称:microscope,代码行数:101,代码来源:AsiMS2000.cpp
示例7: main
int main (void)
{
struct R1 A1 = My_R1;
struct R2 A2 = My_R2;
struct Nested1 N1;
struct Nested2 N2;
unsigned C1;
unsigned C2;
unsigned C3;
put ("A1 :");
dump (&A1, sizeof (struct R1));
new_line ();
/* { dg-output "A1 : c2 7b f3 2a 5e 12 9a 95\n" } */
put ("A2 :");
dump (&A2, sizeof (struct R2));
new_line ();
/* { dg-output "A2 : 09 e2 af 37 bd 24 d2 b4\n" } */
N1 = A1.N;
C1 = N1.C1;
C2 = N1.C2;
C3 = N1.C3;
printf ("C1 : %d\n", C1);
/* { dg-output "C1 : 18\n" } */
printf ("C2 : %d\n", C2);
/* { dg-output "C2 : 52\n" } */
printf ("C3 : %d\n", C3);
/* { dg-output "C3 : 86\n" } */
N1.C1 = C1;
N1.C2 = C2;
N1.C3 = C3;
A1.N = N1;
N2 = A2.N;
C1 = N2.C1;
C2 = N2.C2;
C3 = N2.C3;
printf ("C1 : %d\n", C1);
/* { dg-output "C1 : 18\n" } */
printf ("C2 : %d\n", C2);
/* { dg-output "C2 : 52\n" } */
printf ("C3 : %d\n", C3);
/* { dg-output "C3 : 86\n" } */
N2.C1 = C1;
N2.C2 = C2;
N2.C3 = C3;
A2.N = N2;
put ("A1 :");
dump (&A1, sizeof (struct R1));
new_line ();
/* { dg-output "A1 : c2 7b f3 2a 5e 12 9a 95\n" } */
put ("A2 :");
dump (&A2, sizeof (struct R2));
new_line ();
/* { dg-output "A2 : 09 e2 af 37 bd 24 d2 b4\n" } */
return 0;
}
开发者ID:shabesoglu,项目名称:gcc,代码行数:72,代码来源:s3.c
示例8: dump
void SurfaceMediaSource::dump(String8& result) const
{
char buffer[1024];
dump(result, "", buffer, 1024);
}
开发者ID:FirefoxSTE,项目名称:android_frameworks_av,代码行数:5,代码来源:SurfaceMediaSource.cpp
示例9: dump
inline void dump(const std::string& str, bool putColon = true)
{
dump(str.c_str(), str.size(), putColon);
}
开发者ID:herumi,项目名称:msoffice,代码行数:4,代码来源:util.hpp
示例10: main
int main (void)
{
struct R1 Local_R1;
struct R2 Local_R2;
Local_R1.I = My_R1.I + 1;
Local_R1.N.A[0] = My_R1.N.A[0] + 1;
Local_R1.N.A[1] = My_R1.N.A[1] + 1;
Local_R1.N.A[2] = My_R1.N.A[2] + 1;
put ("Local_R1 :");
dump (&Local_R1, sizeof (struct R1));
new_line ();
/* { dg-output "Local_R1 : 79 56 34 12 00 ab 00 13 00 cd 00 35 00 ef 00 57.*\n" } */
Local_R2.I = My_R2.I + 1;
Local_R2.N.A[0] = My_R2.N.A[0] + 1;
Local_R2.N.A[1] = My_R2.N.A[1] + 1;
Local_R2.N.A[2] = My_R2.N.A[2] + 1;
put ("Local_R2 :");
dump (&Local_R2, sizeof (struct R2));
new_line ();
/* { dg-output "Local_R2 : 12 34 56 79 13 00 ab 00 35 00 cd 00 57 00 ef 00.*\n" } */
Local_R1.I = 0x12345678;
Local_R1.N.A[0] = 0xAB0012;
Local_R1.N.A[1] = 0xCD0034;
Local_R1.N.A[2] = 0xEF0056;
put ("Local_R1 :");
dump (&Local_R1, sizeof (struct R1));
new_line ();
/* { dg-output "Local_R1 : 78 56 34 12 00 ab 00 12 00 cd 00 34 00 ef 00 56.*\n" } */
Local_R2.I = 0x12345678;
Local_R2.N.A[0] = 0xAB0012;
Local_R2.N.A[1] = 0xCD0034;
Local_R2.N.A[2] = 0xEF0056;
put ("Local_R2 :");
dump (&Local_R2, sizeof (struct R2));
new_line ();
/* { dg-output "Local_R2 : 12 34 56 78 12 00 ab 00 34 00 cd 00 56 00 ef 00.*\n" } */
Local_R1.I = Local_R1.I + 1;
Local_R1.N.A[0] = Local_R1.N.A[0] + 1;
Local_R1.N.A[1] = Local_R1.N.A[1] + 1;
Local_R1.N.A[2] = Local_R1.N.A[2] + 1;
put ("Local_R1 :");
dump (&Local_R1, sizeof (struct R1));
new_line ();
/* { dg-output "Local_R1 : 79 56 34 12 00 ab 00 13 00 cd 00 35 00 ef 00 57.*\n" } */
Local_R2.I = Local_R2.I + 1;
Local_R2.N.A[0] = Local_R2.N.A[0] + 1;
Local_R2.N.A[1] = Local_R2.N.A[1] + 1;
Local_R2.N.A[2] = Local_R2.N.A[2] + 1;
put ("Local_R2 :");
dump (&Local_R2, sizeof (struct R2));
new_line ();
/* { dg-output "Local_R2 : 12 34 56 79 13 00 ab 00 35 00 cd 00 57 00 ef 00.*\n" } */
return 0;
}
开发者ID:pjump,项目名称:gcc,代码行数:65,代码来源:t6.c
示例11: dump
void shader::dump_ir() {
if (ctx.dump_pass)
dump(*this).run();
}
开发者ID:DirectFB,项目名称:mesa,代码行数:4,代码来源:sb_shader.cpp
示例12: main
int
main(int argc, char **argv)
{
int ch, mode = 0;
char *arg = NULL;
pid = getpid();
thiszone = gmt2local(0);
while ((ch = getopt(argc, argv, "acd:f:Ii:nprstA:HPR")) != -1)
switch (ch) {
case 'a':
case 'c':
case 'p':
case 'r':
case 'H':
case 'P':
case 'R':
case 's':
case 'I':
if (mode) {
usage();
/*NOTREACHED*/
}
mode = ch;
arg = NULL;
break;
case 'f':
exit(file(optarg) ? 1 : 0);
case 'd':
case 'i':
if (mode) {
usage();
/*NOTREACHED*/
}
mode = ch;
arg = optarg;
break;
case 'n':
nflag = 1;
break;
case 't':
tflag = 1;
break;
case 'A':
if (mode) {
usage();
/*NOTREACHED*/
}
mode = 'a';
repeat = atoi(optarg);
if (repeat < 0) {
usage();
/*NOTREACHED*/
}
break;
default:
usage();
}
argc -= optind;
argv += optind;
switch (mode) {
case 'a':
case 'c':
if (argc != 0) {
usage();
/*NOTREACHED*/
}
dump(0, mode == 'c');
break;
case 'd':
if (argc != 0) {
usage();
/*NOTREACHED*/
}
delete(arg);
break;
case 'I':
#ifdef SIOCSDEFIFACE_IN6 /* XXX: check SIOCGDEFIFACE_IN6 as well? */
if (argc > 1) {
usage();
/*NOTREACHED*/
} else if (argc == 1) {
if (strcmp(*argv, "delete") == 0 ||
if_nametoindex(*argv))
setdefif(*argv);
else
errx(1, "invalid interface %s", *argv);
}
getdefif(); /* always call it to print the result */
break;
#else
errx(1, "not supported yet");
/*NOTREACHED*/
#endif
case 'p':
if (argc != 0) {
usage();
/*NOTREACHED*/
//.........这里部分代码省略.........
开发者ID:hmatyschok,项目名称:MeshBSD,代码行数:101,代码来源:ndp.c
示例13: main
//.........这里部分代码省略.........
//infunc.push_back(0.01,new TestFunc(2,1,1));
//infunc.push_back(0.01,new TestFunc(2,2,1));
//infunc.push_back(0.001,new TestFunc(2,1,2));
//infunc.push_back(0.001,new TestFunc(2,2,2));
//infunc.push_back(0.001,new TestFunc(5,5,5));
//infunc.push_back(-0.3,new TestFunc(7,2,3));
//infunc.push_back(0.01,new TestFunc(7,7,7));
//infunc.push_back(0.001,new TestFunc(5,5,5));
//Write to an array
std::vector<double> inData(npts[0]*npts[1]*npts[2]);
std::vector<double>::iterator it(inData.begin());
Pooma::Clock timer;
timer.start();
//Assign the values
for(int ix=0; ix<npts[0]; ix++) {
double x(gridX(ix));
for(int iy=0; iy<npts[1]; iy++) {
double y(gridY(iy));
for(int iz=0; iz<npts[2]; iz++) {
(*it)=infunc.f(x,y,gridZ(iz));++it;
}
}
}
timer.stop();
cout << "Time to evaluate " << timer.cpu_time() << endl;
//Test TriCubicSplineT function
//Create XYZCubicGrid
XYZCubicGrid<double> grid3(&gridX,&gridY,&gridZ);
//Create a TriCubicSpline with PBC: have to think more about fixed-boundary conditions
TriCubicSplineT<double> aorb(&grid3);
//Reset the coefficients
aorb.reset(inData.begin(), inData.end());
double lap,val;
TinyVector<double,3> grad;
//aorb.reset();
//Write for vtk ImageData
string fname("spline3d.vti");
std::ofstream dfile(fname.c_str());
dfile.setf(ios::scientific, ios::floatfield);
dfile.setf(ios::left,ios::adjustfield);
dfile.precision(10);
dfile << "<?xml version=\"1.0\"?>" << endl;
dfile << "<VTKFile type=\"ImageData\" version=\"0.1\">" << endl;
dfile << " <ImageData WholeExtent=\"0 " << npts[0]-2 << " 0 " << npts[1]-2 << " 0 " << npts[2]-2
<< "\" Origin=\"0 0 0\" Spacing=\"1 1 1\">"<< endl;
dfile << " <Piece Extent=\"0 " << npts[0]-2 << " 0 " << npts[1]-2 << " 0 " << npts[2]-2 << "\">" << endl;
dfile << " <PointData Scalars=\"wfs\">" << endl;
dfile << " <DataArray type=\"Float32\" Name=\"wfs\">" << endl;
timer.start();
int ng=0;
for(int ix=0; ix<npts[0]-1; ix++) {
double x(gridX(ix));
for(int iy=0; iy<npts[1]-1; iy++) {
double y(gridY(iy));
for(int iz=0; iz<npts[2]-1; iz++, ng++) {
TinyVector<double,3> p(x,y,gridZ(iz));
//aorb.setgrid(p);
//Timing with the ofstream is not correct.
//Uncomment the line below and comment out the next two line.
//double t=aorb.evaluate(p,grad,lap);
dfile << setw(20) << aorb.evaluate(p,grad,lap);
if(ng%5 == 4) dfile << endl;
}
}
}
timer.stop();
cout << "Time to evaluate with spline " << timer.cpu_time() << endl;
dfile << " </DataArray>" << endl;
dfile << " </PointData>" << endl;
dfile << " </Piece>" << endl;
dfile << " </ImageData>" << endl;
dfile << "</VTKFile>" << endl;
hid_t h_file = H5Fcreate("spline3d.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
HDFAttribIO<std::vector<double> > dump(inData,npts);
dump.write(h_file,"orb0000");
HDFAttribIO<TriCubicSplineT<double> > dump1(aorb);
dump1.write(h_file,"spline0000");
H5Fclose(h_file);
//double lap;
//TinyVector<double,3> grad;
//for(int k=0; k<nptY-1; k++) {
// //TinyVector<double,3> p(xcut,ycut,gridZ(k)+0.11*gridZ.dr(k));
// TinyVector<double,3> p(xcut,gridY(k)+0.11*gridY.dr(k),ycut);
// aorb.setgrid(p);
// double y=aorb.evaluate(p,grad,lap);
// dfile << setw(30) << p[1] << setw(30) << infunc.f(p) << setw(30) << y << setw(30) << infunc.d2f(p) << setw(30) << lap << endl;
//}
return 0;
}
开发者ID:digideskio,项目名称:qmcpack,代码行数:101,代码来源:spline3.cpp
示例14: main
int main(int argc, char **argv){
// Local variables
struct sockaddr_in our_addr;
void *buf = NULL;
int sock = -1;
unsigned int slen = 0;
int err = 0;
int i;
// Parse parameters
while ((i = getopt(argc, argv, "n:s:t:q")) != -1){
switch(i){
case 'n': // Number of packets
npkts = atoi(optarg);
break;
case 's': // Payload size
bufsz = atoi(optarg);
if (bufsz < sizeof(udpdata_t)){
fprintf(stderr, "Payload size must be at least %zd bytes\n",
sizeof(udpdata_t));
goto err;
}
break;
case 't': // Tolerance timer duration
toler_sec = atoi(optarg);
break;
case 'q': // Suppress per-packet output
suppress_dump = 1;
break;
default:
usage(argv[0]);
goto err;
}
}
// Initialise timer
timer_init();
// Allocate receive buffer
if ((udpdata = (udpdata_t *)calloc(npkts, sizeof(*udpdata))) == NULL)
{
perror("calloc");
goto err;
}
if ((buf = malloc(bufsz)) == NULL){
perror("malloc");
goto err;
}
// Handles kill
signal(SIGINT, sigterm_h);
// Handles timer
signal(SIGALRM, sigalrm_h);
// Setup UDP socket
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0){
perror("socket");
fprintf(stderr, "Error creating temporary socket.\n");
goto err;
}
memset(&our_addr, 0, sizeof(our_addr));
our_addr.sin_family = AF_INET;
our_addr.sin_addr.s_addr = INADDR_ANY;
our_addr.sin_port = htons(UDPPORT);
if (bind(sock, (struct sockaddr *)&our_addr, sizeof(struct sockaddr)) < 0){
perror("bind");
goto err;
}
// Receive packets
for (i=0; i<npkts; i++){
slen = sizeof(struct sockaddr);
err = recvfrom(sock, buf, bufsz, 0, (struct sockaddr *)&our_addr, &slen);
if (err < 0){
perror("recvfrom");
goto err;
} else
if (err != bufsz){
fprintf(stderr, "Received unknown packet.\n");
goto err;
}
memcpy(&udpdata[i], buf, sizeof(udpdata_t));
udpdata[i].tscrx = rdtsc();
timer_reset();
}
// Dump
dump();
out:
if (sock >= 0)
close(sock);
if (buf)
free(buf);
//.........这里部分代码省略.........
开发者ID:rosslagerwall,项目名称:udpgen,代码行数:101,代码来源:udprx.c
示例15: dump
std::string dump() const {
std::string out;
dump(out);
return out;
}
开发者ID:nathanworms,项目名称:ppconsul,代码行数:5,代码来源:json11.hpp
示例16: sigterm_h
void sigterm_h(int signal){
dump();
exit(0);
}
开发者ID:rosslagerwall,项目名称:udpgen,代码行数:4,代码来源:udprx.c
示例17: ss_encrypt_all
int ss_encrypt_all(buffer_t *plain, int method, int auth, size_t capacity)
{
if (method > TABLE) {
cipher_ctx_t evp;
cipher_context_init(&evp, method, 1);
size_t iv_len = enc_iv_len;
int err = 1;
static buffer_t tmp = { 0, 0, 0, NULL };
brealloc(&tmp, iv_len + plain->len, capacity);
buffer_t *cipher = &tmp;
cipher->len = plain->len;
uint8_t iv[MAX_IV_LENGTH];
rand_bytes(iv, iv_len);
cipher_context_set_iv(&evp, iv, iv_len, 1);
memcpy(cipher->array, iv, iv_len);
if (auth) {
ss_onetimeauth(plain, iv, capacity);
cipher->len = plain->len;
}
if (method >= SALSA20) {
crypto_stream_xor_ic((uint8_t *)(cipher->array + iv_len),
(const uint8_t *)plain->array, (uint64_t)(plain->len),
(const uint8_t *)iv,
0, enc_key, method);
} else {
err = cipher_context_update(&evp, (uint8_t *)(cipher->array + iv_len),
&cipher->len, (const uint8_t *)plain->array,
plain->len);
}
if (!err) {
bfree(plain);
cipher_context_release(&evp);
return -1;
}
#ifdef DEBUG
dump("PLAIN", plain->array, plain->len);
dump("CIPHER", cipher->array + iv_len, cipher->len);
#endif
cipher_context_release(&evp);
brealloc(plain, iv_len + cipher->len, capacity);
memcpy(plain->array, cipher->array, iv_len + cipher->len);
plain->len = iv_len + cipher->len;
return 0;
} else {
char *begin = plain->array;
char *ptr = plain->array;
while (ptr < begin + plain->len) {
*ptr = (char)enc_table[(uint8_t)*ptr];
ptr++;
}
return 0;
}
}
开发者ID:WODEDADIAO,项目名称:shadowsocks-libev,代码行数:64,代码来源:encrypt.c
示例18: tool_debug_cb
int tool_debug_cb(CURL *handle, curl_infotype type,
unsigned char *data, size_t size,
void *userdata)
{
struct OperationConfig *operation = userdata;
struct GlobalConfig *config = operation->global;
FILE *output = operation->errors;
const char *text;
struct timeval tv;
struct tm *now;
char timebuf[20];
time_t secs;
static time_t epoch_offset;
static int known_offset;
(void)handle; /* not used */
if(config->tracetime) {
tv = tvnow();
if(!known_offset) {
epoch_offset = time(NULL) - tv.tv_sec;
known_offset = 1;
}
secs = epoch_offset + tv.tv_sec;
now = localtime(&secs); /* not thread safe but we don't care */
snprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld ",
now->tm_hour, now->tm_min, now->tm_sec, (long)tv.tv_usec);
}
else
timebuf[0] = 0;
if(!config->trace_stream) {
/* open for append */
if(curlx_strequal("-", config->trace_dump))
config->trace_stream = stdout;
else if(curlx_strequal("%", config->trace_dump))
/* Ok, this is somewhat hackish but we do it undocumented for now */
config->trace_stream = operation->errors; /* aka stderr */
else {
config->trace_stream = fopen(config->trace_dump, "w");
config->trace_fopened = TRUE;
}
}
if(config->trace_stream)
output = config->trace_stream;
if(!output) {
warnf(operation, "Failed to create/open output");
return 0;
}
if(config->tracetype == TRACE_PLAIN) {
/*
* This is the trace look that is similar to what libcurl makes on its
* own.
*/
static const char * const s_infotype[] = {
"*", "<", ">", "{", "}", "{", "}"
};
size_t i;
size_t st = 0;
static bool newl = FALSE;
static bool traced_data = FALSE;
switch(type) {
case CURLINFO_HEADER_OUT:
if(size > 0) {
for(i = 0; i < size - 1; i++) {
if(data[i] == '\n') { /* LF */
if(!newl) {
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
}
(void)fwrite(data + st, i - st + 1, 1, output);
st = i + 1;
newl = FALSE;
}
}
if(!newl)
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
(void)fwrite(data + st, i - st + 1, 1, output);
}
newl = (size && (data[size - 1] != '\n')) ? TRUE : FALSE;
traced_data = FALSE;
break;
case CURLINFO_TEXT:
case CURLINFO_HEADER_IN:
if(!newl)
fprintf(output, "%s%s ", timebuf, s_infotype[type]);
(void)fwrite(data, size, 1, output);
newl = (size && (data[size - 1] != '\n')) ? TRUE : FALSE;
traced_data = FALSE;
break;
case CURLINFO_DATA_OUT:
case CURLINFO_DATA_IN:
case CURLINFO_SSL_DATA_IN:
case CURLINFO_SSL_DATA_OUT:
if(!traced_data) {
/* if the data is output to a tty and we're sending this debug trace
to stderr or stdout, we don't display the alert about the data not
//.........这里部分代码省略.........
开发者ID:devendra93,项目名称:curl,代码行数:101,代码来源:tool_cb_dbg.c
示例19: ss_encrypt
int ss_encrypt(buffer_t *plain, enc_ctx_t *ctx, size_t capacity)
{
if (ctx != NULL) {
static buffer_t tmp = { 0, 0, 0, NULL };
int err = 1;
size_t iv_len = 0;
if (!ctx->init) {
iv_len = enc_iv_len;
}
brealloc(&tmp, iv_len + plain->len, capacity);
buffer_t *cipher = &tmp;
cipher->len = plain->len;
if (!ctx->init) {
cipher_context_set_iv(&ctx->evp, ctx->evp.iv, iv_len, 1);
memcpy(cipher->array, ctx->evp.iv, iv_len);
ctx->counter = 0;
ctx->init = 1;
}
if (enc_method >= SALSA20) {
int padding = ctx->counter % SODIUM_BLOCK_SIZE;
brealloc(cipher, iv_len + (padding + cipher->len) * 2, capacity);
if (padding) {
brealloc(plain, plain->len + padding, capacity);
memmove(plain->array + padding, plain->array, plain->len);
sodium_memzero(plain->array, padding);
}
crypto_stream_xor_ic((uint8_t *)(cipher->array + iv_len),
(const uint8_t *)plain->array,
(uint64_t)(plain->len + padding),
(const uint8_t *)ctx->evp.iv,
ctx->counter / SODIUM_BLOCK_SIZE, enc_key,
enc_method);
ctx->counter += plain->len;
if (padding) {
memmove(cipher->array + iv_len,
cipher->array + iv_len + padding, cipher->len);
}
} else {
err =
cipher_context_update(&ctx->evp,
(uint8_t *)(cipher->array + iv_len),
&cipher->len, (const uint8_t *)plain->array,
plain->len);
if (!err) {
return -1;
}
}
#ifdef DEBUG
dump("PLAIN", plain->array, plain->len);
dump("CIPHER", cipher->array + iv_len, cipher->len);
#endif
brealloc(plain, iv_len + cipher->len, capacity);
memcpy(plain->array, cipher->array, iv_len + cipher->len);
plain->len = iv_len + cipher->len;
return 0;
} else {
char *begin = plain->array;
char *ptr = plain->array;
while (ptr < begin + plain->len) {
*ptr = (char)enc_table[(uint8_t)*ptr];
ptr++;
}
return 0;
}
}
开发者ID:WODEDADIAO,项目名称:shadowsocks-libev,代码行数:72,代码来源:encrypt.c
示例20: cgen64
/*
* attempt to generate 64-bit
* res = n
* return 1 on success, 0 if op not handled.
*/
void
cgen64(Node *n, Node *res)
{
Node t1, t2, *l, *r;
Node lo1, lo2, hi1, hi2;
Node al, ah, bl, bh, cl, ch, s, n1, creg;
Prog *p1, *p2, *p3, *p4, *p5, *p6;
uint64 v;
if(res->op != OINDREG && res->op != ONAME) {
dump("n", n);
dump("res", res);
fatal("cgen64 %O of %O", n->op, res->op);
}
l = n->left;
if(!l->addable) {
tempname(&t1, l->type);
cgen(l, &t1);
l = &t1;
}
split64(l, &lo1, &hi1);
switch(n->op) {
default:
fatal("cgen64 %O", n->op);
case OMINUS:
split64(res, &lo2, &hi2);
regalloc(&t1, lo1.type, N);
regalloc(&al, lo1.type, N);
regalloc(&ah, hi1.type, N);
gins(AMOVW, &lo1, &al);
gins(AMOVW, &hi1, &ah);
gmove(ncon(0), &t1);
p1 = gins(ASUB, &al, &t1);
p1->scond |= C_SBIT;
gins(AMOVW, &t1, &lo2);
gmove(ncon(0), &t1);
gins(ASBC, &ah, &t1);
gins(AMOVW, &t1, &hi2);
regfree(&t1);
regfree(&al);
regfree(&ah);
splitclean();
splitclean();
return;
case OCOM:
split64(res, &lo2, &hi2);
regalloc(&n1, lo1.type, N);
gins(AMOVW, &lo1, &n1);
gins(AMVN, &n1, &n1);
gins(AMOVW, &n1, &lo2);
gins(AMOVW, &hi1, &n1);
gins(AMVN, &n1, &n1);
gins(AMOVW, &n1, &hi2);
regfree(&n1);
splitclean();
splitclean();
return;
case OADD:
case OSUB:
case OMUL:
case OLSH:
case ORSH:
case OAND:
case OOR:
case OXOR:
// binary operators.
// common setup below.
break;
}
// setup for binary operators
r = n->right;
if(r != N && !r->addable) {
tempname(&t2, r->type);
cgen(r, &t2);
r = &t2;
}
if(is64(r->type))
split64(r, &lo2, &hi2);
regalloc(&al, lo1.type, N);
//.........这里部分代码省略.........
开发者ID:8l,项目名称:go-learn,代码行数:101,代码来源:cgen64.c
注:本文中的dump函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论