type
stringclasses
5 values
content
stringlengths
9
163k
functions
void data_blob_clear(DATA_BLOB *d) { if (d->data) { memset(d->data, 0, d->length); }
functions
void data_blob_clear_free(DATA_BLOB *d) { data_blob_clear(d); data_blob_free(d); }
functions
int data_blob_cmp(const DATA_BLOB *d1, const DATA_BLOB *d2) { int ret; if (d1->data == NULL && d2->data != NULL) { return -1; }
functions
DATA_BLOB data_blob_string_const(const char *str) { DATA_BLOB blob; blob.data = discard_const_p(uint8_t, str); blob.length = str ? strlen(str) : 0; return blob; }
functions
DATA_BLOB data_blob_string_const_null(const char *str) { DATA_BLOB blob; blob.data = discard_const_p(uint8_t, str); blob.length = str ? strlen(str)+1 : 0; return blob; }
functions
DATA_BLOB data_blob_const(const void *p, size_t length) { DATA_BLOB blob; blob.data = discard_const_p(uint8_t, p); blob.length = length; return blob; }
functions
bool data_blob_realloc(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, size_t length) { blob->data = talloc_realloc(mem_ctx, blob->data, uint8_t, length); if (blob->data == NULL) return false; blob->length = length; return true; }
functions
bool data_blob_append(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const void *p, size_t length) { size_t old_len = blob->length; size_t new_len = old_len + length; if (new_len < length || new_len < old_len) { return false; }
defines
#define ALWAYS_BBOX_VS_BBOX
defines
#define MAX_POSITION_LEAFS 1024
defines
#define RADIUS_EPSILON 1.0f
functions
void RotatePoint( vec3_t point, /*const*/ vec3_t matrix[3] ) { vec3_t tvec; VectorCopy( point, tvec ); point[0] = DotProduct( matrix[0], tvec ); point[1] = DotProduct( matrix[1], tvec ); point[2] = DotProduct( matrix[2], tvec ); }
functions
void TransposeMatrix( /*const*/ vec3_t matrix[3], vec3_t transpose[3] ) { int i, j; for ( i = 0; i < 3; i++ ) { for ( j = 0; j < 3; j++ ) { transpose[i][j] = matrix[j][i]; }
functions
void CreateRotationMatrix( const vec3_t angles, vec3_t matrix[3] ) { AngleVectors( angles, matrix[0], matrix[1], matrix[2] ); VectorInverse( matrix[1] ); }
functions
void CM_ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vDir, vec3_t vProj ) { vec3_t pVec; VectorSubtract( point, vStart, pVec ); // project onto the directional vector for this segment VectorMA( vStart, DotProduct( pVec, vDir ), vDir, vProj ); }
functions
float CM_DistanceFromLineSquared( vec3_t p, vec3_t lp1, vec3_t lp2, vec3_t dir ) { vec3_t proj, t; int j; CM_ProjectPointOntoVector( p, lp1, dir, proj ); for ( j = 0; j < 3; j++ ) if ( ( proj[j] > lp1[j] && proj[j] > lp2[j] ) || ( proj[j] < lp1[j] && proj[j] < lp2[j] ) ) { break; }
functions
float CM_VectorDistanceSquared( vec3_t p1, vec3_t p2 ) { vec3_t dir; VectorSubtract( p2, p1, dir ); return VectorLengthSquared( dir ); }
functions
float SquareRootFloat( float number ) { floatint_t t; float x, y; const float f = 1.5F; x = number * 0.5F; t.f = number; t.i = 0x5f3759df - ( t.i >> 1 ); y = t.f; y = y * ( f - ( x * y * y ) ); y = y * ( f - ( x * y * y ) ); return number * y; }
functions
void CM_TestBoxInBrush( traceWork_t *tw, cbrush_t *brush ) { int i; cplane_t *plane; float dist; float d1; cbrushside_t *side; float t; vec3_t startp; if ( !brush->numsides ) { return; }
functions
axial if ( tw->bounds[0][0] > brush->bounds[1][0] || tw->bounds[0][1] > brush->bounds[1][1] || tw->bounds[0][2] > brush->bounds[1][2] || tw->bounds[1][0] < brush->bounds[0][0] || tw->bounds[1][1] < brush->bounds[0][1] || tw->bounds[1][2] < brush->bounds[0][2] ) { return; }
functions
remainder for ( i = 6 ; i < brush->numsides ; i++ ) { side = brush->sides + i; plane = side->plane; // adjust the plane distance apropriately for radius dist = plane->dist + tw->sphere.radius; // find the closest point on the capsule to the plane t = DotProduct( plane->normal, tw->sphere.offset ); ...
functions
intersection if ( d1 > 0 ) { return; }
functions
remainder for ( i = 6 ; i < brush->numsides ; i++ ) { side = brush->sides + i; plane = side->plane; // adjust the plane distance apropriately for mins/maxs dist = plane->dist - DotProduct( tw->offsets[ plane->signbits ], plane->normal ); d1 = DotProduct( tw->start, plane->normal ) - dist; // if c...
functions
void CM_TestInLeaf( traceWork_t *tw, cLeaf_t *leaf ) { int k; int brushnum; cbrush_t *b; cPatch_t *patch; // test box position against all brushes in the leaf for ( k = 0 ; k < leaf->numLeafBrushes ; k++ ) { brushnum = cm.leafbrushes[leaf->firstLeafBrush + k]; b = &cm.brushes[brushnum]; if ( b->check...
functions
BSPC if ( 1 ) { #else if ( !cm_noCurves->integer ) { #endif //BSPC for ( k = 0 ; k < leaf->numLeafSurfaces ; k++ ) { patch = cm.surfaces[ cm.leafsurfaces[ leaf->firstLeafSurface + k ] ]; if ( !patch ) { continue; }
functions
void CM_TestCapsuleInCapsule( traceWork_t *tw, clipHandle_t model ) { int i; vec3_t mins, maxs; vec3_t top, bottom; vec3_t p1, p2, tmp; vec3_t offset, symetricSize[2]; float radius, halfwidth, halfheight, offs, r; CM_ModelBounds( model, mins, maxs ); VectorAdd( tw->start, tw->sphere.offset, top ); VectorSubt...
functions
void CM_TestBoundingBoxInCapsule( traceWork_t *tw, clipHandle_t model ) { vec3_t mins, maxs, offset, size[2]; clipHandle_t h; cmodel_t *cmod; int i; // mins maxs of the capsule CM_ModelBounds( model, mins, maxs ); // offset for capsule center for ( i = 0 ; i < 3 ; i++ ) { offset[i] = ( mins[i] + maxs[i] ) *...
functions
void CM_PositionTest( traceWork_t *tw ) { int leafs[MAX_POSITION_LEAFS]; int i; leafList_t ll; // identify the leafs we are touching VectorAdd( tw->start, tw->size[0], ll.bounds[0] ); VectorAdd( tw->start, tw->size[1], ll.bounds[1] ); for ( i = 0 ; i < 3 ; i++ ) { ll.bounds[0][i] -= 1; ll.bounds[1][i] += 1...
functions
leafs for ( i = 0 ; i < ll.count ; i++ ) { CM_TestInLeaf( tw, &cm.leafs[leafs[i]] ); if ( tw->trace.allsolid ) { break; }
functions
void CM_TraceThroughPatch( traceWork_t *tw, cPatch_t *patch ) { float oldFrac; c_patch_traces++; oldFrac = tw->trace.fraction; CM_TraceThroughPatchCollide( tw, patch->pc ); if ( tw->trace.fraction < oldFrac ) { tw->trace.surfaceFlags = patch->surfaceFlags; tw->trace.contents = patch->contents; }
functions
void CM_TraceThroughBrush( traceWork_t *tw, cbrush_t *brush ) { int i; cplane_t *plane, *clipplane; float dist; float enterFrac, leaveFrac; float d1, d2; qboolean getout, startout; float f; cbrushside_t *side, *leadside; float t; vec3_t startp; vec3_t endp; enterFrac = -1.0; leaveFrac = 1.0; clippl...
functions
relevent if ( d1 <= 0 && d2 <= 0 ) { continue; }
functions
face if ( d1 > d2 ) { // enter f = ( d1 - SURFACE_CLIP_EPSILON ) / ( d1 - d2 ); if ( f < 0 ) { f = 0; }
functions
relevent if ( d1 <= 0 && d2 <= 0 ) { continue; }
functions
face if ( d1 > d2 ) { // enter f = ( d1 - SURFACE_CLIP_EPSILON ) / ( d1 - d2 ); if ( f < 0 ) { f = 0; }
functions
void CM_TraceThroughLeaf( traceWork_t *tw, cLeaf_t *leaf ) { int k; int brushnum; cbrush_t *b; cPatch_t *patch; // trace line against all brushes in the leaf for ( k = 0 ; k < leaf->numLeafBrushes ; k++ ) { brushnum = cm.leafbrushes[leaf->firstLeafBrush + k]; b = &cm.brushes[brushnum]; if ( b->check...
functions
BSPC if ( 1 ) { #else if ( !cm_noCurves->integer ) { #endif for ( k = 0 ; k < leaf->numLeafSurfaces ; k++ ) { patch = cm.surfaces[ cm.leafsurfaces[ leaf->firstLeafSurface + k ] ]; if ( !patch ) { continue; }
functions
void CM_TraceThroughSphere( traceWork_t *tw, vec3_t origin, float radius, vec3_t start, vec3_t end ) { float l1, l2, length, scale, fraction; //float a; float b, c, d, sqrtd; vec3_t v1, dir, intersection; // if inside the sphere VectorSubtract( start, origin, dir ); l1 = VectorLengthSquared( dir ); if ( l1 < S...
functions
else if ( d == 0 ) { //t1 = (- b ) / 2; // slide along the sphere }
functions
void CM_TraceThroughVerticalCylinder( traceWork_t *tw, vec3_t origin, float radius, float halfheight, vec3_t start, vec3_t end ) { float length, scale, fraction, l1, l2; //float a; float b, c, d, sqrtd; vec3_t v1, dir, start2d, end2d, org2d, intersection; // 2d coordinates VectorSet( start2d, start[0], start[1],...
functions
bound if ( intersection[2] <= origin[2] + halfheight && intersection[2] >= origin[2] - halfheight ) { // tw->trace.fraction = fraction; VectorSubtract( intersection, origin, dir ); dir[2] = 0; #ifdef CAPSULE_DEBUG l2 = VectorLength( dir ); if ( l2 <= radius ) { int bah = 1; ...
functions
else if ( d == 0 ) { //t[0] = (- b ) / 2 * a; // slide along the cylinder }
functions
void CM_TraceCapsuleThroughCapsule( traceWork_t *tw, clipHandle_t model ) { int i; vec3_t mins, maxs; vec3_t top, bottom, starttop, startbottom, endtop, endbottom; vec3_t offset, symetricSize[2]; float radius, halfwidth, halfheight, offs, h; CM_ModelBounds( model, mins, maxs ); // test trace bounds vs. capsule ...
functions
with for ( i = 0 ; i < 3 ; i++ ) { offset[i] = ( mins[i] + maxs[i] ) * 0.5; symetricSize[0][i] = mins[i] - offset[i]; symetricSize[1][i] = maxs[i] - offset[i]; }
functions
movement if ( tw->start[0] != tw->end[0] || tw->start[1] != tw->end[1] ) { // height of the expanded cylinder is the height of both cylinders minus the radius of both spheres h = halfheight + tw->sphere.halfheight - radius; // if the cylinder has a height if ( h > 0 ) { // test for collisions between the cy...
functions
void CM_TraceBoundingBoxThroughCapsule( traceWork_t *tw, clipHandle_t model ) { vec3_t mins, maxs, offset, size[2]; clipHandle_t h; cmodel_t *cmod; int i; // mins maxs of the capsule CM_ModelBounds( model, mins, maxs ); // offset for capsule center for ( i = 0 ; i < 3 ; i++ ) { offset[i] = ( mins[i] + maxs[...
functions
void CM_TraceThroughTree( traceWork_t *tw, int num, float p1f, float p2f, vec3_t p1, vec3_t p2 ) { cNode_t *node; cplane_t *plane; float t1, t2, offset; float frac, frac2; float idist; vec3_t mid; int side; float midf; if ( tw->trace.fraction <= p1f ) { return; // already hit something nearer }
functions
node if ( num < 0 ) { CM_TraceThroughLeaf( tw, &cm.leafs[-1 - num] ); return; }
functions
maxs if ( plane->type < 3 ) { t1 = p1[plane->type] - plane->dist; t2 = p2[plane->type] - plane->dist; offset = tw->extents[plane->type]; }
functions
consider if ( t1 >= offset + 1 && t2 >= offset + 1 ) { CM_TraceThroughTree( tw, node->children[0], p1f, p2f, p1, p2 ); return; }
functions
side if ( t1 < t2 ) { idist = 1.0 / ( t1 - t2 ); side = 1; frac2 = ( t1 + offset + SURFACE_CLIP_EPSILON ) * idist; frac = ( t1 - offset + SURFACE_CLIP_EPSILON ) * idist; }
functions
else if ( t1 > t2 ) { idist = 1.0 / ( t1 - t2 ); side = 0; frac2 = ( t1 - offset - SURFACE_CLIP_EPSILON ) * idist; frac = ( t1 + offset + SURFACE_CLIP_EPSILON ) * idist; }
functions
node if ( frac < 0 ) { frac = 0; }
functions
node if ( frac2 < 0 ) { frac2 = 0; }
functions
void CM_Trace( trace_t *results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, const vec3_t origin, int brushmask, int capsule, sphere_t *sphere ) { int i; traceWork_t tw; vec3_t offset; cmodel_t *cmod; cmod = CM_ClipHandleToModel( model ); cm.che...
functions
0 if ( !mins ) { mins = vec3_origin; }
functions
bmodels for ( i = 0 ; i < 3 ; i++ ) { offset[i] = ( mins[i] + maxs[i] ) * 0.5; tw.size[0][i] = mins[i] - offset[i]; tw.size[1][i] = maxs[i] - offset[i]; tw.start[i] = start[i] + offset[i]; tw.end[i] = end[i] + offset[i]; }
functions
specified if ( sphere ) { tw.sphere = *sphere; }
functions
ALWAYS_BBOX_VS_BBOX if ( model == BOX_MODEL_HANDLE || model == CAPSULE_MODEL_HANDLE ) { tw.sphere.use = qfalse; CM_TestInLeaf( &tw, &cmod->leaf ); }
functions
else if ( model == CAPSULE_MODEL_HANDLE ) { if ( tw.sphere.use ) { CM_TestCapsuleInCapsule( &tw, model ); }
functions
ALWAYS_BBOX_VS_BBOX if ( model == BOX_MODEL_HANDLE || model == CAPSULE_MODEL_HANDLE ) { tw.sphere.use = qfalse; CM_TraceThroughLeaf( &tw, &cmod->leaf ); }
functions
else if ( model == CAPSULE_MODEL_HANDLE ) { if ( tw.sphere.use ) { CM_TraceCapsuleThroughCapsule( &tw, model ); }
functions
end if ( tw.trace.fraction == 1 ) { VectorCopy( end, tw.trace.endpos ); }
functions
void CM_BoxTrace( trace_t *results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask, int capsule ) { CM_Trace( results, start, end, mins, maxs, model, vec3_origin, brushmask, capsule, NULL ); }
functions
void CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask, const vec3_t origin, const vec3_t angles, int capsule ) { trace_t trace; vec3_t start_l, end_l; qboolean rotated; vec3_t offset; vec3...
functions
bmodels for ( i = 0 ; i < 3 ; i++ ) { offset[i] = ( mins[i] + maxs[i] ) * 0.5; symetricSize[0][i] = mins[i] - offset[i]; symetricSize[1][i] = maxs[i] - offset[i]; start_l[i] = start[i] + offset[i]; end_l[i] = end[i] + offset[i]; }
functions
collision if ( rotated && trace.fraction != 1.0 ) { // rotation of bmodel collision plane TransposeMatrix( matrix, transpose ); RotatePoint( trace.plane.normal, transpose ); }
includes
#include <ncurses.h>
functions
int load_map(char *filename, char map[MAP_YSIZE][MAP_XSIZE]) { int x, y; FILE *fp; int c; fp = fopen(filename, "r"); if(fp == NULL) { return 1; }
includes
#include <stdio.h>
defines
#define size 30000
functions
void BF_execute(const char* code) { char array[size] = {0}
functions
void BF_executeFile(const char* filename) { char code[size+1] = {0}
functions
Result GDB_InitializeServer(GDBServer *server) { Result ret = server_init(&server->super); if(ret != 0) return ret; server->super.host = 0; server->super.accept_cb = (sock_accept_cb)GDB_AcceptClient; server->super.data_cb = (sock_data_cb) GDB_DoPacket; server->super.close_cb = (soc...
functions
void GDB_FinalizeServer(GDBServer *server) { server_finalize(&server->super); svcCloseHandle(server->statusUpdated); }
functions
void GDB_IncrementServerReferenceCount(GDBServer *server) { AtomicPostIncrement(&server->referenceCount); }
functions
void GDB_DecrementServerReferenceCount(GDBServer *server) { if(AtomicDecrement(&server->referenceCount) == 0) GDB_FinalizeServer(server); }
functions
void GDB_RunServer(GDBServer *server) { server_bind(&server->super, GDB_PORT_BASE); server_bind(&server->super, GDB_PORT_BASE + 1); server_bind(&server->super, GDB_PORT_BASE + 2); server_run(&server->super); }
functions
int GDB_AcceptClient(GDBContext *ctx) { RecursiveLock_Lock(&ctx->lock); Result r = svcDebugActiveProcess(&ctx->debug, ctx->pid); if(R_SUCCEEDED(r)) { DebugEventInfo *info = &ctx->latestDebugEvent; ctx->state = GDB_STATE_CONNECTED; ctx->processExited = ctx->processEnded = false; ...
functions
int GDB_CloseClient(GDBContext *ctx) { RecursiveLock_Lock(&ctx->lock); for(u32 i = 0; i < ctx->nbBreakpoints; i++) { if(!ctx->breakpoints[i].persistent) GDB_DisableBreakpointById(ctx, i); }
functions
void GDB_ReleaseClient(GDBServer *server, GDBContext *ctx) { DebugEventInfo dummy; svcSignalEvent(server->statusUpdated); RecursiveLock_Lock(&ctx->lock); /* There's a possibility of a race condition with a possible user exception handler, but you shouldn't use 'kill' on APPLICATION ti...
functions
GDBCommandHandler GDB_GetCommandHandler(char command) { static const u32 nbHandlers = sizeof(gdbCommandHandlers) / sizeof(gdbCommandHandlers[0]); u32 i; for(i = 0; i < nbHandlers && gdbCommandHandlers[i].command != command; i++); return i < nbHandlers ? gdbCommandHandlers[i].handler : GDB_HANDLER(Unsu...
functions
int GDB_DoPacket(GDBContext *ctx) { int ret; RecursiveLock_Lock(&ctx->lock); GDBFlags oldFlags = ctx->flags; if(ctx->state == GDB_STATE_DISCONNECTED) return -1; int r = GDB_ReceivePacket(ctx); if(r == 0) ret = 0; else if(r == -1) ret = -1; else if(ctx->buffer[0...
functions
else if(ctx->buffer[0] == '$') { GDBCommandHandler handler = GDB_GetCommandHandler(ctx->buffer[1]); ctx->commandData = ctx->buffer + 2; ret = handler(ctx); }
includes
#include <stdlib.h>
includes
#include <stdio.h>
includes
#include <string.h>
functions
void cmdline_failure(char *argv0, char *format, ...) { va_list argp; va_start(argp, format); vfprintf(stderr, format, argp); va_end(argp); esl_usage(stdout, argv0, usage); printf("\nTo see more help on available options, do %s -h\n\n", argv0); exit(1); }
functions
void cmdline_help(char *argv0, ESL_GETOPTS *go) { esl_banner(stdout, argv0, banner); esl_usage (stdout, argv0, usage); puts("\n where general options are:"); esl_opt_DisplayHelp(stdout, go, 1, 2, 80); exit(0); }
main
int main(int argc, char **argv) { ESL_GETOPTS *go = NULL; ESL_RANDOMNESS *r = NULL; int nselect = 0; char *filename = NULL; FILE *fp = NULL; char **larr = NULL; char *buf = NULL; int buflen = 0; char ...
includes
#include <math.h>
defines
#define M_LN2 0.69314718055994530942
defines
#define min(x,y) ((x) < (y)? (x) : (y))
defines
#define local_abs(x) ((unsigned)((x)<0? -(x) : (x)))
functions
FLAC__fixedpoint local__compute_rbps_integerized(FLAC__uint32 err, FLAC__uint32 n) { FLAC__uint32 rbps; unsigned bits; /* the number of bits required to represent a number */ int fracbits; /* the number of bits of rbps that comprise the fractional part */ FLAC__ASSERT(sizeof(rbps) == sizeof(FLAC__fixedpoint)); FL...
functions
FLAC__fixedpoint local__compute_rbps_wide_integerized(FLAC__uint64 err, FLAC__uint32 n) { FLAC__uint32 rbps; unsigned bits; /* the number of bits required to represent a number */ int fracbits; /* the number of bits of rbps that comprise the fractional part */ FLAC__ASSERT(sizeof(rbps) == sizeof(FLAC__fixedpoint))...
functions
void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, unsigned order, FLAC__int32 residual[]) { const int idata_len = (int)data_len; int i; switch(order) { case 0: for(i = 0; i < idata_len; i++) { residual[i] = data[i]; }
functions
void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len, unsigned order, FLAC__int32 data[]) { int i, idata_len = (int)data_len; switch(order) { case 0: for(i = 0; i < idata_len; i++) { data[i] = residual[i]; }
defines
#define MSG_ERR_OLD_VIDEO_DRIVER \
functions
qboolean GL_CheckForExtension(const char *ext) { #ifdef FEATURE_RENDERER2 int i = 0, exts = 0; glGetIntegerv(GL_NUM_EXTENSIONS, &exts); for (i = 0; i < exts; i++) { if (!Q_stricmp(ext, (char *)glGetStringi(GL_EXTENSIONS, i))) { return qtrue; }