]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - string.c
Implement client-server feature negotiation.
[paraslash.git] / string.c
index a1f2a43c65756dc6ce066a5b6707c91b94f4c7d4..7123ba1ae5e00dfc13e1417bfbafd102c3946175 100644 (file)
--- a/string.c
+++ b/string.c
@@ -128,7 +128,8 @@ __must_check __malloc char *para_strdup(const char *s)
  * function calls exit() if insufficient memory is available, while vasprintf()
  * returns -1 in this case.
  *
- * \return Number of bytes written, not including the terminating '\0'.
+ * \return Number of bytes written, not including the terminating \p NULL
+ * character.
  *
  * \sa printf(3), vsnprintf(3), va_start(3), vasprintf(3), \ref xasprintf().
  */
@@ -854,6 +855,27 @@ err:
        return ret;
 }
 
+/**
+ * Find out if the given string is contained in the arg vector.
+ *
+ * \param arg The string to look for.
+ * \param argv The array to search.
+ *
+ * \return The first index whose value equals \a arg, or \p -E_ARG_NOT_FOUND if
+ * arg was not found in \a argv.
+ */
+int find_arg(const char *arg, char **argv)
+{
+       int i;
+
+       if (!argv)
+               return -E_ARG_NOT_FOUND;
+       for (i = 0; argv[i]; i++)
+               if (strcmp(arg, argv[i]) == 0)
+                       return i;
+       return -E_ARG_NOT_FOUND;
+}
+
 /**
  * Compile a regular expression.
  *