2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
20 * @brief This is part of C api for ValidationCore.
22 #ifndef _CERTSVC_CSTRING_H_
23 #define _CERTSVC_CSTRING_H_
25 #include <cert-svc/cinstance.h>
26 #include <cert-svc/cstring.h>
33 typedef struct CertSvcStringList_t {
34 size_t privateHandler;
35 CertSvcInstance privateInstance;
38 typedef struct CertSvcString_t {
40 * You are not allowed to use private fields of this structure. It is internal
41 * implementation of strings and it may change at any time without notice!
42 * To extract data use certsvc_string_to_cstring function!
46 CertSvcInstance privateInstance;
50 * This function will duplicate input data. Data in ouput string will be managed by certsvc.
52 * @param[in] instance CertSvcString will be conected with this instance.
53 * @param[in] input Input data.
54 * @param[in] size Input buffer size.
55 * @param[out] output Buffer with output data.
56 * @return CERTSVC_SUCCESS, CERTSVC_FAIL, CERTSVC_WRONG_ARGUMENT
58 int certsvc_string_new(
59 CertSvcInstance instance,
62 CertSvcString *output);
65 * This function wont duplicate input data. Output param will contain pointer to input
66 * so input could not be free as long as ouput param is used.
68 * @param[in] instance CertSvcString will be conected with this instance.
69 * @param[in] input Input data.
70 * @param[in] size Input buffer size.
71 * @param[out] output Buffer with output data.
72 * @return CERTSVC_SUCCESS, CERTSVC_WRONG_ARGUMENT
74 int certsvc_string_not_managed(
75 CertSvcInstance instance,
78 CertSvcString *output);
81 * Extract next result from result set. Function certsvc_string_list_free
82 * does not free results returned by this function. CertSvcString is valid
83 * until certsvc_string_free or vcore_instance_reset or vcore_instance_free
86 * @param[in] handler Handler to set of strings.
87 * @param[out] buffer The buffer will be pointing to string with distrubution point url or will be set to NULL if error occures.
88 * @param[out] size Size of data pointed by buffer or 0 if error occures.
89 * @return CERTSVC_SUCCESS, CERTSVC_FAIL, CERTSVC_WRONG_ARGUMENT, CERTSVC_BAD_ALLOC
91 int certsvc_string_list_get_one(CertSvcStringList hander,
93 CertSvcString *buffer);
96 * Extract CertSvcStringList size.
98 * @param[in] handler Handler to string list.
99 * @param[out] size Number of elements on the list.
100 * @return CERTSVC_SUCCESS, CERTSVC_WRONG_ARGUMENT
102 int certsvc_string_list_get_length(CertSvcStringList hander, size_t *size);
107 * @param[in] string Data allocated by certsvc_certificate_get_string_field
109 void certsvc_string_free(CertSvcString string);
114 * Note: This function does not free strings returned by certsvc_string_list_get_one_result.
116 * @param[in] handler String set handler.
118 void certsvc_string_list_free(CertSvcStringList handler);
121 * Convert CertSvcStringPtr into pure c pointer. Please note that this pointer is valid as long as CertSvcString is valid.
123 * @param[in] string CertSvcStringPtr.
124 * @param[out] buffer cstring
125 * @param[out] len Length of cstring
127 void certsvc_string_to_cstring(CertSvcString string, const char **buffer, size_t *len);