upload http
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / srclib / apr-util / test / testuuid.c
1 /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
2  * applicable.
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 <stdio.h>
18 #include <stdlib.h>
19
20 #include "apr_general.h"
21 #include "apr_uuid.h"
22
23
24 int main(int argc, char **argv)
25 {
26     apr_uuid_t uuid;
27     apr_uuid_t uuid2;
28     char buf[APR_UUID_FORMATTED_LENGTH + 1];
29     int retcode = 0;
30
31     apr_initialize();
32     atexit(apr_terminate);
33
34     apr_uuid_get(&uuid);
35     apr_uuid_format(buf, &uuid);
36     printf("UUID: %s\n", buf);
37
38     apr_uuid_parse(&uuid2, buf);
39     if (memcmp(&uuid, &uuid2, sizeof(uuid)) == 0)
40         printf("Parse appears to work.\n");
41     else {
42         printf("ERROR: parse produced a different UUID.\n");
43         retcode = 1;
44     }
45
46     apr_uuid_format(buf, &uuid2);
47     printf("parsed/reformatted UUID: %s\n", buf);
48
49     /* generate two of them quickly */
50     apr_uuid_get(&uuid);
51     apr_uuid_get(&uuid2);
52     apr_uuid_format(buf, &uuid);
53     printf("UUID 1: %s\n", buf);
54     apr_uuid_format(buf, &uuid2);
55     printf("UUID 2: %s\n", buf);
56
57     return retcode;
58 }