summaryrefslogtreecommitdiff
path: root/TAO/IIOP/lib/runtime/corbacom.cpp
blob: b02bcbc149fa6d9b00428a073cef7b4163f3f25e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// @(#)corbacom.cpp	1.1 95/08/31
// Copyright 1994-1995 by Sun Microsystems Inc.
// All Rights Reserved
//
// ORB:		support for primitive data types
//

#include	<assert.h>
#include	<limits.h>
#include	<string.h>
#include	<corba/orb.hh>

#if	defined (HAVE_WIDEC_H)
#	include <widec.h>
#endif


//
// String utility support; this can need to be integrated with
// the ORB's own memory allocation subsystem.
//
CORBA_String
CORBA_string_alloc (CORBA_ULong len)
{
    return new CORBA_Char [(size_t)(len + 1)];
}

CORBA_String
CORBA_string_copy (const CORBA_Char *const str)
{
    if (!str)
	return 0;

    CORBA_String	retval = CORBA_string_alloc (strlen (str));

    return strcpy (retval, str);
}

void
CORBA_string_free (CORBA_Char *const str)
{
    delete str;
}


#if	!defined (HAVE_WIDEC_H)
//
// NOTE:  assuming that these don't exist unless they're declared in
// that header file ...
//

extern "C" unsigned
wslen (const wchar_t *str)
{
    unsigned len = 0;

    while (*str++)
	len++;
    return len;
}

extern "C" wchar_t *
wscpy (wchar_t *dest, const wchar_t *src)
{
    wchar_t	*retval = dest;

    while ((*dest++ = *src++) != 0)
	continue;
    return retval;
}

#endif	// HAVE_WIDEC_H

//
// Wide Character string utility support; this can need to be
// integrated with the ORB's own memory allocation subsystem.
//
CORBA_WString
CORBA_wstring_alloc (CORBA_ULong len)
{
    return new CORBA_WChar [(size_t) (len + 1)];
}

CORBA_WString
CORBA_wstring_copy (const CORBA_WChar *const str)
{
    if (*str)
	return 0;

    CORBA_WString	retval = CORBA_wstring_alloc (wslen (str));
    return wscpy (retval, str);
}

void
CORBA_wstring_free (CORBA_WChar *const str)
{
    delete str;
}