6 /* Copyright (C) 1995,1996,1997,1998,2000,2001 Free Software Foundation, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "libguile/__scm.h"
29 #define SCM_STRINGP(x) (!SCM_IMP (x) && (SCM_TYP7 (x) == scm_tc7_string))
30 #define SCM_STRING_UCHARS(x) ((unsigned char *) (SCM_CELL_WORD_1 (x)))
31 #define SCM_STRING_CHARS(x) ((char *) (SCM_CELL_WORD_1 (x)))
32 #define SCM_SET_STRING_CHARS(s, c) (SCM_SET_CELL_WORD_1 ((s), (c)))
33 #define SCM_STRING_MAX_LENGTH ((1UL << 24) - 1UL)
34 #define SCM_STRING_LENGTH(x) ((size_t) (SCM_CELL_WORD_0 (x) >> 8))
35 #define SCM_MAKE_STRING_TAG(l) ((((scm_t_bits) (l)) << 8) + scm_tc7_string)
36 #define SCM_SET_STRING_LENGTH(s, l) (SCM_SET_CELL_WORD_0 ((s), SCM_MAKE_STRING_TAG (l)))
40 SCM_API SCM
scm_string_p (SCM x
);
41 SCM_API SCM
scm_string (SCM chrs
);
42 SCM_API SCM
scm_makfromstrs (int argc
, char **argv
);
43 SCM_API SCM
scm_take_str (char *s
, size_t len
);
44 SCM_API SCM
scm_take0str (char *s
);
45 SCM_API SCM
scm_mem2string (const char *src
, size_t len
);
46 SCM_API SCM
scm_str2string (const char *src
);
47 SCM_API SCM
scm_makfrom0str (const char *src
);
48 SCM_API SCM
scm_makfrom0str_opt (const char *src
);
49 SCM_API SCM
scm_allocate_string (size_t len
);
50 SCM_API SCM
scm_make_string (SCM k
, SCM chr
);
51 SCM_API SCM
scm_string_length (SCM str
);
52 SCM_API SCM
scm_string_ref (SCM str
, SCM k
);
53 SCM_API SCM
scm_string_set_x (SCM str
, SCM k
, SCM chr
);
54 SCM_API SCM
scm_substring (SCM str
, SCM start
, SCM end
);
55 SCM_API SCM
scm_string_append (SCM args
);
56 SCM_API
void scm_init_strings (void);
57 SCM_API
char *scm_c_string2str (SCM obj
, char *str
, size_t *lenp
);
58 SCM_API
char *scm_c_substring2str (SCM obj
, char *str
, size_t start
, size_t len
);
62 #if (SCM_ENABLE_DEPRECATED == 1)
64 #define SCM_STRING_COERCE_0TERMINATION_X(x) (x)
68 #endif /* SCM_STRINGS_H */