1 /* 2 * Copyright (C) 2020-2021 Bareos GmbH & Co. KG 3 * Copyright (C) 2010 SCALITY SA. All rights reserved. 4 * http://www.scality.com 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * 13 * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY SCALITY SA ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL SCALITY SA OR CONTRIBUTORS BE LIABLE FOR 21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 26 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 * POSSIBILITY OF SUCH DAMAGE. 28 * 29 * The views and conclusions contained in the software and documentation 30 * are those of the authors and should not be interpreted as representing 31 * official policies, either expressed or implied, of SCALITY SA. 32 * 33 * https://github.com/scality/Droplet 34 */ 35 #ifndef BAREOS_DROPLET_LIBDROPLET_INCLUDE_DROPLET_CDMI_OBJECT_ID_H_ 36 #define BAREOS_DROPLET_LIBDROPLET_INCLUDE_DROPLET_CDMI_OBJECT_ID_H_ 37 38 typedef struct { 39 uint32_t enterprise_number; 40 unsigned char reserved; 41 unsigned char length; 42 uint16_t crc; 43 char opaque[32]; 44 } dpl_cdmi_object_id_t; 45 46 #define DPL_CDMI_OBJECT_ID_LEN (sizeof(dpl_cdmi_object_id_t) * 2 + 1) 47 48 dpl_status_t dpl_cdmi_object_id_init(dpl_cdmi_object_id_t* object_id, 49 uint32_t enterprise_number, 50 const void* opaque_data, 51 char opaque_len); 52 dpl_status_t dpl_cdmi_object_id_to_string(const dpl_cdmi_object_id_t* object_id, 53 char* output); 54 dpl_status_t dpl_cdmi_opaque_to_string(const dpl_cdmi_object_id_t* object_id, 55 char* output); 56 dpl_status_t dpl_cdmi_string_to_object_id(const char* input, 57 dpl_cdmi_object_id_t* output); 58 dpl_status_t dpl_cdmi_string_to_opaque(const char* input, 59 char* output, 60 int* opaque_lenp); 61 void dpl_cdmi_object_id_undef(dpl_cdmi_object_id_t* object_id); 62 int dpl_cdmi_object_id_is_def(const dpl_cdmi_object_id_t* object_id); 63 dpl_status_t dpl_cdmi_object_id_opaque_len( 64 const dpl_cdmi_object_id_t* object_id, 65 size_t* lenp); 66 67 #endif // BAREOS_DROPLET_LIBDROPLET_INCLUDE_DROPLET_CDMI_OBJECT_ID_H_ 68