diff options
author | Stephen D. Huston <shuston@apache.org> | 2008-10-08 16:13:18 +0000 |
---|---|---|
committer | Stephen D. Huston <shuston@apache.org> | 2008-10-08 16:13:18 +0000 |
commit | 2f747f62dd8c71e41675b4ea6de0385604e81d75 (patch) | |
tree | 60754560fda6fd0b39c1a0f47c45e6ea72e981de /cpp/src | |
parent | 251fc8cdea1e5f6ad76b0264a0e59c146a9e50b6 (diff) | |
download | qpid-python-2f747f62dd8c71e41675b4ea6de0385604e81d75.tar.gz |
Add uuid wrapper for Windows; resolves QPID-1328
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@702917 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Makefile.am | 3 | ||||
-rw-r--r-- | cpp/src/qpid/framing/Uuid.h | 4 | ||||
-rw-r--r-- | cpp/src/qpid/sys/uuid.h | 28 | ||||
-rw-r--r-- | cpp/src/qpid/sys/windows/uuid.cpp | 54 | ||||
-rw-r--r-- | cpp/src/qpid/sys/windows/uuid.h | 41 |
5 files changed, 127 insertions, 3 deletions
diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am index 64c2b3fcc1..9486d7a8b9 100644 --- a/cpp/src/Makefile.am +++ b/cpp/src/Makefile.am @@ -622,7 +622,8 @@ nobase_include_HEADERS = \ qpid/sys/Waitable.h \ qpid/sys/Thread.h \ qpid/sys/Time.h \ - qpid/sys/TimeoutHandler.h + qpid/sys/TimeoutHandler.h \ + qpid/sys/uuid.h if HAVE_XML nobase_include_HEADERS += qpid/broker/XmlExchange.h diff --git a/cpp/src/qpid/framing/Uuid.h b/cpp/src/qpid/framing/Uuid.h index 310d95a6cc..4e5de9ce41 100644 --- a/cpp/src/qpid/framing/Uuid.h +++ b/cpp/src/qpid/framing/Uuid.h @@ -19,13 +19,13 @@ * */ +#include "qpid/sys/uuid.h" + #include <boost/array.hpp> #include <ostream> #include <istream> -#include <uuid/uuid.h> - namespace qpid { namespace framing { diff --git a/cpp/src/qpid/sys/uuid.h b/cpp/src/qpid/sys/uuid.h new file mode 100644 index 0000000000..804ab34463 --- /dev/null +++ b/cpp/src/qpid/sys/uuid.h @@ -0,0 +1,28 @@ +#ifndef _sys_uuid_h +#define _sys_uuid_h + +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifdef _WIN32 +# include "qpid/sys/windows/uuid.h" +#else +# include <uuid/uuid.h> +#endif /* _WIN32 */ + +#endif /* _sys_uuid_h */ diff --git a/cpp/src/qpid/sys/windows/uuid.cpp b/cpp/src/qpid/sys/windows/uuid.cpp new file mode 100644 index 0000000000..76233751ff --- /dev/null +++ b/cpp/src/qpid/sys/windows/uuid.cpp @@ -0,0 +1,54 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "uuid.h" + +#include <string.h> + +void uuid_clear (uuid_t uu) { + UuidCreateNil (reinterpret_cast<UUID*>(uu)); +} + +void uuid_copy (uuid_t dst, const uuid_t src) { + memcpy (dst, src, qpid::sys::UuidSize); +} + +void uuid_generate (uuid_t out) { + UuidCreate (reinterpret_cast<UUID*>(out)); +} + +int uuid_is_null (const uuid_t uu) { + RPC_STATUS unused; + return UuidIsNil ((UUID*)uu, &unused); +} + +int uuid_parse (const char *in, uuid_t uu) { + return UuidFromString ((unsigned char*)in, (UUID*)uu) == RPC_S_OK; +} + +void uuid_unparse (const uuid_t uu, char *out) { + unsigned char *formatted; + if (UuidToString((UUID*)uu, &formatted) == RPC_S_OK) { + strncpy_s (out, 36+1, (char*)formatted, _TRUNCATE); + RpcStringFree(&formatted); + } +} + diff --git a/cpp/src/qpid/sys/windows/uuid.h b/cpp/src/qpid/sys/windows/uuid.h new file mode 100644 index 0000000000..a44ef2e9a3 --- /dev/null +++ b/cpp/src/qpid/sys/windows/uuid.h @@ -0,0 +1,41 @@ +#ifndef _sys_windows_uuid_h +#define _sys_windows_uuid_h + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include <Rpc.h> + +#ifdef uuid_t /* Done in rpcdce.h */ +# undef uuid_t +#endif +#include <qpid/sys/IntegerTypes.h> +namespace qpid { namespace sys { const size_t UuidSize = 16; }} +typedef uint8_t uuid_t[qpid::sys::UuidSize]; + +void uuid_clear (uuid_t uu); +void uuid_copy (uuid_t dst, const uuid_t src); +void uuid_generate (uuid_t out); +int uuid_is_null (const uuid_t uu); // Returns 1 if null, else 0 +int uuid_parse (const char *in, uuid_t uu); // Returns 0 on success, else -1 +void uuid_unparse (const uuid_t uu, char *out); + +#endif /*!_sys_windows_uuid_h*/ |