(file) Return to OperationContext.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

 1 chip  1.1.2.1 //%/////////////////////////////////////////////////////////////////////////////
 2               //
 3               // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
 4               //
 5               // Permission is hereby granted, free of charge, to any person obtaining a copy
 6               // of this software and associated documentation files (the "Software"), to
 7               // deal in the Software without restriction, including without limitation the
 8               // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9               // sell copies of the Software, and to permit persons to whom the Software is
10               // furnished to do so, subject to the following conditions:
11               //
12               // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
13               // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
14               // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15               // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16               // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17               // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18               // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19               // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20               //
21               //==============================================================================
22 chip  1.1.2.1 //
23               // Author: Chip Vincent (cvincent@us.ibm.com)
24               //
25               // Modified By: Mike Day (mdday@us.ibm.com)
26               //
27               //%/////////////////////////////////////////////////////////////////////////////
28               
29               #include "OperationContext.h"
30               
31               PEGASUS_NAMESPACE_BEGIN
32               
33               void default_serialize(Sint8 *dst, Uint32 dst_sz) throw(BufferTooSmall, NotImplemented)
34               {
35                  throw NotImplemented("no serialization routine present") ;
36               }
37               
38               void default_delete(void * data)
39               {
40                  if( data != NULL)
41                     ::operator delete(data);
42               }
43 chip  1.1.2.1 
44               void stringize_uid(void *uid, Sint8 **dest, size_t *size) throw (NullPointer, BufferTooSmall)
45               {
46                  Sint8 *ptr;
47               
48                  if(uid == NULL || dest == NULL || *dest == NULL || size == NULL)
49                     throw NullPointer();
50               
51                  if( *size < 37 )
52                     throw BufferTooSmall(37);
53               
54                  ptr = (Sint8 *)uid;
55                  sprintf(*dest,
56               	   "%.2d%.2d%.2d%.2d-%.2d%.2d-%.2d%.2d-%.2d%.2d-%.2d%.2d%.2d%.2d%.2d%.2d",
57               	   *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3),*(ptr + 4), *(ptr + 5),
58               	   *(ptr + 6), *(ptr + 7), *(ptr + 8), *(ptr + 9), *(ptr + 10),
59               	   *(ptr + 11), *(ptr + 12),*(ptr + 13),*(ptr + 14),*(ptr + 15) );
60                  *dest += 37;
61                  *size -= 37;
62                  return;
63               }
64 chip  1.1.2.1 
65               
66               void binaryize_uid(Sint8 *uid, void *dest, size_t size) throw(NullPointer, BufferTooSmall)
67               {
68               
69                  if(uid == NULL || dest == NULL)
70                     throw NullPointer();
71                  if(size < 16)
72                     throw(BufferTooSmall(16));
73                  Sint8 *src = uid;
74                  Sint8 *dst = (Sint8 *)dest;
75               
76                  int i = 0;
77                  Sint8 temp;
78               
79                  while( i < 16 )
80                  {
81                     temp = *(src + 2);
82                     *(src + 2) = 0x00;
83                     *(dst + i) = (Sint8)atoi(src);
84                     *(src + 2) = temp;
85 chip  1.1.2.1       i++;
86                     src += 2;
87                     if(*src == '-')
88               	 src++;
89                  }
90               }
91               
92               PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2