diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2005-06-27 11:13:00 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2005-06-27 11:13:00 +0000 |
commit | c8c024d98a8a7f19c9f65284c0eea5ecaae52143 (patch) | |
tree | 4b05f79d522242a645b3c88334c62cb5f69db4e8 | |
parent | 146ae80da81118540e73d7d56dc0947cecedfe8c (diff) | |
download | mailutils-c8c024d98a8a7f19c9f65284c0eea5ecaae52143.tar.gz mailutils-c8c024d98a8a7f19c9f65284c0eea5ecaae52143.tar.bz2 |
New file
-rw-r--r-- | examples/argcv.c | 59 | ||||
-rw-r--r-- | mailbox/testsuite/Argcv | 39 |
2 files changed, 98 insertions, 0 deletions
diff --git a/examples/argcv.c b/examples/argcv.c new file mode 100644 index 000000000..83e39bd58 --- /dev/null +++ b/examples/argcv.c @@ -0,0 +1,59 @@ +/* GNU Mailutils -- a suite of utilities for electronic mail + Copyright (C) 2005 Free Software Foundation, Inc. + + GNU Mailutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GNU Mailutils 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Mailutils; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301 USA */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <unistd.h> +#include <getline.h> +#include <mailutils/argcv.h> + +int +main(int argc, char **argv) +{ + char *delim = ""; + char *comment = "#"; + char *buf = NULL; + size_t n = 0; + + while (getline (&buf, &n, stdin) > 0) + { + int status, i, c; + char **v; + char *s; + + status = argcv_get (buf, delim, comment, &c, &v); + if (status) + { + fprintf (stderr, "cannot parse: %s\n", mu_strerror (status)); + continue; + } + status = argcv_string (c, v, &s); + if (status) + fprintf (stderr, "cannot create string: %s\n", mu_strerror (status)); + else + { + printf ("%d: %s\n", c, s); + free (s); + } + argcv_free (c, v); + } + free (buf); + exit (0); +} diff --git a/mailbox/testsuite/Argcv b/mailbox/testsuite/Argcv new file mode 100644 index 000000000..20cf43e68 --- /dev/null +++ b/mailbox/testsuite/Argcv @@ -0,0 +1,39 @@ +# This file is part of Mailutils testsuite. +# Copyright (C) 2005, Free Software Foundation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +1 2 3 +3: 1 2 3 + +quoted\ space +1: "quoted space" + +a "tab character" +2: a tab\tcharacter + +\157\143\164\141\154\40and\x20\x68\x65\x78 +1: "octal and hex" + +\157\143\164\141\154\40 and \x20\x68\x65\x78 +3: "octal " and " hex" + +A\x3-\48\39 +1: A\003-\0048\0039 + +message: ASCII upper part +верхняя половина таблицы +3: \327\305\322\310\316\321\321 \320\317\314\317\327\311\316\301 \324\301\302\314\311\303\331 + |