summaryrefslogtreecommitdiff
path: root/libmailutils/string
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-10-09 13:06:58 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-10-09 13:26:18 +0300
commitf3188dcc18d8de1192c87e7e0284800e9488b976 (patch)
treefed11275f4d8bbc28d8eb2239d93ddcba89fcb84 /libmailutils/string
parent37d7cd77d34cd4bf8d267b3010d923845fe74308 (diff)
downloadmailutils-f3188dcc18d8de1192c87e7e0284800e9488b976.tar.gz
mailutils-f3188dcc18d8de1192c87e7e0284800e9488b976.tar.bz2
Reorganize libmailutils directory structure.
* configure.ac (AC_CONFIG_FILES): Add libmailutils/ subdirs. * include/mailutils/Makefile.am: Update references to libmailutils. * po/POTFILES.in: Likewise. * libmailutils/.gitignore: Update. * libmailutils/Makefile.am: Use convenience libraries in subdirs. * libmailutils/string/Makefile.am: New file. * libmailutils/cstrcasecmp.c: Move to libmailutils/string. * libmailutils/cstrlower.c: Likewise. * libmailutils/cstrupper.c: Likewise. * libmailutils/strltrim.c: Likewise. * libmailutils/strskip.c: Likewise. * libmailutils/stripws.c: Likewise. * libmailutils/strrtrim.c: Likewise. * libmailutils/asnprintf.c: Likewise. * libmailutils/asprintf.c: Likewise. * libmailutils/muctype.c: Likewise. * libmailutils/vasnprintf.c: Likewise. * libmailutils/mkfilename.c: Likewise. * libmailutils/stream/Makefile.am: New file. * libmailutils/dbgstream.c: Move to libmailutils/stream. * libmailutils/file_stream.c: Likewise. * libmailutils/fltstream.c: Likewise. * libmailutils/iostream.c: Likewise. * libmailutils/mapfile_stream.c: Likewise. * libmailutils/memory_stream.c: Likewise. * libmailutils/message_stream.c: Likewise. * libmailutils/prog_stream.c: Likewise. * libmailutils/rdcache_stream.c: Likewise. * libmailutils/socket_stream.c: Likewise. * libmailutils/stdio_stream.c: Likewise. * libmailutils/stream.c: Likewise. * libmailutils/stream_printf.c: Likewise. * libmailutils/stream_vprintf.c: Likewise. * libmailutils/streamcpy.c: Likewise. * libmailutils/streamref.c: Likewise. * libmailutils/tcp.c: Likewise. * libmailutils/temp_file_stream.c: Likewise. * libmailutils/xscript-stream.c * libmailutils/cfg/Makefile.am: New file. * libmailutils/cfg/.gitignore: New file. * libmailutils/cfg_driver.c: Move to libmailutils/cfg/driver.c. * libmailutils/cfg_format.c: Move to libmailutils/cfg/format.c. * libmailutils/cfg_lexer.l: Move to libmailutils/cfg/lexer.l. * libmailutils/cfg_parser.y: Move to libmailutils/cfg/parser.y. * libmailutils/gocs.c: Move to libmailutils/cfg/gocs.c. * libmailutils/diag/Makefile.am: New file. * libmailutils/diag/.gitignore: New file. * libmailutils/debug.c: Move to libmailutils/diag. * libmailutils/diag.c: Likewise. * libmailutils/gdebug.c: Likewise. * libmailutils/errors: Likewise. * libmailutils/muerrno.cin: Likewise. * libmailutils/syslog.c: Likewise. * libmailutils/dbgstderr.c: Likewise. * libmailutils/dbgsyslog.c: Likewise. * libmailutils/address/Makefile.am: New file. * libmailutils/address.c: Move to libmailutils/address. * libmailutils/parse822.c: Likewise. * libmailutils/mailbox/Makefile.am: New file. * libmailutils/mailbox.c: Move to libmailutils/mailbox. * libmailutils/mbx_default.c: Likewise. * libmailutils/mbxitr.c: Likewise. * libmailutils/attribute.c: Likewise. * libmailutils/body.c: Likewise. * libmailutils/envelope.c: Likewise. * libmailutils/folder.c: Likewise. * libmailutils/hdritr.c: Likewise. * libmailutils/header.c: Likewise. * libmailutils/message.c: Likewise. * libmailutils/msgscan.c: Likewise. * libmailutils/mailer/Makefile.am: New file. * libmailutils/mailer.c: Move to libmailutils/mailer. * libmailutils/progmailer.c: Likewise. * libmailutils/mime/Makefile.am: New file. * libmailutils/attachment.c: Move to libmailutils/mime. * libmailutils/mime.c: Likewise. * libmailutils/mimehdr.c: Likewise. * libmailutils/server/Makefile.am: New file. * libmailutils/acl.c: Move to libmailutils/server. * libmailutils/server.c: Likewise. * libmailutils/msrv.c: Likewise. * libmailutils/ipsrv.c: Likewise. * libmailutils/auth/Makefile.am: New file. * libmailutils/auth.c: Move to libmailutils/auth. * libmailutils/mu_auth.c: Likewise. * libmailutils/system.c: Likewise. * libmailutils/base/Makefile.am: New file. * libmailutils/base/.gitignore: New file. * libmailutils/alloc.c: Move to libmailutils/base. * libmailutils/amd.c: Likewise. * libmailutils/argcv.c: Likewise. * libmailutils/assoc.c: Likewise. * libmailutils/daemon.c: Likewise. * libmailutils/date.c: Likewise. * libmailutils/fgetpwent.c: Likewise. * libmailutils/freeitem.c: Likewise. * libmailutils/getpass.c: Likewise. * libmailutils/iterator.c: Likewise. * libmailutils/kwd.c: Likewise. * libmailutils/list.c: Likewise. * libmailutils/listlist.c: Likewise. * libmailutils/locale.c: Likewise. * libmailutils/locker.c: Likewise. * libmailutils/mailcap.c: Likewise. * libmailutils/md5.c: Likewise. * libmailutils/monitor.c: Likewise. * libmailutils/munre.c: Likewise. * libmailutils/mutil.c: Likewise. * libmailutils/nls.c: Likewise. * libmailutils/nullrec.c: Likewise. * libmailutils/observer.c: Likewise. * libmailutils/opool.c: Likewise. * libmailutils/parsedate.y: Likewise. * libmailutils/permstr.c: Likewise. * libmailutils/property.c: Likewise. * libmailutils/registrar.c: Likewise. * libmailutils/refcount.c: Likewise. * libmailutils/rfc2047.c: Likewise. * libmailutils/sha1.c: Likewise. * libmailutils/secret.c: Likewise. * libmailutils/ticket.c: Likewise. * libmailutils/url.c: Likewise. * libmailutils/vartab.c: Likewise. * libmailutils/version.c: Likewise. * libmailutils/wicket.c: Likewise.
Diffstat (limited to 'libmailutils/string')
-rw-r--r--libmailutils/string/Makefile.am34
-rw-r--r--libmailutils/string/asnprintf.c40
-rw-r--r--libmailutils/string/asprintf.c42
-rw-r--r--libmailutils/string/cstrcasecmp.c58
-rw-r--r--libmailutils/string/cstrlower.c31
-rw-r--r--libmailutils/string/cstrupper.c31
-rw-r--r--libmailutils/string/mkfilename.c46
-rw-r--r--libmailutils/string/muctype.c152
-rw-r--r--libmailutils/string/stripws.c33
-rw-r--r--libmailutils/string/strltrim.c63
-rw-r--r--libmailutils/string/strrtrim.c51
-rw-r--r--libmailutils/string/strskip.c59
-rw-r--r--libmailutils/string/vasnprintf.c87
13 files changed, 727 insertions, 0 deletions
diff --git a/libmailutils/string/Makefile.am b/libmailutils/string/Makefile.am
new file mode 100644
index 000000000..52452b98c
--- /dev/null
+++ b/libmailutils/string/Makefile.am
@@ -0,0 +1,34 @@
+# GNU Mailutils -- a suite of utilities for electronic mail
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 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, see
+# <http://www.gnu.org/licenses/>.
+
+noinst_LTLIBRARIES = libstring.la
+
+libstring_la_SOURCES = \
+ cstrcasecmp.c\
+ cstrlower.c\
+ cstrupper.c\
+ strltrim.c\
+ strskip.c\
+ stripws.c\
+ strrtrim.c\
+ asnprintf.c\
+ asprintf.c\
+ muctype.c\
+ vasnprintf.c\
+ mkfilename.c
+
+INCLUDES = @MU_LIB_COMMON_INCLUDES@ -I/libmailutils
diff --git a/libmailutils/string/asnprintf.c b/libmailutils/string/asnprintf.c
new file mode 100644
index 000000000..f8ef54334
--- /dev/null
+++ b/libmailutils/string/asnprintf.c
@@ -0,0 +1,40 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 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 Street, Fifth Floor,
+ Boston, MA 02110-1301 USA */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+#include <mailutils/io.h>
+
+int
+mu_asnprintf (char **pbuf, size_t *psize, const char *fmt, ...)
+{
+ int rc;
+ va_list ap;
+
+ va_start (ap, fmt);
+ rc = mu_vasnprintf (pbuf, psize, fmt, ap);
+ va_end (ap);
+ return rc;
+}
+
diff --git a/libmailutils/string/asprintf.c b/libmailutils/string/asprintf.c
new file mode 100644
index 000000000..c563bcb84
--- /dev/null
+++ b/libmailutils/string/asprintf.c
@@ -0,0 +1,42 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 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 Street, Fifth Floor,
+ Boston, MA 02110-1301 USA */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+#include <mailutils/io.h>
+
+int
+mu_asprintf (char **pbuf, const char *fmt, ...)
+{
+ va_list ap;
+ size_t size;
+ int rc;
+
+ va_start (ap, fmt);
+ *pbuf = NULL;
+ size = 0;
+ rc = mu_vasnprintf (pbuf, &size, fmt, ap);
+ va_end (ap);
+ return rc;
+}
diff --git a/libmailutils/string/cstrcasecmp.c b/libmailutils/string/cstrcasecmp.c
new file mode 100644
index 000000000..4baeae220
--- /dev/null
+++ b/libmailutils/string/cstrcasecmp.c
@@ -0,0 +1,58 @@
+/* This file is part of GNU Mailutils
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stddef.h>
+#include <mailutils/cctype.h>
+
+int
+mu_c_strcasecmp (const char *a, const char *b)
+{
+ int d = 0;
+ for (; d == 0; a++, b++)
+ {
+ int ac = (int) *a;
+ int bc = (int) *b;
+ if (ac == 0 || bc == 0)
+ return ac - bc;
+ if (mu_isascii (ac) && mu_isascii (bc))
+ d = mu_toupper (ac) - mu_toupper (bc);
+ else
+ d = ac - bc;
+ }
+ return d;
+}
+
+int
+mu_c_strncasecmp (const char *a, const char *b, size_t n)
+{
+ int d = 0;
+ for (; d == 0 && n > 0; a++, b++, n--)
+ {
+ int ac = (int) *a;
+ int bc = (int) *b;
+ if (ac == 0 || bc == 0)
+ return ac - bc;
+ if (mu_isascii (ac) && mu_isascii (bc))
+ d = mu_toupper (ac) - mu_toupper (bc);
+ else
+ d = ac - bc;
+ }
+ return d;
+}
diff --git a/libmailutils/string/cstrlower.c b/libmailutils/string/cstrlower.c
new file mode 100644
index 000000000..98afb5f35
--- /dev/null
+++ b/libmailutils/string/cstrlower.c
@@ -0,0 +1,31 @@
+/* This file is part of GNU Mailutils
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <mailutils/cctype.h>
+
+int
+mu_strlower (char *s)
+{
+ if (!s)
+ return 0;
+ for (; *s; s++)
+ *s = mu_tolower (*s);
+ return 0;
+}
diff --git a/libmailutils/string/cstrupper.c b/libmailutils/string/cstrupper.c
new file mode 100644
index 000000000..965977d44
--- /dev/null
+++ b/libmailutils/string/cstrupper.c
@@ -0,0 +1,31 @@
+/* This file is part of GNU Mailutils
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <mailutils/cctype.h>
+
+int
+mu_strupper (char *s)
+{
+ if (!s)
+ return 0;
+ for (; *s; s++)
+ *s = mu_toupper (*s);
+ return 0;
+}
diff --git a/libmailutils/string/mkfilename.c b/libmailutils/string/mkfilename.c
new file mode 100644
index 000000000..ecd6dee78
--- /dev/null
+++ b/libmailutils/string/mkfilename.c
@@ -0,0 +1,46 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 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,
+ see <http://www.gnu.org/licenses/>. */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mailutils/alloc.h>
+#include <mailutils/mutil.h>
+
+char *
+mu_make_file_name (const char *dir, const char *file)
+{
+ char *tmp;
+ size_t dirlen = strlen (dir);
+ size_t len;
+
+ while (dirlen > 0 && dir[dirlen-1] == '/')
+ dirlen--;
+
+ len = dirlen + 1 + strlen (file);
+ tmp = mu_alloc (len + 1);
+ if (tmp)
+ {
+ memcpy (tmp, dir, dirlen);
+ tmp[dirlen++] = '/';
+ strcpy (tmp + dirlen, file);
+ }
+ return tmp;
+}
diff --git a/libmailutils/string/muctype.c b/libmailutils/string/muctype.c
new file mode 100644
index 000000000..e425ffb30
--- /dev/null
+++ b/libmailutils/string/muctype.c
@@ -0,0 +1,152 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 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, see
+ <http://www.gnu.org/licenses/>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8c720
--- /dev/null
+++ b/libmailutils/string/stripws.c
@@ -0,0 +1,33 @@
+/* This file is part of GNU Mailutils
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
+
+/*
+ * removes whitespace from the beginning and end of a string
+ */
+char *
+mu_str_stripws (char *string)
+{
+ mu_rtrim_class (string, MU_CTYPE_SPACE);
+ return mu_str_skip_class (string, MU_CTYPE_SPACE);
+}
diff --git a/libmailutils/string/strltrim.c b/libmailutils/string/strltrim.c
new file mode 100644
index 000000000..e86980723
--- /dev/null
+++ b/libmailutils/string/strltrim.c
@@ -0,0 +1,63 @@
+/* This file is part of GNU Mailutils
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <string.h>
+#include <mailutils/types.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
+
+size_t
+mu_ltrim_class (char *str, int class)
+{
+ size_t i, len;
+
+ if (!*str)
+ return 0;
+ len = strlen (str);
+
+ for (i = 0; i < len && mu_c_is_class (str[i], class); i++)
+ ;
+ if (i)
+ {
+ len -= i;
+ memmove (str, str + i, len + 1);
+ }
+ return len;
+}
+
+size_t
+mu_ltrim_cset (char *str, const char *cset)
+{
+ size_t i, len;
+
+ if (!*str)
+ return 0;
+ len = strlen (str);
+
+ for (i = 0; i < len && strchr (cset, str[i]) != NULL; i++)
+ ;
+ if (i)
+ {
+ len -= i;
+ memmove (str, str + i, len + 1);
+ }
+ return len;
+}
+
diff --git a/libmailutils/string/strrtrim.c b/libmailutils/string/strrtrim.c
new file mode 100644
index 000000000..95e7babf2
--- /dev/null
+++ b/libmailutils/string/strrtrim.c
@@ -0,0 +1,51 @@
+/* This file is part of GNU Mailutils
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <mailutils/types.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
+
+size_t
+mu_rtrim_class (char *str, int class)
+{
+ size_t len;
+
+ if (!*str)
+ return 0;
+ for (len = strlen (str); len > 0 && mu_c_is_class (str[len-1], class); len--)
+ ;
+ str[len] = 0;
+ return len;
+}
+
+size_t
+mu_rtrim_cset (char *str, const char *cset)
+{
+ size_t len;
+
+ if (!*str)
+ return 0;
+ for (len = strlen (str); len > 0 && strchr (cset, str[len-1]) != NULL; len--)
+ ;
+ str[len] = 0;
+ return len;
+}
diff --git a/libmailutils/string/strskip.c b/libmailutils/string/strskip.c
new file mode 100644
index 000000000..5b676d085
--- /dev/null
+++ b/libmailutils/string/strskip.c
@@ -0,0 +1,59 @@
+/* This file is part of GNU Mailutils
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <mailutils/types.h>
+#include <mailutils/cctype.h>
+#include <mailutils/cstr.h>
+
+char *
+mu_str_skip_class (const char *str, int class)
+{
+ for (; *str && mu_c_is_class (*str, class); str++)
+ ;
+ return (char*) str;
+}
+
+char *
+mu_str_skip_class_comp (const char *str, int class)
+{
+ for (; *str && !mu_c_is_class (*str, class); str++)
+ ;
+ return (char*) str;
+}
+
+char *
+mu_str_skip_cset (const char *str, const char *cset)
+{
+ for (; *str && strchr (cset, *str); str++)
+ ;
+ return (char*) str;
+}
+
+char *
+mu_str_skip_cset_comp (const char *str, const char *cset)
+{
+ for (; *str && strchr (cset, *str) == NULL; str++)
+ ;
+ return (char*) str;
+}
+
+
diff --git a/libmailutils/string/vasnprintf.c b/libmailutils/string/vasnprintf.c
new file mode 100644
index 000000000..0f4350edb
--- /dev/null
+++ b/libmailutils/string/vasnprintf.c
@@ -0,0 +1,87 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+ Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 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 Street, Fifth Floor,
+ Boston, MA 02110-1301 USA */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include <mailutils/io.h>
+
+int
+mu_vasnprintf (char **pbuf, size_t *psize, const char *fmt, va_list ap)
+{
+ char *buf = *pbuf;
+ size_t buflen = *psize;
+ int rc = 0;
+
+ if (!buf)
+ {
+ if (buflen == 0)
+ buflen = 512; /* Initial allocation */
+
+ buf = calloc (1, buflen);
+ if (buf == NULL)
+ return ENOMEM;
+ }
+
+ for (;;)
+ {
+ ssize_t n = vsnprintf (buf, buflen, fmt, ap);
+ if (n < 0 || n >= buflen || !memchr (buf, '\0', n + 1))
+ {
+ char *newbuf;
+ size_t newlen = buflen * 2;
+ if (newlen < buflen)
+ {
+ rc = ENOMEM;
+ break;
+ }
+ newbuf = realloc (buf, newlen);
+ if (newbuf == NULL)
+ {
+ rc = ENOMEM;
+ break;
+ }
+ buflen = newlen;
+ buf = newbuf;
+ }
+ else
+ break;
+ }
+
+ if (rc)
+ {
+ if (!*pbuf)
+ {
+ /* We made first allocation, now free it */
+ free (buf);
+ buf = NULL;
+ buflen = 0;
+ }
+ }
+
+ *pbuf = buf;
+ *psize = buflen;
+ return rc;
+}

Return to:

Send suggestions and report system problems to the System administrator.