From 240451a26e3e1fdabe0451a33f8918d4adfa852b Mon Sep 17 00:00:00 2001
From: Werner Koch <wk@gnupg.org>
Date: Thu, 26 Feb 2015 16:08:02 +0100
Subject: [PATCH] Move two functions from g10/ to util/.

* g10/misc.c (has_invalid_email_chars, is_valid_mailbox): Move to ...
* util/strgutil.c: here.

Signed-off-by: Werner Koch <wk@gnupg.org>
---
 g10/main.h      |  2 --
 g10/misc.c      | 48 -----------------------------------------------
 util/strgutil.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/g10/main.h b/g10/main.h
index 05b60bba9..dbc8d8f10 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -125,8 +125,6 @@ char *argsplit(char *string);
 int parse_options(char *str,unsigned int *options,
 		  struct parse_options *opts,int noisy);
 char *unescape_percent_string (const unsigned char *s);
-int has_invalid_email_chars (const char *s);
-int is_valid_mailbox (const char *name);
 char *default_homedir (void);
 const char *get_libexecdir (void);
 int path_access(const char *file,int mode);
diff --git a/g10/misc.c b/g10/misc.c
index 2c5c6cca3..2b38a8fcc 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -1141,54 +1141,6 @@ unescape_percent_string (const unsigned char *s)
 }
 
 
-/* Check whether the string has characters not valid in an RFC-822
-   address.  To cope with OpenPGP we ignore non-ascii characters
-   so that for example umlauts are legal in an email address.  An
-   OpenPGP user ID must be utf-8 encoded but there is no strict
-   requirement for RFC-822.  Thus to avoid IDNA encoding we put the
-   address verbatim as utf-8 into the user ID under the assumption
-   that mail programs handle IDNA at a lower level and take OpenPGP
-   user IDs as utf-8.  Note that we can't do an utf-8 encoding
-   checking here because in keygen.c this function is called with the
-   native encoding and native to utf-8 encoding is only done  later.  */
-int
-has_invalid_email_chars (const char *s)
-{
-  int at_seen=0;
-  const char *valid_chars=
-    "01234567890_-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
-  for ( ; *s; s++ )
-    {
-      if ( *s & 0x80 )
-        continue; /* We only care about ASCII.  */
-      if ( *s == '@' )
-        at_seen=1;
-      else if ( !at_seen && !( !!strchr( valid_chars, *s ) || *s == '+' ) )
-        return 1;
-      else if ( at_seen && !strchr( valid_chars, *s ) )
-        return 1;
-    }
-  return 0;
-}
-
-
-/* Check whether NAME represents a valid mailbox according to
-   RFC822. Returns true if so. */
-int
-is_valid_mailbox (const char *name)
-{
-  return !( !name
-            || !*name
-            || has_invalid_email_chars (name)
-            || string_count_chr (name,'@') != 1
-            || *name == '@'
-            || name[strlen(name)-1] == '@'
-            || name[strlen(name)-1] == '.'
-            || strstr (name, "..") );
-}
-
-
 /* This is a helper function to load a Windows function from either of
    one DLLs. */
 #ifdef HAVE_W32_SYSTEM
diff --git a/util/strgutil.c b/util/strgutil.c
index 402881a6e..620fb33bc 100644
--- a/util/strgutil.c
+++ b/util/strgutil.c
@@ -455,6 +455,56 @@ string_count_chr( const char *string, int c )
     return count;
 }
 
+
+/* Check whether the string has characters not valid in an RFC-822
+   address.  To cope with OpenPGP we ignore non-ascii characters
+   so that for example umlauts are legal in an email address.  An
+   OpenPGP user ID must be utf-8 encoded but there is no strict
+   requirement for RFC-822.  Thus to avoid IDNA encoding we put the
+   address verbatim as utf-8 into the user ID under the assumption
+   that mail programs handle IDNA at a lower level and take OpenPGP
+   user IDs as utf-8.  Note that we can't do an utf-8 encoding
+   checking here because in keygen.c this function is called with the
+   native encoding and native to utf-8 encoding is only done  later.  */
+int
+has_invalid_email_chars (const char *s)
+{
+  int at_seen=0;
+  const char *valid_chars=
+    "01234567890_-.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+  for ( ; *s; s++ )
+    {
+      if ( *s & 0x80 )
+        continue; /* We only care about ASCII.  */
+      if ( *s == '@' )
+        at_seen=1;
+      else if ( !at_seen && !( !!strchr( valid_chars, *s ) || *s == '+' ) )
+        return 1;
+      else if ( at_seen && !strchr( valid_chars, *s ) )
+        return 1;
+    }
+  return 0;
+}
+
+
+/* Check whether NAME represents a valid mailbox according t
+   RFC822. Returns true if so.  */
+int
+is_valid_mailbox (const char *name)
+{
+  return !( !name
+            || !*name
+            || has_invalid_email_chars (name)
+            || string_count_chr (name,'@') != 1
+            || *name == '@'
+            || name[strlen(name)-1] == '@'
+            || name[strlen(name)-1] == '.'
+            || strstr (name, "..") );
+}
+
+
+
 #ifdef USE_GNUPG_ICONV
 static void
 handle_iconv_error (const char *to, const char *from, int use_fallback)