1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 * -*- */ 2 3 /* coap_list.c -- CoAP list structures 4 * 5 * Copyright (C) 2010,2011,2015 Olaf Bergmann <bergmann@tzi.org> 6 * 7 * This file is part of the CoAP library libcoap. Please see README for terms of 8 * use. 9 */ 10 11 /* 12 * examples/coap_list.[ch] are DEPRECATED. You should be using 13 * struct coap_optlist_t instead with the following functions which are a part 14 * of libcoap. 15 * 16 * coap_new_optlist() 17 * coap_insert_optlist() 18 * coap_delete_optlist() 19 * coap_add_optlist_pdu() 20 * 21 * See 'man coap_pdu_setup' for further information. 22 * 23 * examples/coap_list.[ch] files will be removed in a future release 24 * They are left here to support building backward compatability of old versions 25 * of coap-client 26 */ 27 28 /* #include "coap_config.h" */ 29 30 #include <stdio.h> 31 #include <string.h> 32 33 #include <coap2/libcoap.h> 34 #include <coap2/debug.h> 35 #include <coap2/mem.h> 36 #include "coap_list.h" 37 38 39 int coap_insert(coap_list_t ** head,coap_list_t * node)40coap_insert(coap_list_t **head, coap_list_t *node) { 41 if (!node) { 42 coap_log(LOG_WARNING, "cannot create option Proxy-Uri\n"); 43 } else { 44 /* must append at the list end to avoid re-ordering of 45 * options during sort */ 46 LL_APPEND((*head), node); 47 } 48 49 return node != NULL; 50 } 51 52 int coap_delete(coap_list_t * node)53coap_delete(coap_list_t *node) { 54 if (node) { 55 coap_free(node); 56 } 57 return 1; 58 } 59 60 void coap_delete_list(coap_list_t * queue)61coap_delete_list(coap_list_t *queue) { 62 coap_list_t *elt, *tmp; 63 64 if (!queue) 65 return; 66 67 LL_FOREACH_SAFE(queue, elt, tmp) { 68 coap_delete(elt); 69 } 70 } 71 72