+// Takes a series of char *'s in
+/**
+ * \brief Parse space-separated entries into
+ */
+int Server_int_ParseArgs(int bUseLongLast, char *ArgStr, ...)
+{
+ va_list args;
+ char savedChar;
+ char **dest;
+ va_start(args, ArgStr);
+
+ // Check for null
+ if( !ArgStr )
+ {
+ while( (dest = va_arg(args, char **)) )
+ *dest = NULL;
+ va_end(args);
+ return 1;
+ }
+
+ savedChar = *ArgStr;
+
+ while( (dest = va_arg(args, char **)) )
+ {
+ // Trim leading spaces
+ while( *ArgStr == ' ' || *ArgStr == '\t' )
+ ArgStr ++;
+
+ // ... oops, not enough arguments
+ if( *ArgStr == '\0' )
+ {
+ // NULL unset arguments
+ do {
+ *dest = NULL;
+ } while( (dest = va_arg(args, char **)) );
+ va_end(args);
+ return -1;
+ }
+
+ if( *ArgStr == '"' )
+ {
+ ArgStr ++;
+ *dest = ArgStr;
+ // Read until quote
+ while( *ArgStr && *ArgStr != '"' )
+ ArgStr ++;
+ }
+ else
+ {
+ // Set destination
+ *dest = ArgStr;
+ // Read until a space
+ while( *ArgStr && *ArgStr != ' ' && *ArgStr != '\t' )
+ ArgStr ++;
+ }
+ savedChar = *ArgStr; // savedChar is used to un-mangle the last string
+ *ArgStr = '\0';
+ ArgStr ++;
+ }
+ va_end(args);
+
+ // Oops, extra arguments, and greedy not set
+ if( (savedChar == ' ' || savedChar == '\t') && !bUseLongLast ) {
+ return -1;
+ }
+
+ // Un-mangle last
+ if(bUseLongLast) {
+ ArgStr --;
+ *ArgStr = savedChar;
+ }
+
+ return 0; // Success!
+}
+