本文整理汇总了C++中writef函数的典型用法代码示例。如果您正苦于以下问题:C++ writef函数的具体用法?C++ writef怎么用?C++ writef使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了writef函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: umain
void umain()
{
int a = 0;
int id = 0;
if ((id = fork()) == 0) {
if ((id = fork()) == 0) {
a += 3;
for (;;) {
writef("\t\tthis is child2 :a:%d\n", a);
}
}
a += 2;
for (;;) {
writef("\tthis is child :a:%d\n", a);
}
}
a++;
for (;;) {
writef("this is father: a:%d\n", a);
}
}
示例2: write
int
write(int fdnum, const void *buf, u_int n)
{
int r;
struct Dev *dev;
struct Fd *fd;
if ((r = fd_lookup(fdnum, &fd)) < 0
|| (r = dev_lookup(fd->fd_dev_id, &dev)) < 0) {
return r;
}
if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
writef("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
return -E_INVAL;
}
if (debug) writef("write %d %p %d via dev %s\n",
fdnum, buf, n, dev->dev_name);
r = (*dev->dev_write)(fd, buf, n, fd->fd_offset);
if (r > 0) {
fd->fd_offset += r;
}
return r;
}
示例3: umain
void
umain(int argc, char **argv)
{
int fd, r, n, n2;
if ((fd = open("motd", O_RDONLY)) < 0)
user_panic("open motd: %e", fd);
seek(fd, 0);
if ((n = readn(fd, buf, sizeof buf)) <= 0)
user_panic("readn: %e", n);
if ((r = fork()) < 0)
user_panic("fork: %e", r);
if (r == 0) {
seek(fd, 0);
writef("going to read in child (might page fault if your sharing is buggy)\n");
if ((n2 = readn(fd, buf2, sizeof buf2)) != n2)
user_panic("read in parent got %d, read in child got %d", n, n2);
if(memcmp(buf, buf2, n) != 0)
user_panic("read in parent got different bytes from read in child");
writef("read in child succeeded\n");
seek(fd, 0);
close(fd);
exit();
}
wait(r);
//seek(fd, 0);
if ((n2 = readn(fd, buf2, sizeof buf2)) != n)
user_panic("read in parent got %d, then got %d", n, n2);
writef("buf : %s\n",buf);
writef("read in parent succeeded\n");
}
示例4: pack_write_dir
bool_t pack_write_dir(restable_t *rt)
{
size_t i;
size_t offset;
offset = ftell(rt->file);
fseek(rt->file, 0, SEEK_SET);
if (writef(rt->file, "c4l4l4", PACK_IDENT, offset, rt->number * PACK_ENTRY_SIZE) != OK)
{
fprintf(stderr, "pack_write_dir: Can't write header.\n");
return FALSE;
}
fseek(rt->file, offset, SEEK_SET);
for(i = 0; i < rt->number; i++)
{
if (writef(rt->file, "s56l4l4",
rt->entries[i].name,
rt->entries[i].offset,
rt->entries[i].size) != OK)
{
fprintf(stderr, "pack_write_dir: Can't write entry #%u.\n", i);
return FALSE;
}
}
return TRUE;
}
示例5: showcelltype
void showcelltype(void)
/* Prints the type of cell and what is in it */
{
char colstr[3], *s;
int color;
formdisplay = !formdisplay;
s = cellstring(curcol, currow, &color, NOFORMAT);
colstring(curcol, colstr);
if (curcell == NULL)
writef(1, 23, CELLTYPECOLOR, 80, "%s%d %s", colstr, currow + 1, MSGEMPTY);
else switch(curcell->attrib)
{
case TEXT :
writef(1, 23, CELLTYPECOLOR, 80, "%s%d %s", colstr, currow + 1,
MSGTEXT);
break;
case VALUE :
writef(1, 23, CELLTYPECOLOR, 80, "%s%d %s", colstr, currow + 1,
MSGVALUE);
break;
case FORMULA :
writef(1, 23, CELLTYPECOLOR, 80, "%s%d %s", colstr, currow + 1,
MSGFORMULA);
break;
} /* switch */
writef(1, 24, CELLCONTENTSCOLOR, 80, "%s", s);
formdisplay = !formdisplay;
} /* showcelltype */
示例6: grp_write_dir
bool_t grp_write_dir(restable_t *rt)
{
size_t i;
size_t offset;
offset = ftell(rt->file);
fseek(rt->file, 0, SEEK_SET);
if (writef(rt->file, "c12l4", GRP_IDENT, rt->number) != OK)
{
fprintf(stderr, "grp_read_dir: Can't write header.\n");
return FALSE;
}
for(i = 0; i < rt->number; i++)
{
if (writef(rt->file, "s12l4",
rt->entries[i].name,
rt->entries[i].size) != OK)
{
fprintf(stderr, "grp_write_dir: Can't write entry #%u.\n", i);
return FALSE;
}
}
fseek(rt->file, offset, SEEK_SET);
return TRUE;
}
示例7: gob_write_dir
bool_t gob_write_dir(restable_t *rt)
{
size_t i;
size_t offset;
offset = ftell(rt->file);
fseek(rt->file, 0, SEEK_SET);
if (writef(rt->file, "c4l4", GOB_IDENT, offset) != OK)
{
fprintf(stderr, "gob_write_dir: Can't write header.\n");
return FALSE;
}
fseek(rt->file, offset, SEEK_SET);
if (writef(rt->file, "l4", rt->number) != OK)
{
fprintf(stderr, "gob_write_dir: Can't write number of entries.\n");
return FALSE;
}
for(i = 0; i < rt->number; i++)
{
if (writef(rt->file, "l4l4s13",
rt->entries[i].offset,
rt->entries[i].size,
rt->entries[i].name) != OK)
{
fprintf(stderr, "gob_write_dir: Can't write entry #%u.\n", i);
return FALSE;
}
}
return TRUE;
}
示例8: printPrompt
void ConsoleSession::onCommand(const std::vector<std::string>& args) {
if(args.empty()) {
printPrompt();
return;
}
const std::string& commandName = args[0];
std::vector<std::string> commandArgs(args.begin() + 1, args.end());
const ConsoleCommands::Command* command = consoleCommands->getCommand(commandName);
if(!command) {
writef("Unknown command : %s\r\n", commandName.c_str());
} else {
ConsoleCommands::Command::CallStatus status = command->call(this, commandArgs);
switch(status) {
case ConsoleCommands::Command::CS_Success:
break;
case ConsoleCommands::Command::CS_NotEnoughArgs:
write("Not enough arguments\r\n");
break;
case ConsoleCommands::Command::CS_TooMuchArgs:
write("Too many arguments\r\n");
break;
};
if(status != ConsoleCommands::Command::CS_Success) {
writef("Usage:\r\n%s\r\n", command->usageExample.c_str());
}
}
printPrompt();
}
示例9: write
ssize_t
write(int fd, const void *buf, size_t sz)
{
struct openposixfile* of = ofposix_find(posix_files, fd_of, &fd);
if(of == NULL) {
return writef(fd, buf, sz);
}
TRACE(posix, "writing %zu bytes to %d", sz, fd);
stream(transferlibs, of->name, buf, sz);
/* It will cause us a lot of problems if a write ends up being short, and the
* application then resubmits the next part of the partial write. So,
* iterate and make sure we avoid any partial writes. */
{
ssize_t written = 0;
do {
errno=0;
ssize_t bytes = writef(fd, ((const char*)buf)+written, sz-written);
if(bytes == -1 && errno == EINTR) { continue; }
if(bytes == -1 && written == 0) { return -1; }
if(bytes == -1) { return written; }
written += bytes;
} while((size_t)written < sz);
return written;
}
}
示例10: do_wri
int do_wri(u8 * file){
s8 ret,fd;
u32 retlba ;
u8 i=0;
u32 ch;
u8 buff[256] = {0};
if (!check_for_args(WRI,1))return 1;
fd = openf(file,O_RW);
if ( fd == -1){
retlba=NO_LBA;
if (ERROR_NO == NO_DIR_FILE)
retlba = creatf(file , 064);
if (retlba == NO_LBA){
vd_puts ( "COULD NOT OPEN OR CREATE THE DESTINATION FILE\n" );
errormessage(geterror());
closef(fd);
fl_clean();
return 0;
}
fd = openf(file,O_RW);
}
if(fd == -1){
vd_puts("CANNOT OPEN THE FILE\n");
errormessage(geterror());
fl_clean();
return 1;
}
while(1){
ch=getche();
if(ch == 1)
break;
if( ch == 13 || ch == 10){printf("\n"); ch = '\n';}
if (i == 255){
i=0;
ret = writef(fd,buff,256);
if(ret == -1){
vd_puts("SORRY SORRY CANNOT WRITE TO FILE SO REMOVING IT\n");
errormessage(geterror());
unlinkf(file);
fl_clean();
return 1;
}
}
buff[i++] = ch;
}
ret = writef(fd,buff,i);
if(ret == -1){
vd_puts("SORRY SORRY CANNOT WRITE TO FILE SO REMOVING IT\n");
errormessage(geterror());
unlinkf(file);
fl_clean();
return 1;
}
closef(fd);
vd_puts(" \n");
fl_clean();
return 0;
}
示例11: serve_open
void
serve_open(u_int envid, struct Fsreq_open *rq)
{
writef("serve_open %08x %x 0x%x\n", envid, (int)rq->req_path, rq->req_omode);
u_char path[MAXPATHLEN];
struct File *f;
struct Filefd *ff;
int fileid;
int r;
struct Open *o;
// Copy in the path, making sure it's null-terminated
user_bcopy(rq->req_path, path, MAXPATHLEN);
path[MAXPATHLEN - 1] = 0;
//writef("serve_open:enter open %s\n",rq->req_path);
// Find a file id.
if ((r = open_alloc(&o)) < 0) {
writef("open_alloc failed: %d", r);
goto out;
}
fileid = r;
//writef("serve_open:ending find a file id o = %x\n",o);
// Open the file.
if ((r = file_open((char *)path, &f)) < 0) {
writef("file_open failed: %e", r);
goto out;
}
//writef("serve_open:ending open the file\n");
// Save the file pointer.
o->o_file = f;
// Fill out the Filefd structure
ff = (struct Filefd *)o->o_ff;
ff->f_file = *f;
ff->f_fileid = o->o_fileid;
o->o_mode = rq->req_omode;
ff->f_fd.fd_omode = o->o_mode;
ff->f_fd.fd_dev_id = devfile.dev_id;
//writef("serve_open:will to ipc send\n");
if (debug) {
writef("sending success, page %08x\n", (u_int)o->o_ff);
}
ipc_send(envid, 0, (u_int)o->o_ff, PTE_V | PTE_R | PTE_LIBRARY);
//writef("serve_open:end of open %s\n",rq->req_path);
return;
out:
user_panic("*********************path:%s", path);
ipc_send(envid, r, 0, 0);
}
示例12: errormsg
void errormsg(char *s)
/* Prints an error message at the bottom of the screen */
{
printf("%c", 7); /* Beeps the speaker */
writef(1, 25, ERRORCOLOR, 79, "%s %s", s, MSGKEYPRESS);
gotoxy(strlen(s) + strlen(MSGKEYPRESS) + 3, 25);
getkey();
gotoxy(1, 25);
writef(1, 25, WHITE, 79, "");
} /* errormsg */
示例13: serve
void
serve(void)
{
u_int req, whom, perm;
for (;;) {
perm = 0;
req = ipc_recv(&whom, REQVA, &perm);
// All requests must contain an argument page
if (!(perm & PTE_V)) {
writef("Invalid request from %08x: no argument page\n",
whom);
continue; // just leave it hanging...
}
switch (req) {
case FSREQ_OPEN:
serve_open(whom, (struct Fsreq_open *)REQVA);
break;
case FSREQ_MAP:
serve_map(whom, (struct Fsreq_map *)REQVA);
break;
case FSREQ_SET_SIZE:
serve_set_size(whom, (struct Fsreq_set_size *)REQVA);
break;
case FSREQ_CLOSE:
serve_close(whom, (struct Fsreq_close *)REQVA);
break;
case FSREQ_DIRTY:
serve_dirty(whom, (struct Fsreq_dirty *)REQVA);
break;
case FSREQ_REMOVE:
serve_remove(whom, (struct Fsreq_remove *)REQVA);
break;
case FSREQ_SYNC:
serve_sync(whom);
break;
default:
writef("Invalid request code %d from %08x\n", whom, req);
break;
}
syscall_mem_unmap(0, REQVA);
}
}
示例14: redrawscreen
void redrawscreen(void)
/* Displays the entire screen */
{
setrightcol();
setbottomrow();
writef(1, 1, MSGMEMORYCOLOR, strlen(MSGMEMORY), MSGMEMORY);
writef(29, 1, PROMPTCOLOR, strlen(MSGCOMMAND), MSGCOMMAND);
changeautocalc(autocalc);
changeformdisplay(formdisplay);
printfreemem();
displayscreen(NOUPDATE);
} /* redrawscreen */
示例15: output
/* ................................ OUTPUT ............................. */
void output (FILE *Fptr[], double T)
{
int i1;
/* Evaluate output quantities */
k = 0.125*(m*pow(z[4],2)+4*i*pow(z[3],2))*pow(omega,2);
p = -0.5*g*l*m*z[1];
longoutput = 2 + 2*theta + p + z[1] + omega + 0.125*(m*pow(z[4],2)+4*i*pow(
z[3],2))*pow(omega,2);
z[13] = z[8]*z[1]*z[4]/z[11];
z[14] = (m*pow(z[4],2)+4*i*pow(z[3],2))*omega;
z[16] = z[15]*z[2];
z[17] = 1 + 0.25*(m*pow(z[4],2)+4*i*pow(z[3],2))*omega;
/* Write output to screen and to output file(s) */
writef(stdout, " %- 14.6E", omega,theta,k,p,longoutput,_NAN);
writef(Fptr[1]," %- 14.6E", omega,theta,k,p,longoutput,_NAN);
A[0][0] = 0;
A[0][1] = -0.5*z[13];
A[1][0] = 1;
A[1][1] = 0;
B[0][0] = z[3]/z[11];
B[0][1] = -0.5*z[4]/z[11];
B[1][0] = 0;
B[1][1] = 0;
C[0][0] = 1;
C[0][1] = 0;
C[1][0] = 0;
C[1][1] = 1;
C[2][0] = 0.25*z[14];
C[2][1] = 0;
C[3][0] = 0;
C[3][1] = 0.5*z[16];
C[4][0] = z[17];
C[4][1] = 2 + 0.5*z[16] - sin(theta);
D[0][0] = 0;
D[0][1] = 0;
D[1][0] = 0;
D[1][1] = 0;
D[2][0] = 0;
D[2][1] = 0;
D[3][0] = 0;
D[3][1] = 0;
D[4][0] = 0;
D[4][1] = 0;
Encode[0] = 0.0;
Encode[1] = 0.0;
Encode[2] = 0.0;
Encode[3] = 0.0;
}