blob: 2e40838c366e5f6e18baf85f5918b0b2bc9250a5 [file] [log] [blame]
// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "linux_port.h"
#include <stdlib.h>
#include <string.h>
#include <uuid/uuid.h>
static const char* progname = NULL;
void setprogname(const char* name) {
progname = name;
}
const char* getprogname(void) {
return (progname == NULL) ? "gpt" : progname;
}
void strlcpy(char* dst, const char* src, size_t len) {
strncpy(dst, src, len);
if (len > 0) {
dst[len - 1] = '\0';
}
}
int32_t uuid_equal(struct uuid* a, struct uuid* b, uint32_t* unused) {
return (uuid_compare(*(uuid_t *)a, *(uuid_t *)b) == 0);
}
int32_t uuid_is_nil(struct uuid* uuid, uint32_t* unused) {
return uuid_is_null(*(uuid_t *)uuid);
}
void uuid_create(struct uuid* uuid, uint32_t* unused) {
return uuid_generate(*(uuid_t *)uuid);
}
void uuid_create_nil(struct uuid* uuid, uint32_t* unused) {
return uuid_clear(*(uuid_t *)uuid);
}
void uuid_from_string(const char* s, struct uuid* uuid, uint32_t* status) {
*status = uuid_parse(s, *(uuid_t *)uuid);
}
void uuid_to_string(struct uuid* uuid, char** s, uint32_t* unused) {
*s = malloc(36 + 1); /* 36 byte uuid plus '\0' */
uuid_unparse(*(uuid_t *)uuid, *s);
}