Changeset 988 for vendor/current/librpc/ndr/uuid.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/librpc/ndr/uuid.c
r740 r988 158 158 159 159 /** 160 build a GUID from a string161 */162 _PUBLIC_ NTSTATUS NS_GUID_from_string(const char *s, struct GUID *guid)163 {164 NTSTATUS status = NT_STATUS_INVALID_PARAMETER;165 uint32_t time_low;166 uint32_t time_mid, time_hi_and_version;167 uint32_t clock_seq[2];168 uint32_t node[6];169 int i;170 171 if (s == NULL) {172 return NT_STATUS_INVALID_PARAMETER;173 }174 175 if (11 == sscanf(s, "%08x-%04x%04x-%02x%02x%02x%02x-%02x%02x%02x%02x",176 &time_low, &time_mid, &time_hi_and_version,177 &clock_seq[0], &clock_seq[1],178 &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) {179 status = NT_STATUS_OK;180 }181 182 if (!NT_STATUS_IS_OK(status)) {183 return status;184 }185 186 guid->time_low = time_low;187 guid->time_mid = time_mid;188 guid->time_hi_and_version = time_hi_and_version;189 guid->clock_seq[0] = clock_seq[0];190 guid->clock_seq[1] = clock_seq[1];191 for (i=0;i<6;i++) {192 guid->node[i] = node[i];193 }194 195 return NT_STATUS_OK;196 }197 198 /**199 160 * generate a random GUID 200 161 */ … … 237 198 _PUBLIC_ bool GUID_equal(const struct GUID *u1, const struct GUID *u2) 238 199 { 239 if (u1->time_low != u2->time_low || 240 u1->time_mid != u2->time_mid || 241 u1->time_hi_and_version != u2->time_hi_and_version || 242 u1->clock_seq[0] != u2->clock_seq[0] || 243 u1->clock_seq[1] != u2->clock_seq[1] || 244 memcmp(u1->node, u2->node, 6) != 0) { 245 return false; 246 } 247 return true; 200 return (GUID_compare(u1, u2) == 0); 248 201 } 249 202 … … 278 231 _PUBLIC_ char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) 279 232 { 280 return talloc_asprintf(mem_ctx, 281 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", 282 guid->time_low, guid->time_mid, 283 guid->time_hi_and_version, 284 guid->clock_seq[0], 285 guid->clock_seq[1], 286 guid->node[0], guid->node[1], 287 guid->node[2], guid->node[3], 288 guid->node[4], guid->node[5]); 233 struct GUID_txt_buf buf; 234 return talloc_strdup(mem_ctx, GUID_buf_string(guid, &buf)); 235 } 236 237 /** 238 * Does the same without allocating memory, using the structure buffer. 239 * Useful for debug messages, so that you do not have to talloc_free the result 240 */ 241 _PUBLIC_ char* GUID_buf_string(const struct GUID *guid, 242 struct GUID_txt_buf *dst) 243 { 244 if (!guid) { 245 return NULL; 246 } 247 snprintf(dst->buf, sizeof(dst->buf), 248 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", 249 guid->time_low, guid->time_mid, 250 guid->time_hi_and_version, 251 guid->clock_seq[0], 252 guid->clock_seq[1], 253 guid->node[0], guid->node[1], 254 guid->node[2], guid->node[3], 255 guid->node[4], guid->node[5]); 256 return dst->buf; 289 257 } 290 258 … … 319 287 } 320 288 321 _PUBLIC_ char *NS_GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid) 322 { 323 return talloc_asprintf(mem_ctx, 324 "%08x-%04x%04x-%02x%02x%02x%02x-%02x%02x%02x%02x", 325 guid->time_low, guid->time_mid, 326 guid->time_hi_and_version, 327 guid->clock_seq[0], 328 guid->clock_seq[1], 329 guid->node[0], guid->node[1], 330 guid->node[2], guid->node[3], 331 guid->node[4], guid->node[5]); 332 } 333 334 _PUBLIC_ bool policy_handle_empty(const struct policy_handle *h) 289 _PUBLIC_ bool ndr_policy_handle_empty(const struct policy_handle *h) 335 290 { 336 291 return (h->handle_type == 0 && GUID_all_zero(&h->uuid)); 337 292 } 338 293 339 _PUBLIC_ bool is_valid_policy_hnd(const struct policy_handle *hnd) 340 { 341 return !policy_handle_empty(hnd); 342 } 343 344 _PUBLIC_ bool policy_handle_equal(const struct policy_handle *hnd1, 294 _PUBLIC_ bool ndr_policy_handle_equal(const struct policy_handle *hnd1, 345 295 const struct policy_handle *hnd2) 346 296 {
Note:
See TracChangeset
for help on using the changeset viewer.