LCOV - code coverage report
Current view: top level - collection - collection_cnv.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 98 201 48.8 %
Date: 2014-04-01 Functions: 26 51 51.0 %

          Line data    Source code
       1             : /*
       2             :     COLLECTION LIBRARY
       3             : 
       4             :     Convenience wrapper functions are implemented here.
       5             :     They take a lot of space but pretty simple so they
       6             :     are separated from the core logic.
       7             : 
       8             :     Copyright (C) Dmitri Pal <dpal@redhat.com> 2009
       9             : 
      10             :     Collection Library is free software: you can redistribute it and/or modify
      11             :     it under the terms of the GNU Lesser General Public License as published by
      12             :     the Free Software Foundation, either version 3 of the License, or
      13             :     (at your option) any later version.
      14             : 
      15             :     Collection Library is distributed in the hope that it will be useful,
      16             :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      17             :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      18             :     GNU Lesser General Public License for more details.
      19             : 
      20             :     You should have received a copy of the GNU Lesser General Public License
      21             :     along with Collection Library.  If not, see <http://www.gnu.org/licenses/>.
      22             : */
      23             : 
      24             : #include "config.h"
      25             : #include <string.h>
      26             : #include <stdlib.h>
      27             : #include <ctype.h>
      28             : #include <time.h>
      29             : #include "trace.h"
      30             : 
      31             : /* The collection should use the teal structures */
      32             : #include "collection_priv.h"
      33             : #include "collection.h"
      34             : 
      35             : /* PROPERTIES */
      36             : /* Insert string property with positioning */
      37         375 : int col_insert_str_property(struct collection_item *ci,
      38             :                             const char *subcollection,
      39             :                             int disposition,
      40             :                             const char *refprop,
      41             :                             int idx,
      42             :                             unsigned flags,
      43             :                             const char *property,
      44             :                             const char *string,
      45             :                             int length)
      46             : {
      47         375 :     int error = EOK;
      48             : 
      49             :     TRACE_FLOW_STRING("col_insert_string_property", "Entry.");
      50             : 
      51         375 :     if (length == 0) length = strlen(string) + 1;
      52             : 
      53         375 :     error = col_insert_property_with_ref(ci,
      54             :                                          subcollection,
      55             :                                          disposition,
      56             :                                          refprop,
      57             :                                          idx,
      58             :                                          flags,
      59             :                                          property,
      60             :                                          COL_TYPE_STRING,
      61             :                                          (const void *)string,
      62             :                                          length,
      63             :                                          NULL);
      64             : 
      65             :     TRACE_FLOW_NUMBER("col_insert_string_property returning", error);
      66         375 :     return error;
      67             : }
      68             : 
      69             : /* Insert binary property with positioning */
      70       67830 : int col_insert_binary_property(struct collection_item *ci,
      71             :                                const char *subcollection,
      72             :                                int disposition,
      73             :                                const char *refprop,
      74             :                                int idx,
      75             :                                unsigned flags,
      76             :                                const char *property,
      77             :                                void *binary_data,
      78             :                                int length)
      79             : {
      80       67830 :     int error = EOK;
      81             : 
      82             :     TRACE_FLOW_STRING("col_insert_binary_property", "Entry.");
      83             : 
      84       67830 :     error = col_insert_property_with_ref(ci,
      85             :                                          subcollection,
      86             :                                          disposition,
      87             :                                          refprop,
      88             :                                          idx,
      89             :                                          flags,
      90             :                                          property,
      91             :                                          COL_TYPE_BINARY,
      92             :                                          binary_data,
      93             :                                          length,
      94             :                                          NULL);
      95             : 
      96             :     TRACE_FLOW_NUMBER("col_insert_binary_property returning", error);
      97       67830 :     return error;
      98             : }
      99             : 
     100             : 
     101             : /* Insert integer property with positioning */
     102          27 : int col_insert_int_property(struct collection_item *ci,
     103             :                             const char *subcollection,
     104             :                             int disposition,
     105             :                             const char *refprop,
     106             :                             int idx,
     107             :                             unsigned flags,
     108             :                             const char *property,
     109             :                             int32_t number)
     110             : {
     111          27 :     int error = EOK;
     112             : 
     113             :     TRACE_FLOW_STRING("col_insert_int_property", "Entry.");
     114             : 
     115          27 :     error = col_insert_property_with_ref(ci,
     116             :                                          subcollection,
     117             :                                          disposition,
     118             :                                          refprop,
     119             :                                          idx,
     120             :                                          flags,
     121             :                                          property,
     122             :                                          COL_TYPE_INTEGER,
     123             :                                          (void *)&number,
     124             :                                          sizeof(int32_t),
     125             :                                          NULL);
     126             : 
     127             :     TRACE_FLOW_NUMBER("col_insert_int_property returning", error);
     128          27 :     return error;
     129             : }
     130             : 
     131             : 
     132             : /* Insert unsigned property with positioning */
     133      496482 : int col_insert_unsigned_property(struct collection_item *ci,
     134             :                                  const char *subcollection,
     135             :                                  int disposition,
     136             :                                  const char *refprop,
     137             :                                  int idx,
     138             :                                  unsigned flags,
     139             :                                  const char *property,
     140             :                                  uint32_t number)
     141             : {
     142      496482 :     int error = EOK;
     143             : 
     144             :     TRACE_FLOW_STRING("col_insert_unsigned_property", "Entry.");
     145             : 
     146      496482 :     error = col_insert_property_with_ref(ci,
     147             :                                          subcollection,
     148             :                                          disposition,
     149             :                                          refprop,
     150             :                                          idx,
     151             :                                          flags,
     152             :                                          property,
     153             :                                          COL_TYPE_UNSIGNED,
     154             :                                          (void *)&number,
     155             :                                          sizeof(uint32_t),
     156             :                                          NULL);
     157             : 
     158             :     TRACE_FLOW_NUMBER("col_insert_unsigned_property returning", error);
     159      496482 :     return error;
     160             : }
     161             : 
     162             : 
     163             : /* Insert long property with positioning */
     164          14 : int col_insert_long_property(struct collection_item *ci,
     165             :                              const char *subcollection,
     166             :                              int disposition,
     167             :                              const char *refprop,
     168             :                              int idx,
     169             :                              unsigned flags,
     170             :                              const char *property,
     171             :                              int64_t number)
     172             : {
     173          14 :     int error = EOK;
     174             : 
     175             :     TRACE_FLOW_STRING("col_insert_long_property", "Entry.");
     176             : 
     177          14 :     error = col_insert_property_with_ref(ci,
     178             :                                          subcollection,
     179             :                                          disposition,
     180             :                                          refprop,
     181             :                                          idx,
     182             :                                          flags,
     183             :                                          property,
     184             :                                          COL_TYPE_LONG,
     185             :                                          (void *)&number,
     186             :                                          sizeof(int64_t),
     187             :                                          NULL);
     188             : 
     189             :     TRACE_FLOW_NUMBER("col_insert_long_property returning", error);
     190          14 :     return error;
     191             : }
     192             : 
     193             : /* Insert unsigned long property with positioning */
     194           8 : int col_insert_ulong_property(struct collection_item *ci,
     195             :                               const char *subcollection,
     196             :                               int disposition,
     197             :                               const char *refprop,
     198             :                               int idx,
     199             :                               unsigned flags,
     200             :                               const char *property,
     201             :                               uint64_t number)
     202             : {
     203           8 :     int error = EOK;
     204             : 
     205             :     TRACE_FLOW_STRING("col_insert_ulong_property", "Entry.");
     206             : 
     207           8 :     error = col_insert_property_with_ref(ci,
     208             :                                          subcollection,
     209             :                                          disposition,
     210             :                                          refprop,
     211             :                                          idx,
     212             :                                          flags,
     213             :                                          property,
     214             :                                          COL_TYPE_ULONG,
     215             :                                          (void *)&number,
     216             :                                          sizeof(uint64_t),
     217             :                                          NULL);
     218             : 
     219             :     TRACE_FLOW_NUMBER("col_insert_ulong_property returning", error);
     220           8 :     return error;
     221             : }
     222             : 
     223             : /* Insert double property with positioning */
     224          10 : int col_insert_double_property(struct collection_item *ci,
     225             :                                const char *subcollection,
     226             :                                int disposition,
     227             :                                const char *refprop,
     228             :                                int idx,
     229             :                                unsigned flags,
     230             :                                const char *property,
     231             :                                double number)
     232             : {
     233          10 :     int error = EOK;
     234             : 
     235             :     TRACE_FLOW_STRING("col_insert_double_property", "Entry.");
     236             : 
     237          10 :     error = col_insert_property_with_ref(ci,
     238             :                                          subcollection,
     239             :                                          disposition,
     240             :                                          refprop,
     241             :                                          idx,
     242             :                                          flags,
     243             :                                          property,
     244             :                                          COL_TYPE_DOUBLE,
     245             :                                          (void *)&number,
     246             :                                          sizeof(double),
     247             :                                          NULL);
     248             : 
     249             :     TRACE_FLOW_NUMBER("col_insert_double_property returning", error);
     250          10 :     return error;
     251             : }
     252             : 
     253             : /* Insert bool property with positioning */
     254           8 : int col_insert_bool_property(struct collection_item *ci,
     255             :                              const char *subcollection,
     256             :                              int disposition,
     257             :                              const char *refprop,
     258             :                              int idx,
     259             :                              unsigned flags,
     260             :                              const char *property,
     261             :                              unsigned char logical)
     262             : {
     263           8 :     int error = EOK;
     264             : 
     265             :     TRACE_FLOW_STRING("col_insert_bool_property", "Entry.");
     266             : 
     267           8 :     error = col_insert_property_with_ref(ci,
     268             :                                          subcollection,
     269             :                                          disposition,
     270             :                                          refprop,
     271             :                                          idx,
     272             :                                          flags,
     273             :                                          property,
     274             :                                          COL_TYPE_BOOL,
     275             :                                          (void *)&logical,
     276             :                                          sizeof(unsigned char),
     277             :                                          NULL);
     278             : 
     279             :     TRACE_FLOW_NUMBER("col_insert_bool_property returning", error);
     280           8 :     return error;
     281             : }
     282             : 
     283             : 
     284             : /* Insert string property with positioning and reference. */
     285           0 : int col_insert_str_property_with_ref(struct collection_item *ci,
     286             :                                      const char *subcollection,
     287             :                                      int disposition,
     288             :                                      const char *refprop,
     289             :                                      int idx,
     290             :                                      unsigned flags,
     291             :                                      const char *property,
     292             :                                      const char *string,
     293             :                                      int length,
     294             :                                      struct collection_item **ret_ref)
     295             : {
     296           0 :     int error = EOK;
     297             :     void *ptr;
     298             : 
     299             :     TRACE_FLOW_STRING("col_insert_string_property_with_ref", "Entry.");
     300             : 
     301           0 :     if (length == 0) length = strlen(string) + 1;
     302             : 
     303             :     /* Work around a compilation warning */
     304           0 :     memcpy(&ptr, &string, sizeof(void *));
     305             : 
     306           0 :     error = col_insert_property_with_ref(ci,
     307             :                                          subcollection,
     308             :                                          disposition,
     309             :                                          refprop,
     310             :                                          idx,
     311             :                                          flags,
     312             :                                          property,
     313             :                                          COL_TYPE_STRING,
     314             :                                          ptr,
     315             :                                          length,
     316             :                                          ret_ref);
     317             : 
     318             :     TRACE_FLOW_NUMBER("col_insert_string_property_with_ref returning", error);
     319           0 :     return error;
     320             : }
     321             : 
     322             : /* Insert binary property with positioning and reference. */
     323           0 : int col_insert_binary_property_with_ref(struct collection_item *ci,
     324             :                                         const char *subcollection,
     325             :                                         int disposition,
     326             :                                         const char *refprop,
     327             :                                         int idx,
     328             :                                         unsigned flags,
     329             :                                         const char *property,
     330             :                                         void *binary_data,
     331             :                                         int length,
     332             :                                         struct collection_item **ret_ref)
     333             : {
     334           0 :     int error = EOK;
     335             : 
     336             :     TRACE_FLOW_STRING("col_insert_binary_property_with_ref", "Entry.");
     337             : 
     338           0 :     error = col_insert_property_with_ref(ci,
     339             :                                          subcollection,
     340             :                                          disposition,
     341             :                                          refprop,
     342             :                                          idx,
     343             :                                          flags,
     344             :                                          property,
     345             :                                          COL_TYPE_BINARY,
     346             :                                          (void *)binary_data,
     347             :                                          length,
     348             :                                          ret_ref);
     349             : 
     350             :     TRACE_FLOW_NUMBER("col_insert_binary_property_with_ref returning", error);
     351           0 :     return error;
     352             : }
     353             : 
     354             : /* Insert int property with positioning and reference. */
     355           0 : int col_insert_int_property_with_ref(struct collection_item *ci,
     356             :                                      const char *subcollection,
     357             :                                      int disposition,
     358             :                                      const char *refprop,
     359             :                                      int idx,
     360             :                                      unsigned flags,
     361             :                                      const char *property,
     362             :                                      int32_t number,
     363             :                                      struct collection_item **ret_ref)
     364             : {
     365           0 :     int error = EOK;
     366             : 
     367             :     TRACE_FLOW_STRING("col_insert_int_property_with_ref", "Entry.");
     368             : 
     369           0 :     error = col_insert_property_with_ref(ci,
     370             :                                          subcollection,
     371             :                                          disposition,
     372             :                                          refprop,
     373             :                                          idx,
     374             :                                          flags,
     375             :                                          property,
     376             :                                          COL_TYPE_INTEGER,
     377             :                                          (void *)&number,
     378             :                                          sizeof(int32_t),
     379             :                                          ret_ref);
     380             : 
     381             :     TRACE_FLOW_NUMBER("col_insert_int_property_with_ref returning", error);
     382           0 :     return error;
     383             : }
     384             : 
     385             : 
     386             : /* Insert unsigned property with positioning and reference. */
     387           0 : int col_insert_unsigned_property_with_ref(struct collection_item *ci,
     388             :                                           const char *subcollection,
     389             :                                           int disposition,
     390             :                                           const char *refprop,
     391             :                                           int idx,
     392             :                                           unsigned flags,
     393             :                                           const char *property,
     394             :                                           uint32_t number,
     395             :                                           struct collection_item **ret_ref)
     396             : {
     397           0 :     int error = EOK;
     398             : 
     399             :     TRACE_FLOW_STRING("col_insert_unsigned_property_with_ref", "Entry.");
     400             : 
     401           0 :     error = col_insert_property_with_ref(ci,
     402             :                                          subcollection,
     403             :                                          disposition,
     404             :                                          refprop,
     405             :                                          idx,
     406             :                                          flags,
     407             :                                          property,
     408             :                                          COL_TYPE_UNSIGNED,
     409             :                                          (void *)&number,
     410             :                                          sizeof(uint32_t),
     411             :                                          ret_ref);
     412             : 
     413             :     TRACE_FLOW_NUMBER("col_insert_unsigned_property_with_ref returning", error);
     414           0 :     return error;
     415             : }
     416             : 
     417             : /* Insert long property with positioning and reference. */
     418           0 : int col_insert_long_property_with_ref(struct collection_item *ci,
     419             :                                       const char *subcollection,
     420             :                                       int disposition,
     421             :                                       const char *refprop,
     422             :                                       int idx,
     423             :                                       unsigned flags,
     424             :                                       const char *property,
     425             :                                       int64_t number,
     426             :                                       struct collection_item **ret_ref)
     427             : {
     428           0 :     int error = EOK;
     429             : 
     430             :     TRACE_FLOW_STRING("col_insert_long_property_with_ref", "Entry.");
     431             : 
     432           0 :     error = col_insert_property_with_ref(ci,
     433             :                                          subcollection,
     434             :                                          disposition,
     435             :                                          refprop,
     436             :                                          idx,
     437             :                                          flags,
     438             :                                          property,
     439             :                                          COL_TYPE_LONG,
     440             :                                          (void *)&number,
     441             :                                          sizeof(int64_t),
     442             :                                          ret_ref);
     443             : 
     444             :     TRACE_FLOW_NUMBER("col_insert_long_property_with_ref returning", error);
     445           0 :     return error;
     446             : }
     447             : 
     448             : /* Insert unsigned long property with positioning and reference. */
     449           0 : int col_insert_ulong_property_with_ref(struct collection_item *ci,
     450             :                                        const char *subcollection,
     451             :                                        int disposition,
     452             :                                        const char *refprop,
     453             :                                        int idx,
     454             :                                        unsigned flags,
     455             :                                        const char *property,
     456             :                                        uint64_t number,
     457             :                                        struct collection_item **ret_ref)
     458             : {
     459           0 :     int error = EOK;
     460             : 
     461             :     TRACE_FLOW_STRING("col_insert_ulong_property_with_ref", "Entry.");
     462             : 
     463           0 :     error = col_insert_property_with_ref(ci,
     464             :                                          subcollection,
     465             :                                          disposition,
     466             :                                          refprop,
     467             :                                          idx,
     468             :                                          flags,
     469             :                                          property,
     470             :                                          COL_TYPE_ULONG,
     471             :                                          (void *)&number,
     472             :                                          sizeof(uint64_t),
     473             :                                          ret_ref);
     474             : 
     475             :     TRACE_FLOW_NUMBER("col_insert_ulong_property_with_ref returning", error);
     476           0 :     return error;
     477             : }
     478             : 
     479             : /* Insert double property with positioning and reference. */
     480           0 : int col_insert_double_property_with_ref(struct collection_item *ci,
     481             :                                         const char *subcollection,
     482             :                                         int disposition,
     483             :                                         const char *refprop,
     484             :                                         int idx,
     485             :                                         unsigned flags,
     486             :                                         const char *property,
     487             :                                         double number,
     488             :                                         struct collection_item **ret_ref)
     489             : {
     490           0 :     int error = EOK;
     491             : 
     492             :     TRACE_FLOW_STRING("col_insert_double_property_with_ref", "Entry.");
     493             : 
     494           0 :     error = col_insert_property_with_ref(ci,
     495             :                                          subcollection,
     496             :                                          disposition,
     497             :                                          refprop,
     498             :                                          idx,
     499             :                                          flags,
     500             :                                          property,
     501             :                                          COL_TYPE_DOUBLE,
     502             :                                          (void *)&number,
     503             :                                          sizeof(double),
     504             :                                          ret_ref);
     505             : 
     506             :     TRACE_FLOW_NUMBER("col_insert_double_property_with_ref returning", error);
     507           0 :     return error;
     508             : }
     509             : 
     510             : /* Insert bool property with positioning and reference. */
     511           0 : int col_insert_bool_property_with_ref(struct collection_item *ci,
     512             :                                       const char *subcollection,
     513             :                                       int disposition,
     514             :                                       const char *refprop,
     515             :                                       int idx,
     516             :                                       unsigned flags,
     517             :                                       const char *property,
     518             :                                       unsigned char logical,
     519             :                                       struct collection_item **ret_ref)
     520             : {
     521           0 :     int error = EOK;
     522             : 
     523             :     TRACE_FLOW_STRING("col_insert_bool_property_with_ref", "Entry.");
     524             : 
     525           0 :     error = col_insert_property_with_ref(ci,
     526             :                                          subcollection,
     527             :                                          disposition,
     528             :                                          refprop,
     529             :                                          idx,
     530             :                                          flags,
     531             :                                          property,
     532             :                                          COL_TYPE_BOOL,
     533             :                                          (void *)&logical,
     534             :                                          sizeof(unsigned char),
     535             :                                          ret_ref);
     536             : 
     537             :     TRACE_FLOW_NUMBER("col_insert_bool_property_with_ref returning", error);
     538           0 :     return error;
     539             : }
     540             : 
     541             : 
     542             : /* Add a string property. */
     543          72 : int col_add_str_property(struct collection_item *ci,
     544             :                          const char *subcollection,
     545             :                          const char *property,
     546             :                          const char *string,
     547             :                          int length)
     548             : {
     549          72 :     int error = EOK;
     550             : 
     551             :     TRACE_FLOW_STRING("col_add_str_property", "Entry.");
     552             : 
     553          72 :     error = col_insert_str_property(ci,
     554             :                                     subcollection,
     555             :                                     COL_DSP_END,
     556             :                                     NULL,
     557             :                                     0,
     558             :                                     0,
     559             :                                     property,
     560             :                                     string,
     561             :                                     length);
     562             : 
     563             :     TRACE_FLOW_NUMBER("col_add_str_property returning", error);
     564          72 :     return error;
     565             : }
     566             : 
     567             : /* Add a binary property. */
     568         194 : int col_add_binary_property(struct collection_item *ci,
     569             :                             const char *subcollection,
     570             :                             const char *property,
     571             :                             void *binary_data,
     572             :                             int length)
     573             : {
     574         194 :     int error = EOK;
     575             : 
     576             :     TRACE_FLOW_STRING("col_add_binary_property", "Entry.");
     577             : 
     578         194 :     error = col_insert_binary_property(ci,
     579             :                                        subcollection,
     580             :                                        COL_DSP_END,
     581             :                                        NULL,
     582             :                                        0,
     583             :                                        0,
     584             :                                        property,
     585             :                                        binary_data,
     586             :                                        length);
     587             : 
     588             :     TRACE_FLOW_NUMBER("col_add_binary_property returning", error);
     589         194 :     return error;
     590             : }
     591             : 
     592             : /* Add an int property. */
     593          27 : int col_add_int_property(struct collection_item *ci,
     594             :                          const char *subcollection,
     595             :                          const char *property,
     596             :                          int32_t number)
     597             : {
     598          27 :     int error = EOK;
     599             : 
     600             :     TRACE_FLOW_STRING("col_add_int_property", "Entry.");
     601             : 
     602          27 :     error = col_insert_int_property(ci,
     603             :                                     subcollection,
     604             :                                     COL_DSP_END,
     605             :                                     NULL,
     606             :                                     0,
     607             :                                     0,
     608             :                                     property,
     609             :                                     number);
     610             : 
     611             :     TRACE_FLOW_NUMBER("col_add_int_property returning", error);
     612          27 :     return error;
     613             : }
     614             : 
     615             : /* Add an unsigned int property. */
     616      496482 : int col_add_unsigned_property(struct collection_item *ci,
     617             :                               const char *subcollection,
     618             :                               const char *property,
     619             :                               uint32_t number)
     620             : {
     621      496482 :     int error = EOK;
     622             : 
     623             :     TRACE_FLOW_STRING("col_add_unsigned_property", "Entry.");
     624             : 
     625      496482 :     error = col_insert_unsigned_property(ci,
     626             :                                          subcollection,
     627             :                                          COL_DSP_END,
     628             :                                          NULL,
     629             :                                          0,
     630             :                                          0,
     631             :                                          property,
     632             :                                          number);
     633             : 
     634             :     TRACE_FLOW_NUMBER("col_add_unsigned_property returning", error);
     635      496482 :     return error;
     636             : }
     637             : 
     638             : /* Add an long property. */
     639          14 : int col_add_long_property(struct collection_item *ci,
     640             :                           const char *subcollection,
     641             :                           const char *property,
     642             :                           int64_t number)
     643             : {
     644          14 :     int error = EOK;
     645             : 
     646             :     TRACE_FLOW_STRING("col_add_long_property", "Entry.");
     647             : 
     648             : 
     649          14 :     error = col_insert_long_property(ci,
     650             :                                      subcollection,
     651             :                                      COL_DSP_END,
     652             :                                      NULL,
     653             :                                      0,
     654             :                                      0,
     655             :                                      property,
     656             :                                      number);
     657             : 
     658             :     TRACE_FLOW_NUMBER("col_add_long_property returning", error);
     659          14 :     return error;
     660             : }
     661             : 
     662             : /* Add an unsigned long property. */
     663           8 : int col_add_ulong_property(struct collection_item *ci,
     664             :                            const char *subcollection,
     665             :                            const char *property,
     666             :                            uint64_t number)
     667             : {
     668           8 :     int error = EOK;
     669             : 
     670             :     TRACE_FLOW_STRING("col_add_ulong_property", "Entry.");
     671             : 
     672           8 :     error = col_insert_ulong_property(ci,
     673             :                                       subcollection,
     674             :                                       COL_DSP_END,
     675             :                                       NULL,
     676             :                                       0,
     677             :                                       0,
     678             :                                       property,
     679             :                                       number);
     680             : 
     681             :     TRACE_FLOW_NUMBER("col_add_ulong_property returning", error);
     682           8 :     return error;
     683             : }
     684             : 
     685             : /* Add a double property. */
     686          10 : int col_add_double_property(struct collection_item *ci,
     687             :                             const char *subcollection,
     688             :                             const char *property,
     689             :                             double number)
     690             : {
     691          10 :     int error = EOK;
     692             : 
     693             :     TRACE_FLOW_STRING("col_add_double_property", "Entry.");
     694             : 
     695          10 :     error = col_insert_double_property(ci,
     696             :                                        subcollection,
     697             :                                        COL_DSP_END,
     698             :                                        NULL,
     699             :                                        0,
     700             :                                        0,
     701             :                                        property,
     702             :                                        number);
     703             : 
     704             :     TRACE_FLOW_NUMBER("col_add_double_property returning", error);
     705          10 :     return error;
     706             : }
     707             : 
     708             : /* Add a bool property. */
     709           8 : int col_add_bool_property(struct collection_item *ci,
     710             :                           const char *subcollection,
     711             :                           const char *property,
     712             :                           unsigned char logical)
     713             : {
     714           8 :     int error = EOK;
     715             : 
     716             :     TRACE_FLOW_STRING("col_add_bool_property", "Entry.");
     717             : 
     718           8 :     error = col_insert_bool_property(ci,
     719             :                                      subcollection,
     720             :                                      COL_DSP_END,
     721             :                                      NULL,
     722             :                                      0,
     723             :                                      0,
     724             :                                      property,
     725             :                                      logical);
     726             : 
     727             :     TRACE_FLOW_NUMBER("col_add_bool_property returning", error);
     728           8 :     return error;
     729             : }
     730             : 
     731             : /* A function to add a property */
     732           0 : int col_add_any_property(struct collection_item *ci,
     733             :                          const char *subcollection,
     734             :                          const char *property,
     735             :                          int type,
     736             :                          void *data,
     737             :                          int length)
     738             : {
     739           0 :     int error = EOK;
     740             : 
     741             :     TRACE_FLOW_STRING("col_add_any_property", "Entry.");
     742             : 
     743           0 :     error = col_insert_property_with_ref(ci,
     744             :                                          subcollection,
     745             :                                          COL_DSP_END,
     746             :                                          NULL,
     747             :                                          0,
     748             :                                          0,
     749             :                                          property,
     750             :                                          type,
     751             :                                          data,
     752             :                                          length,
     753             :                                          NULL);
     754             : 
     755             :     TRACE_FLOW_NUMBER("col_add_any_property returning", error);
     756           0 :     return error;
     757             : }
     758             : 
     759             : /* Add a string property with reference */
     760           0 : int col_add_str_property_with_ref(struct collection_item *ci,
     761             :                                   const char *subcollection,
     762             :                                   const char *property,
     763             :                                   char *string, int length,
     764             :                                   struct collection_item **ref_ret)
     765             : {
     766           0 :     int error = EOK;
     767             : 
     768             :     TRACE_FLOW_STRING("col_add_str_property_with_ref", "Entry.");
     769             : 
     770           0 :     error = col_insert_str_property_with_ref(ci,
     771             :                                              subcollection,
     772             :                                              COL_DSP_END,
     773             :                                              NULL,
     774             :                                              0,
     775             :                                              0,
     776             :                                              property,
     777             :                                              string,
     778             :                                              length,
     779             :                                              ref_ret);
     780             : 
     781             :     TRACE_FLOW_NUMBER("col_add_str_property_with_ref returning", error);
     782           0 :     return error;
     783             : }
     784             : 
     785             : /* Add a binary property with reference. */
     786           0 : int col_add_binary_property_with_ref(struct collection_item *ci,
     787             :                                      const char *subcollection,
     788             :                                      const char *property,
     789             :                                      void *binary_data, int length,
     790             :                                      struct collection_item **ref_ret)
     791             : {
     792           0 :     int error = EOK;
     793             : 
     794             :     TRACE_FLOW_STRING("col_add_binary_property_with_ref", "Entry.");
     795             : 
     796           0 :     error = col_insert_binary_property_with_ref(ci,
     797             :                                                 subcollection,
     798             :                                                 COL_DSP_END,
     799             :                                                 NULL,
     800             :                                                 0,
     801             :                                                 0,
     802             :                                                 property,
     803             :                                                 binary_data,
     804             :                                                 length,
     805             :                                                 ref_ret);
     806             : 
     807             :     TRACE_FLOW_NUMBER("col_add_binary_property_with_ref returning", error);
     808           0 :     return error;
     809             : }
     810             : 
     811             : /* Add an int property with reference. */
     812           0 : int col_add_int_property_with_ref(struct collection_item *ci,
     813             :                                   const char *subcollection,
     814             :                                   const char *property,
     815             :                                   int32_t number,
     816             :                                   struct collection_item **ref_ret)
     817             : {
     818           0 :     int error = EOK;
     819             : 
     820             :     TRACE_FLOW_STRING("col_add_int_property_with_ref", "Entry.");
     821             : 
     822           0 :     error = col_insert_int_property_with_ref(ci,
     823             :                                              subcollection,
     824             :                                              COL_DSP_END,
     825             :                                              NULL,
     826             :                                              0,
     827             :                                              0,
     828             :                                              property,
     829             :                                              number,
     830             :                                              ref_ret);
     831             : 
     832             :     TRACE_FLOW_NUMBER("col_add_int_property_with_ref returning", error);
     833           0 :     return error;
     834             : }
     835             : 
     836             : /* Add an unsigned int property with reference.  */
     837           0 : int col_add_unsigned_property_with_ref(struct collection_item *ci,
     838             :                                        const char *subcollection,
     839             :                                        const char *property,
     840             :                                        uint32_t number,
     841             :                                        struct collection_item **ref_ret)
     842             : {
     843           0 :     int error = EOK;
     844             : 
     845             :     TRACE_FLOW_STRING("col_add_unsigned_property_with_ref", "Entry.");
     846             : 
     847           0 :     error = col_insert_unsigned_property_with_ref(ci,
     848             :                                                   subcollection,
     849             :                                                   COL_DSP_END,
     850             :                                                   NULL,
     851             :                                                   0,
     852             :                                                   0,
     853             :                                                   property,
     854             :                                                   number,
     855             :                                                   ref_ret);
     856             : 
     857             :     TRACE_FLOW_NUMBER("col_add_unsigned_property_with_ref returning", error);
     858           0 :     return error;
     859             : }
     860             : 
     861             : /* Add an long property with reference. */
     862           0 : int col_add_long_property_with_ref(struct collection_item *ci,
     863             :                                    const char *subcollection,
     864             :                                    const char *property,
     865             :                                    int64_t number,
     866             :                                    struct collection_item **ref_ret)
     867             : {
     868           0 :     int error = EOK;
     869             : 
     870             :     TRACE_FLOW_STRING("col_add_long_property_with_ref", "Entry.");
     871             : 
     872           0 :     error = col_insert_long_property_with_ref(ci,
     873             :                                               subcollection,
     874             :                                               COL_DSP_END,
     875             :                                               NULL,
     876             :                                               0,
     877             :                                               0,
     878             :                                               property,
     879             :                                               number,
     880             :                                               ref_ret);
     881             : 
     882             :     TRACE_FLOW_NUMBER("col_add_long_property_with_ref returning", error);
     883           0 :     return error;
     884             : }
     885             : 
     886             : /* Add an unsigned long property with reference. */
     887           0 : int col_add_ulong_property_with_ref(struct collection_item *ci,
     888             :                                     const char *subcollection,
     889             :                                     const char *property,
     890             :                                     uint64_t number,
     891             :                                     struct collection_item **ref_ret)
     892             : {
     893           0 :     int error = EOK;
     894             : 
     895             :     TRACE_FLOW_STRING("col_add_ulong_property_with_ref", "Entry.");
     896             : 
     897           0 :     error = col_insert_ulong_property_with_ref(ci,
     898             :                                                subcollection,
     899             :                                                COL_DSP_END,
     900             :                                                NULL,
     901             :                                                0,
     902             :                                                0,
     903             :                                                property,
     904             :                                                number,
     905             :                                                ref_ret);
     906             : 
     907             :     TRACE_FLOW_NUMBER("col_add_ulong_property_with_ref returning", error);
     908           0 :     return error;
     909             : }
     910             : 
     911             : /* Add a double property with reference. */
     912           0 : int col_add_double_property_with_ref(struct collection_item *ci,
     913             :                                      const char *subcollection,
     914             :                                      const char *property,
     915             :                                      double number,
     916             :                                      struct collection_item **ref_ret)
     917             : {
     918           0 :     int error = EOK;
     919             : 
     920             :     TRACE_FLOW_STRING("col_add_double_property_with_ref", "Entry.");
     921             : 
     922           0 :     error = col_insert_double_property_with_ref(ci,
     923             :                                                 subcollection,
     924             :                                                 COL_DSP_END,
     925             :                                                 NULL,
     926             :                                                 0,
     927             :                                                 0,
     928             :                                                 property,
     929             :                                                 number,
     930             :                                                 ref_ret);
     931             : 
     932             :     TRACE_FLOW_NUMBER("col_add_double_property_with_ref returning", error);
     933           0 :     return error;
     934             : }
     935             : 
     936             : /* Add a bool property with reference. */
     937           0 : int col_add_bool_property_with_ref(struct collection_item *ci,
     938             :                                    const char *subcollection,
     939             :                                    const char *property,
     940             :                                    unsigned char logical,
     941             :                                    struct collection_item **ref_ret)
     942             : {
     943           0 :     int error = EOK;
     944             : 
     945             :     TRACE_FLOW_STRING("col_add_bool_property_with_ref", "Entry.");
     946             : 
     947           0 :     error = col_insert_bool_property_with_ref(ci,
     948             :                                               subcollection,
     949             :                                               COL_DSP_END,
     950             :                                               NULL,
     951             :                                               0,
     952             :                                               0,
     953             :                                               property,
     954             :                                               logical,
     955             :                                               ref_ret);
     956             : 
     957             :     TRACE_FLOW_NUMBER("col_add_bool_property_with_ref returning", error);
     958           0 :     return error;
     959             : }
     960             : 
     961             : /* A function to add a property with reference. */
     962           0 : int col_add_any_property_with_ref(struct collection_item *ci,
     963             :                                   const char *subcollection,
     964             :                                   const char *property,
     965             :                                   int type,
     966             :                                   void *data,
     967             :                                   int length,
     968             :                                   struct collection_item **ref_ret)
     969             : {
     970           0 :     int error = EOK;
     971             : 
     972             :     TRACE_FLOW_STRING("col_add_any_property_with_ref", "Entry.");
     973             : 
     974           0 :     error = col_insert_property_with_ref(ci,
     975             :                                          subcollection,
     976             :                                          COL_DSP_END,
     977             :                                          NULL,
     978             :                                          0,
     979             :                                          0,
     980             :                                          property,
     981             :                                          type,
     982             :                                          data,
     983             :                                          length,
     984             :                                          ref_ret);
     985             : 
     986             :     TRACE_FLOW_NUMBER("col_add_any_property_with_ref returning", error);
     987           0 :     return error;
     988             : }
     989             : 
     990             : 
     991             : /* Update a string property in the collection.
     992             :  * Length should include the terminating 0  */
     993           0 : int col_update_str_property(struct collection_item *ci,
     994             :                             const char *property,
     995             :                             int mode_flags,
     996             :                             char *string,
     997             :                             int length)
     998             : {
     999           0 :     int error = EOK;
    1000             :     TRACE_FLOW_STRING("col_update_str_property", "Entry.");
    1001             : 
    1002           0 :     if (length == 0) length = strlen(string) + 1;
    1003           0 :     error = col_update_property(ci, property, COL_TYPE_STRING,
    1004             :                                 (void *)string, length, mode_flags);
    1005             : 
    1006             :     TRACE_FLOW_NUMBER("col_update_str_property Returning", error);
    1007           0 :     return error;
    1008             : }
    1009             : 
    1010             : /* Update a binary property in the collection.  */
    1011           0 : int col_update_binary_property(struct collection_item *ci,
    1012             :                                const char *property,
    1013             :                                int mode_flags,
    1014             :                                void *binary_data,
    1015             :                                int length)
    1016             : {
    1017           0 :     int error = EOK;
    1018             :     TRACE_FLOW_STRING("col_update_binary_property", "Entry.");
    1019             : 
    1020           0 :     error = col_update_property(ci, property, COL_TYPE_BINARY,
    1021             :                                 binary_data, length, mode_flags);
    1022             : 
    1023             :     TRACE_FLOW_NUMBER("col_update_binary_property Returning", error);
    1024           0 :     return error;
    1025             : }
    1026             : 
    1027             : /* Update an int property in the collection. */
    1028           0 : int col_update_int_property(struct collection_item *ci,
    1029             :                             const char *property,
    1030             :                             int mode_flags,
    1031             :                             int32_t number)
    1032             : {
    1033           0 :     int error = EOK;
    1034             :     TRACE_FLOW_STRING("col_update_int_property", "Entry.");
    1035             : 
    1036           0 :     error = col_update_property(ci, property, COL_TYPE_INTEGER,
    1037             :                                 (void *)(&number), sizeof(int32_t), mode_flags);
    1038             : 
    1039             :     TRACE_FLOW_NUMBER("col_update_int_property Returning", error);
    1040           0 :     return error;
    1041             : }
    1042             : 
    1043             : /* Update an unsigned int property. */
    1044           0 : int col_update_unsigned_property(struct collection_item *ci,
    1045             :                                  const char *property,
    1046             :                                  int mode_flags,
    1047             :                                  uint32_t number)
    1048             : {
    1049           0 :     int error = EOK;
    1050             :     TRACE_FLOW_STRING("col_update_unsigned_property", "Entry.");
    1051             : 
    1052           0 :     error = col_update_property(ci, property, COL_TYPE_UNSIGNED,
    1053             :                                 (void *)(&number), sizeof(uint32_t),
    1054             :                                 mode_flags);
    1055             : 
    1056             :     TRACE_FLOW_NUMBER("col_update_unsigned_property Returning", error);
    1057           0 :     return error;
    1058             : }
    1059             : 
    1060             : /* Update a long property. */
    1061           0 : int col_update_long_property(struct collection_item *ci,
    1062             :                              const char *property,
    1063             :                              int mode_flags,
    1064             :                              int64_t number)
    1065             : {
    1066           0 :     int error = EOK;
    1067             :     TRACE_FLOW_STRING("col_update_long_property", "Entry.");
    1068             : 
    1069           0 :     error = col_update_property(ci, property, COL_TYPE_LONG,
    1070             :                                 (void *)(&number), sizeof(int64_t),
    1071             :                                 mode_flags);
    1072             : 
    1073             :     TRACE_FLOW_NUMBER("col_update_long_property Returning", error);
    1074           0 :     return error;
    1075             : 
    1076             : }
    1077             : 
    1078             : /* Update an unsigned long property. */
    1079           0 : int col_update_ulong_property(struct collection_item *ci,
    1080             :                               const char *property,
    1081             :                               int mode_flags,
    1082             :                               uint64_t number)
    1083             : {
    1084           0 :     int error = EOK;
    1085             :     TRACE_FLOW_STRING("col_update_ulong_property", "Entry.");
    1086             : 
    1087           0 :     error = col_update_property(ci, property, COL_TYPE_ULONG,
    1088             :                                 (void *)(&number), sizeof(uint64_t),
    1089             :                                 mode_flags);
    1090             : 
    1091             :     TRACE_FLOW_NUMBER("col_update_ulong_property Returning", error);
    1092           0 :     return error;
    1093             : }
    1094             : 
    1095             : /* Update a double property. */
    1096           1 : int col_update_double_property(struct collection_item *ci,
    1097             :                                const char *property,
    1098             :                                int mode_flags,
    1099             :                                double number)
    1100             : {
    1101           1 :     int error = EOK;
    1102             :     TRACE_FLOW_STRING("col_update_double_property", "Entry.");
    1103             : 
    1104           1 :     error = col_update_property(ci, property, COL_TYPE_DOUBLE,
    1105             :                                 (void *)(&number), sizeof(double),
    1106             :                                 mode_flags);
    1107             : 
    1108             :     TRACE_FLOW_NUMBER("col_update_double_property Returning", error);
    1109           1 :     return error;
    1110             : }
    1111             : 
    1112             : /* Update a bool property. */
    1113           0 : int col_update_bool_property(struct collection_item *ci,
    1114             :                              const char *property,
    1115             :                              int mode_flags,
    1116             :                              unsigned char logical)
    1117             : {
    1118           0 :     int error = EOK;
    1119             :     TRACE_FLOW_STRING("col_update_bool_property", "Entry.");
    1120             : 
    1121           0 :     error = col_update_property(ci, property, COL_TYPE_BOOL,
    1122             :                              (void *)(&logical), sizeof(unsigned char),
    1123             :                              mode_flags);
    1124             : 
    1125             :     TRACE_FLOW_NUMBER("col_update_bool_property Returning", error);
    1126           0 :     return error;
    1127             : }
    1128             : 
    1129             : /* Rename item */
    1130           2 : int col_modify_item_property(struct collection_item *item,
    1131             :                              const char *property)
    1132             : {
    1133             :     int error;
    1134             : 
    1135             :     TRACE_FLOW_STRING("col_modify_item_property", "Entry");
    1136             : 
    1137           2 :     error = col_modify_item(item, property, 0, NULL, 0);
    1138             : 
    1139             :     TRACE_FLOW_STRING("col_modify_item_property", "Exit");
    1140           2 :     return error;
    1141             : }
    1142             : 
    1143             : /* Convenience functions that wrap modify_item(). */
    1144             : /* Modify item data to be str */
    1145           4 : int col_modify_str_item(struct collection_item *item,
    1146             :                         const char *property,
    1147             :                         const char *string,
    1148             :                         int length)
    1149             : {
    1150             :     int len;
    1151             :     int error;
    1152             : 
    1153             :     TRACE_FLOW_STRING("col_modify_str_item", "Entry");
    1154             : 
    1155           4 :     if (length != 0) len = length;
    1156           2 :     else len = strlen(string) + 1;
    1157             : 
    1158           4 :     error = col_modify_item(item, property,
    1159             :                             COL_TYPE_STRING, (const void *)string, len);
    1160             : 
    1161             :     TRACE_FLOW_STRING("col_modify_str_item", "Exit");
    1162           4 :     return error;
    1163             : }
    1164             : 
    1165             : /* Modify item data to be binary */
    1166       66616 : int col_modify_binary_item(struct collection_item *item,
    1167             :                            const char *property,
    1168             :                            void *binary_data,
    1169             :                            int length)
    1170             : {
    1171             :     int error;
    1172             : 
    1173             :     TRACE_FLOW_STRING("col_modify_binary_item", "Entry");
    1174             : 
    1175       66616 :     error = col_modify_item(item, property, COL_TYPE_BINARY, binary_data, length);
    1176             : 
    1177             :     TRACE_FLOW_STRING("col_modify_binary_item", "Exit");
    1178       66616 :     return error;
    1179             : }
    1180             : 
    1181             : /* Modify item data to be bool */
    1182           2 : int col_modify_bool_item(struct collection_item *item,
    1183             :                          const char *property,
    1184             :                          unsigned char logical)
    1185             : {
    1186             :     int error;
    1187             : 
    1188             :     TRACE_FLOW_STRING("col_modify_bool_item", "Entry");
    1189             : 
    1190           2 :     error = col_modify_item(item, property, COL_TYPE_BOOL, (void *)(&logical), 1);
    1191             : 
    1192             :     TRACE_FLOW_STRING("col_modify_bool_item", "Exit");
    1193           2 :     return error;
    1194             : }
    1195             : 
    1196             : /* Modify item data to be int */
    1197           2 : int col_modify_int_item(struct collection_item *item,
    1198             :                         const char *property,
    1199             :                         int32_t number)
    1200             : {
    1201             :     int error;
    1202             : 
    1203             :     TRACE_FLOW_STRING("col_modify_int_item","Entry");
    1204             : 
    1205           2 :     error = col_modify_item(item, property, COL_TYPE_INTEGER,
    1206             :                             (void *)(&number), sizeof(int32_t));
    1207             : 
    1208             :     TRACE_FLOW_STRING("col_modify_int_item", "Exit");
    1209           2 :     return error;
    1210             : }
    1211             : 
    1212             : /* Modify item data to be long */
    1213           2 : int col_modify_long_item(struct collection_item *item,
    1214             :                          const char *property,
    1215             :                          int64_t number)
    1216             : {
    1217             :     int error;
    1218             : 
    1219             :     TRACE_FLOW_STRING("col_modify_long_item", "Entry");
    1220             : 
    1221           2 :     error = col_modify_item(item, property, COL_TYPE_LONG,
    1222             :                             (void *)(&number), sizeof(int64_t));
    1223             : 
    1224             :     TRACE_FLOW_STRING("col_modify_long_item", "Exit");
    1225           2 :     return error;
    1226             : }
    1227             : 
    1228             : /* Modify item data to be unigned long */
    1229           2 : int col_modify_ulong_item(struct collection_item *item,
    1230             :                           const char *property,
    1231             :                           uint64_t number)
    1232             : {
    1233             :     int error;
    1234             : 
    1235             :     TRACE_FLOW_STRING("col_modify_ulong_item", "Entry");
    1236             : 
    1237           2 :     error = col_modify_item(item, property, COL_TYPE_ULONG,
    1238             :                             (void *)(&number), sizeof(uint64_t));
    1239             : 
    1240             :     TRACE_FLOW_STRING("col_modify_ulong_item", "Exit");
    1241           2 :     return error;
    1242             : }
    1243             : 
    1244           2 : int col_modify_unsigned_item(struct collection_item *item,
    1245             :                              const char *property,
    1246             :                              uint32_t number)
    1247             : {
    1248             :     int error;
    1249             : 
    1250             :     TRACE_FLOW_STRING("col_modify_unsigned_item", "Entry");
    1251             : 
    1252           2 :     error = col_modify_item(item, property, COL_TYPE_UNSIGNED,
    1253             :                             (void *)(&number), sizeof(uint32_t));
    1254             : 
    1255             :     TRACE_FLOW_STRING("col_modify_unsigned_item", "Exit");
    1256           2 :     return error;
    1257             : }
    1258             : 
    1259           2 : int col_modify_double_item(struct collection_item *item,
    1260             :                            const char *property,
    1261             :                            double number)
    1262             : {
    1263             :     int error;
    1264             : 
    1265             :     TRACE_FLOW_STRING("col_modify_double_item", "Entry");
    1266             : 
    1267           2 :     error = col_modify_item(item, property, COL_TYPE_DOUBLE,
    1268             :                             (void *)(&number), sizeof(double));
    1269             : 
    1270             :     TRACE_FLOW_STRING("col_modify_double_item", "Exit");
    1271           2 :     return error;
    1272             : }

Generated by: LCOV version 1.10