本文整理汇总了C++中qprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ qprintf函数的具体用法?C++ qprintf怎么用?C++ qprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qprintf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: drv_BuE_init
/* initialize driver & display */
int drv_BuE_init(const char *section, const int quiet)
{
WIDGET_CLASS wc;
int ret;
info("%s: %s", Name, "$Rev: 840 $");
/* start display */
if ((ret = drv_BuE_start(section)) != 0) {
return ret;
}
/* display preferences */
XRES = 5; /* pixel width of one char */
YRES = 8; /* pixel height of one char */
CHARS = 8; /* number of user-defineable characters */
/* real worker functions */
switch (Protocol) {
case 1:
CHAR0 = 0; /* ASCII of first user-defineable char */
GOTO_COST = 6; /* number of bytes a goto command requires */
drv_generic_text_real_write = drv_BuE_MT_write;
drv_generic_text_real_defchar = drv_BuE_MT_defchar;
break;
case 2:
CHAR0 = 128; /* ASCII of first user-defineable char */
GOTO_COST = 6; /* number of bytes a goto command requires */
drv_generic_text_real_write = drv_BuE_CT_write;
drv_generic_text_real_defchar = drv_BuE_CT_defchar;
break;
}
if (!quiet) {
char buffer[40];
qprintf(buffer, sizeof(buffer), "%s %s", Name, Models[Model].name);
if (drv_generic_text_greet(buffer, "www.bue.com")) {
sleep(3);
drv_BuE_clear();
}
}
/* initialize generic text driver */
if ((ret = drv_generic_text_init(section, Name)) != 0)
return ret;
/* initialize generic icon driver */
if ((ret = drv_generic_text_icon_init()) != 0)
return ret;
/* initialize generic bar driver */
if ((ret = drv_generic_text_bar_init(0)) != 0)
return ret;
/* add fixed chars to the bar driver */
drv_generic_text_bar_add_segment(0, 0, 255, 32); /* ASCII 32 = blank */
drv_generic_text_bar_add_segment(255, 255, 255, 255); /* ASCII 255 = block */
/* register text widget */
wc = Widget_Text;
wc.draw = drv_generic_text_draw;
widget_register(&wc);
/* register icon widget */
wc = Widget_Icon;
wc.draw = drv_generic_text_icon_draw;
widget_register(&wc);
/* register bar widget */
wc = Widget_Bar;
wc.draw = drv_generic_text_bar_draw;
widget_register(&wc);
/* register plugins */
AddFunction("LCD::contrast", -1, plugin_contrast);
AddFunction("LCD::backlight", -1, plugin_backlight);
AddFunction("LCD::gpo", -1, plugin_gpo);
AddFunction("LCD::gpi", 1, plugin_gpi);
AddFunction("LCD::adc", 0, plugin_adc);
AddFunction("LCD::pwm", -1, plugin_pwm);
return 0;
}
开发者ID:KCFTech,项目名称:lcd4linux,代码行数:84,代码来源:drv_BeckmannEgle.c
示例2: qprintf
/*
=================
BrushBSP
The incoming list will be freed before exiting
=================
*/
tree_t *BrushBSP (bspbrush_t *brushlist, vec3_t mins, vec3_t maxs)
{
node_t *node;
bspbrush_t *b;
int c_faces, c_nonvisfaces;
int c_brushes;
tree_t *tree;
int i;
vec_t volume;
qprintf ("--- BrushBSP ---\n");
tree = AllocTree ();
c_faces = 0;
c_nonvisfaces = 0;
c_brushes = 0;
for (b=brushlist ; b ; b=b->next)
{
c_brushes++;
volume = BrushVolume (b);
if (volume < microvolume)
{
printf ("WARNING: entity %i, brush %i: microbrush\n",
b->original->entitynum, b->original->brushnum);
}
for (i=0 ; i<b->numsides ; i++)
{
if (b->sides[i].bevel)
continue;
if (!b->sides[i].winding)
continue;
if (b->sides[i].texinfo == TEXINFO_NODE)
continue;
if (b->sides[i].visible)
c_faces++;
else
c_nonvisfaces++;
}
AddPointToBounds (b->mins, tree->mins, tree->maxs);
AddPointToBounds (b->maxs, tree->mins, tree->maxs);
}
qprintf ("%5i brushes\n", c_brushes);
qprintf ("%5i visible faces\n", c_faces);
qprintf ("%5i nonvisible faces\n", c_nonvisfaces);
c_nodes = 0;
c_nonvis = 0;
node = AllocNode ();
node->volume = BrushFromBounds (mins, maxs);
tree->headnode = node;
node = BuildTree_r (node, brushlist);
qprintf ("%5i visible nodes\n", c_nodes/2 - c_nonvis);
qprintf ("%5i nonvis nodes\n", c_nonvis);
qprintf ("%5i leafs\n", (c_nodes+1)/2);
#if 0
{ // debug code
static node_t *tnode;
vec3_t p;
p[0] = -1469;
p[1] = -118;
p[2] = 119;
tnode = PointInLeaf (tree->headnode, p);
printf ("contents: %i\n", tnode->contents);
p[0] = 0;
}
#endif
return tree;
}
开发者ID:amitahire,项目名称:development,代码行数:84,代码来源:brushbsp.c
示例3: PatchMapDrawSurfs
/*
=====================
PatchMapDrawSurfs
Any patches that share an edge need to choose their
level of detail as a unit, otherwise the edges would
pull apart.
=====================
*/
void PatchMapDrawSurfs( entity_t *e ) {
parseMesh_t *pm;
parseMesh_t *check, *scan;
mapDrawSurface_t *ds;
int patchCount, groupCount;
int i, j, k, l, c1, c2;
drawVert_t *v1, *v2;
vec3_t bounds[2];
byte *bordering;
parseMesh_t *meshes[MAX_MAP_DRAW_SURFS];
qboolean grouped[MAX_MAP_DRAW_SURFS];
byte group[MAX_MAP_DRAW_SURFS];
qprintf( "----- PatchMapDrawSurfs -----\n" );
patchCount = 0;
for ( pm = e->patches ; pm ; pm = pm->next ) {
meshes[patchCount] = pm;
patchCount++;
}
if ( !patchCount ) {
return;
}
bordering = malloc( patchCount * patchCount );
memset( bordering, 0, patchCount * patchCount );
// build the bordering matrix
for ( k = 0 ; k < patchCount ; k++ ) {
bordering[k*patchCount+k] = 1;
for ( l = k+1 ; l < patchCount ; l++ ) {
check = meshes[k];
scan = meshes[l];
c1 = scan->mesh.width * scan->mesh.height;
v1 = scan->mesh.verts;
for ( i = 0 ; i < c1 ; i++, v1++ ) {
c2 = check->mesh.width * check->mesh.height;
v2 = check->mesh.verts;
for ( j = 0 ; j < c2 ; j++, v2++ ) {
if ( fabs( v1->xyz[0] - v2->xyz[0] ) < 1.0
&& fabs( v1->xyz[1] - v2->xyz[1] ) < 1.0
&& fabs( v1->xyz[2] - v2->xyz[2] ) < 1.0 ) {
break;
}
}
if ( j != c2 ) {
break;
}
}
if ( i != c1 ) {
// we have a connection
bordering[k*patchCount+l] =
bordering[l*patchCount+k] = 1;
} else {
// no connection
bordering[k*patchCount+l] =
bordering[l*patchCount+k] = 0;
}
}
}
// build groups
memset( grouped, 0, sizeof(grouped) );
groupCount = 0;
for ( i = 0 ; i < patchCount ; i++ ) {
if ( !grouped[i] ) {
groupCount++;
}
// recursively find all patches that belong in the same group
memset( group, 0, patchCount );
GrowGroup_r( i, patchCount, bordering, group );
// bound them
ClearBounds( bounds[0], bounds[1] );
for ( j = 0 ; j < patchCount ; j++ ) {
if ( group[j] ) {
grouped[j] = qtrue;
scan = meshes[j];
c1 = scan->mesh.width * scan->mesh.height;
v1 = scan->mesh.verts;
for ( k = 0 ; k < c1 ; k++, v1++ ) {
AddPointToBounds( v1->xyz, bounds[0], bounds[1] );
}
}
}
// create drawsurf
//.........这里部分代码省略.........
开发者ID:AHPlankton,项目名称:Quake-III-Arena,代码行数:101,代码来源:patch.c
示例4: AddThread
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
void AddThread(void (*func)(int))
{
thread_t *thread;
if (numthreads == 1)
{
if (currentnumthreads >= numthreads)
{
return;
}
currentnumthreads++;
func(-1);
currentnumthreads--;
} //end if
else
{
ThreadLock();
if (currentnumthreads >= numthreads)
{
ThreadUnlock();
return;
} //end if
//allocate new thread
thread = GetMemory(sizeof(thread_t));
if (!thread)
{
Error("can't allocate memory for thread\n");
}
//
thread->threadid = currentthreadid;
thread->handle = CreateThread(
NULL, // LPSECURITY_ATTRIBUTES lpsa,
0, // DWORD cbStack,
(LPTHREAD_START_ROUTINE)func, // LPTHREAD_START_ROUTINE lpStartAddr,
(LPVOID) thread->threadid, // LPVOID lpvThreadParm,
0, // DWORD fdwCreate,
&thread->id);
//add the thread to the end of the list
thread->next = NULL;
if (lastthread)
{
lastthread->next = thread;
}
else
{
firstthread = thread;
}
lastthread = thread;
//
#ifdef THREAD_DEBUG
qprintf("added thread with id %d\n", thread->threadid);
#endif //THREAD_DEBUG
//
currentnumthreads++;
currentthreadid++;
//
ThreadUnlock();
} //end else
} //end of the function AddThread
开发者ID:morsik,项目名称:war-territory,代码行数:67,代码来源:l_threads.c
示例5: glob0
/*
* The main glob() routine: compiles the pattern (optionally processing
* quotes), calls glob1() to do the real pattern matching, and finally
* sorts the list (unless unsorted operation is requested). Returns 0
* if things went well, nonzero if errors occurred. It is not an error
* to find no matches.
*/
static int
glob0(const Char *pattern, glob_t *pglob, struct glob_lim *limitp)
{
const Char *qpatnext;
int c, err, oldpathc;
Char *bufnext, patbuf[PATH_MAX];
qpatnext = globtilde(pattern, patbuf, PATH_MAX, pglob);
oldpathc = pglob->gl_pathc;
bufnext = patbuf;
/* We don't need to check for buffer overflow any more. */
while ((c = *qpatnext++) != EOS) {
switch (c) {
case LBRACKET:
c = *qpatnext;
if (c == NOT)
++qpatnext;
if (*qpatnext == EOS ||
g_strchr(qpatnext+1, RBRACKET) == NULL) {
*bufnext++ = LBRACKET;
if (c == NOT)
--qpatnext;
break;
}
*bufnext++ = M_SET;
if (c == NOT)
*bufnext++ = M_NOT;
c = *qpatnext++;
do {
if (c == LBRACKET && *qpatnext == ':') {
do {
err = g_charclass(&qpatnext,
&bufnext);
if (err)
break;
c = *qpatnext++;
} while (c == LBRACKET && *qpatnext == ':');
if (err == -1 &&
!(pglob->gl_flags & GLOB_NOCHECK))
return GLOB_NOMATCH;
if (c == RBRACKET)
break;
}
*bufnext++ = CHAR(c);
if (*qpatnext == RANGE &&
(c = qpatnext[1]) != RBRACKET) {
*bufnext++ = M_RNG;
*bufnext++ = CHAR(c);
qpatnext += 2;
}
} while ((c = *qpatnext++) != RBRACKET);
pglob->gl_flags |= GLOB_MAGCHAR;
*bufnext++ = M_END;
break;
case QUESTION:
pglob->gl_flags |= GLOB_MAGCHAR;
*bufnext++ = M_ONE;
break;
case STAR:
pglob->gl_flags |= GLOB_MAGCHAR;
/* collapse adjacent stars to one,
* to avoid exponential behavior
*/
if (bufnext == patbuf || bufnext[-1] != M_ALL)
*bufnext++ = M_ALL;
break;
default:
*bufnext++ = CHAR(c);
break;
}
}
*bufnext = EOS;
#ifdef DEBUG
qprintf("glob0:", patbuf);
#endif
if ((err = glob1(patbuf, patbuf + PATH_MAX - 1, pglob, limitp)) != 0)
return err;
/*
* If there was no match we are going to append the pattern
* if GLOB_NOCHECK was specified.
*/
if (pglob->gl_pathc == oldpathc) {
if ((pglob->gl_flags & GLOB_NOCHECK))
return globextend(pattern, pglob, limitp, NULL);
else
return GLOB_NOMATCH;
}
if (!(pglob->gl_flags & GLOB_NOSORT)) {
qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
pglob->gl_pathc - oldpathc, sizeof(char *), compare);
//.........这里部分代码省略.........
开发者ID:ScottyBauer,项目名称:sudo-1.8.13,代码行数:101,代码来源:glob.c
示例6: Log_Print
//===========================================================================
// The incoming brush list will be freed before exiting
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
tree_t *BrushBSP( bspbrush_t *brushlist, vec3_t mins, vec3_t maxs ) {
int i, c_faces, c_nonvisfaces, c_brushes;
bspbrush_t *b;
node_t *node;
tree_t *tree;
vec_t volume;
// vec3_t point;
Log_Print( "-------- Brush BSP ---------\n" );
tree = Tree_Alloc();
c_faces = 0;
c_nonvisfaces = 0;
c_brushes = 0;
c_totalsides = 0;
for ( b = brushlist; b; b = b->next )
{
c_brushes++;
volume = BrushVolume( b );
if ( volume < microvolume ) {
Log_Print( "WARNING: entity %i, brush %i: microbrush\n",
b->original->entitynum, b->original->brushnum );
} //end if
for ( i = 0 ; i < b->numsides ; i++ )
{
if ( b->sides[i].flags & SFL_BEVEL ) {
continue;
}
if ( !b->sides[i].winding ) {
continue;
}
if ( b->sides[i].texinfo == TEXINFO_NODE ) {
continue;
}
if ( b->sides[i].flags & SFL_VISIBLE ) {
c_faces++;
} //end if
else
{
c_nonvisfaces++;
//if (create_aas) b->sides[i].texinfo = TEXINFO_NODE;
} //end if
} //end for
c_totalsides += b->numsides;
AddPointToBounds( b->mins, tree->mins, tree->maxs );
AddPointToBounds( b->maxs, tree->mins, tree->maxs );
} //end for
Log_Print( "%6i brushes\n", c_brushes );
Log_Print( "%6i visible faces\n", c_faces );
Log_Print( "%6i nonvisible faces\n", c_nonvisfaces );
Log_Print( "%6i total sides\n", c_totalsides );
c_active_brushes = c_brushes;
c_nodememory = 0;
c_brushmemory = 0;
c_peak_brushmemory = 0;
c_nodes = 0;
c_nonvis = 0;
node = AllocNode();
//volume of first node (head node)
node->volume = BrushFromBounds( mins, maxs );
//
tree->headnode = node;
//just get some statistics and the mins/maxs of the node
numrecurse = 0;
// qprintf("%6d splits", numrecurse);
tree->headnode->brushlist = brushlist;
BuildTree( tree );
//build the bsp tree with the start node from the brushlist
// node = BuildTree_r(node, brushlist);
//if the conversion is cancelled
if ( cancelconversion ) {
return tree;
}
qprintf( "\n" );
Log_Write( "%6d splits\r\n", numrecurse );
// Log_Print("%6i visible nodes\n", c_nodes/2 - c_nonvis);
// Log_Print("%6i nonvis nodes\n", c_nonvis);
// Log_Print("%6i leaves\n", (c_nodes+1)/2);
// Log_Print("%6i solid leaf nodes\n", c_solidleafnodes);
// Log_Print("%6i active brushes\n", c_active_brushes);
if ( numthreads == 1 ) {
//.........这里部分代码省略.........
开发者ID:JackalFrost,项目名称:RTCW-WSGF,代码行数:101,代码来源:brushbsp.c
示例7: bsd_glob
//.........这里部分代码省略.........
static int
globexp2(const Char *ptr, const Char *pattern,
glob_t *pglob, int *rv)
{
int i;
Char *lm, *ls;
const Char *pe, *pm, *pl;
Char patbuf[MAXPATHLEN];
/* copy part up to the brace */
for (lm = patbuf, pm = pattern; pm != ptr; *lm++ = *pm++)
;
*lm = BG_EOS;
ls = lm;
/* Find the balanced brace */
for (i = 0, pe = ++ptr; *pe; pe++)
if (*pe == BG_LBRACKET) {
/* Ignore everything between [] */
for (pm = pe++; *pe != BG_RBRACKET && *pe != BG_EOS; pe++)
;
if (*pe == BG_EOS) {
/*
* We could not find a matching BG_RBRACKET.
* Ignore and just look for BG_RBRACE
*/
pe = pm;
}
} else if (*pe == BG_LBRACE)
i++;
else if (*pe == BG_RBRACE) {
if (i == 0)
break;
i--;
}
/* Non matching braces; just glob the pattern */
if (i != 0 || *pe == BG_EOS) {
*rv = glob0(patbuf, pglob);
return 0;
}
for (i = 0, pl = pm = ptr; pm <= pe; pm++) {
switch (*pm) {
case BG_LBRACKET:
/* Ignore everything between [] */
for (pl = pm++; *pm != BG_RBRACKET && *pm != BG_EOS; pm++)
;
if (*pm == BG_EOS) {
/*
* We could not find a matching BG_RBRACKET.
* Ignore and just look for BG_RBRACE
*/
pm = pl;
}
break;
case BG_LBRACE:
i++;
break;
case BG_RBRACE:
if (i) {
i--;
break;
}
/* FALLTHROUGH */
case BG_COMMA:
if (i && *pm == BG_COMMA)
break;
else {
/* Append the current string */
for (lm = ls; (pl < pm); *lm++ = *pl++)
;
/*
* Append the rest of the pattern after the
* closing brace
*/
for (pl = pe + 1; (*lm++ = *pl++) != BG_EOS; )
;
/* Expand the current pattern */
#ifdef GLOB_DEBUG
qprintf("globexp2:", patbuf);
#endif /* GLOB_DEBUG */
*rv = globexp1(patbuf, pglob);
/* move after the comma, to the next string */
pl = pm + 1;
}
break;
default:
break;
}
}
*rv = 0;
return 0;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:101,代码来源:bsd_glob.c
示例8: glob0
/*
* The main glob() routine: compiles the pattern (optionally processing
* quotes), calls glob1() to do the real pattern matching, and finally
* sorts the list (unless unsorted operation is requested). Returns 0
* if things went well, nonzero if errors occurred. It is not an error
* to find no matches.
*/
static int
glob0(const Char *pattern, glob_t *pglob)
{
const Char *qpat, *qpatnext;
int c, err, oldflags, oldpathc;
Char *bufnext, patbuf[MAXPATHLEN];
size_t limit = 0;
#ifdef MACOS_TRADITIONAL
if ( (*pattern == BG_TILDE) && (pglob->gl_flags & GLOB_TILDE) ) {
return(globextend(pattern, pglob, &limit));
}
#endif
qpat = globtilde(pattern, patbuf, MAXPATHLEN, pglob);
qpatnext = qpat;
oldflags = pglob->gl_flags;
oldpathc = pglob->gl_pathc;
bufnext = patbuf;
/* We don't need to check for buffer overflow any more. */
while ((c = *qpatnext++) != BG_EOS) {
switch (c) {
case BG_LBRACKET:
c = *qpatnext;
if (c == BG_NOT)
++qpatnext;
if (*qpatnext == BG_EOS ||
g_strchr((Char *) qpatnext+1, BG_RBRACKET) == NULL) {
*bufnext++ = BG_LBRACKET;
if (c == BG_NOT)
--qpatnext;
break;
}
*bufnext++ = M_SET;
if (c == BG_NOT)
*bufnext++ = M_NOT;
c = *qpatnext++;
do {
*bufnext++ = CHAR(c);
if (*qpatnext == BG_RANGE &&
(c = qpatnext[1]) != BG_RBRACKET) {
*bufnext++ = M_RNG;
*bufnext++ = CHAR(c);
qpatnext += 2;
}
} while ((c = *qpatnext++) != BG_RBRACKET);
pglob->gl_flags |= GLOB_MAGCHAR;
*bufnext++ = M_END;
break;
case BG_QUESTION:
pglob->gl_flags |= GLOB_MAGCHAR;
*bufnext++ = M_ONE;
break;
case BG_STAR:
pglob->gl_flags |= GLOB_MAGCHAR;
/* collapse adjacent stars to one,
* to avoid exponential behavior
*/
if (bufnext == patbuf || bufnext[-1] != M_ALL)
*bufnext++ = M_ALL;
break;
default:
*bufnext++ = CHAR(c);
break;
}
}
*bufnext = BG_EOS;
#ifdef GLOB_DEBUG
qprintf("glob0:", patbuf);
#endif /* GLOB_DEBUG */
if ((err = glob1(patbuf, patbuf+MAXPATHLEN-1, pglob, &limit)) != 0) {
pglob->gl_flags = oldflags;
return(err);
}
/*
* If there was no match we are going to append the pattern
* if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified
* and the pattern did not contain any magic characters
* GLOB_NOMAGIC is there just for compatibility with csh.
*/
if (pglob->gl_pathc == oldpathc &&
((pglob->gl_flags & GLOB_NOCHECK) ||
((pglob->gl_flags & GLOB_NOMAGIC) &&
!(pglob->gl_flags & GLOB_MAGCHAR))))
{
#ifdef GLOB_DEBUG
printf("calling globextend from glob0\n");
#endif /* GLOB_DEBUG */
pglob->gl_flags = oldflags;
return(globextend(qpat, pglob, &limit));
//.........这里部分代码省略.........
开发者ID:OPSF,项目名称:uClinux,代码行数:101,代码来源:bsd_glob.c
示例9: main
//.........这里部分代码省略.........
{
strcpy( qproject, argv[ i + 1 ] );
i++;
}
else if (!strcmp(argv[i], "-hullfile"))
{
hullfile = true;
strcpy( qhullfile, argv[i + 1] );
i++;
}
else if (argv[i][0] == '-')
Error ("Unknown option \"%s\"", argv[i]);
else
break;
}
if (i != argc - 1)
Error ("usage: qcsg [-nowadtextures] [-wadinclude <name>] [-draw] [-glview] [-noclip] [-onlyents] [-proj <name>] [-threads #] [-v] [-hullfile <name>] mapfile");
SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_ABOVE_NORMAL);
start = I_FloatTime ();
CheckHullFile( hullfile, qhullfile );
ThreadSetDefault ();
SetQdirFromPath (argv[i]);
strcpy (source, ExpandArg (argv[i]));
COM_FixSlashes(source);
StripExtension (source);
strcpy (name, ExpandArg (argv[i]));
DefaultExtension (name, ".map"); // might be .reg
//
// if onlyents, just grab the entites and resave
//
if (onlyents && !glview)
{
char out[1024];
int old_entities;
sprintf (out, "%s.bsp", source);
LoadBSPFile (out);
// Get the new entity data from the map file
LoadMapFile (name);
// Write it all back out again.
WriteBSP (source);
end = I_FloatTime ();
printf ("%5.0f seconds elapsed\n", end-start);
return 0;
}
//
// start from scratch
//
LoadMapFile (name);
RunThreadsOnIndividual (nummapbrushes, true, CreateBrush);
BoundWorld ();
qprintf ("%5i map planes\n", nummapplanes);
for (i=0 ; i<NUM_HULLS ; i++)
{
char name[1024];
if (glview)
sprintf (name, "%s.gl%i",source, i);
else
sprintf (name, "%s.p%i",source, i);
out[i] = fopen (name, "w");
if (!out[i])
Error ("Couldn't open %s",name);
}
ProcessModels ();
qprintf ("%5i csg faces\n", c_csgfaces);
qprintf ("%5i used faces\n", c_outfaces);
qprintf ("%5i tiny faces\n", c_tiny);
qprintf ("%5i tiny clips\n", c_tiny_clip);
for (i=0 ; i<NUM_HULLS ; i++)
fclose (out[i]);
if (!glview)
{
EmitPlanes ();
WriteBSP (source);
}
end = I_FloatTime ();
printf ("%5.0f seconds elapsed\n", end-start);
return 0;
}
开发者ID:6779660,项目名称:halflife,代码行数:101,代码来源:qcsg.c
示例10: ProcessEntity
/*
===============
ProcessEntity
===============
*/
static void ProcessEntity (int entnum)
{
entity_t *ent;
char mod[80];
surface_t *surfs;
node_t *nodes;
brushset_t *bs;
ent = &entities[entnum];
if (!ent->brushes)
return; // non-bmodel entity
if (entnum > 0)
{
worldmodel = false;
if (entnum == 1)
qprintf ("--- Internal Entities ---\n");
sprintf (mod, "*%i", nummodels);
if (verbose)
PrintEntity (ent);
if (hullnum == 0)
printf ("MODEL: %s\n", mod);
SetKeyValue (ent, "model", mod);
}
else
worldmodel = true;
//
// take the brush_ts and clip off all overlapping and contained faces,
// leaving a perfect skin of the model with no hidden faces
//
bs = Brush_LoadEntity (ent, hullnum);
if (!bs->brushes)
{
PrintEntity (ent);
Error ("Entity with no valid brushes");
}
brushset = bs;
surfs = CSGFaces (bs);
if (hullnum != 0)
{
nodes = SolidBSP (surfs, true);
if (entnum == 0 && !nofill) // assume non-world bmodels are simple
{
PortalizeWorld (nodes);
if (FillOutside (nodes))
{
surfs = GatherNodeFaces (nodes);
nodes = SolidBSP (surfs, false); // make a really good tree
}
FreeAllPortals (nodes);
}
WriteNodePlanes (nodes);
WriteClipNodes (nodes);
BumpModel (hullnum);
}
else
{
//
// SolidBSP generates a node tree
//
// if not the world, make a good tree first
// the world is just going to make a bad tree
// because the outside filling will force a regeneration later
nodes = SolidBSP (surfs, entnum == 0);
//
// build all the portals in the bsp tree
// some portals are solid polygons, and some are paths to other leafs
//
if (entnum == 0 && !nofill) // assume non-world bmodels are simple
{
PortalizeWorld (nodes);
if (FillOutside (nodes))
{
FreeAllPortals (nodes);
// get the remaining faces together into surfaces again
surfs = GatherNodeFaces (nodes);
// merge polygons
MergeAll (surfs);
// make a really good tree
nodes = SolidBSP (surfs, false);
// make the real portals for vis tracing
PortalizeWorld (nodes);
// save portal file for vis tracing
//.........这里部分代码省略.........
开发者ID:crutchwalkfactory,项目名称:motocakerteam,代码行数:101,代码来源:qbsp.c
示例11: CSGBrush
/*
===========
CSGBrush
===========
*/
void CSGBrush (int brushnum)
{
int hull;
brush_t *b1, *b2;
brushhull_t *bh1, *bh2;
int bn;
qboolean overwrite;
int i;
bface_t *f, *f2, *next, *fcopy;
bface_t *outside, *oldoutside;
entity_t *e;
vec_t area;
SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_ABOVE_NORMAL);
b1 = &mapbrushes[brushnum];
e = &entities[b1->entitynum];
for (hull = 0 ; hull<NUM_HULLS ; hull++)
{
bh1 = &b1->hulls[hull];
// set outside to a copy of the brush's faces
outside = CopyFacesToOutside (bh1);
overwrite = false;
for (bn=0 ; bn<e->numbrushes ; bn++)
{
// see if b2 needs to clip a chunk out of b1
if (bn==brushnum)
{
overwrite = true; // later brushes now overwrite
continue;
}
b2 = &mapbrushes[e->firstbrush + bn];
bh2 = &b2->hulls[hull];
if (!bh2->faces)
continue; // brush isn't in this hull
// check brush bounding box first
for (i=0 ; i<3 ; i++)
if (bh1->mins[i] > bh2->maxs[i]
|| bh1->maxs[i] < bh2->mins[i])
break;
if (i<3)
continue;
// divide faces by the planes of the b2 to find which
// fragments are inside
f = outside;
outside = NULL;
for ( ; f ; f=next)
{
next = f->next;
// check face bounding box first
for (i=0 ; i<3 ; i++)
if (bh2->mins[i] > f->maxs[i]
|| bh2->maxs[i] < f->mins[i])
break;
if (i<3)
{ // this face doesn't intersect brush2's bbox
f->next = outside;
outside = f;
continue;
}
oldoutside = outside;
fcopy = CopyFace (f); // save to avoid fake splits
// throw pieces on the front sides of the planes
// into the outside list, return the remains on the inside
for (f2=bh2->faces ; f2 && f ; f2=f2->next)
f = ClipFace (b1, f, &outside, f2->planenum, overwrite);
area = f ? WindingArea (f->w) : 0;
if (f && area < 1.0)
{
qprintf ("Entity %i, Brush %i: tiny penetration\n"
, b1->entitynum, b1->brushnum);
c_tiny_clip++;
FreeFace (f);
f = NULL;
}
if (f)
{
// there is one convex fragment of the original
// face left inside brush2
FreeFace (fcopy);
//.........这里部分代码省略.........
开发者ID:6779660,项目名称:halflife,代码行数:101,代码来源:qcsg.c
示例12: parse_proc_stat
static int parse_proc_stat(void)
{
int age;
/* reread every 10 msec only */
age = hash_age(&Stat, NULL);
if (age > 0 && age <= 10)
return 0;
#ifndef __MAC_OS_X_VERSION_10_3
/* Linux Kernel, /proc-filesystem */
if (stream == NULL)
stream = fopen("/proc/stat", "r");
if (stream == NULL) {
error("fopen(/proc/stat) failed: %s", strerror(errno));
return -1;
}
rewind(stream);
while (!feof(stream)) {
char buffer[1024];
if (fgets(buffer, sizeof(buffer), stream) == NULL)
break;
if (strncmp(buffer, "cpu", 3) == 0) {
char *key[] = { "user", "nice", "system", "idle", "iow", "irq", "sirq" };
char delim[] = " \t\n";
char *cpu, *beg, *end;
int i;
cpu = buffer;
/* skip "cpu" or "cpu0" block */
if ((end = strpbrk(buffer, delim)) != NULL)
*end = '\0';
beg = end ? end + 1 : NULL;
for (i = 0; i < 7 && beg != NULL; i++) {
while (strchr(delim, *beg))
beg++;
if ((end = strpbrk(beg, delim)))
*end = '\0';
hash_put2(cpu, key[i], beg);
beg = end ? end + 1 : NULL;
}
}
else if (strncmp(buffer, "page ", 5) == 0) {
char *key[] = { "in", "out" };
char delim[] = " \t\n";
char *beg, *end;
int i;
for (i = 0, beg = buffer + 5; i < 2 && beg != NULL; i++) {
while (strchr(delim, *beg))
beg++;
if ((end = strpbrk(beg, delim)))
*end = '\0';
hash_put2("page", key[i], beg);
beg = end ? end + 1 : NULL;
}
}
else if (strncmp(buffer, "swap ", 5) == 0) {
char *key[] = { "in", "out" };
char delim[] = " \t\n";
char *beg, *end;
int i;
for (i = 0, beg = buffer + 5; i < 2 && beg != NULL; i++) {
while (strchr(delim, *beg))
beg++;
if ((end = strpbrk(beg, delim)))
*end = '\0';
hash_put2("swap", key[i], beg);
beg = end ? end + 1 : NULL;
}
}
else if (strncmp(buffer, "intr ", 5) == 0) {
char delim[] = " \t\n";
char *beg, *end, num[4];
int i;
for (i = 0, beg = buffer + 5; i < 17 && beg != NULL; i++) {
while (strchr(delim, *beg))
beg++;
if ((end = strpbrk(beg, delim)))
*end = '\0';
if (i == 0)
strcpy(num, "sum");
else
qprintf(num, sizeof(num), "%d", i - 1);
hash_put2("intr", num, beg);
beg = end ? end + 1 : NULL;
}
}
//.........这里部分代码省略.........
开发者ID:KCFTech,项目名称:lcd4linux,代码行数:101,代码来源:plugin_proc_stat.c
示例13: write_spec
//.........这里部分代码省略.........
if (format == PACKAGE_LSB)
{
/*
* Use LSB commands to install the init scripts...
*/
for (; i > 0; i --, file ++)
if (tolower(file->type) == 'i' && file->subpackage == subpackage)
{
fprintf(fp, " /usr/lib/lsb/install_initd /etc/init.d/%s\n", file->dst);
fprintf(fp, " /etc/init.d/%s start\n", file->dst);
}
}
else
{
/*
* Find where the frigging init scripts go...
*/
fputs(" rcdir=\"\"\n", fp);
fputs(" for dir in /sbin/rc.d /sbin /etc/rc.d /etc ; do\n", fp);
fputs(" if test -d $dir/rc3.d -o -h $dir/rc3.d; then\n", fp);
fputs(" rcdir=\"$dir\"\n", fp);
fputs(" fi\n", fp);
fputs(" done\n", fp);
fputs(" if test \"$rcdir\" = \"\" ; then\n", fp);
fputs(" echo Unable to determine location of startup scripts!\n", fp);
fputs(" else\n", fp);
for (; i > 0; i --, file ++)
if (tolower(file->type) == 'i' && file->subpackage == subpackage)
{
fputs(" if test -d $rcdir/init.d; then\n", fp);
qprintf(fp, " /bin/rm -f $rcdir/init.d/%s\n", file->dst);
qprintf(fp, " /bin/ln -s %s/init.d/%s "
"$rcdir/init.d/%s\n", SoftwareDir, file->dst, file->dst);
fputs(" else\n", fp);
fputs(" if test -d /etc/init.d; then\n", fp);
qprintf(fp, " /bin/rm -f /etc/init.d/%s\n", file->dst);
qprintf(fp, " /bin/ln -s %s/init.d/%s "
"/etc/init.d/%s\n", SoftwareDir, file->dst, file->dst);
fputs(" fi\n", fp);
fputs(" fi\n", fp);
for (runlevels = get_runlevels(dist->files + i, "0123456");
isdigit(*runlevels & 255);
runlevels ++)
{
if (*runlevels == '0')
number = get_stop(file, 0);
else
number = get_start(file, 99);
qprintf(fp, " /bin/rm -f $rcdir/rc%c.d/%c%02d%s\n", *runlevels,
(*runlevels == '0' || *runlevels == '1' ||
*runlevels == '6') ? 'K' : 'S', number, file->dst);
qprintf(fp, " /bin/ln -s %s/init.d/%s "
"$rcdir/rc%c.d/%c%02d%s\n", SoftwareDir, file->dst,
*runlevels,
(*runlevels == '0' || *runlevels == '1' ||
*runlevels == '6') ? 'K' : 'S', number, file->dst);
}
qprintf(fp, " %s/init.d/%s start\n", SoftwareDir, file->dst);
}
开发者ID:brandongooch,项目名称:epm,代码行数:66,代码来源:rpm.c
示例14: qprintf
//===========================================================================
//
// Parameter: -
// Returns: -
// Changes Globals: -
//===========================================================================
bspbrush_t *MergeBrushes( bspbrush_t *brushlist ) {
int nummerges, merged;
bspbrush_t *b1, *b2, *tail, *newbrush, *newbrushlist;
bspbrush_t *lastb2;
if ( !brushlist ) {
return NULL;
}
qprintf( "%5d brushes merged", nummerges = 0 );
do
{
for ( tail = brushlist; tail; tail = tail->next )
{
if ( !tail->next ) {
break;
}
} //end for
merged = 0;
newbrushlist = NULL;
for ( b1 = brushlist; b1; b1 = brushlist )
{
lastb2 = b1;
for ( b2 = b1->next; b2; b2 = b2->next )
{
//if the brushes don't have the same contents
if ( b1->original->contents != b2->original->contents ||
b1->original->expansionbbox != b2->original->expansionbbox ) {
newbrush = NULL;
} else { newbrush = TryMergeBrushes( b1, b2 );}
if ( newbrush ) {
tail->next = newbrush;
lastb2->next = b2->next;
brushlist = brushlist->next;
FreeBrush( b1 );
FreeBrush( b2 );
for ( tail = brushlist; tail; tail = tail->next )
{
if ( !tail->next ) {
break;
}
} //end for
merged++;
qprintf( "\r%5d", nummerges++ );
break;
} //end if
lastb2 = b2;
} //end for
//if b1 can't be merged with any of the other brushes
if ( !b2 ) {
brushlist = brushlist->next;
//keep b1
b1->next = newbrushlist;
newbrushlist = b1;
} //end else
} //end for
brushlist = newbrushlist;
} while ( merged );
qprintf( "\n" );
return newbrushlist;
} //end of the function MergeBrushes
开发者ID:AdrienJaguenet,项目名称:Enemy-Territory,代码行数:67,代码来源:csg.c
示例15: glob0
/*
* The main glob() routine: compiles the pattern (optionally processing
* quotes), calls glob1() to do the real pattern matching, and finally
* sorts the list (unless unsorted operation is requested). Returns 0
* if things went well, nonzero if errors occurred. It is not an error
* to find no matches.
*/
static int
glob0(const Char *pattern, glob_t *pglob, struct glob_lim *limitp)
{
const Char *qpatnext;
int c, err, oldpathc;
Char *bufnext, patbuf[PATH_MAX];
qpatnext = globtilde(pattern, patbuf, PATH_MAX, pglob);
oldpathc = pglob->gl_pathc;
bufnext = patbuf;
/* We don't need to check for buffer overflow any more. */
while ((c = *qpatnext++) != EOS) {
switch (c) {
case LBRACKET:
c = *qpatnext;
if (c == NOT)
++qpatnext;
if (*qpatnext == EOS ||
g_strchr(qpatnext+1, RBRACKET) == NULL) {
*bufnext++ = LBRACKET;
if (c == NOT)
--qpatnext;
break;
}
*bufnext++ = M_SET;
if (c == NOT)
*bufnext++ = M_NOT;
c = *qpatnext++;
do {
if (c == LBRACKET && *qpatnext == ':') {
do {
err = g_charclass(&qpatnext,
&bufnext);
if (err)
break;
c = *qpatnext++;
} while (c == LBRACKET && *qpatnext == ':');
if (err == -1 &&
!(pglob->gl_flags & GLOB_NOCHECK))
return GLOB_NOMATCH;
if (c == RBRACKET)
break;
}
*bufnext++ = CHAR(c);
if (*qpatnext == RANGE &&
(c = qpatnext[1]) != RBRACKET) {
*bufnext++ = M_RNG;
*bufnext++ = CHAR(c);
qpatnext += 2;
}
} while ((c = *qpatnext++) != RBRACKET);
pglob->gl_flags |= GLOB_MAGCHAR;
*bufnext++ = M_END;
break;
case QUESTION:
pglob->gl_flags |= GLOB_MAGCHAR;
*bufnext++ = M_ONE;
break;
case STAR:
pglob->gl_flags |= GLOB_MAGCHAR;
/* collapse adjacent stars to one,
* to avoid exponential behavior
*/
if (bufnext == patbuf || bufnext[-1] != M_ALL)
*bufnext++ = M_ALL;
break;
default:
*bufnext++ = CHAR(c);
break;
}
}
*bufnext = EOS;
#ifdef DEBUG
qprintf("glob0:", patbuf);
#endif
if ((err = glob1(patbuf, patbuf+PATH_MAX-1, pglob, limitp)) != 0)
return(err);
/*
* If there was no match we are going to append the pattern
* if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified
* and the pattern did not contain any magic characters
* GLOB_NOMAGIC is there just for compatibility with csh.
*/
if (pglob->gl_pathc == oldpathc) {
if ((pglob->gl_flags & GLOB_NOCHECK) ||
((pglob->gl_flags & GLOB_NOMAGIC) &&
!(pglob->gl_flags & GLOB_MAGCHAR)))
return(globextend(pattern, pglob, limitp, NULL));
else
return(GLOB_NOMATCH);
//.........这里部分代码省略.........
开发者ID:NaldoDj,项目名称:openbsd-libc,代码行数:101,代码来源:glob.c
示例16: globexp2
/*
* Recursive brace globbing helper. Tries to expand a single brace.
* If it succeeds then it invokes globexp1 with the new pattern.
* If it fails then it tries to glob the rest of the pattern and returns.
*/
static int
globexp2(const Char *ptr, const Char *pattern, glob_t *pglob,
struct glob_lim *limitp)
{
int i, rv;
Char *lm, *ls;
const Char *pe, *pm, *pl;
Char patbuf[PATH_MAX];
/* copy part up to the brace */
for (lm = patbuf, pm = pattern; pm != ptr; *lm++ = *pm++)
continue;
*lm = EOS;
ls = lm;
/* Find the balanced brace */
for (i = 0, pe = ++ptr; *pe; pe++)
if (*pe == LBRACKET) {
/* Ignore everything between [] */
for (pm = pe++; *pe != RBRACKET && *pe != EOS; pe++)
continue;
if (*pe == EOS) {
/*
* We could not find a matching RBRACKET.
* Ignore and just look for RBRACE
*/
pe = pm;
}
} else if (*pe == LBRACE)
i++;
else if (*pe == RBRACE) {
if (i == 0)
break;
i--;
}
/* Non matching braces; just glob the pattern */
if (i != 0 || *pe == EOS)
return glob0(patbuf, pglob, limitp);
for (i = 0, pl = pm = ptr; pm <= pe; pm++) {
switch (*pm) {
case LBRACKET:
/* Ignore everything between [] */
for (pl = pm++; *pm != RBRACKET && *pm != EOS; pm++)
continue;
if (*pm == EOS) {
/*
* We could not find a matching RBRACKET.
* Ignore and just look for RBRACE
*/
pm = pl;
}
break;
case LBRACE:
i++;
break;
case RBRACE:
if (i) {
i--;
break;
}
/* FALLTHROUGH */
case COMMA:
if (i && *pm == COMMA)
break;
else {
/* Append the current string */
for (lm = ls; (pl < pm); *lm++ = *pl++)
continue;
/*
* Append the rest of the pattern after the
* closing brace
*/
for (pl = pe + 1; (*lm++ = *pl++) != EOS; )
continue;
/* Expand the current pattern */
#ifdef DEBUG
qprintf("globexp2:", patbuf);
#endif
rv = globexp1(patbuf, pglob, limitp);
if (rv && rv != GLOB_NOMATCH)
return rv;
/* move after the comma, to the next string */
pl = pm + 1;
}
break;
default:
break;
//.........这里部分代码省略.........
开发者ID:ScottyBauer,项目名称:sudo-1.8.13,代码行数:101,代码来源:glob.c
示例17: AAS_CreateCurveBrushes
void AAS_CreateCurveBrushes(void)
{
int i, j, n, planenum, numcurvebrushes = 0;
q3_dsurface_t *surface;
q3_drawVert_t *dv_p;
vec3_t points[MAX_PATCH_VERTS];
int width, height, c;
patchCollide_t *pc;
facet_t *facet;
mapbrush_t *brush;
side_t *side;
entity_t *mapent;
winding_t *winding;
qprintf("nummapbrushsides = %d\n", nummapbrushsides);
mapent = &entities[0];
for (i = 0; i < q3_numDrawSurfaces; i++)
{
surface = &q3_drawSurfaces[i];
if ( ! surface->patchWidth ) continue;
// if the curve is not solid
if (!(q3_dshaders[surface->shaderNum].contentFlags & (CONTENTS_SOLID|CONTENTS_PLAYERCLIP)))
{
//Log_Print("skipped non-solid curve\n");
continue;
} //end if
// if this curve should not be used for AAS
if ( q3_dshaders[surface->shaderNum].contentFlags & CONTENTS_NOBOTCLIP ) {
continue;
}
//
width = surface->patchWidth;
height = surface->patchHeight;
c = width * height;
if (c > MAX_PATCH_VERTS)
{
Error("ParseMesh: MAX_PATCH_VERTS");
} //end if
dv_p = q3_drawVerts + surface->firstVert;
for ( j = 0 ; j < c ; j++, dv_p++ )
{
points[j][0] = dv_p->xyz[0];
points[j][1] = dv_p->xyz[1];
points[j][2] = dv_p->xyz[2];
} //end for
// create the internal facet structure
pc = CM_GeneratePatchCollide(width, height, points);
//
for (j = 0; j < pc->numFacets; j++)
{
facet = &pc->facets[j];
//
brush = &mapbrushes[nummapbrushes];
brush->original_sides = &brushsides[nummapbrushsides];
brush->entitynum = 0;
brush->brushnum = nummapbrushes - mapent->firstbrush;
//
brush->numsides = facet->numBorders + 2;
nummapbrushsides += brush->numsides;
brush->contents = CONTENTS_SOLID;
//
//qprintf("\r%6d curve brushes", nummapbrushsides);//++numcurvebrushes);
qprintf("\r%6d curve brushes", ++numcurvebrushes);
//
planenum = FindFloatPlane(pc->planes[facet->surfacePlane].plane, pc->planes[facet->surfacePlane].plane[3]);
//
side = &brush->original_sides[0];
side->planenum = planenum;
side->contents = CONTENTS_SOLID;
side->flags |= SFL_TEXTURED|SFL_VISIBLE|SFL_CURVE;
side->surf = 0;
//
side = &brush->original_sides[1];
if (create_aas)
{
//the plane is expanded later so it's not a problem that
//these first two opposite sides are coplanar
side->planenum = planenum ^ 1;
} //end if
|
请发表评论