su_strlst.h 3.92 KB
Newer Older
Pekka Pessi's avatar
Pekka Pessi committed
1 2 3
/*
 * This file is part of the Sofia-SIP package
 *
4
 * Copyright (C) 2006 Nokia Corporation.
Pekka Pessi's avatar
Pekka Pessi committed
5 6 7
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
8
 * This library is free software; you can redistribute it and/or
Pekka Pessi's avatar
Pekka Pessi committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

Pekka Pessi's avatar
Pekka Pessi committed
25
#ifndef SU_STRLST_H  /** Defined when <sofia-sip/su_strlst.h> has been included. */
Pekka Pessi's avatar
Pekka Pessi committed
26
#define SU_STRLST_H
Pekka Pessi's avatar
Pekka Pessi committed
27
/**@ingroup su_strlst
Pekka Pessi's avatar
Pekka Pessi committed
28
 * @file sofia-sip/su_strlst.h String lists
Pekka Pessi's avatar
Pekka Pessi committed
29 30
 *
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
31
 *
Pekka Pessi's avatar
Pekka Pessi committed
32 33 34 35
 * @date Created: Fri May  3 09:13:22 2002 ppessi
 */

#ifndef SU_ALLOC_H
36
#include <sofia-sip/su_alloc.h>
Pekka Pessi's avatar
Pekka Pessi committed
37 38
#endif

39 40
SOFIA_BEGIN_DECLS

Pekka Pessi's avatar
Pekka Pessi committed
41 42 43 44 45 46 47 48
typedef struct su_strlst_s su_strlst_t;

/** Create a string list. */
SU_DLL su_strlst_t *su_strlst_create(su_home_t *home)
     __attribute__((__malloc__));
/** Destroy a string list. */
SU_DLL void su_strlst_destroy(su_strlst_t *);

49 50 51 52 53 54 55 56 57 58 59 60
SU_DLL su_strlst_t *su_strlst_create_with(su_home_t *, char const *, ...)
     __attribute__((__malloc__));

SU_DLL su_strlst_t *su_strlst_create_with_dup(su_home_t *, char const *, ...)
     __attribute__((__malloc__));

SU_DLL su_strlst_t *su_strlst_vcreate_with(su_home_t *,
					   char const *,
					   va_list va)
     __attribute__((__malloc__));

SU_DLL su_strlst_t *su_strlst_vcreate_with_dup(su_home_t *,
61
					       char const *,
62 63 64
					       va_list va)
     __attribute__((__malloc__));

Pekka Pessi's avatar
Pekka Pessi committed
65 66 67 68 69 70 71 72 73 74 75 76
/** Shallow copy a string list. */
SU_DLL su_strlst_t *su_strlst_copy(su_home_t *home, su_strlst_t const *orig);

/** Deep copy a string list. */
SU_DLL su_strlst_t *su_strlst_dup(su_home_t *home, su_strlst_t const *orig);

/** Duplicate and append a string to list. */
SU_DLL char *su_strlst_dup_append(su_strlst_t *, char const *str);

/** Append a string to list. */
SU_DLL char const *su_strlst_append(su_strlst_t *, char const *str);

77
/** Append a formatted string to the list. */
Pekka Pessi's avatar
Pekka Pessi committed
78
SU_DLL char const *su_slprintf(su_strlst_t *self, char const *fmt, ...);
79 80

/** Append a formatted string to the list. */
Pekka Pessi's avatar
Pekka Pessi committed
81
SU_DLL char const *su_slvprintf(su_strlst_t *self, char const *fmt, va_list ap);
82

Pekka Pessi's avatar
Pekka Pessi committed
83
/** Get a numbered item from list. */
Michael Jerris's avatar
Michael Jerris committed
84
SU_DLL char const *su_strlst_item(su_strlst_t const *, usize_t i);
Pekka Pessi's avatar
Pekka Pessi committed
85 86

/** Set a numbered item to list */
87
SU_DLL char const *su_strlst_set_item(su_strlst_t *self, usize_t i,
Pekka Pessi's avatar
Pekka Pessi committed
88 89 90
				      char const *s);

/** Remove a numbered item from list. */
91
SU_DLL char const *su_strlst_remove(su_strlst_t *, usize_t i);
Pekka Pessi's avatar
Pekka Pessi committed
92 93

/** Concatenate list of strings to one string. */
94
SU_DLL char *su_strlst_join(su_strlst_t *s, su_home_t *home,
Pekka Pessi's avatar
Pekka Pessi committed
95 96 97 98 99 100 101 102
			     char const *sep)
     __attribute__((__malloc__));

/** Split a string. */
SU_DLL su_strlst_t *su_strlst_split(su_home_t *, char *s, char const *sep)
     __attribute__((__malloc__));

/** Duplicate and split a string. */
103
SU_DLL su_strlst_t *su_strlst_dup_split(su_home_t *, char const *s,
Pekka Pessi's avatar
Pekka Pessi committed
104 105 106 107
					char const *sep)
     __attribute__((__malloc__));

/** Get number of items in list. */
108
SU_DLL usize_t su_strlst_len(su_strlst_t const *l);
Pekka Pessi's avatar
Pekka Pessi committed
109

110
#if SU_HAVE_INLINE
111
su_inline
Pekka Pessi's avatar
Pekka Pessi committed
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
su_home_t *su_strlst_home(su_strlst_t *s)
{
  return (su_home_t *)s;
}
#else
#define su_strlst_home(s) ((su_home_t *)(s))
#endif

/** Get a string array from list. */
SU_DLL char const **su_strlst_get_array(su_strlst_t *self)
     __attribute__((__malloc__));

/** Free a string array */
SU_DLL void su_strlst_free_array(su_strlst_t *self, char const * array[]);

127 128
SOFIA_END_DECLS

Pekka Pessi's avatar
Pekka Pessi committed
129
#endif /* ! defined(SU_STRLST_H) */