本文整理汇总了C++中Cprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ Cprintf函数的具体用法?C++ Cprintf怎么用?C++ Cprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Cprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ws_status_timer
void
ws_status_timer(Timer tm, Name status)
{ UINT id;
if ( (id = getIdTimer(tm)) )
{ KillTimer(NULL, id);
deleteHashTable(TimerTable, toInt(id));
setIdTimer(tm, 0);
}
if ( status != NAME_idle )
{ long msec = (long) (valReal(tm->interval) * 1000.0);
if ( (id = SetTimer(NULL, 0, (UINT)msec, (TIMERPROC) timer_proc)) )
{ if ( !TimerTable )
{ TimerTable = globalObject(CtoName("active_timers"),
ClassHashTable, EAV);
assign(TimerTable, refer, NAME_none);
}
appendHashTable(TimerTable, toInt(id), tm);
setIdTimer(tm, id);
DEBUG(NAME_timer, Cprintf("Created timer of %d milliseconds (id = %d)\n",
msec, id));
} else
Cprintf("Failed SetTimer()\n");
}
}
示例2: cmd_exec
static void cmd_exec(int argc, const char * const * argv)
{
#define CMD_EXEC_MAX_ARGS (8)
int args[CMD_EXEC_MAX_ARGS];
int fidx;
int i, exec_res;
char *eptr;
if (argc < 1 || argc > CMD_EXEC_MAX_ARGS+1)
goto syntax_err;
fidx = csp_vm_find_func(argv[0]);
if (fidx < 0){
Cprintf("not found\n");
}
for (i=1;i<argc && i<CMD_EXEC_MAX_ARGS+1;i++){
args[i-1] = strtoul(argv[i], &eptr, 0);
if (!eptr || *eptr != 0){
goto syntax_err;
}
}
exec_res = csp_vm_run_function(1000, fidx, argc-1, args);
Cprintf("\nexec %s(): %d %d\n", argv[0], exec_res, csp_vm_get_call_result());
return;
syntax_err:
Cprintf("Usage: exec <name> [args...]\n");
}
示例3: main
int main()
{
BOOL bSuccess;
int i;
char szBuf[30];
InitConsoleIO(); // must call this at startup
ClrScr(); // clear the screen
for ( i=0; i < 20; i += 2 ) {
// QUESTION H what does the next line do?
GotoXY(i,i);
// make a message and put it out
sprintf( szBuf, "%d,%d", i, 2*i );
bSuccess = PutText(szBuf); // test PutText.
if (!bSuccess)
printf("WriteConsoleOutputCharacter error\n");
}
// make some cool messages in different colours
TextColour( BC_RED );
TextBackground( BC_GREEN );
Cprintf("Cool %d ", i++);
TextColour( BC_BLACK );
TextBackground( BC_LIGHTGRAY );
Cprintf("colours %d ", i++);
TextColour( BC_LIGHTMAGENTA );
TextBackground( BC_BLUE );
Cprintf(" Eh %d?", i);
return(1);
}
示例4: colourPixel
static unsigned long
colourPixel(Display *disp, int depth, Colormap cmap,
Table t, int r, int g, int b)
{ unsigned long pixel;
unsigned long direct = (r << 16) + (g << 8) + b;
XColor c;
if ( (pixel = memberTable(t, direct)) != NOPIXEL )
return pixel;
ncolours++;
c.red = r * 257;
c.green = g * 257;
c.blue = b * 257;
if ( !XAllocColor(disp, cmap, &c) )
{ if ( !allocNearestColour(disp, cmap, depth, DEFAULT, &c) )
{ Cprintf("PNM: failed to alloc pixel %d/%d/%d\n", r, g, b);
c.pixel = 0;
nfailed++;
}
}
addTable(t, direct, c.pixel);
DEBUG(NAME_ppm, Cprintf("PNM: Colour %d %d %d on pixel %d\n",
r, g, b, c.pixel));
return c.pixel;
}
示例5: x_error_handler
static int
x_error_handler(Display *display, XErrorEvent *error)
{ if ( !catchedErrorPce(PCE, NAME_xError) )
{ char msg[1024];
char request[100];
char buf[100];
/* XSetInputFocus() can generate a */
/* BadMatch that is hard to avoid */
if ( error->request_code == X_SetInputFocus &&
error->error_code == BadMatch )
return 0;
XGetErrorText(display, error->error_code, msg, 1024);
sprintf(buf, "%d", error->request_code);
XGetErrorDatabaseText(display, "XRequest", buf,
"Unknown request", request, 100);
Cprintf("X error of failed request: %s\n", msg);
Cprintf("Major opcode of failed request: %d (%s)\n",
error->request_code, request);
Cprintf("Minor opcode of failed request: %d\n", error->minor_code);
Cprintf("Resource id in failed request: 0x%x\n",
(unsigned int) error->resourceid);
Cprintf("Serial number of failed request: %ld\n", error->serial);
errorPce(NIL, NAME_xError);
}
return 0; /* what to return here? */
}
示例6: parse_font
static status
parse_font(char *s, LOGFONT *lfont)
{ while(*s)
{ char att[100];
int n = -1;
char *q;
for(q=att; isalpha(*s); *q++ = *s++)
;
*q = EOS;
if ( stricmp(att, "height") == 0 )
n=long_attribute(s, &lfont->lfHeight);
else if ( stricmp(att, "width") == 0 )
n=long_attribute(s, &lfont->lfWidth);
else if ( stricmp(att, "escapement") == 0 )
n=long_attribute(s, &lfont->lfEscapement);
else if ( stricmp(att, "orientation") == 0 )
n=long_attribute(s, &lfont->lfOrientation);
else if ( stricmp(att, "weight") == 0 )
n=long_attribute(s, &lfont->lfWeight);
else if ( stricmp(att, "italic") == 0 )
n=bool_attribute(s, &lfont->lfItalic);
else if ( stricmp(att, "underline") == 0 )
n=bool_attribute(s, &lfont->lfUnderline);
else if ( stricmp(att, "strikeout") == 0 )
n=bool_attribute(s, &lfont->lfStrikeOut);
else if ( stricmp(att, "charset") == 0 )
n=named_attribute(s, charset_names, 0xff, &lfont->lfCharSet);
else if ( stricmp(att, "outprecision") == 0 )
n=named_attribute(s, outprecision_names, 0xff, &lfont->lfOutPrecision);
else if ( stricmp(att, "clipprecision") == 0 )
n=named_attribute(s, clipprecision_names, 0xff, &lfont->lfClipPrecision);
else if ( stricmp(att, "quality") == 0 )
n=named_attribute(s, quality_names, 0xff, &lfont->lfQuality);
else if ( stricmp(att, "pitch") == 0 )
n=named_attribute(s, pitch_names, 0x3, &lfont->lfPitchAndFamily);
else if ( stricmp(att, "family") == 0 )
n=named_attribute(s, family_names, 0xf8, &lfont->lfPitchAndFamily);
else if ( stricmp(att, "face") == 0 )
n=string_attribute(s, lfont->lfFaceName, LF_FACESIZE);
else
Cprintf("Bad font-attribute name: %s\n", att);
if ( n < 0 )
{ Cprintf("Bad value for font-attribute %s\n", att);
while( *s && *s != ':' )
s++;
} else
{ DEBUG(NAME_font, Cprintf("att %s: read %d chars\n", att, n));
s += n;
if ( *s == ':' )
s++;
}
}
succeed;
}
示例7: ws_create_window
status
ws_create_window(PceWindow sw, PceWindow parent)
{ Widget w;
DisplayObj d = getDisplayGraphical((Graphical)sw);
/* create the widget */
{ Arg args[8];
Cardinal n = 0;
int pen = valInt(sw->pen);
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Actually, it appears Xt is ignoring the geometry parameters. Hence,
ws_realise_frame() sends ->geometry to all windows.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
XtSetArg(args[n], XtNx, valInt(sw->area->x)); n++;
XtSetArg(args[n], XtNy, valInt(sw->area->y)); n++;
XtSetArg(args[n], XtNwidth, valInt(sw->area->w) - 2*pen); n++;
XtSetArg(args[n], XtNheight, valInt(sw->area->h) - 2*pen); n++;
XtSetArg(args[n], XtNborderWidth, pen); n++;
XtSetArg(args[n], XtNinput, True); n++;
if ( instanceOfObject(sw->background, ClassColour) )
{ XtSetArg(args[n], XtNbackground, getPixelColour(sw->background, d));
n++;
} else
{ Pixmap pm = (Pixmap) getXrefObject(sw->background, d);
XtSetArg(args[n], XtNbackgroundPixmap, pm); n++;
}
DEBUG(NAME_create, Cprintf("Calling XtCreateWidget ..."));
w = XtCreateWidget(strName(sw->name),
canvasWidgetClass,
isDefault(parent) ? widgetFrame(sw->frame)
: widgetWindow(parent),
args, n);
DEBUG(NAME_create, Cprintf("Widget = %p\n", w));
}
if ( !w )
return errorPce(w, NAME_createFailed);
setWidgetWindow(sw, w);
XtAddCallback(w, XtNeventCallback, event_window, sw);
XtAddCallback(w, XtNexposeCallback, expose_window, sw);
XtAddCallback(w, XtNresizeCallback, resize_window, sw);
XtAddCallback(w, XtNdestroyCallback, destroy_window, sw);
if ( notDefault(parent) ) /* make a sub-window */
{ XtManageChild(w);
send(sw, NAME_displayed, ON, EAV);
}
succeed;
}
示例8: Wait
void Wait () /* Busy-wait for a key from keyboard */
{
int flag;
Cprintf ("Press any key to continue... ") ;
flag = Mod_int (INT_ENABLE);
while( Get_char() == NULL ) ;
Mod_int (flag);
Cprintf ("\n") ;
}
示例9: test3a_Q
/** Aux function **/
int test3a_Q( int argc, char** argv )
{
if( argv[0][0] != 'M' ) {
Cprintf( "%s.q ", argv[0] );
}
else {
Cprintf( "notes to " );
}
return 0;
}
示例10: Proc
int Proc( int argc, char** argv )
{
PROCPTR p;
int pid;
char c;
Cprintf( "test1i: Hello!\n" );
Cprintf( "test1i: [Loading test1a...]\n" );
p = Load_module( "test1a.mod" );
Cprintf( "test1i: proc == %p\n", p );
Cprintf( "test1i: [Starting test1a...]\n" );
pid = Proc_start( p, child_argc, child_argv );
Cprintf( "test1i: pid == %d\n", pid );
Cprintf( "test1i: [Closing test1a...]\n" );
Close_module( "test1a.mod" );
Cprintf( "test1i: [Sleeping until keypress...]\n" );
c = Get_char();
Cprintf( "test1i: c == '%c'\n", c );
Cprintf( "test1i: [Terminating...]\n" );
return 0;
}
示例11: cmd_help
static void cmd_help(int argc, const char * const * argv)
{
const struct shell_command *cmd;
int i;
Cprintf("Commands:\n");
for (i=0;i<shell_commands_count;i++){
cmd = &shell_commands[i];
Cprintf(" %-16s - %s\n", cmd->name, cmd->descr);
}
}
示例12: ws_discard_input
void
ws_discard_input(const char *msg)
{ if ( dispatch_fd >= 0 && input_on_fd(dispatch_fd) )
{ char buf[1024];
Cprintf("%s; discarding input ...", msg);
if ( read(dispatch_fd, buf, sizeof(buf)) >= 0 )
Cprintf("ok\n");
else
Cprintf("failed\n");
}
}
示例13: cmd_load
static void cmd_load(int argc, const char * const * argv)
{
if (argc != 0)
goto syntax_err;
Cprintf("Expecting script code.\nEnd with a Ctrl+D (ASCII char code 4).\n");
load_script_from_console();
return;
syntax_err:
Cprintf("Usage: load\n");
}
示例14: ws_provide_selection
int
ws_provide_selection(int format)
{ DisplayObj d = CurrentDisplay(NIL);
Hyper h;
Function msg;
Name which = NAME_primary;
Name hypername = getAppendName(which, NAME_selectionOwner);
Name type;
if ( d && notNil(d) &&
(h = getFindHyperObject(d, hypername, DEFAULT)) &&
(type = getAttributeObject(h, NAME_type)) &&
(msg = getAttributeObject(h, NAME_convertFunction)) &&
(msg = checkType(msg, TypeFunction, NIL)) )
{ Any val;
DEBUG(NAME_selection, Cprintf("Provide %s selection of type %s\n",
pp(which), pp(type)));
if ( !(val = getForwardReceiverFunction(msg, h->to, which, type, EAV)) )
return FALSE;
DEBUG(NAME_selection, Cprintf("Got %s\n", pp(val)));
if ( type == NAME_text )
{ CharArray ca = checkType(val, TypeCharArray, NIL);
if ( ca )
{ String s = &ca->data;
HGLOBAL mem = ws_string_to_global_mem(s);
if ( mem )
SetClipboardData(CF_UNICODETEXT, mem);
return TRUE;
}
} else if ( type == NAME_emf || type == NAME_wmf )
{ Any mf = checkType(val, nameToType(NAME_winMetafile), NIL);
if ( mf )
{ DEBUG(NAME_selection, Cprintf("Providing win_metafile\n"));
return ws_on_clipboard_metafile(mf, type);
}
} else
return errorPce(d, NAME_noSelectionType, type);
}
return FALSE;
}
示例15: main
int
main(int argc, char* argv[])
{ if ( !pceInitialise(0, NULL, argc, argv) )
{ Cprintf("Sorry, failed to initialise XPCE\n");
exit(1);
}
if ( !pceInitApplication(argc, argv) )
{ Cprintf("Failed to run pceInitApplication()\n");
exit(1);
}
for(;;)
pceDispatch(0, 1000);
}