本文整理汇总了C++中write_output函数的典型用法代码示例。如果您正苦于以下问题:C++ write_output函数的具体用法?C++ write_output怎么用?C++ write_output使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write_output函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logger_command_line
static void logger_command_line(const struct logger_ctl *ctl, char **argv)
{
/* note: we never re-generate the syslog header here, even if we
* generate multiple messages. If so, we think it is the right thing
* to do to report them with the same timestamp, as the user actually
* intended to send a single message.
*/
char *const buf = xmalloc(ctl->max_message_size + 1);
char *p = buf;
const char *endp = buf + ctl->max_message_size - 1;
size_t len;
while (*argv) {
len = strlen(*argv);
if (endp < p + len && p != buf) {
write_output(ctl, buf);
p = buf;
}
if (ctl->max_message_size < len) {
(*argv)[ctl->max_message_size] = '\0'; /* truncate */
write_output(ctl, *argv++);
continue;
}
if (p != buf)
*p++ = ' ';
memmove(p, *argv++, len);
*(p += len) = '\0';
}
if (p != buf)
write_output(ctl, buf);
free(buf);
}
示例2: clear_program_state_action
static void
clear_program_state_action (Widget w, XtPointer client_data,
XtPointer call_data)
{
long clear_op = (long) client_data;
switch (clear_op)
{
case CLEAR_REGS:
write_output (message_out, "Registers cleared\n\n");
initialize_registers ();
break;
case CLEAR_MEM_REGS:
write_output (message_out, "Memory and registers cleared\n\n");
initialize_world (load_exception_handler ? exception_file_name : NULL);
write_startup_message ();
break;
case CLEAR_CONSOLE:
write_output (message_out, "Console display cleared\n\n");
clear_console_display ();
break;
default:
fatal_error("Unknown action: %d\n", clear_op);
}
redisplay_text ();
redisplay_data ();
}
示例3: write_opcodes
char write_opcodes (void)
{
char err;
opcs = get_opcodes();
if (pass == 1)
{
addr = addr + opcs;
return;
}
if (pass==2)
{
if (opcs == 0)
{
opc0 = get_opcode0();
err = write_output(addr,0,(unsigned char *)file_line,line);
}
if (opcs == 1)
{
opc0 = get_opcode0();
err = write_output(addr,opc0,(unsigned char *)file_line,line);
addr++;
}
if (opcs == 2)
{
opc0 = get_opcode0();
opc1 = get_opcode1();
err = write_output(addr,opc0,(unsigned char *)file_line,line);
addr++;
err = write_output(addr,opc1,(unsigned char *)"",line);
addr++;
}
}
return err;
}
示例4: lasikbd_leds
static void lasikbd_leds(unsigned char leds)
{
int loop = 1000;
if (!lasikbd_hpa)
return;
cmd_status=2;
while (cmd_status!=0 && --loop > 0) {
write_output(KBD_CMD_SET_LEDS, lasikbd_hpa);
mdelay(5);
}
cmd_status=2;
while (cmd_status!=0 && --loop > 0) {
write_output(leds, lasikbd_hpa);
mdelay(5);
}
cmd_status=2;
while (cmd_status!=0 && --loop > 0) {
write_output(KBD_CMD_ENABLE, lasikbd_hpa);
mdelay(5);
}
if (loop <= 0)
printk("lasikbd_leds: timeout\n");
}
示例5: mmap_read
static void mmap_read(struct mmap_data *md)
{
unsigned int head = mmap_read_head(md);
unsigned int old = md->prev;
unsigned char *data = md->base + page_size;
unsigned long size;
void *buf;
int diff;
gettimeofday(&this_read, NULL);
/*
* If we're further behind than half the buffer, there's a chance
* the writer will bite our tail and mess up the samples under us.
*
* If we somehow ended up ahead of the head, we got messed up.
*
* In either case, truncate and restart at head.
*/
diff = head - old;
if (diff < 0) {
struct timeval iv;
unsigned long msecs;
timersub(&this_read, &last_read, &iv);
msecs = iv.tv_sec*1000 + iv.tv_usec/1000;
fprintf(stderr, "WARNING: failed to keep up with mmap data."
" Last read %lu msecs ago.\n", msecs);
/*
* head points to a known good entry, start there.
*/
old = head;
}
last_read = this_read;
if (old != head)
samples++;
size = head - old;
if ((old & md->mask) + size != (head & md->mask)) {
buf = &data[old & md->mask];
size = md->mask + 1 - (old & md->mask);
old += size;
write_output(buf, size);
}
buf = &data[old & md->mask];
size = head - old;
old += size;
write_output(buf, size);
md->prev = old;
mmap_write_tail(md, old);
}
示例6: go
void go() override
{
std::unique_ptr<Botan::Private_Key> key;
std::string pass_in = get_arg("pass-in");
if (pass_in.empty())
{
key.reset(Botan::PKCS8::load_key(get_arg("key"), rng()));
}
else
{
key.reset(Botan::PKCS8::load_key(get_arg("key"), rng(), pass_in));
}
const std::chrono::milliseconds pbe_millis(get_arg_sz("pbe-millis"));
const std::string pbe = get_arg("pbe");
const bool der_out = flag_set("der-out");
if(flag_set("pub-out"))
{
if(der_out)
{
write_output(Botan::X509::BER_encode(*key));
}
else
{
output() << Botan::X509::PEM_encode(*key);
}
}
else
{
const std::string pass_out = get_arg("pass-out");
if(der_out)
{
if(pass_out.empty())
{
write_output(Botan::PKCS8::BER_encode(*key));
}
else
{
write_output(Botan::PKCS8::BER_encode(*key, rng(), pass_out, pbe_millis, pbe));
}
}
else
{
if(pass_out.empty())
{
output() << Botan::PKCS8::PEM_encode(*key);
}
else
{
output() << Botan::PKCS8::PEM_encode(*key, rng(), pass_out, pbe_millis, pbe);
}
}
}
}
示例7: list_breakpoints
void
list_breakpoints ()
{
bkpt *b;
if (bkpts)
for (b = bkpts; b != NULL; b = b->next)
write_output (message_out, "Breakpoint at 0x%08x\n", b->addr);
else
write_output (message_out, "No breakpoints set\n");
}
示例8: WRITE8_HANDLER
static WRITE8_HANDLER( firetrk_out_w )
{
if (GAME_IS_FIRETRUCK || GAME_IS_MONTECARLO)
{
write_output(data);
}
if (GAME_IS_SUPERBUG)
{
write_output(offset);
}
}
示例9: main
int main(int argc, char *argv[])
{
bool success = true;
if (argc < 3) {
std::cerr << "Syntax error: use" << std::endl;
std::cerr << argv[0] << " classname inputpath" << std::endl;
return 1;
}
std::string modname(argv[1]);
std::string inputpath(argv[2]);
std::string ifname = inputpath + std::string("/") + modname + std::string("_tests.un");
std::string impl_fname = modname + std::string("_test_impls-tmp.F90");
std::string calls_fname = modname + std::string("_test_calls.F90");
std::string list_fname = modname + std::string("_tests.tests");
std::string mpilist_fname = modname + std::string("_tests.mpitests");
std::vector<std::string> input, output;
try {
success = success && read_template(ifname, input);
success = success && replace_modname(modname, input);
success = success && parse_impl(ifname, input, output);
success = success && write_output(impl_fname, output);
output.clear();
success = success && parse_calls(ifname, input, output);
success = success && write_output(calls_fname, output);
output.clear();
success = success && parse_list(ifname, input, output);
success = success && write_output(list_fname, output);
output.clear();
success = success && parse_mpilist(ifname, input, output);
success = success && write_output(mpilist_fname, output);
output.clear();
} catch (ParserException &ex) {
std::cerr << "Caught exception: " << ex.getMsg() << std::endl;
success = false;
} catch (std::string &ex) {
std::cerr << "Caught exception: " << ex << std::endl;
success = false;
} catch (...) {
std::cerr << "Caught unknown exception." << std::endl;
success = false;
}
return (success ? 0 : 1);
}
示例10: run
int run(int argc, const char** argv) {
options opts;
if(int err = parse_options(argc, argv, opts)) {
return err;
}
if(opts.output_path.value() == eagine::cstr_ref("-")) {
write_output(std::cout, opts);
} else {
std::ofstream output_file(opts.output_path.value().c_str());
write_output(output_file, opts);
}
return 0;
}
示例11: mp3_close
static void mp3_close(void)
{
if (output_file) {
int imp3, encout;
/* write remaining mp3 data */
encout = lame_encode_flush_nogap(gfp, encbuffer, LAME_MAXMP3BUFFER);
write_output(encbuffer, encout);
/* set gfp->num_samples for valid TLEN tag */
lame_set_num_samples(gfp, numsamples);
/* append v1 tag */
imp3 = lame_get_id3v1_tag(gfp, encbuffer, sizeof(encbuffer));
if (imp3 > 0)
write_output(encbuffer, imp3);
/* update v2 tag */
imp3 = lame_get_id3v2_tag(gfp, encbuffer, sizeof(encbuffer));
if (imp3 > 0) {
if (vfs_fseek(output_file, 0, SEEK_SET) != 0) {
AUDDBG("can't rewind\n");
}
else {
write_output(encbuffer, imp3);
}
}
/* update lame tag */
if (id3v2_size) {
if (vfs_fseek(output_file, id3v2_size, SEEK_SET) != 0) {
AUDDBG("fatal error: can't update LAME-tag frame!\n");
}
else {
imp3 = lame_get_lametag_frame(gfp, encbuffer, sizeof(encbuffer));
write_output(encbuffer, imp3);
}
}
}
g_free (write_buffer);
lame_close(gfp);
AUDDBG("lame_close() done\n");
free_lameid3(&lameid3);
numsamples = 0;
}
示例12: mp3_write
static void mp3_write(void *ptr, gint length)
{
gint encoded;
if (write_buffer_size == 0)
{
write_buffer_size = 8192;
write_buffer = g_realloc (write_buffer, write_buffer_size);
}
RETRY:
if (input.channels == 1)
encoded = lame_encode_buffer (gfp, ptr, ptr, length / 2, write_buffer,
write_buffer_size);
else
encoded = lame_encode_buffer_interleaved (gfp, ptr, length / 4,
write_buffer, write_buffer_size);
if (encoded == -1)
{
write_buffer_size *= 2;
write_buffer = g_realloc (write_buffer, write_buffer_size);
goto RETRY;
}
if (encoded > 0)
write_output (write_buffer, encoded);
numsamples += length / (2 * input.channels);
}
示例13: main
int main(int argc, char *argv[])
{
PetscErrorCode ierr;
params params;
Mat H;
SlepcInitialize(&argc,&argv,(char*)0,help);
ierr = PetscPrintf(PETSC_COMM_WORLD,"--------------------------------------------------------------------------------------\n");CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD," _______ __ __ _______ _______ ______ _______ \n");CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD," |__ __| \\/ |/ ____\\ \\ / /_ _| ____|__ __| \n");CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD," | | | \\ / | (___ \\ \\ /\\ / / | | | |__ | | \n");CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD," | | | |\\/| |\\___ \\ \\ \\/ \\/ / | | | __| | | \n");CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD," | | | | | |____) | \\ /\\ / _| |_| | | | \n");CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD," |_| |_| |_|_____/ \\/ \\/ |_____|_| |_| \n");CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD," True Muonium Solver with Iterative Front-Form Techniques \n");CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD," \n");CHKERRQ(ierr);
ierr = PetscPrintf(PETSC_COMM_WORLD,"--------------------------------------------------------------------------------------\n");CHKERRQ(ierr);
read_input(ierr,argv,¶ms);
print_input(ierr,¶ms);
if(check_file(params.hfile))
{
PetscViewer viewer_H;
PetscViewerBinaryOpen(PETSC_COMM_WORLD,params.hfile.c_str(),FILE_MODE_READ,&viewer_H);
MatCreate(PETSC_COMM_WORLD,&H);
MatSetFromOptions(H);
MatLoad(H,viewer_H);
PetscViewerDestroy(&viewer_H);
}else
{
discretize(ierr,¶ms);
// ierr = VecView(params.mu,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
// ierr = VecView(params.theta,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
write_output(ierr,¶ms);
coulomb_trick(ierr,¶ms);
// ierr = VecView(params.CT,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
ct_discrete(ierr,¶ms);
// ierr = VecView(params.CT,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
hamiltonian(ierr,¶ms,H);
// ierr = PetscViewerSetFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_DENSE);//DENSE<-->COMMON
// MatView(H,PETSC_VIEWER_STDOUT_WORLD);
}
cleanup(ierr,¶ms);
eigensolver(ierr,¶ms,H,argc,argv);
ierr = MatDestroy(&H);CHKERRQ(ierr);
ierr = SlepcFinalize();
return 0;
}
示例14: render_pdf
/** Reads an skp file, renders it to pdf and writes the output to a pdf file
* @param inputPath The skp file to be read.
* @param outputDir Output dir.
* @param renderer The object responsible to render the skp object into pdf.
*/
static bool render_pdf(const SkString& inputPath, const SkString& outputDir,
sk_tools::PdfRenderer& renderer) {
SkString inputFilename;
sk_tools::get_basename(&inputFilename, inputPath);
SkFILEStream inputStream;
inputStream.setPath(inputPath.c_str());
if (!inputStream.isValid()) {
SkDebugf("Could not open file %s\n", inputPath.c_str());
return false;
}
bool success = false;
SkAutoTUnref<SkPicture>
picture(SkNEW_ARGS(SkPicture, (&inputStream, &success)));
if (!success) {
SkDebugf("Could not read an SkPicture from %s\n", inputPath.c_str());
return false;
}
SkDebugf("exporting... [%i %i] %s\n", picture->width(), picture->height(),
inputPath.c_str());
renderer.init(picture);
renderer.render();
success = write_output(outputDir, inputFilename, renderer);
renderer.end();
return success;
}
示例15: main
int main( int argc, char *argv[] )
{
if ( argc != 2 )
{
std::cout << "usage: " << argv[0] << " N " << "\n";
return 1;
}
int N = atoi( argv[1] );
assert( N > 1 );
double h = N / 100.0;
double y = 1;
std::ofstream write_output("xy.dat");
assert(write_output.is_open());
write_output.setf(std::ios::scientific);
write_output.setf(std::ios::showpos);
write_output.precision(4);
for ( double i = 0; i < N; i += h )
{
y += h * (-i);
write_output << i << " " << y << "\n";
}
write_output << "\n";
write_output.flush();
write_output.close();
return 0;
}