4 -- Grant of Unlimited Rights
6 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
7 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
8 -- unlimited rights in the software and documentation contained herein.
9 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
10 -- this public release, the Government intends to confer upon all
11 -- recipients unlimited rights equal to those held by the Government.
12 -- These rights include rights to use, duplicate, release or disclose the
13 -- released technical data and computer software in whole or in part, in
14 -- any manner and for any purpose whatsoever, and to have or permit others
19 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
20 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
21 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
22 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
23 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
24 -- PARTICULAR PURPOSE OF SAID MATERIAL.
27 -- FUNCTION NAME: CXB30131 ("combine_two_strings")
29 -- FUNCTION DESCRIPTION:
30 -- This C function returns a pointer to the combination of two
34 -- This function requires that two parameters be passed to it.
35 -- The type of both of these parameters are pointer to char (which
36 -- is used to reference an array of chars).
39 -- The function will create a char array that is equal to the combined
40 -- length of the char arrays referenced by the two input parameters.
41 -- The char elements contained in the char arrays specified by the
42 -- parameters will be combined (in order) into this new char array.
45 -- The newly created char array will be returned as the function
46 -- result through the function name. The char arrays referenced by the
47 -- two parameters will be unaffected.
50 -- 12 Oct 95 SAIC Initial prerelease version.
51 -- 26 Oct 96 SAIC Modified temp array initialization.
52 -- 15 Feb 99 RLB Repaired to remove non-standard function strdup.
58 char *stringdup (char *s
)
60 char *result
= (char *) malloc(sizeof(char)*(strlen(s
)+1));
61 return strcpy(result
,s
);
64 char *CXB30131 (char *string1
, char *string2
)
66 /* NOTE: The above function definition should be accepted by an ANSI-C */
67 /* compiler. Older C compilers may reject it; they may, however */
68 /* accept the following three lines. An implementation may comment */
69 /* out the above function definition and uncomment the following */
70 /* one. Otherwise, an implementation must provide the necessary */
71 /* modifications to this C code to satisfy the function */
72 /* requirements (see Function Description). */
74 /* char *CXB30131 (string1, string2) */
79 char temp
[100]; /* Local array that holds the combined strings */
80 int index
; /* Loop counter */
81 int length
= 0; /* Variable that holds the length of the strings */
83 /* Initialize the local array */
84 for (index
= 0; index
< 100; index
++)
87 /* Use the library function strcpy to copy the contents of string1
89 strcpy (temp
, string1
);
91 /* Use the library function strlen to determine the number of
92 characters in the temp array (without the trailing nul). */
93 length
= strlen (temp
);
95 /* Add each character in string2 into the temp array, add nul
96 to the end of the array. */
97 for (index
= length
; *string2
!= '\0'; index
++)
98 { temp
[index
] = *string2
++; }
101 /* Use the library function strdup to return a pointer to temp. */
102 return (stringdup(temp
));