1 /*
2 * Copyright 1999-2006 University of Chicago
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 #include "globus_soap_message.h"
18 #include "xsd_string.h"
19
20 /**
21 * Initialize a xsd_string from a NULL-terminated character array.
22 * @ingroup xsd_string
23 *
24 * Allocates a new xsd_string and sets it's value to be @a str. The
25 * @a ip parameter will point to the new xsd_string when this function
26 * returns successfully.
27 *
28 * @param ip
29 * Pointer to hold the newly allocated xsd_string value.
30 * @param str
31 * Pointer to a character array allocated on the heap. The caller must
32 * not free this value after this function is called. It will be freed
33 * when the xsd_string pointed to by @a ip is destroyed.
34 *
35 * @retval GLOBUS_SUCCESS
36 * Success.
37 * @retval GLOBUS_SOAP_MESSAGE_ERROR_TYPE_NULL_PARAM
38 * Null parameter.
39 * @retval GLOBUS_SOAP_MESSAGE_ERROR_TYPE_OUT_OF_MEMORY
40 * Out of memory.
41 */
42 globus_result_t
43 xsd_string_init_cstr(
44 xsd_string ** ip,
45 char * str)
46 456 {
47 456 globus_result_t result = GLOBUS_SUCCESS;
48 GlobusFuncName(xsd_string_init_cstr);
49 456 GlobusSoapMessageDebugEnter();
50
51 456 result = xsd_string_init(ip);
52 456 if(result == GLOBUS_SUCCESS)
53 {
54 456 **ip = str;
55 }
56
57 456 GlobusSoapMessageDebugExit();
58 456 return result;
59 }
60 /* xsd_string_init_cstr() */
61
62 /**
63 * Initialize the contents of xsd_string from a NULL-terminated character array.
64 * @ingroup xsd_string
65 *
66 * Initializes an already allocated xsd_string and sets it's value to be
67 * @a str.
68 *
69 * @param instance
70 * Allocated but uninitialized xsd_string value.
71 * @param str
72 * Pointer to a character array allocated on the heap. The caller must
73 * not free this value after this function is called. It will be freed
74 * when @a instance is destroyed by calling
75 * xsd_string_destroy_contents().
76 *
77 * @retval GLOBUS_SUCCESS
78 * Success.
79 * @retval GLOBUS_SOAP_MESSAGE_ERROR_TYPE_NULL_PARAM
80 * Null parameter.
81 * @retval GLOBUS_SOAP_MESSAGE_ERROR_TYPE_OUT_OF_MEMORY
82 * Out of memory.
83 */
84 globus_result_t
85 xsd_string_init_contents_cstr(
86 xsd_string * instance,
87 char * str)
88 1960 {
89 1960 globus_result_t result = GLOBUS_SUCCESS;
90 GlobusFuncName(xsd_string_init_contents_cstr);
91 1960 GlobusSoapMessageDebugEnter();
92
93 1960 *instance = str;
94
95 1960 GlobusSoapMessageDebugExit();
96 1960 return result;
97 }
98 /* xsd_string_init_contents_cstr() */
99
100
101 /**
102 * Initialize a xsd_string with a copy of a NULL-terminated character array.
103 * @ingroup xsd_string
104 *
105 * Allocates a new xsd_string and sets it's value to be a newly allocated
106 * copy of @a str. The @a ip parameter will point to the new xsd_string
107 * when this function returns successfully.
108 *
109 * @param ip
110 * Pointer to hold the newly allocated xsd_string value.
111 * @param str
112 * Pointer to a character array. The caller is responsible for freeing this
113 * if it was allocated on the heap.
114 *
115 * @retval GLOBUS_SUCCESS
116 * Success.
117 * @retval GLOBUS_SOAP_MESSAGE_ERROR_TYPE_NULL_PARAM
118 * Null parameter.
119 * @retval GLOBUS_SOAP_MESSAGE_ERROR_TYPE_OUT_OF_MEMORY
120 * Out of memory.
121 */
122 globus_result_t
123 xsd_string_copy_cstr(
124 xsd_string ** ip,
125 const char * str)
126 0 {
127 0 globus_result_t result = GLOBUS_SUCCESS;
128 GlobusFuncName(xsd_string_copy_cstr);
129 0 GlobusSoapMessageDebugEnter();
130
131 0 result = xsd_string_copy(ip, (const xsd_string *) &str);
132
133 0 GlobusSoapMessageDebugExit();
134 0 return result;
135 }
136 /* xsd_string_copy_cstr() */
137
138 /**
139 * Initialize a xsd_string with a copy of a NULL-terminated character array.
140 * @ingroup xsd_string
141 *
142 * Initializes a xsd_string and sets it's value to be a newly allocated
143 * copy of @a str.
144 *
145 * @param instance
146 * Pointer to the xsd_string.
147 * @param str
148 * Pointer to a character array. The caller is responsible for freeing this
149 * if it was allocated on the heap.
150 *
151 * @retval GLOBUS_SUCCESS
152 * Success.
153 * @retval GLOBUS_SOAP_MESSAGE_ERROR_TYPE_NULL_PARAM
154 * Null parameter.
155 * @retval GLOBUS_SOAP_MESSAGE_ERROR_TYPE_OUT_OF_MEMORY
156 * Out of memory.
157 */
158 globus_result_t
159 xsd_string_copy_contents_cstr(
160 xsd_string * instance,
161 const char * str)
162 0 {
163 0 globus_result_t result = GLOBUS_SUCCESS;
164 GlobusFuncName(xsd_string_copy_cstr);
165 0 GlobusSoapMessageDebugEnter();
166
167 0 result = xsd_string_copy_contents(
168 instance, (const xsd_string *) &str);
169
170 0 GlobusSoapMessageDebugExit();
171 0 return result;
172 }