Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: [Patch] Watchtower v3
Home

[Freeciv-Dev] Re: [Patch] Watchtower v3

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Freeciv Developers <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [Patch] Watchtower v3
From: Justin Moore <justin@xxxxxxxxxxx>
Date: Thu, 30 Aug 2001 17:51:43 -0400 (EDT)

> > I totaly disagree here. The opposite would be useful: make all
> > rulesets server variables. Especialy on meta server games it is
> > a pain that you still can not change citymindist at runtime.
>
> That's what he was suggesting, basically.
>
> This qwould require a better (.e. half-decent) server cmdline parsing
> mechanism, strtok() at the least.  That way it becomes easier to extend
> the syntax, which is required to represent all ruleset variables.

   How about something like this?  PERL-like split syntax, and the ability
to split on several different characters simultaneously (but always on
whitespace).  As always, memory allocation rears its ugly head, but not
too badly.  Sample code:

  char *str = "foo bar.baz=5";
  int nargs;
  char **ptrs;
  char **subptrs;

  ptrs = fc_malloc(3 * sizeof(char *));
  nargs = split("=", str, strlen(str), ptrs, 3);
  if(nargs < 3) { err_msg(); }
  /* ptrs[0] = "foo", ptrs[1] = "bar.baz", ptrs[2] = "5" */

  subptrs = fc_malloc(2 * sizeof(char*));
  nargs = split(".", ptrs[1], strlen(ptrs[1]), subptrs, 2);
  if(nargs < 2) { err_msg2(); }
  /* subptrs[0] = "bar", subptrs[1] = "baz" */

  /* ... do stuff ... */

  free(subptrs);
  free(ptrs);

-jdm

Department of Computer Science, Duke University, Durham, NC 27708-0129
Email:  justin@xxxxxxxxxxx

Attachment: split-stdinhand-cvs.patch
Description: PERL-like split


[Prev in Thread] Current Thread [Next in Thread]