Implement client-server feature negotiation.
[paraslash.git] / string.c
index aa3bcbddabe425cc823e3ad5e567f707f70dbccb..7123ba1ae5e00dfc13e1417bfbafd102c3946175 100644 (file)
--- a/string.c
+++ b/string.c
@@ -855,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.
  *