Move new mailbox.c source file to common/.

* g10/mailbox.c: Move to ...
* common/mbox-util.c: new file.
* common/mbox-util.h: New. Include where needed.
* g10/t-mailbox.c: Move to ...
* common/t-mbox-util.c: new file.
--

This will make it easier to use the code by other modules in common/.
This commit is contained in:
Werner Koch 2015-02-25 11:43:50 +01:00
parent e2d9340280
commit 9913253610
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
10 changed files with 67 additions and 48 deletions

View File

@ -75,6 +75,7 @@ common_sources = \
b64enc.c b64dec.c zb32.c \
convert.c \
percent.c \
mbox-util.c mbox-util.h \
miscellaneous.c \
xasprintf.c \
xreadline.c \
@ -177,7 +178,7 @@ jnlib_tests += t-w32-reg
endif
module_tests = t-convert t-percent t-gettime t-sysutils t-sexputil \
t-session-env t-openpgp-oid t-ssh-utils t-dns-cert \
t-mapstrings t-zb32
t-mapstrings t-zb32 t-mbox-util
if !HAVE_W32CE_SYSTEM
module_tests += t-exechelp
endif
@ -223,6 +224,7 @@ t_ssh_utils_LDADD = $(t_common_ldadd)
t_dns_cert_LDADD = $(t_common_ldadd) $(DNSLIBS)
t_mapstrings_LDADD = $(t_common_ldadd)
t_zb32_LDADD = $(t_common_ldadd)
t_mbox_util_LDADD = $(t_common_ldadd)
# http tests
t_http_SOURCES = t-http.c

View File

@ -1,15 +1,25 @@
/* mailbox.c - Mail address helper functions
/* mbox-util.c - Mail address helper functions
* Copyright (C) 1998-2010 Free Software Foundation, Inc.
* Copyright (C) 2014-2015 Werner Koch
* Copyright (C) 1998-2015 Werner Koch
*
* This file is part of GnuPG.
*
* GnuPG 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 3 of the License, or
* (at your option) any later version.
* This file is free software; you can redistribute it and/or modify
* it under the terms of either
*
* GnuPG is distributed in the hope that it will be useful,
* - 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.
*
* or
*
* - 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.
*
* or both in parallel, as here.
*
* This file 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.
@ -25,9 +35,8 @@
#include <unistd.h>
#include <errno.h>
#include "gpg.h"
#include "util.h"
#include "main.h"
#include "mbox-util.h"
static int

38
common/mbox-util.h Normal file
View File

@ -0,0 +1,38 @@
/* mbox-util.h - Defs for mail address helper functions
* Copyright (C) 2015 Werner Koch
*
* This file is part of GnuPG.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of either
*
* - 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.
*
* or
*
* - 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.
*
* or both in parallel, as here.
*
* This file 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef GNUPG_COMMON_MBOX_UTIL_H
#define GNUPG_COMMON_MBOX_UTIL_H
int has_invalid_email_chars (const char *s);
int is_valid_mailbox (const char *name);
char *mailbox_from_userid (const char *userid);
int is_valid_user_id (const char *uid);
#endif /*GNUPG_COMMON_MBOX_UTIL_H*/

View File

@ -1,4 +1,4 @@
/* t-mailbox.c - Module test for mailbox.c
/* t-mbox-util.c - Module test for mbox-util.c
* Copyright (C) 2015 Werner Koch
*
* This file is part of GnuPG.
@ -22,9 +22,8 @@
#include <stdlib.h>
#include <string.h>
#include "gpg.h"
#include "util.h"
#include "main.h"
#include "mbox-util.h"
#define pass() do { ; } while(0)
#define fail(a) do { fprintf (stderr, "%s:%d: test %d failed\n",\
@ -33,29 +32,6 @@
} while(0)
void *
gcry_malloc (size_t n)
{
return malloc (n);
}
char *
gcry_strdup (const char *string)
{
return strdup (string);
}
void
gcry_free (void *a)
{
if (a)
free (a);
}
static void
run_test (void)
{

View File

@ -83,7 +83,6 @@ common_source = \
textfilter.c \
progress.c \
misc.c \
mailbox.c \
rmd160.c rmd160.h \
options.h \
openfile.c \
@ -155,11 +154,9 @@ gpgv2_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) \
gpgv2_LDFLAGS = $(extra_bin_ldflags)
t_common_ldadd =
module_tests = t-rmd160 t-mailbox
module_tests = t-rmd160
t_rmd160_SOURCES = t-rmd160.c rmd160.c
t_rmd160_LDADD = $(t_common_ldadd)
t_mailbox_SOURCES = t-mailbox.c mailbox.c
t_mailbox_LDADD = $(t_common_ldadd)
$(PROGRAMS): $(needed_libs) ../common/libgpgrl.a

View File

@ -37,7 +37,7 @@
#include "keyserver-internal.h"
#include "call-agent.h"
#include "host2net.h"
#include "mbox-util.h"
#define MAX_PK_CACHE_ENTRIES PK_UID_CACHE_SIZE
#define MAX_UID_CACHE_ENTRIES PK_UID_CACHE_SIZE

View File

@ -44,6 +44,7 @@
#include "pkglue.h"
#include "../common/shareddefs.h"
#include "host2net.h"
#include "mbox-util.h"
/* The default algorithms. If you change them remember to change them

View File

@ -42,6 +42,8 @@
#include "i18n.h"
#include "status.h"
#include "call-agent.h"
#include "mbox-util.h"
static void list_all (int, int);
static void list_one (strlist_t names, int secret, int mark_secret);

View File

@ -176,13 +176,6 @@ int mpi_print (estream_t stream, gcry_mpi_t a, int mode);
unsigned int ecdsa_qbits_from_Q (unsigned int qbits);
/*-- mailbox.c --*/
int has_invalid_email_chars (const char *s);
int is_valid_mailbox (const char *name);
char *mailbox_from_userid (const char *userid);
int is_valid_user_id (const char *uid);
/*-- status.c --*/
void set_status_fd ( int fd );
int is_status_enabled ( void );

View File

@ -39,6 +39,7 @@
#include "keyserver-internal.h"
#include "photoid.h"
#include "pka.h"
#include "mbox-util.h"
/* Put an upper limit on nested packets. The 32 is an arbitrary