-- -- -------------------------------------------------------------------------------- -- -- C_String_Utilities -- -- This package exports a type which is the Ada representation -- of a C string as well as a routine to convert from a C -- string to a an Ada string. -- -- -- -- -- Gerardo A. Colon -- 19 September 1990 -- -- Science Applications International Corporation --
311 Park Place Boulevard, Suite 360 --
Clearwater, Florida 34619 -- -- Developed for the STARS program under task S40. -- -- -- -- -- Dependencies => -- ( Operating_System => None , -- Compiler => None , -- Device => None ) ; -- -- -------------------------------------------------------------------------------- with System ; pragma Page ; -------------------------------------------------------------------------------- -- package C_String_Utilities (specification). -------------------------------------------------------------------------------- package C_String_Utilities is subtype String_Pointer is System.Address ; -- -- This type is compatible with the C type * char. -- -- -- A C string is represented by a reference (address) to a string terminated -- with a null character. A routine which converts an Ada string to a C -- string needs to append a null character to the end of the Ada string and -- then return the address of the string. This will not work because as soon -- as the routine is executed the memory space allocated by the local string -- will be deallocated. There is really not a good way to implement a routine -- which converts an Ada string to a C string. That is the reason why this -- package does not export such a routine. -- function String_Of ( The_C_String : in String_Pointer ) return String ; -------------------------------------------------------------------------------- -- -- To_String -- -- This function converts the C string given by the parameter -- The_C_String to an Ada string. -- -- None. -- -- -------------------------------------------------------------------------------- end C_String_Utilities ; --