1 /* cstring.h 2 * 3 * $Id$ 4 * 5 * Copyright 1990, 1991, 1992, 1993, 1994, 1995, Oliver Laumann, Berlin 6 * Copyright 2002, 2003 Sam Hocevar <sam@hocevar.net>, Paris 7 * 8 * This software was derived from Elk 1.2, which was Copyright 1987, 1988, 9 * 1989, Nixdorf Computer AG and TELES GmbH, Berlin (Elk 1.2 has been written 10 * by Oliver Laumann for TELES Telematic Services, Berlin, in a joint project 11 * between TELES and Nixdorf Microprocessor Engineering, Berlin). 12 * 13 * Oliver Laumann, TELES GmbH, Nixdorf Computer AG and Sam Hocevar, as co- 14 * owners or individual owners of copyright in this software, grant to any 15 * person or company a worldwide, royalty free, license to 16 * 17 * i) copy this software, 18 * ii) prepare derivative works based on this software, 19 * iii) distribute copies of this software or derivative works, 20 * iv) perform this software, or 21 * v) display this software, 22 * 23 * provided that this notice is not removed and that neither Oliver Laumann 24 * nor Teles nor Nixdorf are deemed to have made any representations as to 25 * the suitability of this software for any purpose nor are held responsible 26 * for any defects of this software. 27 * 28 * THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. 29 */ 30 31 /* These must be defined as macros, because they use Alloca(). 32 */ 33 34 #define Get_String_Stack(_from,_to) {\ 35 unsigned int _len;\ 36 Check_Type(_from, T_String);\ 37 _len = STRING(_from)->size;\ 38 Alloca ((_to), char*, _len+1);\ 39 memcpy ((_to), STRING(_from)->data, _len);\ 40 (_to)[_len] = '\0';\ 41 } 42 43 #define Get_Strsym_Stack(_from,_to) {\ 44 unsigned int _len;\ 45 if (TYPE(_from) == T_Symbol)\ 46 (_from) = SYMBOL(_from)->name;\ 47 else if (TYPE(_from) != T_String)\ 48 Wrong_Type_Combination ((_from), "string or symbol");\ 49 _len = STRING(_from)->size;\ 50 Alloca ((_to), char*, _len+1);\ 51 memcpy ((_to), STRING(_from)->data, _len);\ 52 (_to)[_len] = '\0';\ 53 } 54