コード例 #1
0
ファイル: http.c プロジェクト: JackieXie168/movgrab
void HTTPInfoDestroy(void *p_Info)
{
HTTPInfoStruct *Info;

if (! p_Info) return;
Info=(HTTPInfoStruct *) p_Info;
DestroyString(Info->Host);
DestroyString(Info->Method);
DestroyString(Info->Doc);
DestroyString(Info->Destination);
DestroyString(Info->ResponseCode);
DestroyString(Info->PreviousRedirect);
DestroyString(Info->RedirectPath);
DestroyString(Info->ContentType);
DestroyString(Info->Timestamp);
DestroyString(Info->PostData);
DestroyString(Info->PostContentType);
DestroyString(Info->Proxy);

ListDestroy(Info->ServerHeaders,DestroyString);
ListDestroy(Info->CustomSendHeaders,DestroyString);
if (Info->Authorization) HTTPAuthDestroy(Info->Authorization);
if (Info->ProxyAuthorization) HTTPAuthDestroy(Info->ProxyAuthorization);
free(Info);
}
コード例 #2
0
ファイル: cpost.c プロジェクト: pmuellr/cpost
/*------------------------------------------------------------------
 * clean up function list
 *------------------------------------------------------------------*/
static int CleanUpFuncList(
   Function *func,
   Info     *info
   )
   {
   ListDestroy(func->callsList);
   ListDestroy(func->calledByList);

   free(func->name);

   return 0;
   }
コード例 #3
0
ファイル: dmscp.c プロジェクト: cvsuser-chromium/librhino
int YX_Dmscp_Destroy(void)
{
	HT_DBG_FUNC_START(HT_MOD_DMC, HT_BIT_FEW,0, NULL);

	ListDestroy(&(s_dmscp_updated_list), 1);//??????????????????
	sem_destroy(&(s_dmscp_updated_lock) );
	
	ListDestroy(&(s_dmscp_service_updated_list), 1);//??????????????????
	sem_destroy(&(s_dmscp_service_updated_lock) );
	
	HT_DBG_FUNC_END(0, NULL);
	return 0;
}
コード例 #4
0
ファイル: oauth.c プロジェクト: ColumPaget/daytime
void OAuthInstalledAppGetAccessToken(char *TokenURL, char *ClientID, char *ClientSecret, char *AuthCode, char *RedirectURL, char **AccessToken, char **RefreshToken)
{
char *Tempstr=NULL, *Encode=NULL;
ListNode *Vars=NULL;
STREAM *S;

Vars=ListCreate();

Tempstr=MCopyStr(Tempstr,TokenURL,"?client_id=",ClientID,NULL);
Tempstr=MCatStr(Tempstr,"&client_secret=",ClientSecret,NULL);
Tempstr=MCatStr(Tempstr,"&code=",AuthCode,NULL);
Tempstr=MCatStr(Tempstr,"&redirect_uri=",RedirectURL,NULL);
Tempstr=MCatStr(Tempstr,"&grant_type=","authorization_code",NULL);

S=HTTPMethod("POST",Tempstr,"","","","",0);
if (S)
{
Tempstr=STREAMReadLine(Tempstr,S);
while (Tempstr)
{
StripTrailingWhitespace(Tempstr);
fprintf(stderr,"OA: %s\n",Tempstr);
OAuthParseJSON(Tempstr, Vars);
Tempstr=STREAMReadLine(Tempstr,S);
}
}

*AccessToken=CopyStr(*AccessToken,GetVar(Vars,"access_token"));
*RefreshToken=CopyStr(*RefreshToken,GetVar(Vars,"refresh_token"));

ListDestroy(Vars,DestroyString);
DestroyString(Tempstr);
DestroyString(Encode);
}
コード例 #5
0
ファイル: server.c プロジェクト: ColumPaget/Alaya
void HTTPServerHandleStream(STREAM *Output, HTTPSession *Session, char *SearchPath, int SendData)
{
char *Tempstr=NULL;
HTTPSession *Response;
ListNode *Vars;
STREAM *S;
glob_t Glob;
int i;


Vars=ListCreate();
SetVar(Vars,"ContentType","audio/mpeg");
Response=FileSendCreateSession("", Session, Vars, 0);
HTTPServerSendHeaders(Output, Response, FALSE);
STREAMFlush(Output);

Tempstr=MCopyStr(Tempstr,SearchPath,"/*",NULL);
glob(Tempstr,0,0,&Glob);

LogToFile(Settings.LogPath,"Stream from Dir: %s, %d files",SearchPath,Glob.gl_pathc);

for (i=0; i < Glob.gl_pathc; i++)
{
	S=STREAMOpenFile(Glob.gl_pathv[i],SF_RDONLY);
	if (S)
	{
		IcecastSendData(S, Output, 4096000);
		STREAMClose(S);
	}
}

globfree(&Glob);
DestroyString(Tempstr);
ListDestroy(Vars,DestroyString);
}
コード例 #6
0
ファイル: containerfiles.c プロジェクト: JackieXie168/movgrab
int DownloadM3U(char *URL, char *Title, int Flags)
{
char *Tempstr=NULL, *ID=NULL, *Doc=NULL, *ptr;
int Port=0, BytesRead=0, len=0, count=0;
int RetVal=FALSE;
ListNode *Items, *Curr;
int M3UType=M3U_PLAYLIST;
STREAM *Con;

if (Flags & FLAG_DEBUG) fprintf(stderr,"M3U STREAM: %s\n",URL);


Items=ListCreate();
Con=ConnectAndRetryUntilDownload(URL, 0, 0);
if (Con)
{
Tempstr=STREAMReadLine(Tempstr,Con);
while (Tempstr)
{
StripTrailingWhitespace(Tempstr);
StripLeadingWhitespace(Tempstr);

if (Flags & (FLAG_DEBUG2 | FLAG_DEBUG3)) fprintf(stderr,"%s\n",Tempstr);
if (StrLen(Tempstr))
{
	if (strncmp("#EXT-X-STREAM-INF",Tempstr,StrLen("#EXT-X-STREAM-INF"))==0)
	{
			RetVal=M3UStreamInfo(Con,Title,URL,Tempstr,Flags);
			M3UType=M3U_STREAMINFO;
	}
	else if (strncmp("#EXT-X-MEDIA-SEQUENCE",Tempstr,StrLen("#EXT-X-MEDIA-SEQUENCE"))==0) M3UType=M3U_PLAYLIST;
	else if (*Tempstr != '#') 
	{
		if (strncasecmp(Tempstr,"http",4) !=0) 
		{
			Doc=CopyStr(Doc,URL);
			ptr=strrchr(Doc,'/');
			if (ptr) *ptr='\0';
			Doc=MCatStr(Doc,"/",Tempstr,NULL);
		}
		else Doc=CopyStr(Doc,Tempstr);
		ListAddItem(Items,CopyStr(NULL,Doc));
	}
}

Tempstr=STREAMReadLine(Tempstr,Con);
}

STREAMClose(Con);
if (M3UType == M3U_PLAYLIST) RetVal=DownloadStream(URL, Title, Items, Flags);
}

ListDestroy(Items,DestroyString);
DestroyString(Tempstr);
DestroyString(Doc);
DestroyString(ID);


return(RetVal);
}
コード例 #7
0
ファイル: server.c プロジェクト: ColumPaget/Alaya
void HTTPServerSendDocument(STREAM *S, HTTPSession *Session, char *Path, int Flags)
{
int result;
ListNode *Vars;

	Vars=ListCreate();

	if (StrLen(Path)==0) result=FILE_NOSUCH;
	else result=LoadFileRealProperties(Path, TRUE, Vars);

	if (result==FILE_NOSUCH) HTTPServerSendHTML(S, Session, "404 Not Found","Couldn't find that document.");
	else
	{
		//Set 'LastModified' so we can use it if the server sends 'If-Modified-Since'
	  Session->LastModified=atoi(GetVar(Vars,"MTime-secs"));

		//If we are asking for details of a file then we treat that as a directory function
		if ((result==FILE_DIR) || (strstr(Session->Arguments,"format=")))
		{
			HTTPServerSendDirectory(S,Session,Path,Vars);
		}
		else HTTPServerSendFile(S, Session, Path, Vars, Flags);
	}

ListDestroy(Vars,DestroyString);
}
コード例 #8
0
ファイル: database.c プロジェクト: Avi2011class/Test
void HashMapDestroy(struct HashMap* HashMap)
{
    int CurList;
    for(CurList = 0; CurList < HashMap->MaxHashValue; CurList++)
        ListDestroy(HashMap->Map[CurList]);
    free(HashMap);
}
コード例 #9
0
ファイル: findhub_test.c プロジェクト: ajlill/core
static void test_multipleHubsFound(void)
{
    List *list = NULL;

    hostcount = 2;

    assert_int_equal(ListHubs(&list), 3);
    assert_int_not_equal(list, NULL);
    
    ListIterator *i = NULL;
    i = ListIteratorGet(list);
    
    HostProperties *host1 = (HostProperties *)ListIteratorData(i); 
    assert_int_not_equal(ListIteratorNext(i), -1);
    HostProperties *host2 = (HostProperties *)ListIteratorData(i); 
    assert_int_not_equal(ListIteratorNext(i), -1);
    HostProperties *host3 = (HostProperties *)ListIteratorData(i); 

    assert_int_equal(host1->Port, 5308);
    assert_string_equal(host1->Hostname, "host1");
    assert_string_equal(host1->IPAddress, "10.0.0.100");

    assert_int_equal(host2->Port, 1234);
    assert_string_equal(host2->Hostname, "host2");
    assert_string_equal(host2->IPAddress, "10.0.0.100");

    assert_int_equal(host3->Port, 4321);
    assert_string_equal(host3->Hostname, "host3");
    assert_string_equal(host3->IPAddress, "10.0.0.100");

    ListIteratorDestroy(&i);
    ListDestroy(&list);
}
コード例 #10
0
ファイル: oauth.c プロジェクト: ColumPaget/daytime
void OAuthDeviceGetAccessToken(char *TokenURL, char *ClientID, char *ClientSecret, char *DeviceCode, char **AccessToken, char **RefreshToken)
{
char *Tempstr=NULL, *Encode=NULL;
ListNode *Vars=NULL;
STREAM *S;

Vars=ListCreate();

Encode=HTTPQuote(Encode,ClientID);
Tempstr=MCopyStr(Tempstr,TokenURL,"?client_id=",Encode,NULL);
Encode=HTTPQuote(Encode,ClientSecret);
Tempstr=MCatStr(Tempstr,"&client_secret=",Encode,NULL);
Tempstr=MCatStr(Tempstr,"&code=",DeviceCode,NULL);
Tempstr=MCatStr(Tempstr,"&grant_type=","http://oauth.net/grant_type/device/1.0",NULL);

S=HTTPMethod("POST",Tempstr,"","","","",0);
if (S)
{
Tempstr=STREAMReadLine(Tempstr,S);
while (Tempstr)
{
StripTrailingWhitespace(Tempstr);
printf("OA: %s\n",Tempstr);
OAuthParseJSON(Tempstr, Vars);
Tempstr=STREAMReadLine(Tempstr,S);
}
}

*AccessToken=CopyStr(*AccessToken,GetVar(Vars,"access_token"));
*RefreshToken=CopyStr(*RefreshToken,GetVar(Vars,"refresh_token"));

ListDestroy(Vars,DestroyString);
DestroyString(Tempstr);
DestroyString(Encode);
}
コード例 #11
0
ファイル: oauth.c プロジェクト: ColumPaget/daytime
void OAuthDeviceRefreshToken(char *TokenURL, char *ClientID, char *ClientSecret, char *RequestRefreshToken, char **AccessToken, char **RefreshToken)
{
char *Tempstr=NULL, *Encode=NULL;
ListNode *Vars=NULL;
STREAM *S;

Vars=ListCreate();

Tempstr=MCopyStr(Tempstr,TokenURL,"?client_id=",ClientID,NULL);
Tempstr=MCatStr(Tempstr,"&client_secret=",ClientSecret,NULL);
Tempstr=MCatStr(Tempstr,"&refresh_token=",RequestRefreshToken,NULL);
Tempstr=MCatStr(Tempstr,"&grant_type=","refresh_token",NULL);

S=HTTPMethod("POST",Tempstr,"","","","",0);
if (S)
{
Tempstr=STREAMReadLine(Tempstr,S);
while (Tempstr)
{
StripTrailingWhitespace(Tempstr);
OAuthParseJSON(Tempstr, Vars);

Tempstr=STREAMReadLine(Tempstr,S);
}
} 

*AccessToken=CopyStr(*AccessToken,GetVar(Vars,"access_token"));
*RefreshToken=CopyStr(*RefreshToken,GetVar(Vars,"refresh_token"));

ListDestroy(Vars,DestroyString);
DestroyString(Tempstr);
DestroyString(Encode);
}
コード例 #12
0
void ProcessLSCmd(TFileStore *FS, TFileStore *DiskFS, int CmdFlags, char *Pattern, int LinesToList)
{
 TFileInfo *FI;
 ListNode *Items, *Curr;
 int val, count=0, total_bytes=0;
 char *Tempstr=NULL, *ptr;
 
	Items=ListCreate();
	val=LIST_INCLUDE_DIRS;
	if (CmdFlags & FLAG_LS_REFRESH) val |=LIST_REFRESH;
	if (StrLen(Pattern)==0) FileStoreLoadDir(FS,"*",Items,val);
	else FileStoreLoadDir(FS,Pattern,Items,val);

	total_bytes=DirectoryListingPrintOutput(FS, CmdFlags, LinesToList, Items);

	printf(".\n");
	if (FS->BytesAvailable > 0) Tempstr=GenerateQuotaString(Tempstr,FS);
	else Tempstr=CopyStr(Tempstr,"");
 
	if (CmdFlags & (FLAG_LS_LONGDETAILS | FLAG_LS_MEDIADETAILS)) printf("% 8d bytes total  %s\n",total_bytes,Tempstr);
	else if (CmdFlags & FLAG_LS_DETAILS) printf("% 8s total  %s\n",GetHumanReadableDataQty(total_bytes,0),Tempstr);
 
	fflush(NULL); 
	ListDestroy(Items,FileInfoDestroy);
 
	DestroyString(Tempstr);
}
コード例 #13
0
void STREAMClearDataProcessors(STREAM *S)
{
TProcessingModule *Mod;

STREAMFlush(S);
STREAMResetInputBuffers(S);
ListDestroy(S->ProcessingModules, DataProcessorDestroy);
}
コード例 #14
0
ファイル: main.c プロジェクト: prost0/course_project_8
int main()
{

    List *l = ListCreate();
    int code;
    int index;
    double item;
    instructions();
    while ((code =  getchar()) != EOF) {
        switch (code) {
            case 'p':
                ListPrint(l);
                break;
            case 'a':
                //printf("add: ");
                if (scanf("%d %lf", &index, &item) == 2) {
                    ListInsert(l, index, item);
                } else {
                    printf("Input error\n");
                }
                break;
            case 'd':
                if (scanf("%lf", &item) == 1) {
                    Node *item_ptr = ListFind(l, item);
                    if (item_ptr) {
                        ListDeleteNode(l, item_ptr);
                    } else {
                        printf("Incorrect index\n");
                    }
                } else {
                    printf("Input error\n");
                }
                break;
                
            case 'q':
                ListDestroy(&l);
                return 0;
                
            case 'e':
                ListExchange(l);
                break;
        }
    }
    ListDestroy(&l);
    return 0;
}
コード例 #15
0
/************************************************************************
 * Function: TimerThreadInit
 * 
 *  Description:
 *     Initializes and starts timer thread.
 *
 *  Parameters:
 *             timer - valid timer thread pointer.
 *             tp  - valid thread pool to use. Must be
 *                   started. Must be valid for lifetime
 *                   of timer.  Timer must be shutdown
 *                   BEFORE thread pool.
 *  Return:
 *            0 on success, nonzero on failure
 *            Returns error from ThreadPoolAddPersistent if failure.
 ************************************************************************/
int
TimerThreadInit( TimerThread * timer,
                 ThreadPool * tp )
{

    int rc = 0;

    ThreadPoolJob timerThreadWorker;

    assert( timer != NULL );
    assert( tp != NULL );

    if( ( timer == NULL ) || ( tp == NULL ) ) {
        return EINVAL;
    }

    rc += ithread_mutex_init( &timer->mutex, NULL );

    assert( rc == 0 );

    rc += ithread_mutex_lock( &timer->mutex );
    assert( rc == 0 );

    rc += ithread_cond_init( &timer->condition, NULL );
    assert( rc == 0 );

    rc += FreeListInit( &timer->freeEvents, sizeof( TimerEvent ), 100 );
    assert( rc == 0 );

    timer->shutdown = 0;
    timer->tp = tp;
    timer->lastEventId = 0;
    rc += ListInit( &timer->eventQ, NULL, NULL );

    assert( rc == 0 );

    if( rc != 0 ) {
        rc = EAGAIN;
    } else {

        TPJobInit( &timerThreadWorker, TimerThreadWorker, timer );
        TPJobSetPriority( &timerThreadWorker, HIGH_PRIORITY );

        rc = ThreadPoolAddPersistent( tp, &timerThreadWorker, NULL );
    }

    ithread_mutex_unlock( &timer->mutex );

    if( rc != 0 ) {
        ithread_cond_destroy( &timer->condition );
        ithread_mutex_destroy( &timer->mutex );
        FreeListDestroy( &timer->freeEvents );
        ListDestroy( &timer->eventQ, 0 );
    }

    return rc;

}
コード例 #16
0
ファイル: containerfiles.c プロジェクト: JackieXie168/movgrab
int M3UStreamInfo(STREAM *S, char *Title, char *URL, char *FirstLine, int Flags)
{
	char *Tempstr=NULL, *Doc=NULL, *Resolution=NULL, *Bandwidth=NULL, *ptr;
	ListNode *Vars=NULL;
	int RetVal=FALSE;

	Vars=ListCreate();
	Tempstr=CopyStr(Tempstr,FirstLine);
	while (Tempstr)
	{
	StripTrailingWhitespace(Tempstr);
  if (Flags & (FLAG_DEBUG2 | FLAG_DEBUG3)) fprintf(stderr,"%s\n",Tempstr);

	if (strncmp("#EXT-X-STREAM-INF",Tempstr,StrLen("#EXT-X-STREAM-INF"))==0) M3UParseStreamInfo(Tempstr, &Resolution, &Bandwidth);
	else if (*Tempstr != '#') 
	{
		if (strncasecmp(Tempstr,"http",4) !=0) 
		{
			Doc=CopyStr(Doc,URL);
			ptr=strrchr(Doc,'/');
			if (ptr) *ptr='\0';
			Doc=MCatStr(Doc,"/",Tempstr,NULL);
		}
		else Doc=CopyStr(Doc,Tempstr);

		ptr=FileTypeFromURL(Doc);
		if (strcmp(ptr,"m3u8")==0) ptr="stream";
		if (StrLen(Resolution)) 
		{
			if (StrLen(ptr)) Tempstr=MCopyStr(Tempstr,"item:",ptr,":",Resolution,NULL);
			else Tempstr=MCopyStr(Tempstr,"item:stream:",Resolution,NULL);
		}
		else if (StrLen(Bandwidth)) 
		{
			if (StrLen(ptr)) Tempstr=MCopyStr(Tempstr,"item:",ptr,":",Bandwidth,NULL);
			else Tempstr=MCopyStr(Tempstr,"item:stream:",Bandwidth,NULL);
		}
		else Tempstr=CopyStr(Tempstr,"ID");
		SetVar(Vars,Tempstr,Doc);
	}
	Tempstr=STREAMReadLine(Tempstr,S);
	}

	ptr=GetVar(Vars,"ID");
	if (! StrLen(ptr)) Type=SelectDownloadFormat(Vars, TYPE_REFERENCE, FALSE);
	ptr=GetVar(Vars,"ID");
	if (StrLen(ptr)) RetVal=DownloadM3U(ptr, Title, Flags);

	ListDestroy(Vars,DestroyString);
	DestroyString(Tempstr);
	DestroyString(Resolution);
	DestroyString(Bandwidth);
	DestroyString(Doc);

	return(RetVal);
}
コード例 #17
0
ファイル: directory_listing.c プロジェクト: ColumPaget/Alaya
void HTTPServerSendM3U(STREAM *S, HTTPSession *Session, char *Path, int NoOfFiles, TPathItem **Files)
{
char *Tempstr=NULL, *M3U=NULL, *URL=NULL, *Salt=NULL, *AccessToken=NULL, *ptr;
ListNode *Vars;
STREAM *F;
int i;

M3U=CopyStr(M3U,"#EXTM3U\n");

for (i=0; i < NoOfFiles; i++)
{
	if (InFileTypeList(Files[i]->Path,Settings.M3UFileTypes))
	{

		//Examine file for Artist/title information
		Vars=ListCreate();
		F=STREAMOpenFile(Files[i]->Path, SF_RDONLY);
		if (F) 
		{
			MediaReadDetails(F, Vars);
			STREAMClose(F);
		}
		ptr=GetVar(Vars, "Media-title");
		if (StrLen(ptr))
		{
			//#EXTINF - extra info - length (seconds), title
			Tempstr=CopyStr(Tempstr, GetVar(Vars, "Media-artist"));
			if (! StrLen(Tempstr)) Tempstr=CopyStr(Tempstr,"unknown-artist");
			M3U=MCatStr(M3U,"#EXTINF: -1, ", Tempstr, "-", GetVar(Vars,"Media-title"),"\n",NULL);
		}

		//Actually supply the URL
		M3U=CatStr(M3U,Files[i]->URL);

		//if we are supporting access token authentication, supply that
		if (AuthenticateExamineMethods(Settings.AuthMethods, FALSE) & AUTH_ACCESSTOKEN)
		{
			GenerateRandomBytes(&Salt,24,ENCODE_HEX);
			AccessToken=MakeAccessToken(AccessToken, Session->UserName, Salt, Session->ClientIP, Files[i]->URL);
			M3U=MCatStr(M3U,"?AccessToken=",AccessToken,NULL);
		}
		ListDestroy(Vars,DestroyString);
		M3U=CatStr(M3U,"\n");
	}	
}

Tempstr=MCopyStr(Tempstr,Path,".m3u",NULL);
SetVar(Session->Headers,"Content-disposition",Tempstr);
HTTPServerSendResponse(S, Session, "200 OK","audio/x-mpegurl",M3U);

DestroyString(AccessToken);
DestroyString(Tempstr);
DestroyString(Salt);
DestroyString(URL);
DestroyString(M3U);
}
コード例 #18
0
ファイル: cpost.c プロジェクト: pmuellr/cpost
/*------------------------------------------------------------------
 * clean up file list
 *------------------------------------------------------------------*/
static int CleanUpFileList(
   File     *file,
   Info     *info
   )
   {
   PageEject *pe;

   if (!(info->oDebug & 1) && (file->tempName))
      remove(file->tempName);

   /*---------------------------------------------------------------
    * free up file fields
    *---------------------------------------------------------------*/
   free(file->name);
   free(file->pathName);

   if (*(file->ext))
      free(file->ext);

   if (file->tempName)
      free(file->tempName);

   /*---------------------------------------------------------------
    * free function lists
    *---------------------------------------------------------------*/
   ListDestroy(file->funcDefList);
   ListDestroy(file->funcProList);

   /*---------------------------------------------------------------
    * free page eject list
    *---------------------------------------------------------------*/
   pe = file->breakList;
   while (pe)
      {
      PageEject *next;

      next = pe->next;
      free(pe);
      pe   = next;
      }

   return 0;
   }
コード例 #19
0
ファイル: point.c プロジェクト: 01org/opa-ff
void PointFabricDestroy(Point *point)
{
	switch (point->Type) {
	case POINT_TYPE_PORT_LIST:
		ListDestroy(&point->u.portList);
		break;
	case POINT_TYPE_NODE_LIST:
		ListDestroy(&point->u.nodeList);
		break;
#if !defined(VXWORKS) || defined(BUILD_DMC)
	case POINT_TYPE_IOC_LIST:
		ListDestroy(&point->u.iocList);
		break;
#endif
	default:
		break;
	}
	point->Type = POINT_TYPE_NONE;
}
コード例 #20
0
ファイル: point.c プロジェクト: 01org/opa-ff
void PointEsmDestroy(Point *point)
{
	switch (point->EsmType) {
	case POINT_ESM_TYPE_SM_LIST:
		ListDestroy(&point->u3.esmList);
		break;
	default:
		break;
	}
	point->EsmType = POINT_ESM_TYPE_NONE;
}
コード例 #21
0
ファイル: point.c プロジェクト: 01org/opa-ff
void PointEnodeDestroy(Point *point)
{
	switch (point->EnodeType) {
	case POINT_ENODE_TYPE_NODE_LIST:
		ListDestroy(&point->u2.enodeList);
		break;
	default:
		break;
	}
	point->EnodeType = POINT_ENODE_TYPE_NONE;
}
コード例 #22
0
ファイル: findhub_test.c プロジェクト: ajlill/core
static void test_noHubsFound(void)
{
    List *list = NULL;
    
    hostcount = 0;

    assert_int_equal(ListHubs(&list), 0);
    assert_int_not_equal(list, NULL);

    ListDestroy(&list);
}
コード例 #23
0
/************************************************************************
 * Function: TimerThreadShutdown
 * 
 *  Description:
 *    Shutdown the timer thread
 *    Events scheduled in the future will NOT be run.
 *    Timer thread should be shutdown BEFORE it's associated
 *    thread pool.
 *  Returns:
 *    returns 0 if succesfull,
 *            nonzero otherwise.
 *            Always returns 0.
 ***********************************************************************/
int
TimerThreadShutdown( TimerThread * timer )
{
    ListNode *tempNode2 = NULL;
    ListNode *tempNode = NULL;

    assert( timer != NULL );

    if( timer == NULL ) {
        return EINVAL;
    }

    ithread_mutex_lock( &timer->mutex );

    timer->shutdown = 1;
    tempNode = ListHead( &timer->eventQ );

    //Delete nodes in Q
    //call registered free function 
    //on argument
    while( tempNode != NULL ) {
        TimerEvent *temp = ( TimerEvent * ) tempNode->item;

        tempNode2 = ListNext( &timer->eventQ, tempNode );
        ListDelNode( &timer->eventQ, tempNode, 0 );
        if( temp->job.free_func ) {
            temp->job.free_func( temp->job.arg );
        }
        FreeTimerEvent( timer, temp );
        tempNode = tempNode2;
    }

    ListDestroy( &timer->eventQ, 0 );
    FreeListDestroy( &timer->freeEvents );

    ithread_cond_broadcast( &timer->condition );

    while( timer->shutdown )    //wait for timer thread to shutdown
    {
        ithread_cond_wait( &timer->condition, &timer->mutex );
    }

    ithread_mutex_unlock( &timer->mutex );

    //destroy condition
    while( ithread_cond_destroy( &timer->condition ) != 0 ) {
    }

    //destroy mutex
    while( ithread_mutex_destroy( &timer->mutex ) != 0 ) {
    }

    return 0;
}
コード例 #24
0
ファイル: point.c プロジェクト: 01org/opa-ff
void PointElinkDestroy(Point *point)
{
	switch (point->ElinkType) {
	case POINT_ELINK_TYPE_LINK_LIST:
		ListDestroy(&point->u4.elinkList);
		break;
	default:
		break;
	}
	point->ElinkType = POINT_ELINK_TYPE_NONE;
}
コード例 #25
0
int ProcessGetFileInfo(TFileStore *FS, char *Pattern, char *Arg, int CmdFlags, ListNode *Vars)
{
ListNode *Items=NULL, *Curr;
char *Tempstr=NULL, *IncludePattern=NULL, *ExcludePattern=NULL, *ptr;
TFileInfo *FI;
int result=FALSE, Flags, i;
char *DisplayVars[]={"Category","Author","Subtitle","Duration","Dimensions",NULL};
//"Summary","Description",NULL};

IncludePattern=CopyStr(IncludePattern,GetVar(Vars,"IncludePattern"));
ExcludePattern=CopyStr(ExcludePattern,GetVar(Vars,"ExcludePattern"));

Items=ListCreate();

Flags=LIST_REFRESH;
//if (CmdFlags & FLAG_CMD_RECURSE) Flags |= LIST_INCLUDE_DIRS;
FileStoreLoadDir(FS,Pattern,Items, Flags);
Curr=ListGetNext(Items);

while (Curr)
{
	FI=(TFileInfo *) Curr->Item;

  if (FileIncluded(FI,IncludePattern,ExcludePattern,CmdFlags, Vars))
	{
		if (FI->Type==FTYPE_DIR) 
		{
			if (CmdFlags & FLAG_CMD_RECURSE) InternalRecurseInfoCommand(FS, FI->Name, Arg,  CmdFlags, Vars, ProcessGetFileInfo);
		}
		else 
		{
			printf("\nInfo For %s\n",FI->Path);
			printf("Size: %s (%d bytes)\n",GetHumanReadableDataQty(FI->Size,0),FI->Size);
			printf("ContentType: %s\n",FI->MediaType);

			printf("Timestamp: %s\n",GetDateStrFromSecs("%Y/%m/%d %H:%M:%S",FI->Mtime,NULL));
			for (i=0; DisplayVars[i]; i++)
			{
				ptr=GetVar(FI->Vars,DisplayVars[i]);
				if (StrLen(ptr)) printf("%s: %s\n",DisplayVars[i],ptr);
			}
		}
	}

Curr=ListGetNext(Curr);
}

ListDestroy(Items,FileInfoDestroy);

DestroyString(IncludePattern);
DestroyString(ExcludePattern);
DestroyString(Tempstr);
}
コード例 #26
0
int ProcessGetDigest(TFileStore *FS, char *Pattern, char *Type, int CmdFlags, ListNode *Vars)
{
ListNode *Items=NULL, *Curr;
char *Tempstr=NULL, *IncludePattern=NULL, *ExcludePattern=NULL;
TFileInfo *FI;
int result=FALSE, Flags;

if (! FS->GetDigest) return(FALSE);

IncludePattern=CopyStr(IncludePattern,GetVar(Vars,"IncludePattern"));
ExcludePattern=CopyStr(ExcludePattern,GetVar(Vars,"ExcludePattern"));

Items=ListCreate();

Flags=LIST_REFRESH;
//if (CmdFlags & FLAG_CMD_RECURSE) Flags |= LIST_INCLUDE_DIRS;
FileStoreLoadDir(FS,Pattern,Items, Flags);
Curr=ListGetNext(Items);

while (Curr)
{
	FI=(TFileInfo *) Curr->Item;

  if (FileIncluded(FI,IncludePattern,ExcludePattern,CmdFlags, Vars))
	{
		if (FI->Type==FTYPE_DIR) 
		{
			if (CmdFlags & FLAG_CMD_RECURSE) InternalRecurseInfoCommand(FS, FI->Name, Type, CmdFlags, Vars, ProcessGetDigest);
		}
		else 
		{
			result=FS->GetDigest(FS,FI->Name,Type,&Tempstr);
			if (result)
			{
				if (CmdFlags & FLAG_CMD_RECURSE) printf("OKAY: %s %s%s\n",Tempstr,FS->CurrDir,FI->Name);
				else printf("OKAY: %s %s\n",Tempstr,FI->Name);
			}
			else printf("ERROR: %s\n",Tempstr);
		}
	}

Curr=ListGetNext(Curr);
}

ListDestroy(Items,FileInfoDestroy);

DestroyString(IncludePattern);
DestroyString(ExcludePattern);
DestroyString(Tempstr);

return(result);
}
コード例 #27
0
ファイル: cpost.c プロジェクト: pmuellr/cpost
/*------------------------------------------------------------------
 * atexit processing
 *------------------------------------------------------------------*/
static void RunAtExit(void)
   {

   if (!AllDone)
      fprintf(stderr,"%s : Program terminated.\n",PROGRAM_NAME);

   /*---------------------------------------------------------------
    * erase any temporary files we might have open
    *---------------------------------------------------------------*/
   if (!AllDone)
      fprintf(stderr,"%s : Cleaning up temporary files.\n",PROGRAM_NAME);

   ListIterate(info.fileList,(ListIterateFunc *)CleanUpFileList,&info);

   /*---------------------------------------------------------------
    * destroy file list
    *---------------------------------------------------------------*/
   ListDestroy(info.fileList);

   /*---------------------------------------------------------------
    * destroy hash tables
    *---------------------------------------------------------------*/
   HashDestroy(info.identHash);
   HashDestroy(info.reservedHash);

   /*---------------------------------------------------------------
    * destroy function list
    *---------------------------------------------------------------*/
   ListIterate(info.funcTree,(ListIterateFunc *)CleanUpFuncList,&info);
   ListDestroy(info.funcTree);

   /*---------------------------------------------------------------
    * dump memory (if debug enabled
    *---------------------------------------------------------------*/
#if defined(__DEBUG_ALLOC__)
   _dump_allocated(0);
#endif
   }
コード例 #28
0
ファイル: DataParser.c プロジェクト: ColumPaget/Crayonizer
void ParserItemsDestroy(ListNode *Items)
{
    ListNode *Curr;

    Curr=ListGetNext(Items);
    while (Curr)
    {
        if (Curr->ItemType==ITEM_ARRAY) ParserItemsDestroy((ListNode *) Curr->Item);
        else if (Curr->ItemType==ITEM_ENTITY) ParserItemsDestroy((ListNode *) Curr->Item);
        else DestroyString(Curr->Item);
        Curr=ListGetNext(Curr);
    }
    ListDestroy(Items, NULL);
}
コード例 #29
0
int M3UStreamDownload(STREAM *ManifestCon, const char *URL, const char *Title)
{
STREAM *Con=NULL;
char *Tempstr=NULL, *BasePath=NULL, *Line=NULL;
const char *ptr;
ListNode *Segments, *Curr;
int result;
double BytesRead=0;

Segments=ListCreate();
ptr=strrchr(URL, '/');
if (ptr)
{
BasePath=CopyStrLen(BasePath, URL, ptr - URL);
	Line=STREAMReadLine(Line,ManifestCon);
	while (Line)
	{
		StripLeadingWhitespace(Line);
		StripTrailingWhitespace(Line);
		
		if (*Line != '#')
		{
			Tempstr=MCopyStr(Tempstr, BasePath, "/", Line, NULL);
			ListAddItem(Segments, CopyStr(NULL, Tempstr));
		}
	Line=STREAMReadLine(Line,ManifestCon);
	}

	OpenOutputFiles(Title, URL, &BytesRead);
	Tempstr=SetStrLen(Tempstr,BUFSIZ);
	Curr=ListGetNext(Segments);
	while (Curr)
	{
		Con=ConnectAndRetryUntilDownload(Curr->Item, 0, 0);
		if (Con)
		{
		TransferItem(Con, Title, URL, "m3u8-stream", 0, 0, &BytesRead, FALSE);
		STREAMClose(Con);
		}

	Curr=ListGetNext(Curr);
	}
	CloseOutputFiles();
}

ListDestroy(Segments, DestroyString);
DestroyString(Tempstr);
DestroyString(BasePath);
DestroyString(Line);
}
コード例 #30
0
ファイル: cgi.c プロジェクト: ColumPaget/Hashrat
static void CGIDisplayOptions(const char *HashType, const char *Encoding, const char *LineEnding, int OutputLength)
{
char *Token=NULL, *Tempstr=NULL;
const char *ptr;
ListNode *Items=NULL;
int i;

Items=ListCreate();
printf("<tr>\r\n");

Tempstr=HashAvailableTypes(Tempstr);
ptr=GetToken(Tempstr, ",",&Token,0);
while (ptr)
{
ListAddNamedItem(Items, Token, CopyStr(NULL, Token));
ptr=GetToken(ptr, ",",&Token,0);
}

printf("<td align=left>Type: ");
CGIPrintSelect("HashType", HashType, Items);
ListClear(Items, Destroy);
printf("</td>\r\n");

printf("<td align=right>Encoding: ");
for (i=0; EncodingNames[i] !=NULL; i++) SetVar(Items, EncodingNames[i], EncodingDescriptions[i]);
CGIPrintSelect("Encoding", Encoding, Items);
ListClear(Items, Destroy);
printf("</td>\r\n");

printf("<tr>\r\n");
printf("<td align=left>Line Ending: </td>");
printf("<td align=right>");
for (i=0; LineEndingNames[i] !=NULL; i++) SetVar(Items, LineEndingNames[i], LineEndingDescriptions[i]);
CGIPrintSelect("LineEnding", LineEnding, Items);
ListClear(Items, Destroy);
printf("</td>\r\n");
printf("</tr>\r\n");

printf("<tr>\r\n");
printf("<td align=left>Hash Length: </td>");
printf("<td align=right>");
if (OutputLength > 0) printf("<input type=text width=90%% name=\"OutputLength\" style=\"font-weight: bold;  font-size:16px\" value=\"%d\">\r\n",OutputLength);
else printf("<input type=text width=90%% name=\"OutputLength\" style=\"font-weight: bold;  font-size:16px\">\r\n");
printf("</td>\r\n");
printf("</tr>\r\n");

ListDestroy(Items, Destroy);
Destroy(Tempstr);
Destroy(Token);
}