Exemplo n.º 1
0
Bool WdeFreeAllCustLibs ( void )
{
    LIST        *llist;
    WdeCustLib  *lib;

    if ( WdeCustomLibList != NULL ) {
        for ( llist = WdeCustomLibList; llist; llist = ListNext(llist) ) {
            lib = (WdeCustLib *) ListElement(llist);
            WdeFreeCustLib ( lib );
        }
        ListFree ( WdeCustomLibList );
        WdeCustomLibList = NULL;
    }

    if ( WdeLibList != NULL ) {
        for ( llist = WdeLibList; llist; llist = ListNext(llist) ) {
            lib = (WdeCustLib *) ListElement(llist);
            WdeFreeCustLib ( lib );
        }
        ListFree ( WdeLibList );
        WdeLibList = NULL;
    }

    return ( TRUE );
}
Exemplo n.º 2
0
void
ServerFree(TServer * const serverP) {

    struct _TServer * const srvP = serverP->srvP;

    if (srvP->weCreatedListenSocket)
        SocketDestroy(srvP->listenSocketP);

    xmlrpc_strfree(srvP->name);

    xmlrpc_strfree(srvP->filespath);
    
    ListFree(&srvP->defaultfilenames);

    terminateHandlers(&srvP->handlers);

    ListFree(&srvP->handlers);

    logClose(srvP);

    if (srvP->logfilename)
        xmlrpc_strfree(srvP->logfilename);

    free(srvP);
}
Exemplo n.º 3
0
void ListRemoveEntry(struct List **hist, int *count)
{
  struct List *temp, *temp2;

  if(*hist) {
    if(!(*hist)->prev) {
      temp = (*hist)->next;
      ListFree(hist);
      *hist = temp;
      if(*hist) (*hist)->prev = NULL;
    } else {
      if(!(*hist)->next) {
        temp = (struct List *)(*hist)->prev;
        ListFree(hist);
        *hist = (struct List *)temp;
        if(*hist) (*hist)->next = NULL;
      } else {
        temp = (struct List *)(*hist)->prev;
        temp2 = (struct List *)(*hist)->next;
        ListFree(hist);
        temp->next = (struct List *)temp2;
        temp2->prev = (struct List *)temp;
        *hist = temp;
      }
    }
    if(count)
      --(*count);
  }
}
Exemplo n.º 4
0
int main(int argc, char *args[])
{
    char *buffer = (char *)malloc(MAX_LINE_LEN);;
    char *result = (char *)malloc(MAX_LINE_LEN);;
    int number;
    int dwnum;

    dwnum = GetPrice();
    if(dwnum != 0)
    {
	return dwnum;
    }
    list_t *L = ListInit();
    if(L == NULL)
    {
	return ERRNO_NULL_POINTER;
    }

    while(fgets(buffer, MAX_LINE_LEN, stdin))
    {
	number = 0;
	memset(result, 0, MAX_LINE_LEN);
	dwnum = ParseLine(buffer, result, &number);

	if(dwnum == 0)
	{
	    item_t* curnode;
	    if((curnode = ListIsNodeInListById(L, result)) != NULL)
	    {
		curnode->count += number;
		continue;
	    }

	    item_t * node = ItemMakeitem(result, number);
	    if(node == NULL)
	    {
		return ERRNO_MAKEITEM_FAIL;
	    }

	    dwnum = ListPushBack(L, (void*) node);
	    if(dwnum != 0)
	    {
		return ERRNO_LISTPUSHBACK_FAIL;
	    }
	}
    }

    dwnum = CalculateSum(L);
    if(dwnum != 0)
    {
	return ERRNO_CALCULATESUM_FAIL;	
    }

    ListFree(L);
    ListFree(my_price);
    free(buffer);
    free(result);
    return 0;
}
Exemplo n.º 5
0
void heapDestroy (heap_t *h)
{
    ListFree(h->empty);
    ListFree(h->full);
    free(h->base);
    free(h);
    return;
}
Exemplo n.º 6
0
void
RequestFree(TSession * const sessionP) {

    if (sessionP->validRequest)
        freeRequestInfo(&sessionP->requestInfo);

    ListFree(&sessionP->cookies);
    ListFree(&sessionP->ranges);
    TableFree(&sessionP->requestHeaderFields);
    TableFree(&sessionP->responseHeaderFields);
    StringFree(&(sessionP->header));
}
Exemplo n.º 7
0
/**
 * Terminate the socket module
 */
void Socket_outTerminate()
{
	FUNC_ENTRY;
	ListFree(s.connect_pending);
	ListFree(s.write_pending);
	ListFree(s.clientsds);
	SocketBuffer_terminate();
#if defined(WIN32) || defined(WIN64)
	WSACleanup();
#endif
	FUNC_EXIT;
}
Exemplo n.º 8
0
void
MIMETypeTerm(void) {

    if (globalMimeTypeP == NULL)
        abort();

	ListFree(&globalMimeTypeP->extList);
	ListFree(&globalMimeTypeP->typeList);

    MIMETypeDestroy(globalMimeTypeP);

    globalMimeTypeP = NULL;
}
Exemplo n.º 9
0
static int ProcMemFini( void )
{
    ListFree( Directive_List );
    ListFree( Files_List );
    ListFree( Obj_List );
    ListFree( Libs_List );
    MemFree( Map_Name );
    MemFree( Obj_Name );
    MemFree( Link_Name );
    MemFree( SystemName );
    MemFree( StackSize );
    return( 0 );
}
Exemplo n.º 10
0
void WdeSOP( OBJPTR obj, OBJPTR parent )
{
    LIST       *ilist, *tlist, *clist;
    WdeResInfo *info;
    RECT        orect;
    OBJPTR      sib;
    OBJ_ID      id;
    bool        clear;
    POINT       origin;

    info = WdeGetCurrentRes();
    if( info == NULL ) {
        return;
    }
    GetClientRect( info->edit_win, &orect );

    GetOffset( &origin );
    OffsetRect( &orect, origin.x, origin.y );

    if( parent == NULL ) {
        GetObjectParent( obj, &parent );
        if( parent == NULL ) {
            return;
        }
    }

    Forward( parent, GET_SUBOBJ_LIST, &tlist, NULL );

    if( tlist != NULL && WdeFindObjectsInRect( &orect, &ilist, tlist ) && ilist != NULL ) {
        clist = NULL;
        tlist = NULL;
        for( ; ilist != NULL; ilist = ListConsume( ilist ) ) {
            sib = ListElement( ilist );
            if( (Forward( sib, IS_OBJECT_CLEAR, &clear, NULL ) && clear) ||
                (Forward( sib, IDENTIFY, &id, NULL ) && id == DIALOG_OBJ) ) {
                WdeInsertObject( &clist, sib );
            } else {
                WdeInsertObject( &tlist, sib );
            }
        }
        if( clist != NULL ) {
            WdeListConcat( &tlist, clist, 0 );
            ListFree( clist );
        }
        if( tlist != NULL ) {
            WdeReorderObjectWindows( tlist );
            ListFree( tlist );
        }
    }
}
Exemplo n.º 11
0
/**
 * Empty and free up all storage used by a message list
 * @param msgList the message list to empty and free
 */
void MQTTProtocol_freeMessageList(List* msgList)
{
	FUNC_ENTRY;
	MQTTProtocol_emptyMessageList(msgList);
	ListFree(msgList);
	FUNC_EXIT;
}
Exemplo n.º 12
0
/**
 * Terminate the log module
 */
void Log_terminate()
{
	ListFree(log_buffer);
	log_buffer = NULL;
	free(trace_queue);
	trace_queue = NULL;
}
Exemplo n.º 13
0
/**
 * Free a client structure
 * @param client the client data to free
 */
void MQTTProtocol_freeClient(Clients* client)
{
	FUNC_ENTRY;
	/* free up pending message lists here, and any other allocated data */
	MQTTProtocol_freeMessageList(client->outboundMsgs);
	MQTTProtocol_freeMessageList(client->inboundMsgs);
	ListFree(client->messageQueue);
	free(client->clientID);
	if (client->will)
	{
		free(client->will->payload);
		free(client->will->topic);
		free(client->will);
	}
#if defined(OPENSSL)
	if (client->sslopts)
	{
		if (client->sslopts->trustStore)
			free((void*)client->sslopts->trustStore);
		if (client->sslopts->keyStore)
			free((void*)client->sslopts->keyStore);
		if (client->sslopts->privateKey)
			free((void*)client->sslopts->privateKey);
		if (client->sslopts->privateKeyPassword)
			free((void*)client->sslopts->privateKeyPassword);
		if (client->sslopts->enabledCipherSuites)
			free((void*)client->sslopts->enabledCipherSuites);
		free(client->sslopts);
	}
#endif
	/* don't free the client structure itself... this is done elsewhere */
	FUNC_EXIT;
}
Exemplo n.º 14
0
/**
 * Shutdown the broker.
 * @param rc - startup success code
 */
void Broker_shutdown(int rc)
{
	FUNC_ENTRY;
	if (rc != -99)
	{
		time_t now = 0;

		Log_setPublish(false);
#if !defined(NO_BRIDGE)
		Bridge_terminate(&(BrokerState.bridge));
#endif
		if (rc != -98)
		{
			if (rc != -97)
			{
				if (BrokerState.persistence)
					SubscriptionEngines_save(BrokerState.se);
				Protocol_terminate();
				Socket_terminate();
				SubscriptionEngines_terminate(BrokerState.se);

				Log(LOG_INFO, 44, NULL, BrokerState.msgs_sent);
				Log(LOG_INFO, 43, NULL, BrokerState.msgs_received);
				time(&(now));
				Log(LOG_INFO, 42, NULL, (int)difftime(now, BrokerState.start_time));
				Log(LOG_INFO, 55, NULL, Heap_get_info()->max_size);
			}
		}
		ListFree(BrokerState.clients);
		Persistence_free_config(&BrokerState);
	}
	FUNC_EXIT;
}
Exemplo n.º 15
0
/**
 * Free allocated storage for a suback packet.
 * @param pack pointer to the suback packet structure
 */
void MQTTPacket_freeSuback(Suback* pack)
{
	FUNC_ENTRY;
	if (pack->qoss != NULL)
		ListFree(pack->qoss);
	free(pack);
	FUNC_EXIT;
}
Exemplo n.º 16
0
/**
 * Terminate the socket module for outbound communications only
 */
void Socket_outTerminate()
{
	FUNC_ENTRY;
#if defined(USE_POLL)
	TreeFree(s.fds_tree);
#else
	ListFree(s.connect_pending);
	ListFree(s.write_pending);
	ListFree(s.clientsds);
#endif
	ListFree(s.newSockets);
	SocketBuffer_terminate();
#if defined(WIN32)
	WSACleanup();
#endif
	FUNC_EXIT;
}
Exemplo n.º 17
0
static void
handleDirectory(TSession *const sessionP,
                const char *const dirName,
                time_t const fileModTime,
                MIMEType *const mimeTypeP) {

    bool text;
    bool ascending;
    uint16_t sort;    /* 1=by name, 2=by date */
    const char *error;

    determineSortType(sessionP->requestInfo.query,
                      &ascending, &sort, &text, &error);

    if (error) {
        ResponseStatus(sessionP, 400);
        xmlrpc_strfree(error);
    } else if (notRecentlyModified(sessionP, fileModTime)) {
        ResponseStatus(sessionP, 304);
        ResponseWriteStart(sessionP);
    } else {
        TPool pool;
        bool succeeded;
        succeeded = PoolCreate(&pool, 1024);
        if (!succeeded)
            ResponseStatus(sessionP, 500);
        else {
            TList list;
            uint16_t responseStatus;
            const char *error;
            generateListing(&list, dirName, sessionP->requestInfo.uri,
                            &pool, &error, &responseStatus);
            if (error) {
                ResponseStatus(sessionP, responseStatus);
                xmlrpc_strfree(error);
            } else {
                ResponseStatus(sessionP, 200);
                ResponseContentType(sessionP,
                                    text ? "text/plain" : "text/html");

                addLastModifiedHeader(sessionP, fileModTime);

                ResponseChunked(sessionP);
                ResponseWriteStart(sessionP);

                if (sessionP->requestInfo.method != m_head)
                    sendDirectoryDocument(&list, ascending, sort, text,
                                          sessionP->requestInfo.uri, mimeTypeP,
                                          sessionP);

                HTTPWriteEndChunk(sessionP);

                ListFree(&list);
            }
            PoolFree(&pool);
        }
    }
}
Exemplo n.º 18
0
static void
sendFileAsResponse(TSession *const sessionP,
                   TFile *const fileP,
                   const char *const fileName,
                   time_t const fileModTime,
                   MIMEType *const mimeTypeP) {

    uint64_t const filesize = FileSize(fileP);
    const char *const mediatype = MIMETypeGuessFromFile2(mimeTypeP, fileName);

    uint64_t start;  /* Defined only if session has one range */
    uint64_t end;    /* Defined only if session has one range */

    switch (sessionP->ranges.size) {
        case 0:
            ResponseStatus(sessionP, 200);
            break;

        case 1: {
            bool decoded;
            decoded = RangeDecode((char *) (sessionP->ranges.item[0]), filesize,
                                  &start, &end);
            if (!decoded) {
                ListFree(&sessionP->ranges);
                ResponseStatus(sessionP, 200);
            } else {
                const char *contentRange;
                xmlrpc_asprintf(&contentRange,
                                "bytes %" PRIu64 "-%" PRIu64 "/%" PRIu64,
                                start, end, filesize);
                ResponseAddField(sessionP, "Content-range", contentRange);
                xmlrpc_strfree(contentRange);

                ResponseContentLength(sessionP, end - start + 1);
                ResponseStatus(sessionP, 206);
            }
        }
            break;

        default:
            ResponseContentType(sessionP,
                                "multipart/ranges; boundary=" BOUNDARY);
            ResponseStatus(sessionP, 206);
            break;
    }

    if (sessionP->ranges.size == 0) {
        ResponseContentLength(sessionP, filesize);
        ResponseContentType(sessionP, mediatype);
    }

    addLastModifiedHeader(sessionP, fileModTime);

    ResponseWriteStart(sessionP);

    if (sessionP->requestInfo.method != m_head)
        sendBody(sessionP, fileP, filesize, mediatype, start, end);
}
Exemplo n.º 19
0
void
HandlerDestroy(BIHandler *const handlerP) {

    ListFree(&handlerP->defaultFileNames);

    xmlrpc_strfree(handlerP->filesPath);

    free(handlerP);
}
Exemplo n.º 20
0
void MQTTClient_terminate(void)
{
	FUNC_ENTRY;
	MQTTClient_stop();
	if (initialized)
	{
		ListFree(bstate->clients);
		ListFree(handles);
		handles = NULL;
		Socket_outTerminate();
		#if defined(HEAP_H)
			Heap_terminate();
		#endif
		Log_terminate();
		initialized = 0;
	}
	FUNC_EXIT;
}
Exemplo n.º 21
0
void SocketBuffer_terminate(void)
{
    ListElement* cur = NULL;
    ListEmpty(&writes);
    
    FUNC_ENTRY;
    while (ListNextElement(queues, &cur)) { free(((socket_queue*)(cur->content))->buf); }
    ListFree(queues);
    SocketBuffer_freeDefQ();
    FUNC_EXIT;
}
Exemplo n.º 22
0
Arquivo: v4p.c Projeto: miellaby/v4p
// delete all ActiveEdges of a poly
PolygonP v4pPolygonDelActiveEdges(PolygonP p) {
   List l ;
   ActiveEdgeP b;
   l = p->ActiveEdge1 ;
   while (l) {
     b = (ActiveEdgeP)ListData(l) ;
     QuickHeapFree(v4p->activeEdgeHeap, b);
     l = ListFree(l) ;
   }
   p->ActiveEdge1 = NULL;
   return p;
}
Exemplo n.º 23
0
static void DoKbdMove( LPPOINT pt )
/*********************************/
{
    LIST    *list;

    list = GetCurrObjectList();
    SetShowEatoms( FALSE );
    BeginMoveOperation( list );
    ListFree( list );
    MoveCurrObj( pt );
    FinishMoveOperation( FALSE );
    SetShowEatoms( TRUE );
}
Exemplo n.º 24
0
void WdeShutdownToolBars( void )
{
    WdeToolBar  *tbar;
    LIST        *tlist;

    tlist = WdeListCopy( WdeToolBarList );
    for( ; tlist != NULL; tlist = ListConsume( tlist ) ) {
        tbar = ListElement( tlist );
        ToolBarDestroy( tbar->tbar );
    }
    ToolBarFini( NULL );

    ListFree( WdeToolBarList );
}
Exemplo n.º 25
0
void WdeFreeResList( void )
{
    LIST       *rlist;
    WdeResInfo *res_info;

    if( WdeResList != NULL ) {
        for( rlist = WdeResList; rlist != NULL; rlist = ListNext( rlist ) ) {
            res_info = (WdeResInfo *)ListElement( rlist );
            WdeSetCurrentRes( res_info );
            WdeFreeResInfo( res_info );
        }
        ListFree( WdeResList );
        WdeResList = NULL;
    }
}
Exemplo n.º 26
0
static void
generateListing(TList *       const listP,
                char *        const z,
                const char *  const uri,
                TPool *       const poolP,
                const char ** const errorP,
                uint16_t *    const responseStatusP) {
    
    TFileInfo fileinfo;
    TFileFind findhandle;

    *errorP = NULL;

    if (!FileFindFirst(&findhandle, z, &fileinfo)) {
        *responseStatusP = ResponseStatusFromErrno(errno);
        xmlrpc_asprintf(errorP, "Can't read first entry in directory");
    } else {
        ListInit(listP);

        do {
            TFileInfo * fi;
            /* Files whose names start with a dot are ignored */
            /* This includes implicitly the ./ and ../ */
            if (*fileinfo.name == '.') {
                if (xmlrpc_streq(fileinfo.name, "..")) {
                    if (xmlrpc_streq(uri, "/"))
                        continue;
                } else
                    continue;
            }
            fi = (TFileInfo *)PoolAlloc(poolP, sizeof(fileinfo));
            if (fi) {
                abyss_bool success;
                memcpy(fi, &fileinfo, sizeof(fileinfo));
                success =  ListAdd(listP, fi);
                if (!success)
                    xmlrpc_asprintf(errorP, "ListAdd() failed");
            } else
                xmlrpc_asprintf(errorP, "PoolAlloc() failed.");
        } while (!*errorP && FileFindNext(&findhandle, &fileinfo));

        if (*errorP) {
            *responseStatusP = 500;
            ListFree(listP);
        }            
        FileFindClose(&findhandle);
    }
}
Exemplo n.º 27
0
void WdeFreeCustLibControls ( LIST **control_list )
{
    LIST           *clist;
    WdeCustControl *control;

    if ( (control_list != NULL) && (*control_list != NULL) ) {
        for ( clist = *control_list; clist; clist = ListNext(clist) ) {
            control = (WdeCustControl *) ListElement(clist);
            WdeFreeCustControl ( control );
        }
        ListFree ( *control_list );
        *control_list = NULL;
    } else {
        WdeWriteTrail("WdeFreeCustLibControls: NULL control_list!");
    }
}
Exemplo n.º 28
0
int main(int argc, char *argv[])
{
	int i, *ip, *todelete;
	ListElement* current = NULL;
	List* l = ListInitialize();
	printf("List initialized\n");

	for (i = 0; i < 10; i++)
	{
		ip = malloc(sizeof(int));
		*ip = i;
		ListAppend(l, (void*)ip, sizeof(int));
		if (i==5)
			todelete = ip;
		printf("List element appended %d\n",  *((int*)(l->last->content)));
	}

	printf("List contents:\n");
	current = NULL;
	while (ListNextElement(l, &current) != NULL)
		printf("List element: %d\n", *((int*)(current->content)));

	printf("List contents in reverse order:\n");
	current = NULL;
	while (ListPrevElement(l, &current) != NULL)
		printf("List element: %d\n", *((int*)(current->content)));

	//if ListFindItem(l, *ip, intcompare)->content

	printf("List contents having deleted element %d:\n", *todelete);
	ListRemove(l, todelete);
	current = NULL;
	while (ListNextElement(l, &current) != NULL)
		printf("List element: %d\n", *((int*)(current->content)));

	i = 9;
	ListRemoveItem(l, &i, intcompare);
	printf("List contents having deleted another element, %d, size now %d:\n", i, l->size);
	current = NULL;
	while (ListNextElement(l, &current) != NULL)
		printf("List element: %d\n", *((int*)(current->content)));

	ListFree(l);
	printf("List freed\n");
}
Exemplo n.º 29
0
void WREFreeResList( void )
{
    LIST        *rlist;
    WREResInfo  *info;
    HWND        frame;

    if( WREResList != NULL ) {
        frame = WREGetMDIWindowHandle();
        for( rlist = WREResList; rlist != NULL; rlist = ListNext( rlist ) ) {
            info = (WREResInfo *)ListElement( rlist );
            SendMessage( frame, WM_MDIACTIVATE, (WPARAM)info->res_win, 0 );
            WREFreeResInfo( info );
        }
        ListFree( WREResList );
        WREResList = NULL;
        WRENumRes = 0;
    }
}
Exemplo n.º 30
0
static void WoldShell(Widget shell, Ph_Object obj)
{
  Widget pane;
  List items;

  /* RowColumn */
  pane = XmCreateRowColumn(shell, "woldPane", NULL, 0);

  TextVar(pane, obj, "nbr-size");
  TextVar(pane, obj, "alt-metric");
  TextVar(pane, obj, "orien-label");

  items = ListCreate(NULL);
  ListAddRear(items, "none");
  ListAddRear(items, "gorkani");
  ListAddRear(items, "tamura");
  MenuVar(pane, obj, "orien-type", items, NULL);
  ListFree(items);

  XtManageChild(pane);
}