+2001-09-10 Theodore Tso <tytso@valinux.com>
+
+ * compare.c (uuid_compare), copy.c (uuid_copy),
+ isnull.c (uuid_is_null), pack.c (uuid_pack),
+ parse.c (uuid_parse), unpack.c (uuid_unpack),
+ unparse.c (uuid_unparse), uuid.h, uuidP.h,
+ uuid_time.c (uuid_time, uuid_type, uuid_variant):
+ Use const for pointer variables that we don't modify. Add
+ the appropriate ifdef's in uuid.h to make it be C++ friendly.
+
2001-09-02 Theodore Tso <tytso@thunk.org>
* Release of E2fsprogs 1.24a
#define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1);
-int uuid_compare(uuid_t uu1, uuid_t uu2)
+int uuid_compare(const uuid_t uu1, const uuid_t uu2)
{
struct uuid uuid1, uuid2;
#include "uuidP.h"
-void uuid_copy(uuid_t dst, uuid_t src)
+void uuid_copy(uuid_t dst, const uuid_t src)
{
- unsigned char *cp1, *cp2;
- int i;
+ unsigned char *cp1;
+ const unsigned char *cp2;
+ int i;
for (i=0, cp1 = dst, cp2 = src; i < 16; i++)
*cp1++ = *cp2++;
#include "uuidP.h"
/* Returns 1 if the uuid is the NULL uuid */
-int uuid_is_null(uuid_t uu)
+int uuid_is_null(const uuid_t uu)
{
- unsigned char *cp;
- int i;
+ const unsigned char *cp;
+ int i;
for (i=0, cp = uu; i < 16; i++)
if (*cp++)
#include <string.h>
#include "uuidP.h"
-void uuid_pack(struct uuid *uu, uuid_t ptr)
+void uuid_pack(const struct uuid *uu, uuid_t ptr)
{
__u32 tmp;
unsigned char *out = ptr;
#include "uuidP.h"
-int uuid_parse(char *in, uuid_t uu)
+int uuid_parse(const char *in, uuid_t uu)
{
- struct uuid uuid;
- int i;
- char *cp, buf[3];
+ struct uuid uuid;
+ int i;
+ const char *cp;
+ char buf[3];
if (strlen(in) != 36)
return -1;
#include <string.h>
#include "uuidP.h"
-void uuid_unpack(uuid_t in, struct uuid *uu)
+void uuid_unpack(const uuid_t in, struct uuid *uu)
{
- __u8 *ptr = in;
- __u32 tmp;
+ const __u8 *ptr = in;
+ __u32 tmp;
tmp = *ptr++;
tmp = (tmp << 8) | *ptr++;
#include "uuidP.h"
-void uuid_unparse(uuid_t uu, char *out)
+void uuid_unparse(const uuid_t uu, char *out)
{
struct uuid uuid;
#define UUID_VARIANT_MICROSOFT 2
#define UUID_VARIANT_OTHER 3
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* clear.c */
void uuid_clear(uuid_t uu);
/* compare.c */
-int uuid_compare(uuid_t uu1, uuid_t uu2);
+int uuid_compare(const uuid_t uu1, const uuid_t uu2);
/* copy.c */
-void uuid_copy(uuid_t dst, uuid_t src);
+void uuid_copy(uuid_t dst, const uuid_t src);
/* gen_uuid.c */
void uuid_generate(uuid_t out);
void uuid_generate_time(uuid_t out);
/* isnull.c */
-int uuid_is_null(uuid_t uu);
+int uuid_is_null(const uuid_t uu);
/* parse.c */
-int uuid_parse(char *in, uuid_t uu);
+int uuid_parse(const char *in, uuid_t uu);
/* unparse.c */
-void uuid_unparse(uuid_t uu, char *out);
+void uuid_unparse(const uuid_t uu, char *out);
/* uuid_time.c */
-time_t uuid_time(uuid_t uu, struct timeval *ret_tv);
-int uuid_type(uuid_t uu);
-int uuid_variant(uuid_t uu);
+time_t uuid_time(const uuid_t uu, struct timeval *ret_tv);
+int uuid_type(const uuid_t uu);
+int uuid_variant(const uuid_t uu);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* _UUID_UUID_H */
/*
* prototypes
*/
-void uuid_pack(struct uuid *uu, uuid_t ptr);
-void uuid_unpack(uuid_t in, struct uuid *uu);
+void uuid_pack(const struct uuid *uu, uuid_t ptr);
+void uuid_unpack(const uuid_t in, struct uuid *uu);
#include "uuidP.h"
-time_t uuid_time(uuid_t uu, struct timeval *ret_tv)
+time_t uuid_time(const uuid_t uu, struct timeval *ret_tv)
{
struct uuid uuid;
__u32 high;
return tv.tv_sec;
}
-int uuid_type(uuid_t uu)
+int uuid_type(const uuid_t uu)
{
struct uuid uuid;
return ((uuid.time_hi_and_version >> 12) & 0xF);
}
-int uuid_variant(uuid_t uu)
+int uuid_variant(const uuid_t uu)
{
struct uuid uuid;
int var;