Example #1
0
// Remove Fragmentation in FreeMemList
static void MergeFragmentation(UINT8 inst_no)
{
    FREE_MEM_T *node1, *node2;

    node1 = FreeMemHead;

    while(node1 != FreeMemTail){
        node2 = FreeMemHead;
        while(node2 != FreeMemTail){
            if(node1->startAddr + node1->size == node2->startAddr){
                node1->size += node2->size;
                printD("find merge area !! ( node1->startAddr + node1->size == node2->startAddr)\n");
                DeleteNodeFromFreeList(node2, inst_no);
                break;
            }
            else if(node1->startAddr == node2->startAddr + node2->size){
                printD("find merge area !! ( node1->startAddr == node2->startAddr + node2->size)\n");
                node1->startAddr = node2->startAddr;
                node1->size += node2->size;
                DeleteNodeFromFreeList(node2, inst_no);
                break;
            }
            node2 = node2->next;
        }
        node1 = node1->next;
    }
}
Example #2
0
static ALLOC_MEM_T * GetCodecVirAddr(UINT8 inst_no, CMM_ALLOC_PRAM_T *in_param)
{
    DWORD                    p_startAddr;
    ALLOC_MEM_T             *p_allocMem;

    printD("GetCodecVirAddr \n");

    p_startAddr = GetMemArea((UINT32)in_param->size, inst_no);

    if(!p_startAddr)
    {
        RETAILMSG(1, (L"[CMM:ERR] There is no more memory\n\r"));
        return NULL;
    }

    p_allocMem = (ALLOC_MEM_T *)malloc(sizeof(ALLOC_MEM_T));
    memset(p_allocMem, 0x00, sizeof(ALLOC_MEM_T));

    // We need to keep only the cached addresses here.
    // If the user requests uncached address, we can do that by specifying
    // PAGE_NOCACHE to VirtualCopy
    //
    p_allocMem->cached_p_addr = p_startAddr;
    p_allocMem->v_addr =  CachedVirAddr + (p_allocMem->cached_p_addr - CODEC_MEM_START);

    printD("v_addr : 0x%x p_addr : 0x%x\n", p_allocMem->v_addr, p_allocMem->cached_p_addr);

    p_allocMem->size = (UINT32)in_param->size;
    p_allocMem->inst_no = inst_no;
    p_allocMem->cacheFlag = in_param->cacheFlag;

    InsertNodeToAllocList(p_allocMem, inst_no);

    return(p_allocMem);
}
Example #3
0
void sendChannel3()
{
    sendHeader(3);
    printUInt(StackInfo::getNeverUsedStackSize());
    printD();
    printUInt(StackInfo::getFreeStackSize());
    printD();
    sendEnd();
}
Example #4
0
// insert node ahead of AllocMemHead
static void InsertNodeToAllocList(ALLOC_MEM_T *node, UINT8 inst_no)
{
    printD("[%d]InsertNodeToAllocList(p_addr : 0x%08x size:%ld cacheflag : %d)\n", inst_no, node->cached_p_addr, node->size, node->cacheFlag);
    node->next = AllocMemHead;
    node->prev = AllocMemHead->prev;
    AllocMemHead->prev->next = node;
    AllocMemHead->prev = node;
    AllocMemHead = node;
    printD("end InsertNodeToAllocList\n");
}
Example #5
0
/*----------------------------------------------------------------------------
*Function: CMM_Close

*Parameters:         OpenHandle        :
*Return Value:        True/False
*Implementation Notes: This function closes the device context identified by
                        OpenHandle 
-----------------------------------------------------------------------------*/
BOOL
CMM_Close(
    DWORD OpenHandle
    )
{
    CODEC_MEM_CTX *CodecMem;
    DWORD    ret;
    ALLOC_MEM_T *node, *tmp_node;
    int        count=0;

    ret = LockCMMMutex();
    if(!ret){
        RETAILMSG(1, (TEXT("[CMM_Close] CMM Mutex Lock Fail\r\n")));
        return FALSE;
    }

    CodecMem = (CODEC_MEM_CTX *)OpenHandle;
    printD("[%d][CMM Close] \n", CodecMem->inst_no);
    
    if(!CodecMem){
        RETAILMSG(1, (TEXT("[CMM_Close] CMM Invalid Input Handle\r\n")));
        UnlockCMMMutex();
        return FALSE;
    }

    printD("[CMM_Close] CodecMem->inst_no : %d CodecMem->callerProcess : 0x%x\n", CodecMem->inst_no, CodecMem->callerProcess);

    __try
    {
        // release u_addr and v_addr accoring to inst_no
        for(node = AllocMemHead; node != AllocMemTail; node = node->next){
            if(node->inst_no == CodecMem->inst_no){
                tmp_node = node;
                node = node->prev;
                ReleaseAllocMem(tmp_node, CodecMem);
            }
        }
    }
    __except ( EXCEPTION_EXECUTE_HANDLER )
    {
       RETAILMSG( 1, ( _T("CMM_Close:Exception in releasing memory\n")) );
        return FALSE;
    }
    
    printD("[%d][CMM Close] MergeFragmentation\n", CodecMem->inst_no);
    MergeFragmentation(CodecMem->inst_no);

    ReturnInstanceNo(CodecMem->inst_no);

    free(CodecMem);
    UnlockCMMMutex();


    return TRUE;
}
Example #6
0
void mainLoop(void) {
	DIR*	inpDir;
	struct dirent	*cdEntry;
	struct itimerval	tm_alarm;
	struct sigaction sa;

	/* if everything went ok, we should have a pointer in input_dir with the input directory name */
	if (!input_dir) {
		input_dir=(char*)malloc(sizeof(char)*PATH_MAX);
		getcwd(input_dir, PATH_MAX);
	}
	if ( ( inpDir = opendir(input_dir)) == NULL) {
		fprintf (stderr, "Cannot open %s, system error:%s\n", input_dir, strerror(errno));
		exit ( EXIT_FAILURE );
	}
	printD ("Opened %s successfully\n", input_dir);
	printD ("Scanning Directory...\n");
	/* mainly it seems everything ok, so initialize datastructs for our data */
	curMovie = (struct ST_movie*)malloc(sizeof(struct ST_movie));
	curMovie->actors = NULL;
	curMovie->plot = NULL;
	curMovie->tagline = NULL;
	curTV = (struct ST_tv*)malloc(sizeof(struct ST_tv));
	curTV->actors = NULL;
	curTV->plot = NULL;
	curTV->tagline = NULL;
	printD ("Setting up timer...\n");
	tm_alarm.it_value.tv_sec = display_alarm_wait;
	tm_alarm.it_value.tv_usec = 0L;
	tm_alarm.it_interval.tv_sec = display_alarm_wait;
	tm_alarm.it_interval.tv_usec = 0L;
	memset (&sa, 0, sizeof(struct sigaction));
	sa.sa_handler = &printStat;
	sigaction (SIGALRM, &sa, NULL);
	setitimer (ITIMER_REAL, &tm_alarm, NULL);
	printf ("Starting my work in directory: %s\n", input_dir);
	while (( cdEntry = readdir(inpDir)) != NULL) 	{
		/* is it a .xml File ? */
		if (strncasecmp(".xml", &cdEntry->d_name[strlen(&cdEntry->d_name[0])-4], 4) == 0 ) {
			if (parseXML(input_dir, &cdEntry->d_name[0])) {
				printD ("Successfully parsed: %s\n", &cdEntry->d_name[0]);
			}
			else {
				printD ("Parsing of XML failed:%s\n", &cdEntry->d_name[0]);
			}
		}
	}
	printf ("\nTV Episodes written:%li, ", TVCntr);
	printf ("Movies written:%li, ", movieCntr);
	printf ("Total entries written:%li", mediaCntr);
	if (db_newstable)
		createNews();
	closedir(inpDir);
}
Example #7
0
void sendChannel3()
{
    sendHeader(3);
#ifdef    ENABLE_STACK_INFO //ENABLE_SERIAL_LOG
    printUInt(StackInfo::getNeverUsedStackSize());
    printD();
    printUInt(StackInfo::getFreeStackSize());
    printD();
#endif
    sendEnd();
}
Example #8
0
void sendHeader(uint16_t channel)
{
    CRC = 0;
    printChar('$');
    printUInt(channel);
    printD();
    printUInt(Program::programType+1);
    printD();

    printUInt(currentTime/1000);   //timestamp
    printChar('.');
    printUInt((currentTime/100)%10);   //timestamp
    printD();
}
Example #9
0
BOOL connectDB(void) {
	MY_CHARSET_INFO cs;

	if (( mysql_conn = mysql_init(NULL)) == NULL) 	{
		fprintf (stderr, "Initializing mysql-library failed\n");
		return (FALSE);
	}
	if ( mysql_real_connect (mysql_conn, db_host, db_user, db_pass, db_dbname, 0, NULL, CLIENT_COMPRESS) == NULL ) {
		/* connection failed */
		fprintf (stderr, "Connection to %s failed with error:\n\t%s\n", db_host, mysql_error(mysql_conn));
		return (FALSE);
	}
	printD ("Connection to:%s succeeded.\n", db_host);
	if (mysql_set_character_set(mysql_conn, "UTF8") != 0) {
		fprintf (stderr, "Error while setting mysql character set to utf-8\n");
	}

	if (do_debug) {
		mysql_get_character_set_info(mysql_conn, &cs);
		printD("character set information:\n");
		printD("character set name: %s\n", cs.name);
		printD("collation name: %s\n", cs.csname);
		printD("comment: %s\n", cs.comment);
		printD("directory: %s\n", cs.dir);
		printD("multi byte character min. length: %d\n", cs.mbminlen);
		printD("multi byte character max. length: %d\n", cs.mbmaxlen);
	}

	return (TRUE);
}
Example #10
0
static void ReleaseAllocMem(ALLOC_MEM_T *node, CODEC_MEM_CTX *CodecMem)
{
    FREE_MEM_T *free_node;
    BOOL        r;

    __try
    {
        printD("decommit CodecAddr\n");
        r = VirtualFreeEx(CodecMem->callerProcess,    // HANDLE hProcess
                          node->u_addr,
                          0,
                          MEM_RELEASE);
        if (r == FALSE)
        {
            RETAILMSG(1, (L"[%d][CMM_Close] CMM VirtualFreeEx returns FALSE.(u_addr : 0x%08x cacheFlag : %d callerprocess:%ld)\n", 
            CodecMem->inst_no, node->u_addr, node->cacheFlag, CodecMem->callerProcess));
        }

        free_node = (FREE_MEM_T    *)malloc(sizeof(FREE_MEM_T));
        free_node->startAddr = node->cached_p_addr;
        free_node->size = node->size;
        InsertNodeToFreeList(free_node, CodecMem->inst_no);

        // Delete from AllocMem list
        DeleteNodeFromAllocList(node, CodecMem->inst_no);
    }
    __except ( EXCEPTION_EXECUTE_HANDLER )
    {
        RETAILMSG( 1, ( _T("CMM ReleaseAllocMem exception occurred\n")) );
    }
}
Example #11
0
static void DeleteNodeFromAllocList(ALLOC_MEM_T *node, UINT8 inst_no)
{
    printD("[%d]DeleteNodeFromAllocList(p_addr : 0x%08x size:%ld cacheflag : %d)\n", inst_no, node->cached_p_addr, node->size, node->cacheFlag);
    __try
    {
        if(node == AllocMemTail){
            RETAILMSG(1, (TEXT("[CMM] DeleteNodeFromAllocList :: InValid node\n")));
            return;
        }

        if(node == AllocMemHead)
            AllocMemHead = node->next;

        node->prev->next = node->next;
        node->next->prev = node->prev;

        free(node);
    }
    __except ( EXCEPTION_EXECUTE_HANDLER )
    {
        RETAILMSG( 1, ( _T("CMM DeleteNodeFromAllocList exception occurred\n")) );
    }

#if DEBUG
    PrintList();
#endif
}
Example #12
0
int main(int argc, char *argv[]) {
    int i, j;
    int u, v, w;

    FILE *fin = fopen("dist.txt", "r");
    fscanf(fin, "%d", &e);
    for (i = 0; i < e; ++i)
        for (j = 0; j < e; ++j)
            dist[i][j] = 0;
    n = -1;
    for (i = 0; i < e; ++i) {
        fscanf(fin, "%d%d%d", &u, &v, &w);
        dist[u][v] = w;
        n = MAX(u, MAX(v, n));
    }
    fclose(fin);

    dijkstra(1);

    printD();

    printf("\n");
    for (i = 1; i <= n; ++i) {
        printf("Path to %d: ", i);
        printPath(i);
        printf("\n");
    }

    return 0;
}
Example #13
0
void printDevina(int x, int y) {
	printD(x,y);
	printE(x+4*SIZE+GAP,y);
	printV(x+7*SIZE+2*GAP,y);
	printI(x+11*SIZE+3*GAP,y);
	printN(x+12*SIZE+4*GAP,y);
	printA(x+16*SIZE+5*GAP,y);
}
Example #14
0
static DWORD GetMemArea(UINT32 allocSize, UINT8 inst_no)
{
    FREE_MEM_T    *node, *match_node = NULL;
    DWORD        allocAddr = 0;
    int            i = 0;

    printD("request Size : %ld\n", allocSize);
    
    if(FreeMemHead == FreeMemTail){
        RETAILMSG(1, (TEXT("All memory is gone\r\n")));
        return(allocAddr);
    }

    // find best chunk of memory
    for(node = FreeMemHead; node != FreeMemTail; node = node->next){

        if(match_node != NULL){
            if((node->size >= allocSize) && (node->size < match_node->size))
                match_node = node;
        }
        else{
            if(node->size >= allocSize)
                match_node = node;
        }                

    }
    printD("match : startAddr(0x%08x) size(%ld)\n", match_node->startAddr, match_node->size);

    // rearange FreeMemArea
    if(match_node != NULL){
        allocAddr = match_node->startAddr;
        match_node->startAddr += allocSize;
        match_node->size -= allocSize;
        
        if(match_node->size == 0)          // delete match_node.
             DeleteNodeFromFreeList(match_node, inst_no);

        return(allocAddr);
    }
    else RETAILMSG(1, (TEXT("there is no suitable chunk\r\n")));

    return(allocAddr);
}
Example #15
0
/*----------------------------------------------------------------------------
*Function: CMM_Init

*Parameters:         dwContext        :
*Return Value:        True/False
*Implementation Notes: Initialize JPEG Hardware 
-----------------------------------------------------------------------------*/
DWORD
CMM_Init(
    DWORD dwContext
    )
{
    HANDLE            h_Mutex;
    FREE_MEM_T *    freenode;
    ALLOC_MEM_T *   allocnode;
    PHYSICAL_ADDRESS    ioPhysicalBase = {0,0};

    printD("\n[CMM_Init]\n");

    
    // Mutex initialization
    h_Mutex = CreateCMMmutex();
    if (h_Mutex == NULL) 
    {
        RETAILMSG(1, (TEXT("[CMM_Init] CMM Mutex Initialize error : %d \r\n"),GetLastError()));    
        return FALSE;
    }

    ioPhysicalBase.LowPart = CODEC_MEM_START;
    CachedVirAddr = (UINT8 *)MmMapIoSpace(ioPhysicalBase, CODEC_MEM_SIZE, TRUE);
    if (CachedVirAddr == NULL)
    {
        RETAILMSG(1, (TEXT("[CMM_Init] MmMapIoSpace failed: %d\r\n"),GetLastError()));    
        return FALSE;
    }

    // init alloc list, if(AllocMemHead == AllocMemTail) then, the list is NULL
    allocnode = (ALLOC_MEM_T *)malloc(sizeof(ALLOC_MEM_T));
    memset(allocnode, 0x00, sizeof(ALLOC_MEM_T));
    allocnode->next = allocnode;
    allocnode->prev = allocnode;
    AllocMemHead = allocnode;
    AllocMemTail = AllocMemHead;

    // init free list, if(FreeMemHead == FreeMemTail) then, the list is NULL
    freenode = (FREE_MEM_T *)malloc(sizeof(FREE_MEM_T));
    memset(freenode, 0x00, sizeof(FREE_MEM_T));
    freenode->next = freenode;
    freenode->prev = freenode;
    FreeMemHead = freenode;
    FreeMemTail = FreeMemHead;

    freenode = (FREE_MEM_T *)malloc(sizeof(FREE_MEM_T));
    memset(freenode, 0x00, sizeof(FREE_MEM_T));
    freenode->startAddr = CODEC_MEM_START;
    freenode->size = CODEC_MEM_SIZE;
    InsertNodeToFreeList(freenode, -1);

    return TRUE;
}
Example #16
0
// insert node ahead of FreeMemHead
static void InsertNodeToFreeList(FREE_MEM_T *node,  UINT8 inst_no)
{
    printD("[%d]InsertNodeToFreeList(startAddr : 0x%08x size:%ld)\n", inst_no, node->startAddr, node->size);
    node->next = FreeMemHead;
    node->prev = FreeMemHead->prev;
    FreeMemHead->prev->next = node;
    FreeMemHead->prev = node;
    FreeMemHead = node;
#if DEBUG
    PrintList();
#endif
}
Example #17
0
void sendChannel2(bool adc)
{
    sendHeader(2);
    ANALOG_INPUTS_FOR_ALL(it) {
        uint16_t v;
        if(adc) v = AnalogInputs::getAvrADCValue(it);
        else    v = AnalogInputs::getRealValue(it);
        printUInt(v);
        printD();
    }
    printUInt(Balancer::balance);
    printD();

    uint16_t pidV=0;
#ifdef ENABLE_GET_PID_VALUE
    pidV = hardware::getPIDValue();
#endif
    printUInt(pidV);
    printD();
    sendEnd();
}
Example #18
0
void sendChannel1()
{
    sendHeader(1);
    //analog inputs
    for(uint8_t i=0;i < sizeOfArray(channel1);i++) {
        AnalogInputs::Name name = pgm::read(&channel1[i]);
        uint16_t v = AnalogInputs::getRealValue(name);
        printUInt(v);
        printD();
    }

    for(uint8_t i=0;i<MAX_BANANCE_CELLS;i++) {
        printUInt(TheveninMethod::getReadableRthCell(i));
        printD();
    }

    printUInt(TheveninMethod::getReadableBattRth());
    printD();

    printUInt(TheveninMethod::getReadableWiresRth());
    printD();

    printUInt(Monitor::getChargeProcent());
    printD();
    printUInt(Monitor::getETATime());
    printD();

    sendEnd();
}
Example #19
0
void sendChannel2(bool adc)
{
    sendHeader(2);
    FOR_ALL_INPUTS(it) {
        uint16_t v;
        if(adc) v = AnalogInputs::getAvrADCValue(it);
        else    v = AnalogInputs::getRealValue(it);
        printUInt(v);
        printD();
    }
    printUInt(Balancer::balance_);
    printD();

    uint16_t pidV=0;
#ifdef ENABLE_GET_PID_VALUE
    pidV = hardware::getPIDValue();
#endif
//    printUInt(pidV);
    printUInt(TheveninMethod::idebug_);
    printD();
    sendEnd();
}
Example #20
0
static void PrintList()
{
    ALLOC_MEM_T    *node1;
    FREE_MEM_T        *node2;
    int                 count = 0;
    DWORD            p_addr;

    for(node1 = AllocMemHead; node1 != AllocMemTail; node1 = node1->next){
        p_addr = node1->cached_p_addr;
        
        printD("     [AllocList][%d] inst_no : %d p_addr : 0x%08x v_addr:0x%08x size:%ld cacheflag : %d\n", 
            count++, node1->inst_no,  p_addr, node1->v_addr, node1->size, node1->cacheFlag);

    }
                
    count = 0;
    for(node2 = FreeMemHead; node2 != FreeMemTail; node2 = node2->next){
            printD("     [FreeList][%d] startAddr : 0x%08x size:%ld\n", count++, node2->startAddr , node2->size);

    }
    
    
}
Example #21
0
int main(int argc, char *argv[]) {
	int i, j;
	int  v, w, x;
	float f;

	// change "input" to "argv[1]" later
	FILE *fin = fopen("input", "r");
	fscanf(fin, "%d", &nodes);

	char *s[nodes];
	char t[MAXSIZE];
	char u[MAXSIZE];

	for (i = 0; i < nodes; i++) {
		s[i] = malloc(MAXSIZE);
		fscanf(fin, "%s %f", s[i], &f);
	}

	fscanf(fin, "%d", &edges);

	for (i = 0; i < edges; ++i)
		for (j = 0; j < edges; ++j)
			dist[i][j] = 0;
	for (i = 0; i < edges; ++i) {
		fscanf(fin, "%s%s%d", t, u, &x);
		v = find(s, nodes, t);
		w = find(s, nodes, u);
		printf("%d %d %d\n", v, w, x);
		dist[v][w] = x;
	}
	fclose(fin);
	//dijkstra(0);
	dijkstra(1);
	//dijkstra(2);
	//dijkstra(3);

	printD();

	printf("\n");
	for (i = 0; i < nodes; i++) {
		printf("Path to %d: ", i);
		printPath(i);
		printf("\n");
	}

	return 0;
}
Example #22
0
File: main.c Project: xwaynec/eplab
int main() 
{
	char i, j , k = 5;
	//char u = 1, v = 2, w = 4;

	store_cpu_rate(16);

	P0_DIR &= ~0x28;
	P0_ALT &= ~0x28;

	serial_init(19200);

	for(n=0;n<6;n++)
	{
		blink_led();
		mdelay(400);
	}

	n = GRAPHSIZE;


	while(1)
	{
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				dist[i][j] = (k++)%30;
		//n = -1;
		//for (i = 0; i < 6; i++) {
		//fscanf(fin, "%d%d%d", &u, &v, &w);
		//	dist[u][v] = w++;
		//	n = MAX(u, MAX(v+w, n));
		//}
		//fclose(fin);
		for(j=0;j<n;j++)	
			dijkstra(j);

		dij_counter++;

		int_print(dij_counter);
		puts("\r\n");
		
		printD();
	}

	return 0;
}
Example #23
0
/*----------------------------------------------------------------------------
*Function: CMM_DeInit

*Parameters:         InitHandle        :
*Return Value:        True/False
*Implementation Notes: Deinitialize JPEG Hardware 
-----------------------------------------------------------------------------*/
BOOL
CMM_Deinit(
    DWORD InitHandle
    )
{
    CODEC_MEM_CTX *CodecMem;

    printD("[CMM_DeInit] CMM_Deinit\n");
    CodecMem = (CODEC_MEM_CTX *)InitHandle;

    if(!CodecMem){
        RETAILMSG(1, (TEXT("[CMM_DeInit] CMM Invalid Input Handle\r\n")));
        return FALSE;
    }

    DeleteCMMMutex();    
    return TRUE;
}
Example #24
0
BOOL POST_WaitforPostDone( void )
{
    UINT    output, i;

    for (i=0;; i++) 
    {
        output = v_pPOST_SFR->POST_START_VIDEO & (0x1<<31);
        if(output == 0)
            break;
        
        if(i == 10000)
        {
            RETAILMSG(1, (TEXT("DD::POST PROCESS FAILED \r\n")));
            return FALSE;
        }
        Sleep(1);
    }
    printD("DD::POST_WaitforPostDone(i : %d)\n", i);
    return TRUE;
}
Example #25
0
BOOL writeToDB (BOOL isTV) {
	char* SQLexec;
	unsigned long struL;

	/* allocate the maximum possible value */
	struL = isTV ? sizeof(struct ST_tv) : sizeof(struct ST_movie);
	struL += isTV ? strlen(db_FILL_TVTABLE) : strlen(db_FILL_MOVIETABLE);
	struL += isTV ? strlen(curTV->actors) : strlen(curMovie->actors);
	struL += isTV ? strlen(curTV->tagline) : strlen(curMovie->tagline);
	struL += isTV ? strlen(curTV->plot) : strlen(curMovie->plot);

	SQLexec = (char*)malloc(sizeof(char)*struL);
	bzero (SQLexec, struL);

	printD ("Preparing SQLExec Statement ...\n");

	if (isTV) {
		sprintf (SQLexec, db_FILL_TVTABLE, db_tvtable,
				curTV->seriesname, curTV->season, curTV->episode, curTV->episodename, curTV->mediatype, curTV->language, curTV->imdblink, curTV->isHD ? 'Y' : 'N',
				curTV->directors, curTV->writers, curTV->actors, curTV->genres, curTV->plot, curTV->tagline, curTV->year, curTV->imglink, curTV->rating, curTV->filename);
	}
	else {
		sprintf (SQLexec, db_FILL_MOVIETABLE, db_movietable,
				curMovie->moviename, curMovie->mediatype, curMovie->language, curMovie->imdblink, curMovie->isHD ? 'Y' : 'N',
				curMovie->directors, curMovie->writers, curMovie->actors, curMovie->genres, curMovie->plot, curMovie->tagline, curMovie->year, curMovie->imglink, curMovie->rating, curMovie->filename);
	}

	/* Execute query and check result */
	if (mysql_real_query(mysql_conn, SQLexec, strlen(SQLexec)) != 0) {
		if (mysql_errno(mysql_conn) != ER_DUP_ENTRY)	/* don't print duplicates, that's not really an error */
		fprintf (stderr, "Error while saving Data to Table:%s.\nError was:%i\n", db_movietable, mysql_errno(mysql_conn));
	}
	else {
		isTV ? TVCntr++ : movieCntr++;
		mediaCntr++;
	}

	free (SQLexec);

	return (TRUE);
}
Example #26
0
/*----------------------------------------------------------------------------
*Function: CMM_Open

*Parameters:         InitHandle        :Handle to JPEG  context
                    dwAccess        :
                    dwShareMode        :File share mode of JPEG
*Return Value:        This function returns a handle that identifies the 
                    open context of JPEG  to the calling application.
*Implementation Notes: Opens JPEG CODEC device for reading, writing, or both 
-----------------------------------------------------------------------------*/
DWORD
CMM_Open(
    DWORD InitHandle,
    DWORD dwAccess,
    DWORD dwShareMode
    )
{
    CODEC_MEM_CTX *CodecMem;
    DWORD    ret;
    UINT8    inst_no;


    ret = LockCMMMutex();
    if(!ret){
        RETAILMSG(1, (TEXT("[CMM_Open] CMM Mutex Lock Fail\r\n")));
        return FALSE;
    }

    // check the number of instance 
    if((inst_no = GetInstanceNo()) < 0){
        RETAILMSG(1, (TEXT("[CMM_Open] Instance Number error-too many instance\r\n")));
        UnlockCMMMutex();
        return FALSE;
    }

    CodecMem = (CODEC_MEM_CTX *)malloc(sizeof(CODEC_MEM_CTX));
    if(CodecMem == NULL){
        RETAILMSG(1, (TEXT("[CMM_Init] CodecMem allocatopn failed\r\n")));
        UnlockCMMMutex();
        return FALSE;
    }
    
    memset(CodecMem, 0x00, sizeof(CODEC_MEM_CTX));

    CodecMem->inst_no = inst_no;
    printD("\n*****************************\n[CMM_Open] instanceNo : %d\n*****************************\n", CodecMem->inst_no);
    PrintList();
    UnlockCMMMutex();
    return (DWORD)CodecMem;
}
Example #27
0
static void DeleteNodeFromFreeList( FREE_MEM_T *node, UINT8 inst_no)
{
    printD("[%d]DeleteNodeFromFreeList(startAddr : 0x%08x size:%ld)\n", inst_no, node->startAddr, node->size);
    __try
    {
        if(node == FreeMemTail){
            RETAILMSG(1, (TEXT("[CMM] DeleteNodeFromFreeList :: InValid node\n")));
            return;
        }

        if(node == FreeMemHead)
            FreeMemHead = node->next;

        node->prev->next = node->next;
        node->next->prev = node->prev;

        free(node);
    }
    __except ( EXCEPTION_EXECUTE_HANDLER )
    {
        RETAILMSG( 1, ( _T("CMM DeleteNodeFromFreeList exception occurred\n")) );
    }
}
int main(int argc,char* argv[]) {

	/***********************************DECLARATIONS***********************************/
	char data_dir[100],filename[100],input_buffer[50]="";
	extern int root;
	extern int pid,cpid,ppid;
	int fbfd,ioct,map,val=10;
	int* ofile,opfd;
	long frame_num=1,loop=1,read_count=0,reqd_frames,write_count=0,size;
	unsigned int i,j;
	unsigned int* fbuffer;

	struct fb_fix_screeninfo fscreeninfo;
	struct fb_var_screeninfo vscreeninfo;
	struct timeval finish,start;

	CommandData cmd;
	/**********************************~DECLARATIONS***********************************/


	/***********************************INITITIALIZE***********************************/
	gettimeofday(&start,NULL);
	initCommandData(&cmd);
	setCommandData(&cmd,argc,argv);

	if((argc<2) || (argc==2 && argv[1][0]=='-'
					&& argv[1][1]=='h' && !argv[1][2])) {
		displayAppUsage(&cmd);
		displayAppInfo(&cmd);
		__android_log_print(ANDROID_LOG_INFO,TAG_INFO,"Displaying help menu");
		return 0;
	}

	if(checkRoot()==0) {
		//return -1;
	}

	if((fbfd=open(cmd.data[KEY('c')],O_DIRECTORY))<0) {
		printD("Cannot open directory '%s'\n",cmd.data[KEY('c')]);
		__android_log_print(ANDROID_LOG_ERROR,TAG_ERR,
				"Cannot open directory '%s'",cmd.data[KEY('c')]);
		return 1;
	}
	__android_log_print(ANDROID_LOG_INFO,TAG_INFO,"Data Dir : %s",cmd.data[KEY('c')]);
	close(fbfd);

	fbfd=open(cmd.data[KEY('z')],O_RDONLY);
	if(fbfd==-1) {
		__android_log_print(ANDROID_LOG_ERROR,TAG_ERR,
			"Could not open framebuffer fbfd=%d errno=%d",fbfd,errno);
		return 2;
	}
	ioct=ioctl(fbfd,FBIOGET_VSCREENINFO,&vscreeninfo);
	if(ioct==-1) {
		__android_log_print(ANDROID_LOG_ERROR,TAG_ERR,
				"VSCREEN-IOCTL failed ioct=%d errno=%d",ioct,errno);
		return 3;
	}
	ioct=ioctl(fbfd,FBIOGET_FSCREENINFO,&fscreeninfo);
	if(ioct==-1) {
		__android_log_print(ANDROID_LOG_ERROR,TAG_ERR,
				"FSCREEN-IOCTL failed ioct=%d errno=%d",ioct,errno);
		return 4;
	}

	//cpid = ppid = pid = getpid();
	//signal(SIGUSR1,sigcatcher);
	/**********************************~INITITIALIZE***********************************/


	/**************************************MMAP()**************************************/
	/*size = fscreeninfo.smem_len/2;
	fbuffer=(unsigned int*)mmap(0,size,PROT_READ,MAP_SHARED,fbfd,0);
	printD("Address: %x\n", fbuffer);*/
	/*************************************~MMAP()**************************************/


	/**************************************VSCREEN*************************************/

	printD("\nVscreen Info:-\n");
	printD(" Xres   = %4ld | Yres   = %4ld\n",vscreeninfo.xres,vscreeninfo.yres);
	printD(" BPP    = %4ld | Height = %4ld | Width = %4ld\n",vscreeninfo.bits_per_pixel,
													vscreeninfo.height,
													vscreeninfo.width);
	printD(" Xres_V = %4ld | Yres_V = %4ld\n",vscreeninfo.height,vscreeninfo.width);
	printD(" Pixel format : RGBX_%ld%ld%ld%ld\n",vscreeninfo.red.length,
												vscreeninfo.green.length,
												vscreeninfo.blue.length,
												vscreeninfo.transp.length);
	printD(" Begin of bitfields:-\n");
	printD("  Red    : %ld\n",vscreeninfo.red.offset);
	printD("  Green  : %ld\n",vscreeninfo.green.offset);
	printD("  Blue   : %ld\n",vscreeninfo.blue.offset);

	i=1;
	while(i<=100000) {
		ioct=ioctl(fbfd,FBIOGET_VSCREENINFO,&vscreeninfo);
		if(ioct==-1) {
			__android_log_print(ANDROID_LOG_ERROR,TAG_ERR,
					"VSCREEN-IOCTL failed ioct=%d errno=%d",ioct,errno);
			//return 3;
		}
	printD("%8u %8u | %8u %8u | %8u %8u\r",vscreeninfo.xoffset,vscreeninfo.yoffset,
			vscreeninfo.hsync_len,vscreeninfo.vsync_len,
			vscreeninfo.sync,vscreeninfo.vmode);
	i++;
	}
	/*************************************~VSCREEN*************************************/


	/**************************************FSCREEN*************************************/
	printD("\nFscreen Info:-\n");
	printD(" Device ID : %s\n",fscreeninfo.id);
	printD(" Start of FB physical address : %u\n",fscreeninfo.smem_start);
	printD(" Length of FB : %ld\n",fscreeninfo.smem_len);
	printD(" Length of Line : %ld\n",fscreeninfo.line_length);
	printD(" Start of MMIO physical address : %ld\n",fscreeninfo.mmio_start);
	printD(" Length of MMIO : %ld\n",fscreeninfo.mmio_len);
	/*************************************~FSCREEN*************************************/


	/*************************************SPIN-LOCK************************************/
	/*while(val!=VAL_EXIT && cpid && !cmd.print_status) {
		//fgets(input_buffer,sizeof(input_buffer),stdin);
		//fscanf(stdin,"%s",input_buffer);
		//fgetline();
		//scanf("%s",input_buffer);
		val = VAL_REC;//getTokenValue(input_buffer);
		switch(val) {
		case VAL_CAP:
			printC(!cmd.print_status,"%d\n",VAL_CAP);
			return getFrame(&cmd,fbuffer,size,vscreeninfo.xres,vscreeninfo.yres);
			break;
		case VAL_EXIT:
			printC(!cmd.print_status,"%d\n",VAL_EXIT);
			//Do not do anything here
			break;
		case VAL_CST:
			printC(!cmd.print_status,"%d\n",VAL_CST);
			break;
		case VAL_REC:
			printC(!cmd.print_status,"%d\n",VAL_REC);
			if((cpid == ppid) && (ppid == pid)) {
				__android_log_print(ANDROID_LOG_INFO,TAG_INFO,"P: fork()ing...");
				cpid = fork();
			}
			if(cpid<0) {
				__android_log_print(ANDROID_LOG_ERROR,TAG_ERR,"P: fork() failed!");
				break;
			}
			if(cpid) {	//Parent code follows
				__android_log_print(ANDROID_LOG_INFO,TAG_INFO,
						"P: Parent(PID)=%d | Child(PID)=%d",ppid,cpid);
				exit(0);
			} else {	//Child code follows
				gettimeofday(&start,NULL);
				pid = getpid();
				__android_log_print(ANDROID_LOG_INFO,TAG_INFO,
						"C: I am the child(PID)=%d",pid);
				startRecording(&cmd,fbuffer,size);
				//kill(ppid,SIGUSR1);
			}
			break;
		case VAL_STOP:
			printC(!cmd.print_status,"%d\n",VAL_STOP);
			if(cpid!=ppid) {
				__android_log_print(ANDROID_LOG_INFO,TAG_INFO,
						"P: kill()ing child(PID)=%d",cpid);
				kill(cpid,SIGUSR1);
				cpid = ppid;
			}
			break;
		case VAL_UNDEF:
			//printf("UNDEF");
			printC(!cmd.print_status,"%d\n",VAL_UNDEF);
			__android_log_print(ANDROID_LOG_ERROR,TAG_ERR,
					"Undefined input '%s'",input_buffer);
			return -1;
			break;
		}
	}*/
	/************************************~SPIN-LOCK************************************/


	/**********************************CLEANUP-WRAPUP**********************************/
	__android_log_print(ANDROID_LOG_INFO,TAG_INFO,"Unmap = %d",/*munmap(fbuffer,size)*/0);
	close(fbfd);
	gettimeofday(&finish,NULL);
	printD("\nAll sys calls successfull\n");
	__android_log_print(ANDROID_LOG_INFO,TAG_INFO,
								"All sys calls successfull");
	printD("PID = %d | Lifespan = %ldseconds\n",pid,finish.tv_sec-start.tv_sec);
	/*********************************~CLEANUP-WRAPUP**********************************/

	return 0; //End of Program
}
Example #29
0
/*----------------------------------------------------------------------------
*Function: CMM_IOControl

*Parameters:         OpenHandle        :
                    dwIoControlCode    :
*Return Value:        True/False
*Implementation Notes: JPEG_IOControl sends commands to initiate different
*                       operations like Init,Decode and Deinit.The test 
*                       application uses the DeviceIOControl function to 
*                       specify an operation to perform 
-----------------------------------------------------------------------------*/
BOOL
CMM_IOControl(
    DWORD OpenHandle,
    DWORD dwIoControlCode,
    PBYTE pInBuf,
    DWORD nInBufSize,
    PBYTE pOutBuf,
    DWORD nOutBufSize,
    PDWORD pBytesReturned
    )
{
    CODEC_MEM_CTX       *CodecMem;
    BOOL                result = TRUE;
    DWORD               ret;
    UINT8               *u_addr;
    ALLOC_MEM_T         *node;
    CMM_ALLOC_PRAM_T    allocParam;
    
    CodecMem = (CODEC_MEM_CTX *)OpenHandle;

    if(!CodecMem){
        RETAILMSG(1, (TEXT("[CMM_IOControl] CMM Invalid Input Handle\r\n")));
        return FALSE;
    }

    if ((pInBuf == NULL) || (nInBufSize == 0)){
        RETAILMSG(1, (TEXT("[CMM_IOControl] Invalid Input buffer or size\r\n")));
        return FALSE;
    }

    ret = LockCMMMutex();
    if(!ret){
        RETAILMSG(1, (TEXT("[CMM_IOControl] CMM Mutex Lock Fail\r\n")));
        return FALSE;
    }

    switch ( dwIoControlCode ) {

    case IOCTL_CODEC_MEM_ALLOC:
        
        printD("\n[%d][CMM_IOControl] IOCTL_CODEC_MEM_ALLOC\n", CodecMem->inst_no);
        if ((pInBuf == NULL) || 
            (nInBufSize < sizeof(CMM_ALLOC_PRAM_T)) ||
            (pOutBuf == NULL) ||
            (nOutBufSize < sizeof(UINT)))
        {
            RETAILMSG(1, (TEXT("[CMM_IOControl] IOCTL_CODEC_MEM_ALLOC Invalid parameters\r\n")));
            result = FALSE;
            break;
        }

        // Create a local copy of the input buffer first.
        if (!CeSafeCopyMemory(&allocParam, pInBuf, sizeof(CMM_ALLOC_PRAM_T)))// Copies memory inside a __try/__except block
        {
            result = FALSE;
            break;
        }  

        if((allocParam.size) & (0xFFF)) // For 4K alignment
        {
            allocParam.size = (allocParam.size & 0xFFFFF000) + 0x1000;    
        }
    
        printD("[IOCTL_CODEC_MEM_ALLOC] buffSize : %ld\n", allocParam.size);

        if((node = GetCodecVirAddr(CodecMem->inst_no, &allocParam)) == NULL){
            result = FALSE;
            break;
        }

        CodecMem->callerProcess = (HANDLE) GetDirectCallerProcessId();
        node->u_addr = (PBYTE)VirtualAllocEx(CodecMem->callerProcess, 
                                            NULL, 
                                            node->size, 
                                            MEM_RESERVE, 
                                            PAGE_NOACCESS);
        if (node->u_addr == NULL)
        {
            RETAILMSG(1, (_T("[CMM_IOControl]: Memory VirtualAlloc Fail.  Error = %d\r\n"), GetLastError()));
            result = FALSE;
        }
        else
        {
            if (!VirtualCopyEx(CodecMem->callerProcess,           
                                node->u_addr,
                                (HANDLE) GetCurrentProcessId(),
                                node->v_addr,    
                                node->size, 
                                allocParam.cacheFlag ? PAGE_READWRITE : (PAGE_READWRITE | PAGE_NOCACHE)))
            {
                RETAILMSG(1, (_T("[CMM_IOControl]: Memory VirtualCopyEx Fail. Error = %d\r\n"), GetLastError()));
                result = FALSE;
            }
        }

        __try
        {
            if (result)
            {
                *((UINT *)pOutBuf) = (UINT) node->u_addr;
            }
        }
        __except ( EXCEPTION_EXECUTE_HANDLER )
        {
            RETAILMSG( 1, ( _T("[CMM_IOControl]: exception in IOCTL_CODEC_MEM_ALLOC \r\n")) );
            result = FALSE;
        }

        if (!result)
        {
            // free alloc node
            ReleaseAllocMem(node, CodecMem);
        }        

        break;

    case IOCTL_CODEC_MEM_FREE:
        printD("\n[%d][CMM_IOControl] IOCTL_CODEC_MEM_FREE\n", CodecMem->inst_no);
        u_addr = (UINT8 *)pInBuf;
        printD("[CMM_IOControl] free adder : 0x%x \n", u_addr);

        for(node = AllocMemHead; node != AllocMemTail; node = node->next)
        {
            if(node->u_addr == u_addr)
                break;
        }

        if(node  == AllocMemTail)
        {
            RETAILMSG(1, (TEXT("[CMM_IOControl] invalid virtual address(0x%x)\r\n"), u_addr));
            result = FALSE;
            break;
        }
        // free alloc node
        ReleaseAllocMem(node, CodecMem);
        break;

    case IOCTL_CODEC_CACHE_INVALIDATE:
        printD("\n[CMM_IOControl] IOCTL_CODEC_CACHE_INVALIDATE\n");
        u_addr = (UINT8 *)pInBuf;
        printD("[CMM_IOControl] flush adder : 0x%x \n", u_addr);

        for(node = AllocMemHead; node != AllocMemTail; node = node->next)
        {
            if(node->u_addr == u_addr)
                break;
        }

        if(node  == AllocMemTail){
            RETAILMSG(1, (TEXT("[%d][CMM_IOControl] invalid virtual address(0x%x)\r\n"), CodecMem->inst_no, u_addr));
            result = FALSE;
            break;
        }

        InvalidateCacheRange((PBYTE) node->v_addr, 
            (PBYTE) node->v_addr + node->size);
        break;

    case IOCTL_CODEC_CACHE_CLEAN:
        printD("\n[CMM_IOControl] IOCTL_CODEC_CACHE_CLEAN\n");
        u_addr = (UINT8 *)pInBuf;
        printD("[CMM_IOControl] flush adder : 0x%x \n", u_addr);

        for(node = AllocMemHead; node != AllocMemTail; node = node->next)
        {
            if(node->u_addr == u_addr)
                break;
        }

        if(node  == AllocMemTail){
            RETAILMSG(1, (TEXT("[%d][CMM_IOControl] invalid virtual address(0x%x)\r\n"), CodecMem->inst_no, u_addr));
            result = FALSE;
            break;
        }

        CleanCacheRange((PBYTE) node->v_addr, 
            (PBYTE) node->v_addr + node->size);
        break;


        // IOCTL_CODEC_CACHE_FLUSH is same as IOCTL_CODEC_CACHE_CLEAN_INVALIDATE.
        // This is remained for backward capability
    case IOCTL_CODEC_CACHE_FLUSH: 
    case IOCTL_CODEC_CACHE_CLEAN_INVALIDATE:
        printD("\n[CMM_IOControl] IOCTL_CODEC_CACHE_CLEAN_INVALIDATE\n");
        u_addr = (UINT8 *)pInBuf;
        printD("[CMM_IOControl] flush adder : 0x%x \n", u_addr);

        for(node = AllocMemHead; node != AllocMemTail; node = node->next)
        {
            if(node->u_addr == u_addr)
                break;
        }

        if(node  == AllocMemTail){
            RETAILMSG(1, (TEXT("[%d][CMM_IOControl] invalid virtual address(0x%x)\r\n"), CodecMem->inst_no, u_addr));
            result = FALSE;
            break;
        }

        CleanInvalidateCacheRange((PBYTE) node->v_addr, 
            (PBYTE) node->v_addr + node->size);
        break;


    case IOCTL_CODEC_GET_PHY_ADDR:
        u_addr  = (UINT8 *)pInBuf;
        for(node = AllocMemHead; node != AllocMemTail; node = node->next)
        {
            if(node->u_addr == u_addr)
                break;
        }

        if(node  == AllocMemTail){
            RETAILMSG(1, (TEXT("[CMM_IOControl] invalid virtual address(0x%x)\r\n"), u_addr));
            result = FALSE;
            break;
        }
        
        if ((pOutBuf == NULL) || (nOutBufSize < sizeof(UINT8 *)))
        {
            RETAILMSG(1, (TEXT("[CMM_IOControl] IOCTL_CODEC_GET_PHY_ADDR Invalid Output buffer or size\r\n")));
            result = FALSE;
            break;
        }

        __try
        {
            *((UINT *)pOutBuf) = (UINT) node->cached_p_addr;
        }
        __except ( EXCEPTION_EXECUTE_HANDLER )
        {
            RETAILMSG( 1, ( _T("[CMM_IOControl]: exception in IOCTL_CODEC_GET_PHY_ADDR \r\n")) );
            result = FALSE;
        }

        break;


    default : RETAILMSG(1, (TEXT("[CMM_IOControl] CMM Invalid IOControl\r\n")));
    }


    UnlockCMMMutex();
    return result;
}
Example #30
0
BOOL fillTVStruct (xmlNodePtr parentTag) {
	xmlNode *seekChild, *curNode, *airNode;
	char *tmpString;
	char *toFree;
	/* clear Structs */
	if (curTV->actors) free (curTV->actors);
	if (curTV->plot) free (curTV->plot);
	if (curTV->tagline) free (curTV->tagline);
	bzero (curTV, sizeof(struct ST_tv));

	if ( (seekChild = getChildNodeByName(parentTag, "title")) != NULL ) {
		if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) {
			strncat(curTV->seriesname, tmpString, 255);
			free (tmpString);
			printD ("Stored Title:%s\n", curTV->seriesname);
		}
	}
	else {
		printD("Something went wrong while reading title...\n");
		return (FALSE);
	}

	if ( (seekChild = getChildNodeByName(parentTag, "language")) != NULL ) {
		if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) {
			strncat(curTV->language, tmpString, 255);
			free (tmpString);
			printD ("Stored Language:%s\n", curTV->language);
		}
	}
	else {
		printD("Something went wrong while reading language...\n");
		return (FALSE);
	}

	if ( (seekChild = getChildNodeByName(parentTag, "container")) != NULL ) {
		if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) {
			strncat(curTV->mediatype, tmpString, 255);
			xmlFree (tmpString);
			printD ("Stored MediaType:%s\n", curTV->mediatype);
		}
	}
	else {
		printD("Something went wrong while reading container(mediatype)...\n");
		return (FALSE);
	}

	if ( (toFree = getIDs(parentTag)) != NULL ) {
		sprintf (curTV->imdblink, "http://www.imdb.com/title/%s\n", toFree);
		free (toFree);
	}
	else
		sprintf (curTV->imdblink, "http://www.imdb.com/find?s=all&q=%s", curMovie->moviename);
	printD ("Stored IMDBLink:%s\n", curTV->imdblink);

	if ( (seekChild = getChildNodeByName(parentTag, "videoOutput")) != NULL) {
		if ( (tmpString = (char*)xmlNodeGetContent (seekChild)) != NULL) {
			curMovie->isHD = isHD(tmpString);
			xmlFree ((xmlChar*)tmpString);
		}
	}
	else
		curMovie->isHD = FALSE;


	if ( (seekChild = getChildNodeByName(parentTag, "directors")) != NULL ) {
		if ( childTextToString(seekChild, curTV->directors, "director") == 0 )
			strcat (curTV->directors, "UNKNOWN");
		printD ("Stored Directors:%s\n", curTV->directors);
	}
	else {
		printD("Something went wrong while reading directors...\n");
	}

	if ( (seekChild = getChildNodeByName(parentTag, "writers")) != NULL ) {
		if ( childTextToString(seekChild, curTV->writers, "writer") == 0 )
			strcat (curTV->writers, "UNKNOWN");
		printD ("Stored Writers:%s\n", curTV->writers);
	}

	if ( (seekChild = getChildNodeByName(parentTag, "genres")) != NULL ) {
		if ( childTextToString(seekChild, curTV->genres, "genre") == 0 )
			strcat (curTV->genres, "UNKNOWN");
		printD ("Stored Genres:%s\n", curTV->genres);
	}

	if ( (seekChild = getChildNodeByName(parentTag, "cast")) != NULL ) {
		if ( childTextToString_m(seekChild, &curTV->actors, "actor") == 0 )
			curTV->actors = strdup ("UNKNOWN");
		printD ("Stored Actors:%s\n", curTV->actors);
	}
	else
		curTV->actors = strdup ("UNKNOWN");

	if ( (seekChild = getChildNodeByName(parentTag, "tagline")) != NULL ) {
		if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) {
			curTV->tagline=tmpString;
			printD ("Stored Outline:%s\n", curTV->tagline);
		}
	}

	if ( (seekChild = getChildNodeByName(parentTag, "plot")) != NULL ) {
		if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) {
			curTV->plot=tmpString;
			printD ("Stored Plot:%s\n", curTV->plot);
		}
	}

	if ( (seekChild = getChildNodeByName(parentTag, "releaseDate")) != NULL ) {
		if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) {
			strncat (curTV->year, tmpString, 63);
			xmlFree (tmpString);
			printD ("Stored Releasedate:%s\n", curTV->year);
		}
	}

	if ( (seekChild = getChildNodeByName(parentTag, "posterFile")) != NULL ) {
		if ( ( tmpString = encNodeGetContent(seekChild)) != NULL ) {
			strncat (curTV->imglink, tmpString, 255);
			free (tmpString);
			printD ("Stored Imagelink:%s\n", curTV->imglink);
		}
	}

	if ( (seekChild = getChildNodeByName(parentTag, "rating")) != NULL ) {
		if ( ( tmpString = (char*)xmlNodeGetContent(seekChild)) != NULL ) {
			if (atoi((char*)tmpString) < 0)
				curTV->rating=0;
			else
				curTV->rating=atoi((char*)tmpString);
			xmlFree (tmpString);
			printD ("Stored Rating:%i\n", curTV->rating);
		}
	}

	if ( (seekChild = getChildNodeByName(parentTag, "season")) != NULL ) {
		if ( ( tmpString = (char*)xmlNodeGetContent(seekChild)) != NULL ) {
			if (atoi((char*)tmpString) < 0)
				curTV->season=0;
			else
				curTV->season=atoi((char*)tmpString);
			xmlFree (tmpString);
			printD ("Stored Season:%i\n", curTV->season);
		}
	}

	if ( (seekChild = getChildNodeByName(parentTag, "files")) != NULL) {
		if (seekChild->children) {
			curNode = seekChild->children;
			while (curNode) {
				if (curNode->type == XML_ELEMENT_NODE) {
					if (strcasecmp((char*)curNode->name, "file") == 0) {
						if ( (airNode = getChildNodeByName(curNode, "fileTitle")) != NULL) {
							if ( (tmpString = (char*)xmlGetProp(airNode, (xmlChar*)"part")) != NULL ) {
								if (atoi((char*)tmpString) < 0 )
									curTV->episode=0;
								else
									curTV->episode=atoi((char*)tmpString);
								xmlFree (tmpString);
							}
							if ( (tmpString = encNodeGetContent(airNode)) != NULL ) {
								strncat (curTV->episodename, tmpString, 255);
								free(tmpString);
							}
						}
						if ( (airNode = getChildNodeByName(curNode, "fileLocation")) != NULL) {
							tmpString = (char*)xmlNodeGetContent(airNode);
							strncat (curTV->filename, tmpString ? tmpString : "*UNAVAILABLE*", 255);
							if (tmpString) free (tmpString);
						}
					}
					if (!writeToDB(TRUE))
						fprintf (stderr, "%s could not be stored in DB:%s\n", curTV->filename, mysql_error(mysql_conn));
					bzero(curTV->episodename, 255);
					bzero(curTV->filename, 255);
				}
				/* should all be filled by now, pump it in the DB */
				curNode=curNode->next;
			}
		}
	}

	return (TRUE);

}