void mupnp_iconlist_delete(mUpnpIconList* iconList) { mupnp_log_debug_l4("Entering...\n"); mupnp_list_remove((mUpnpList*)iconList); free(iconList); mupnp_log_debug_l4("Leaving...\n"); }
void mupnp_actionlist_delete(mUpnpActionList *actionList) { mupnp_log_debug_l4("Entering...\n"); mupnp_list_remove((mUpnpList *)actionList); free(actionList); mupnp_log_debug_l4("Leaving...\n"); }
void mupnp_http_header_delete(mUpnpHttpHeader* header) { mupnp_log_debug_l4("Entering...\n"); mupnp_list_remove((mUpnpList*)header); mupnp_string_delete(header->name); mupnp_string_delete(header->value); free(header); mupnp_log_debug_l4("Leaving...\n"); }
void mupnp_argument_delete(mUpnpArgument* arg) { mupnp_log_debug_l4("Entering...\n"); mupnp_list_remove((mUpnpList*)arg); mupnp_string_delete(arg->value); mupnp_log_debug_l4("Leaving...\n"); free(arg); }
void mupnp_ssdpresponse_server_delete(mUpnpSSDPResponseServer* server) { mupnp_log_debug_l4("Entering...\n"); mupnp_ssdpresponse_server_stop(server); mupnp_ssdpresponse_server_close(server); mupnp_list_remove((mUpnpList*)server); free(server); mupnp_log_debug_l4("Leaving...\n"); }
void mupnp_net_interface_delete(mUpnpNetworkInterface *netIf) { mupnp_log_debug_l4("Entering...\n"); mupnp_list_remove((mUpnpList *)netIf); mupnp_string_delete(netIf->name); mupnp_string_delete(netIf->ipaddr); mupnp_string_delete(netIf->netmask); mupnp_log_debug_l4("Leaving...\n"); free(netIf); }
void mupnp_action_delete(mUpnpAction *action) { mupnp_log_debug_l4("Entering...\n"); mupnp_argumentlist_delete(action->argumentList); mupnp_status_delete(action->upnpStatus); mupnp_list_remove((mUpnpList *)action); free(action); mupnp_log_debug_l4("Leaving...\n"); }
/** * Destroy an event subscriber * * @param sub The event subscriber */ void mupnp_subscriber_delete(mUpnpSubscriber* sub) { mupnp_log_debug_l4("Entering...\n"); mupnp_subscriber_clear(sub); mupnp_list_remove((mUpnpList*)sub); mupnp_string_delete(sub->sid); mupnp_string_delete(sub->ifAddr); mupnp_net_url_delete(sub->deliveryURL); free(sub); mupnp_log_debug_l4("Leaving...\n"); }
void mupnp_xml_node_delete(mUpnpXmlNode *node) { mupnp_log_debug_l4("Entering...\n"); mupnp_list_remove((mUpnpList *)node); mupnp_string_delete(node->name); mupnp_string_delete(node->value); mupnp_xml_attributelist_delete(node->attrList); mupnp_xml_nodelist_delete(node->nodeList); if (node->userDataDestructorFunc != NULL) node->userDataDestructorFunc(node->userData); free(node); mupnp_log_debug_l4("Leaving...\n"); }
void mupnp_http_server_delete(mUpnpHttpServer *httpServer) { mupnp_log_debug_l4("Entering...\n"); mupnp_http_server_stop(httpServer); mupnp_http_server_close(httpServer); if (httpServer->mutex) mupnp_mutex_delete(httpServer->mutex); mupnp_list_remove((mUpnpList *)httpServer); free(httpServer); mupnp_log_debug_l4("Leaving...\n"); }
void mupnp_upnpav_protocolinfo_delete(mUpnpAvProtocolInfo *info) { mupnp_log_debug_l4("Entering...\n"); mupnp_list_remove((mUpnpList *)info); if (info->protocol) mupnp_string_delete(info->protocol); if (info->network) mupnp_string_delete(info->network); if (info->mimeType) mupnp_string_delete(info->mimeType); if (info->additionalInfo) mupnp_string_delete(info->additionalInfo); if (info->string) mupnp_string_delete(info->string); free(info); mupnp_log_debug_l4("Leaving...\n"); }
/** * Remove a listener from the event listener list * * @param eventListenerList The event listener list * @param listener The listener to remove * */ void mupnp_eventlistenerlist_remove(mUpnpEventListenerList* eventListenerList, MUPNP_EVENT_LISTENER listener) { mUpnpEventListenerList* list_node = NULL; mupnp_log_debug_l4("Entering...\n"); if (listener == NULL) return; for (list_node = mupnp_eventlistenerlist_gets(eventListenerList); list_node != NULL; list_node = mupnp_eventlistenerlist_next(list_node)) { if (list_node->listener == listener) { mupnp_list_remove((mUpnpList*)list_node); free(list_node); break; } } mupnp_log_debug_l4("Leaving...\n"); }
BOOL mupnp_http_persistentconnection_put(char *host, int port, void *data) { mUpnpHttpPersistentConnection *new_node = NULL, *node = NULL; mupnp_log_debug_l4("Entering...\n"); /* If we dont have cache, then just exit */ if (cache == NULL) { mupnp_log_debug("(put) No cache! Persistent connections not initialized?\n"); return FALSE; } /* Check if we already have this one cached */ for (node = (mUpnpHttpPersistentConnection*)mupnp_list_gets((mUpnpList*)cache); node != NULL; node = (mUpnpHttpPersistentConnection*)mupnp_list_next((mUpnpList*)node)) { if (mupnp_strcmp(mupnp_string_getvalue(node->host), host) == 0 && node->port == port) { /* If also data is the same, then update just timestamp */ if (node->cacheData == data) { node->timestamp = mupnp_getcurrentsystemtime(); return TRUE; } mupnp_log_debug_s("Found cached persistent connection for %s:%d\n", mupnp_string_getvalue(node->host), node->port); new_node = node; mupnp_list_remove((mUpnpList*)new_node); break; } } /* We didn't find it */ if (new_node == NULL) { /* Check if we have already too many cached things */ if (mupnp_list_size((mUpnpList*)cache) >= CG_HTTP_PERSISTENT_CACHE_SIZE) { /* Take last node (not refreshed for a long time) */ new_node = (mUpnpHttpPersistentConnection *)mupnp_list_next((mUpnpList *)cache); mupnp_list_remove((mUpnpList*)new_node); mupnp_http_persistentconnection_delete(new_node); new_node = NULL; mupnp_log_debug_s("Max persistent HTTP connection cache reached.\n"); } if (new_node == NULL) { if (data == NULL) return TRUE; new_node = mupnp_http_persistentconnection_new(); if (new_node == NULL) return FALSE; mupnp_log_debug_s("Adding persistent HTTP Connection %s:%d to cache\n", host, port); mupnp_log_debug_s("Persistent connections: %d\n", mupnp_list_size((mUpnpList*)cache)); } } if (data != NULL) { /* Set appropriate values for the node */ mupnp_string_setvalue(new_node->host, host); new_node->port = port; new_node->cacheData = data; new_node->timestamp = mupnp_getcurrentsystemtime(); mupnp_list_add((mUpnpList*)cache, (mUpnpList*)new_node); } else { /* remove and delete node */ mupnp_http_persistentconnection_delete(new_node); } return TRUE; mupnp_log_debug_l4("Leaving...\n"); }
void *mupnp_http_persistentconnection_get(char *host, int port) { mUpnpHttpPersistentConnection *node; mUpnpTime sys_time = mupnp_getcurrentsystemtime(); BOOL iterate; mupnp_log_debug_l4("Entering...\n"); /* If we dont have cache, then just exit */ if (cache == NULL) { mupnp_log_debug("(get) No cache! Persistent connections not initialized?\n"); return NULL; } /* Clear all expired nodes */ do { iterate = FALSE; for (node = (mUpnpHttpPersistentConnection*)mupnp_list_gets((mUpnpList*)cache); node != NULL; node = (mUpnpHttpPersistentConnection*)mupnp_list_next((mUpnpList*)node)) { if (sys_time > node->timestamp + CG_HTTP_PERSISTENT_TIMEOUT_PERIOD) { mupnp_log_debug_s("Timeout for persistent HTTP Connection to %s:%d " "(timestamp: %d)\n", mupnp_string_getvalue(node->host), node->port, node->timestamp); mupnp_list_remove((mUpnpList*)node); mupnp_http_persistentconnection_delete(node); iterate = TRUE; break; } } } while (iterate); /* Get persistent node */ for (node = (mUpnpHttpPersistentConnection*)mupnp_list_gets((mUpnpList*)cache); node != NULL; node = (mUpnpHttpPersistentConnection*)mupnp_list_next((mUpnpList*)node)) { if (mupnp_strcmp(mupnp_string_getvalue(node->host), host) == 0 && node->port == port) { /* Node was required, remove and add again to refresh cache */ mupnp_list_remove((mUpnpList*)node); mupnp_list_add((mUpnpList*)cache, (mUpnpList*)node); node->timestamp = mupnp_getcurrentsystemtime(); mupnp_log_debug_s("Persistent HTTP Connection cache HIT for %s:%d\n", host, port); return node->cacheData; } } mupnp_log_debug_s("Persistent HTTP Connection cache MISS for %s:%d\n", host, port); return NULL; mupnp_log_debug_l4("Leaving...\n"); }