Exemplo n.º 1
0
// Function that does getaddrinfo() and calls the callback function when
// the result is available.
// TODO: actually make this function asynchronous. Right now it just calls
// getaddrinfo() (which blocks) and then schedules the callback.
ResolveState *
getaddrinfoAsync(const char *node, const char *service,
		const struct addrinfo *hints, ResolveFlags *flags,
		ResolveCallback callback, ResolveErrorCallback errorCallback,
		ResolveCallbackArg extra) {
	ResolveState *resolveState;

	resolveState = ResolveState_new();
	resolveState->refCount = 1;
#ifdef DEBUG_RESOLVE_REF
	log_add(log_Debug, "ResolveState %08" PRIxPTR ": ref=1 (%d)\n",
			(uintptr_t) resolveState, resolveState->refCount);
#endif
	resolveState->state = Resolve_resolving;
	resolveState->flags = *flags;
	resolveState->callback = callback;
	resolveState->errorCallback = errorCallback;
	resolveState->extra = extra;
	resolveState->result = NULL;
	
	resolveState->error.gaiRes =
			getaddrinfo(node, service, hints, &resolveState->result);
	resolveState->error.err = errno;

	resolveState->callbackID = Callback_add(
			(CallbackFunction) resolveCallback, (CallbackArg) resolveState);

	return resolveState;
}
Exemplo n.º 2
0
/**
 * Adds a pointer to the tail of a doubly-linked list.
 *
 * @param[in] dll   Pointer to the list to have a pointer added to it.
 * @param[in] ptr   The pointer to be added. Should not be `NULL`.
 * @retval    NULL  Out-of-memory. `log_add()` called.
 * @retval    NULL  `ptr == NULL`. `log_add()` called.
 * @return          Pointer to the list element that contains the pointer.
 */
DllElt*
dll_add(
    Dll* const  dll,
    void* const ptr)
{
    DllElt* elt;

    if (ptr == NULL) {
        log_add("Null pointer");
        elt = NULL;
    }
    else {
        elt = log_malloc(sizeof(DllElt), "doubly-linked list element");

        if (elt) {
            elt->ptr = ptr;
            elt->next = NULL;
            elt->prev = dll->tail;
            if (dll->head == NULL)
                dll->head = elt;
            if (dll->tail)
                dll->tail->next = elt;
            dll->tail = elt;
            dll->size++;
        }
    }

    return elt;
}
Exemplo n.º 3
0
static int
InvalidArgument (const char *supplied, const char *opt_name)
{
	log_add (log_Fatal, "Invalid argument '%s' to option %s.",
			supplied, opt_name);
	return EXIT_FAILURE;
}
Exemplo n.º 4
0
/**
 * Logs a usage message.
 */
static void
mls_usage(void)
{
    log_add(
"Usage: %s [options] feed groupId:groupPort serverPort\n"
"Options:\n"
"    -I serverIface    Interface on which the TCP server will listen. Default\n"
"                      is all interfaces.\n"
"    -l logfile        Log to file <logfile> ('-' => standard error stream).\n"
"                      Defaults are standard error stream if interactive and\n"
"                      system logging daemon if not.\n"
"    -q queue          Use product-queue <queue>. Default is \"%s\".\n"
"    -t ttl            Time-to-live of outgoing packets (default is 1):\n"
"                           0  Restricted to same host. Won't be output by\n"
"                              any interface.\n"
"                           1  Restricted to the same subnet. Won't be\n"
"                              forwarded by a router (default).\n"
"                         <32  Restricted to the same site, organization or\n"
"                              department.\n"
"                         <64  Restricted to the same region.\n"
"                        <128  Restricted to the same continent.\n"
"                        <255  Unrestricted in scope. Global.\n"
"    -v                Verbose logging: log INFO level messages.\n"
"    -x                Debug logging: log DEBUG level messages.\n"
"Operands:\n"
"    feed              Identifier of the multicast group in the form of a\n"
"                      feedtype expression\n"
"    groupId:groupPort Internet service address of multicast group, where\n"
"                      <groupId> is either a group-name or a dotted-decimal\n"
"                      IPv4 address and <groupPort> is the port number.\n"
"    serverPort        Port number of TCP server.",
            getulogident(), getQueuePath());
}
Exemplo n.º 5
0
static int
ThreadHelper (void *startInfo) {
	ThreadFunction func;
	void *data;
	SDL_sem *sem;
	TrueThread thread;
	int result;
	
	func = ((struct ThreadStartInfo *) startInfo)->func;
	data = ((struct ThreadStartInfo *) startInfo)->data;
	sem  = ((struct ThreadStartInfo *) startInfo)->sem;

	// Wait until the Thread structure is available.
	SDL_SemWait (sem);
	SDL_DestroySemaphore (sem);
	thread = ((struct ThreadStartInfo *) startInfo)->thread;
	HFree (startInfo);

	result = (*func) (data);

#ifdef DEBUG_THREADS
	log_add (log_Debug, "Thread '%s' done (returned %d).",
			thread->name, result);
	fflush (stderr);
#endif

	UnQueueThread (thread);
	DestroyThreadLocal (thread->localData);
	FinishThread (thread);
	/* Destroying the thread is the responsibility of ProcessThreadLifecycles() */
	return result;
}
Exemplo n.º 6
0
void 
TFB_DrawImage_Delete (TFB_Image *image)
{
	if (image == 0)
	{
		log_add (log_Warning, "INTERNAL ERROR: Tried to delete a null image!");
		/* Should we die here? */
		return;
	}
	LockMutex (image->mutex);

	TFB_DrawCanvas_Delete (image->NormalImg);
			
	if (image->ScaledImg) {
		TFB_DrawCanvas_Delete (image->ScaledImg);
	}

	if (image->Palette)
		HFree (image->Palette);

	UnlockMutex (image->mutex);
	DestroyMutex (image->mutex);
			
	HFree (image);
}
Exemplo n.º 7
0
int
TFB_DrawCommandQueue_Pop (TFB_DrawCommand *target)
{
	LockRecursiveMutex (DCQ_Mutex);

	if (DrawCommandQueue.Size == 0)
	{
		Unlock_DCQ ();
		return (0);
	}

	if (DrawCommandQueue.Front == DrawCommandQueue.Back &&
			DrawCommandQueue.Size != DCQ_MAX)
	{
		log_add (log_Debug, "Augh!  Assertion failure in DCQ!  "
				"Front == Back, Size != DCQ_MAX");
		DrawCommandQueue.Size = 0;
		Unlock_DCQ ();
		return (0);
	}

	*target = DCQ[DrawCommandQueue.Front];
	DrawCommandQueue.Front = (DrawCommandQueue.Front + 1) % DCQ_MAX;

	DrawCommandQueue.Size--;
	DrawCommandQueue.FullSize--;
	UnlockRecursiveMutex (DCQ_Mutex);

	return 1;
}
Exemplo n.º 8
0
/**
 * Adds an entry to the tail of the queue. Does nothing if the queue has been
 * canceled. The queue must be locked.
 *
 * @pre                      `lock(fiq)` has been called
 * @param[in,out] fiq        Pointer to the queue. Not checked.
 * @param[in]     tail       Pointer to the entry to be added. Not checked.
 *                           Must have NULL "previous" and "next" pointers.
 * @retval        0          Success.
 * @retval        ECANCELED  The queue has been canceled. `log_add()` called.
 */
static int
addTail(
    ProdIndexQueue* const fiq,
    Entry* const       tail)
{
    int status;

    if (fiq->isCancelled) {
        log_add("The queue has been shutdown");
        status = ECANCELED;
    }
    else {
        if (fiq->count == 0) {
            fiq->head = fiq->tail = tail;
        }
        else {
            tail->prev = fiq->tail;
            fiq->tail->next = tail;
            fiq->tail = tail;
        }
        fiq->count++;
        status = 0;

        (void)pthread_cond_signal(&fiq->cond);
    }

    return status;
}
void
openAL_GetSourcei (audio_Object srcobj, audio_SourceProp pname,
		audio_IntVal *value)
{
	alGetSourcei ((ALuint) srcobj, (ALenum) pname, (ALint *) value);
	if (pname == AL_SOURCE_STATE)
	{
		switch (*value)
		{
			case AL_INITIAL:
				*value = audio_INITIAL;
				break;
			case AL_STOPPED:
				*value = audio_STOPPED;
				break;
			case AL_PLAYING:
				*value = audio_PLAYING;
				break;
			case AL_PAUSED:
				*value = audio_PAUSED;
				break;
			default:
				log_add (log_Debug, "openAL_GetSourcei(): unknown value %x",
						*value);
				*value = audio_DRIVER_FAILURE;
		}
	}
}
Exemplo n.º 10
0
/**
 * Returns a new multicast sender. The sender isn't active until
 * `mcastSender_start()` is called.
 *
 * @param[out]    sender        Pointer to returned sender. Caller should call
 *                              `mcastSender_free(*sender)` when it's no longer
 *                              needed.
 * @param[in]     serverAddr    Dotted-decimal IPv4 address of the interface on
 *                              which the TCP server will listen for connections
 *                              from receivers for retrieving missed
 *                              data-blocks.
 * @param[in]     serverPort    Port number for TCP server or 0, in which case
 *                              one is chosen by the operating system.
 * @param[in]     groupAddr     Dotted-decimal IPv4 address address of the
 *                              multicast group.
 * @param[in]     groupPort     Port number of the multicast group.
 * @param[in]     ifaceAddr     IP address of the interface to use to send
 *                              multicast packets. "0.0.0.0" obtains the default
 *                              multicast interface. Caller may free.
 * @param[in]     ttl           Time-to-live of outgoing packets.
 *                                    0  Restricted to same host. Won't be
 *                                       output by any interface.
 *                                    1  Restricted to the same subnet. Won't be
 *                                       forwarded by a router (default).
 *                                  <32  Restricted to the same site,
 *                                       organization or department.
 *                                  <64  Restricted to the same region.
 *                                 <128  Restricted to the same continent.
 *                                 <255  Unrestricted in scope. Global.
 * @param[in]     iProd         Initial product-index. The first multicast data-
 *                              product will have this as its index.
 * @param[in]     timeoutFactor Ratio of the duration that a data-product will
 *                              be held by the FMTP layer before being released
 *                              after being multicast to the duration to
 *                              multicast the product. If negative, then the
 *                              default timeout factor is used.
 * @param[in]     doneWithProd  Function to call when the FMTP layer is done
 *                              with a data-product so that its resources may be
 *                              released.
 * @retval        0             Success. `*sender` is set.
 * @retval        1             Invalid argument. `log_add()` called.
 * @retval        2             Non-system runtime error. `log_add()` called.
 * @retval        3             System error. `log_add()` called.
 */
static int
mcastSender_new(
    McastSender** const    sender,
    const char* const      serverAddr,
    const unsigned short   serverPort,
    const char* const      groupAddr,
    const unsigned short   groupPort,
    const char* const      ifaceAddr,
    const unsigned         ttl,
    const FmtpProdIndex   iProd,
    const float            timeoutFactor,
    void                  (*doneWithProd)(FmtpProdIndex iProd))
{
    McastSender* const send = (McastSender*)log_malloc(sizeof(McastSender),
            "multicast sender");
    int                status;

    if (send == NULL) {
        status = 3;
    }
    else {
        status = mcastSender_init(send, serverAddr, serverPort, groupAddr,
                groupPort, ifaceAddr, ttl, iProd, timeoutFactor, doneWithProd);

        if (status) {
            log_add("Couldn't initialize multicast sender");
        }
        else {
            *sender = send;
        }
    }

    return status;      // Eclipse wants to see a return
}
Exemplo n.º 11
0
/**
 * Initializes this module:
 *     - Opens the product-queue named by `getQueuePath()`;
 *     - Redirects the standard input stream to the given input file;
 *     - Initializes the structure `prod`; and
 *     - Initializes the PRNG module associated with the function `random()`.
 *
 * @retval    true           if and only if successful.
 */
static bool pti_init(void)
{
    int               success = false;
    const char* const pqfname = getQueuePath();
    int               status = pq_open(pqfname, PQ_DEFAULT, &pq);
    if (PQ_CORRUPT == status) {
        log_add("The product-queue \"%s\" is corrupt\n", pqfname);
    }
    else if (status) {
        log_errno_q(status, "Couldn't open product-queue \"%s\"", pqfname);
    }
    else {
        prod.data = malloc(max_prod_size);
        if (prod.data == NULL) {
            log_syserr_q("Couldn't allocate buffer for data-product");
        }
        else {
            (void)strncpy(myname, ghostname(), sizeof(myname));
            myname[sizeof(myname)-1] = 0;
            prod.info.origin = myname;
            prod.info.feedtype = feedtype;
            srandom(1); // for `random()`
            seed[2] = random(); seed[1] = random(); seed[0] = random();
            (void)seed48(seed); // for `mrand48()`
            success = true;
        }
    }

    return success;
}
Exemplo n.º 12
0
static bool
GetFleetByIndex (MELEE_STATE *pMS, COUNT index, MeleeTeam *result)
{
	COUNT firstIndex;

	if (index < pMS->load.preBuiltCount)
	{
		MeleeTeam_copy (result, pMS->load.preBuiltList[index]);
		return true;
	}

	index -= pMS->load.preBuiltCount;
	firstIndex = index;

	for ( ; index < pMS->load.numIndices; index++)
	{
		DIRENTRY entry = SetAbsDirEntryTableIndex (pMS->load.dirEntries,
				pMS->load.entryIndices[index]);
		if (LoadTeamImage (entry, result))
			break;  // Success

		{
			const char *fileName;
			fileName = GetDirEntryAddress (entry);
			log_add (log_Warning, "Warning: File '%s' is not a valid "
					"SuperMelee team.", fileName);
		}
	}

	if (index != firstIndex)
		UnindexFleets (pMS, firstIndex, index - firstIndex);

	return index < pMS->load.numIndices;
}
Exemplo n.º 13
0
void log_printf(char *fmt, ...)
{
	static int buffer_len = 128;
	static char *buffer;
	va_list ap;
	int n = 0;

	do {
		if (n)
			buffer_len = n + 1;
		if (!buffer)
			buffer = malloc(buffer_len);
		if (!buffer)
			return;
		va_start(ap, fmt);
		n = vsnprintf(buffer, sizeof(buffer), fmt, ap);
		va_end(ap);
		if (n < 1)
			return;
		if (n >= buffer_len) {
			free(buffer);
			buffer = NULL;
		}
	} while (n >= buffer_len);

	log_add(buffer, n, SOURCE_INTERNAL);
}
Exemplo n.º 14
0
Arquivo: menu.c Projeto: intgr/sc2-uqm
/* Actually display the menu text */
static void
DrawPCMenu (BYTE beg_index, BYTE end_index, BYTE NewState, BYTE hilite, RECT *r)
{
#define PC_MENU_HEIGHT 8
	BYTE pos;
	COUNT i;
	int num_items;
	FONT OldFont;
	TEXT t;
	UNICODE buf[256];

	pos = beg_index + NewState;
	num_items = 1 + end_index - beg_index;
	r->corner.x -= 1;
	r->extent.width += 1;
	DrawFilledRectangle (r);
	if (num_items * PC_MENU_HEIGHT > r->extent.height)
		log_add (log_Error, "Warning, no room for all menu items!");
	else
		r->corner.y += (r->extent.height - num_items * PC_MENU_HEIGHT) / 2;
	r->extent.height = num_items * PC_MENU_HEIGHT + 4;
	DrawPCMenuFrame (r);
	OldFont = SetContextFont (StarConFont);
	t.align = ALIGN_LEFT;
	t.baseline.x = r->corner.x + 2;
	t.baseline.y = r->corner.y + PC_MENU_HEIGHT -1;
	t.pStr = buf;
	t.CharCount = (COUNT)~0;
	r->corner.x++;
	r->extent.width -= 2;
	for (i = beg_index; i <= end_index; i++)
	{
		utf8StringCopy (buf, sizeof buf,
						(i == PM_FUEL) ? pm_fuel_str :
						(i == PM_CREW) ? pm_crew_str :
						GAME_STRING (MAINMENU_STRING_BASE + i));
		if (hilite && pos == i)
		{
			// Currently selected menu option.
			
			// Draw the background of the selection.
			SetContextForeGroundColor (PCMENU_SELECTION_BACKGROUND_COLOR);
			r->corner.y = t.baseline.y - PC_MENU_HEIGHT + 2;
			r->extent.height = PC_MENU_HEIGHT - 1;
			DrawFilledRectangle (r);

			// Draw the text of the selected item.
			SetContextForeGroundColor (PCMENU_SELECTION_TEXT_COLOR);
			font_DrawText (&t);
		}
		else
		{
			// Draw the text of an unselected item.
			SetContextForeGroundColor (PCMENU_TEXT_COLOR);
			font_DrawText (&t);
		}
		t.baseline.y += PC_MENU_HEIGHT;
	}
	SetContextFont (OldFont);
}
Exemplo n.º 15
0
void *
GetResourceData (uio_Stream *fp, DWORD length)
{
	void *result;
	DWORD compLen;

	// Resource data used to be prefixed by its length in package files.
	// A valid length prefix indicated compressed data, and
	// a length prefix ~0 meant uncompressed.
	// Currently, .ct and .xlt files still carry a ~0 length prefix.
	if (ReadResFile (&compLen, sizeof (compLen), 1, fp) != 1)
		return NULL;
	if (compLen != ~(DWORD)0)
	{
		log_add (log_Warning, "LZ-compressed binary data not supported");
		return NULL;
	}
	length -= sizeof (DWORD);

	result = AllocResourceData (length);
	if (!result)
		return NULL;

	if (ReadResFile (result, 1, length, fp) != length)
	{
		FreeResourceData (result);
		result = NULL;
	}

	return result;
}
Exemplo n.º 16
0
/**
 * Returns the process-ID that's contained in a file.
 *
 * @param[in] pathname  The pathname of the file.
 * @retval     0        The file doesn't exist.
 * @retval    -1        Error. `log_add()` called.
 * @return              The process-ID that was in the file.
 */
static pid_t
getPidFromFile(
    const char* const pathname)
{
    long  pid;
    FILE* file = fopen(pathname, "r");

    if (file == NULL) {
        if (errno == ENOENT) {
            pid = 0;
        }
        else {
            log_syserr_q("Couldn't open PID file \"%s\"", pathname);
            pid = -1;
        }
    }
    else {
        pid = parsePid(file);

        if (pid == -1)
            log_add("Couldn't get PID from file \"%s\"", pathname);

        (void)fclose(file);
    } // `file` is open

    return pid;
}
Exemplo n.º 17
0
// [1] -> string logMessage
static int
logHelper(lua_State *luaState, log_Level level) {
	//const char *str = luaL_checkstring(luaState, 1);
	const char *str = lua_tostring(luaState, 1);
	// TODO: print the file name of the Lua script being executed.
	log_add(level, "Lua: %s", str);
	return 0;
}
Exemplo n.º 18
0
GAME_STATE_FILE *
OpenStateFile (int stateFile, const char *mode)
{
	GAME_STATE_FILE *fp;

	if (stateFile < 0 || stateFile >= NUM_STATE_FILES)
		return NULL;
	
	fp = &state_files[stateFile];
	fp->open_count++;
	if (fp->open_count > 1)
		log_add (log_Warning, "WARNING: "
				"State file %s open count is %d after open()",
				fp->symname, fp->open_count);
	
	if (!fp->data)
	{
		fp->data = HMalloc (fp->size_hint);
		if (!fp->data)
			return NULL;
		fp->size = fp->size_hint;
	}

	// we allow reading and writing for any open mode
	// but the mode determines what happens to the file contents
	if (mode[0] == 'w')
	{	// blow the file away
		fp->used = 0;
#ifdef DEBUG
		// paint buffer for tracking writes
		memset (fp->data, 0xCC, fp->size);
#endif
	}
	else if (mode[0] == 'r')
	{	// nothing
	}
	else
	{
		log_add (log_Warning, "WARNING: "
				"State file %s opened with unsupported mode '%s'",
				fp->symname, mode);
	}
	fp->ptr = 0;
	
	return fp;
}
int main(int argc, const char * argv[]) {
    if (argc <= 1) {
        return 0;
    }
    log_add(DEBUGGING, "Copy %s\n", argv[1]);
    copy(argv[1]);
    return 0;
}
int copy(const char *in_object) {
    
    char object[PATH_SIZE];
    
    strcpy(object, in_object);
    struct stat buf;
   // log_add(DEBUGGING, "In copy %s\n", object);
    if (stat(object, &buf) != 0) {
        log_add(FATAL, "stat failed\n");
        return errno;
    }
    if(S_ISDIR(buf.st_mode)) {
        DIR *dir;
        struct dirent *entry;
        
        if ((dir = opendir(object)) == 0) {
            log_add(FATAL, "Can't open directory\n");
            return errno;
        }

        set_dir(get_filename(object), buf.st_mode);
        
        while ((entry = readdir(dir)) != NULL) {
          //  log_add(DEBUGGING, "In while\n");
           // log_add(DEBUGGING, "object is %s\n", object);
            //log_add(DEBUGGING, "file %s\n", entry->d_name);
            if (is_good_file(entry->d_name)) {
                
                strcat(object, "/");
                strcat(object, entry->d_name);
                
                copy(object);
                object[strlen(object)-strlen(entry->d_name)-1] = '\0';
            }
            
        }
        closedir(dir);
        prev_dir();
    }
    else {
      //  log_add(DEBUGGING, "It's file: %s\n", object);
        copy_file(object, curr_out_dir());
    }
    
    return 0;
}
Exemplo n.º 21
0
/*
 * Opens the backend database.
 *
 * ARGUMENTS:
 *      backend         Pointer to pointer to backend structure.  Shall not be
 *                      NULL.  Upon successful return, "*backend" will be set.
 *                      The client should call "beClose(*backend)" when the
 *                      backend is no longer needed.
 *      dir             Pathname of the parent directory of the database.
 *                      Shall not be NULL.  The client can free it upon return.
 *      forWriting      Open the database for writing? 0 <=> no
 * RETURNS:
 *      0               Success.  "*backend" is set.
 *      ENOMEM          System error.  "log_start()" called.
 *      EIO             Backend database error.  "log_start()" called.
 */
RegStatus
beOpen(
    Backend** const     backend,
    const char* const   dir,
    int                 forWriting)
{
    RegStatus   status;
    Backend*    back = (Backend*)malloc(sizeof(Backend));

    assert(NULL != dir);

    if (NULL == back) {
        log_serror("Couldn't allocate %lu bytes", (long)sizeof(Backend));
        status = ENOMEM;
    }
    else {
        DB_ENV*         env;
        DB*             db;
        StringBuf*      path;

        if (0 == (status = sb_new(&path, PATH_MAX))) {
            if (0 == (status = sb_cat(path, dir, "/", DB_DIRNAME))) {
                if (0 == (status = createDbHandle(path, &env, &db))) {
                    if (status = db->open(db, NULL, DB_FILENAME, NULL,
                                          DB_BTREE, forWriting ? DB_CREATE : DB_RDONLY, 0)) {
                        log_add("Couldn't open database \"%s\" in \"%s\" "
                                "for %s", DB_FILENAME, path,
                                forWriting ? "writing" : "reading");
                        status = EIO;
                    }
                    else {
                        back->db = db;
                        back->cursor.dbCursor = NULL;
                        *backend = back;    /* success */
                    }                       /* "db" opened */

                    /*
                     * According to the documentation on DB->open(), if that
                     * call fails, then DB->close() must be called to discard
                     * the DB handle, so DB->close() is the termination
                     * counterpart of db_create() rather than of DB->open().
                     */
                    if (status) {
                        (void)db->close(db, 0);
                        (void)env->close(env, 0);
                    }
                }                       /* "env" allocated */
            }                           /* DB directory pathname created */

            sb_free(path);
        }                               /* "path" allocated */

        if (status)
            free(back);
    }                                   /* "back" allocated */

    return status;
}
Exemplo n.º 22
0
static void
add_binding (keybinding **newptr, int *target)
{
	keybinding *newbinding;
	keypool *searchbase;
	int i;

	/* Acquire a pointer to the keybinding * that we'll be
	 * overwriting.  Along the way, ensure we haven't already
	 * bound this symbol to this target.  If we have, return.*/
	while (*newptr != NULL)
	{
		if ((*newptr)->target == target)
		{
			return;
		}
		newptr = &((*newptr)->next);
	}

	/* Now hunt through the binding pool for a free binding. */

	/* First, find a chunk with free spots in it */

	searchbase = pool;
	while (searchbase->remaining == 0)
	{
		/* If we're completely full, allocate a new chunk */
		if (searchbase->next == NULL)
		{
			searchbase->next = allocate_key_chunk ();
		}
		searchbase = searchbase->next;
	}

	/* Now find a free binding within it */

	newbinding = NULL;
	for (i = 0; i < POOL_CHUNK_SIZE; i++)
	{
		if (searchbase->pool[i].target == NULL)
		{
			newbinding = &searchbase->pool[i];
			break;
		}
	}

	/* Sanity check. */
	if (!newbinding)
	{
		log_add (log_Warning, "add_binding failed to find a free binding slot!");
		return;
	}

	newbinding->target = target;
	newbinding->next = NULL;
	*newptr = newbinding;
	searchbase->remaining--;
}
Exemplo n.º 23
0
/**
 * Recursively log exception "whats".
 */
void log_what(const std::exception& e)
{
    try {
        std::rethrow_if_nested(e);
    } catch (const std::exception& nested) {
        log_what(nested);
    }
    log_add("%s", e.what());
}
Exemplo n.º 24
0
void
ListenState_incRef(ListenState *listenState) {
	assert(listenState->refCount < REFCOUNT_MAX);
	listenState->refCount++;
#ifdef DEBUG_LISTEN_REF
	log_add(log_Debug, "ListenState %08" PRIxPTR ": ref++ (%d)",
			(uintptr_t) listenState, listenState->refCount);
#endif
}
Exemplo n.º 25
0
void
VControl_RemoveKeyBinding (SDLKey symbol, int *target)
{
	if ((symbol < 0) || (symbol >= num_sdl_keys)) {
		log_add (log_Warning, "VControl: Illegal key index %d", symbol);
		return;
	}
	remove_binding (&bindings[symbol], target);
}
Exemplo n.º 26
0
static void log_taper_scan_errmsg(char * errmsg) {
    char *c, *c1;
    if (errmsg == NULL)
        return;

    c = c1 = errmsg;
    while (*c != '\0') {
        if (*c == '\n') {
            *c = '\0';
            log_add(L_WARNING,"%s", c1);
            c1 = c+1;
        }
        c++;
    }
    if (strlen(c1) > 1 )
        log_add(L_WARNING,"%s", c1);
    amfree(errmsg);
}
Exemplo n.º 27
0
void
ConnectState_incRef(ConnectState *connectState) {
	assert(connectState->refCount < REFCOUNT_MAX);
	connectState->refCount++;
#ifdef DEBUG_CONNECT_REF
	log_add(log_Debug, "ConnectState %08" PRIxPTR ": ref++ (%d)\n",
			(uintptr_t) connectState, connectState->refCount);
#endif
}
Exemplo n.º 28
0
void
crc_processRNG(crc_State *state) {
	DWORD seed;

#ifdef DUMP_CRC_OPS
	log_add(log_Debug, "START crc_processRNG().");
#endif

	seed = TFB_SeedRandom(0);
			// This modifies the seed too.
	crc_processDWORD(state, seed);
	TFB_SeedRandom(seed);
			// Restore the old seed.

#ifdef DUMP_CRC_OPS
	log_add(log_Debug, "END   crc_processRNG().");
#endif
}
Exemplo n.º 29
0
// Uninit the global Lua state.
void
luaUqm_uninitState(void) {
	if (luaUqm_globalState != NULL) {
		lua_close(luaUqm_globalState);
		luaUqm_globalState = NULL;
	} else {
		log_add(log_Warning, "Lua state multiply uninitialized");
	}
}
Exemplo n.º 30
0
void
luaUqm_reinitState(void) {
	if (luaUqm_globalState == NULL) {
		log_add(log_Warning, "Lua state reinitialized while NULL");
	} else {
		luaUqm_uninitState ();
	}
	luaUqm_initState ();
}