コード例 #1
0
ファイル: CyberTsParser.cpp プロジェクト: yuyutao/lt
/**
 * @brief Receive stream from libcloud
 * @param pInjectData
 * @param uDataLen
 * @return
 */
static C_RESULT ts_inject_data(C_U8 *pInjectData, C_U32 uDataLen)
{
	if (memWrite(pInjectData, 1, uDataLen, &(ts_param.file)) <= 0)
	{
		m_ts_status = 0;
		memReset(&(ts_param.file));
	}
	if (ts_param.fp)
		fwrite(pInjectData, 1, uDataLen, ts_param.fp);

	return 1;
}
コード例 #2
0
ファイル: memory.c プロジェクト: Almamu/homeworld
/*-----------------------------------------------------------------------------
    Name        : memInit
    Description : Starts the memory allocation module.  Call before any other
                    functions.
    Inputs      : heapStart - start of heap to use.  Should be aligned on at
                    lease 4-bit boundary.
                  heapSize - size of heap to create
    Outputs     : Global heap set up and (optionally) cleared.
    Return      : OKAY if success.
----------------------------------------------------------------------------*/
sdword memInit(void *heapStart, sdword heapSize)
{
#if MEM_ERROR_CHECKING
    if (memModuleInit == TRUE)
        dbgFatal(DBG_Loc, "Memory module started more than once.");
#endif //MEM_ERROR_CHECKING

    dbgAssert(heapStart != NULL && heapSize > MEM_BlockSize * 20);

#if MEM_VERBOSE_LEVEL >= 1
    dbgMessagef("\nMemory module init.  Heap = 0x%x, Length = %d", heapStart, heapSize);
#endif //MEM_VERBOSE_LEVEL >= 1

    memPool = (ubyte *)(((udword)((ubyte *)heapStart + sizeof(memcookie) - 1)) & (~(sizeof(memcookie) - 1)));
    memPoolLength = heapSize;

    memModuleInit = TRUE;

    return(memReset());
}
コード例 #3
0
ファイル: http.c プロジェクト: zuloo/esniper
/* get META refresh URL (if any) */
char *
memGetMetaRefresh(memBuf_t *mp)
{
	char *cp;
	static char *buf = NULL;
	char *bufptr;
	static size_t bufsize = 0;
	char *metaRefresh = NULL;

	if (!buf) {
		bufsize = 1024;
		buf = myMalloc(bufsize);
	}

	/* look for all "meta" tags until Refresh found */
	while (!metaRefresh && (cp = memStr(mp, "<meta")) != NULL) {
		int c;

		bufptr = buf;
		/* copy whole tag to buffer for processing */
		for (c = memGetc(mp); c != EOF && c != '>'; c = memGetc(mp)) {
			*bufptr++ = (char)c;
			if (bufptr > buf + (bufsize -1)) {
				bufsize += 1024;
				buf = myRealloc(buf, bufsize);
			}
		}

		/* terminate string */
		*bufptr = '\0';
		log(("found META tag: %s", buf));

		cp = strstr(buf, "http-equiv=");
		if (!cp) {
			log(("no http-equiv, looking for next"));
			continue;
		}
		cp += 11;

		if (strncasecmp(cp, "\"Refresh\"", 9)) {
			log(("no Refresh, looking for next"));
			continue;
		}

		cp = strstr(buf, "content=\"");
		if (!cp) {
			log(("no content, looking for next"));
			continue;
		}
		cp += 9;

		/* skip delay value (everything until ';') */
		while (*cp && *cp != ';') cp++;
		/* if not end of string skip ';' */
		if (*cp) cp++;
		/* and skip whitespace */
		while (*cp && isspace(*cp)) cp++;

		/* now there should be "url=" with optional whitespace around '=' */
		if (strncasecmp(cp, "url", 3)) {
			log(("no url key, looking for next"));
			continue;
		}
		cp += 3;

		while (*cp && isspace(*cp)) cp++;
		if (*cp != '=') {
			log(("no = after url, looking for next"));
			continue;
		}
		cp++;
		while (*cp && isspace(*cp)) cp++;

		/* this is the beginning of the redirection URL */
		bufptr = cp;
		cp = strchr(bufptr, '"');
		if (!cp) {
			log(("no closing \", looking for next"));
			continue;
		}
		/* cut off terminating '"' and other trailing garbage */
		*cp = '\0';
		metaRefresh = bufptr;
	}

	if (metaRefresh)
		log(("found redirection"));
	else
		log(("no redirection found"));

	memReset(mp);

	return metaRefresh;
}