[Commit] rrserver array.5c,NONE,1.1 boards.5c,NONE,1.1 connect.5c,NONE,1.1 dispatch.5c,NONE,1.1 games.5c,NONE,1.1 lex.5c,NONE,1.1 main.5c,NONE,1.1 net.5c,NONE,1.1 rr.5c,NONE,1.1 server.5c,NONE,1.1 show.5c,NONE,1.1 shuffle.5c,NONE,1.1 readreq.5c,1.1,1.2 rrnet.5c,1.1,NONE rrparse.5c,1.1,NONE rrproto.5c,1.1,NONE rrserver.5c,1.1,NONE rrservreq.5c,1.1,NONE

Keith Packard commit@keithp.com
Wed, 28 May 2003 23:45:39 -0700


Committed by: keithp

Update of /local/src/CVS/rrserver
In directory home.keithp.com:/tmp/cvs-serv15194

Modified Files:
	readreq.5c 
Added Files:
	array.5c boards.5c connect.5c dispatch.5c games.5c lex.5c 
	main.5c net.5c rr.5c server.5c show.5c shuffle.5c 
Removed Files:
	rrnet.5c rrparse.5c rrproto.5c rrserver.5c rrservreq.5c 
Log Message:
get board generation working, fix nickle file names to match namespaces (for autoload)

--- NEW FILE: array.5c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: boards.5c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: connect.5c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: dispatch.5c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: games.5c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: lex.5c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: main.5c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: net.5c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: rr.5c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: server.5c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: show.5c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: shuffle.5c ---
(This appears to be a binary file; contents omitted.)

Index: readreq.5c
===================================================================
RCS file: /local/src/CVS/rrserver/readreq.5c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- readreq.5c	28 May 2003 06:56:31 -0000	1.1
+++ readreq.5c	29 May 2003 06:45:37 -0000	1.2
@@ -22,73 +22,104 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-namespace Connection {
-    Client[0]    clients;
-
-    public void iterate (void (&Client c) f) {
-	for (int i = 0; i < dim (clients); i++)
-	    f (&clients[i]);
-    }
-
-    public exception no_such_client (file f);
-    
-    public &Client select (file f) {
-	exception found (&Client c);
-	try {
-	    void pick (&Client c) {
-		if (c.f == f)
-		    raise found (&c);
-	    }
-	    iterate (pick);
-	} catch found (&Client c) {
-	    return &c;
-	}
-        raise no_such_client (f);
-    }
-
-    public &Client new (file f) {
-	clients = (Client[dim(clients)+1]) { 
-	    [i] = i < dim(clients) ? 
-	    clients[i] : 
-	    (Client) { f = f, user = User.none, game = GameRef.none }
-	};
-	return &clients[dim(clients)-1];
-    }
+autoload RR::Lex
+autoload Ctype
 
-    public void dispose (&Client c) {
-	bool found = false;
-	
-	clients = (Client[dim(clients)-1]) { 
-	    [i] = found ? clients[i+1] : (&clients[i] == &c ? 
-					  (found=true, clients[i+1]) :
-					  clients[i])
-	};
-    }
+extend namespace Server {
+    public namespace Readreq {
+	public exception invalid_request (string w);
+	public exception request_closed ();
 
-    public void print (&Client c) {
-	printf ("%v\n", c);
-    }
+	import RR;
+	import Lex;
 
-}
+	string function upper (string s)
+	{
+	    string  r = "";
+	    for (int i = 0; i < String::length (s); i++)
+		r = r + String::new (Ctype::toupper (s[i]));
+	    return r;
+	}
 
-namespace Request {
-    public exception invalid_request (string w);
-    public RRRequest read (file f) {
-	switch (string w = RRLex::word (f)) {
-	case "HELO":
-	    return (RRRequest.HELO) (struct { string username; }) {
-		username = RRLex::rest (f)
-	    };
-	case "WHO":
-	    return RRRequest.WHO;
-	case "GAMES":
-	    return RRRequest.GAMES;
-	case "USERS":
-	    return (RRRequest.USERS) (struct { string game; }) {
-		game = RRLex::rest (f)
-	    };
-	default:
-	    raise invalid_request (w);
+	public Request read (file f) {
+	    struct {} packet;
+	    void username_ (&struct { string username; } packet) {
+		packet.username = word (f); 
+	    }
+	    void game_ (&struct { string game; } packet) {
+		packet.game = word (f); 
+	    }
+	    void number_ (&struct { int number; } packet) {
+		packet.number = number (f);
+	    }
+	    void color_ (&struct { Color color; } packet) {
+		packet.color = color (f);
+	    }
+	    void shape_ (&struct { Shape shape; } packet) {
+		packet.shape = shape (f);
+	    }
+	    void direction_ (&struct { Direction direction; } packet) {
+		packet.direction = direction (f);
+	    }
+	    void text_ (&struct { string text; } packet) {
+		packet.text = word (f);
+	    }
+	    switch (string w = upper (firstword (f))) {
+	    case "HELO":
+		packet = (struct { string username; }) {};
+		username_ (&packet);
+		return (Request.HELO) packet;
+	    case "WHO":
+		return Request.WHO;
+	    case "GAMES":
+		return Request.GAMES;
+	    case "USERS":
+		packet = (struct { string game; }) {};
+		game_ (&packet);
+		return (Request.USERS) packet;
+	    case "NEW":
+		packet = (struct { string game; }) {};
+		game_ (&packet);
+		return (Request.NEW) packet;
+	    case "JOIN":
+		packet = (struct { string game; }) {};
+		game_ (&packet);
+		return (Request.JOIN) packet;
+	    case "WATCH":
+		packet = (struct { string game; }) {};
+		game_ (&packet);
+		return (Request.WATCH) packet;
+	    case "SHOW":
+		return Request.SHOW;
+	    case "BID":
+		packet = (struct { int number; }) {};
+		number_ (&packet);
+		return (Request.BID) packet;
+	    case "MOVE":
+		packet = (struct { Color color; Direction direction; }) {};
+		color_ (&packet);
+		direction_ (&packet);
+		return (Request.MOVE) packet;
+	    case "UNDO":
+		return Request.UNDO;
+	    case "RESET":
+		return Request.RESET;
+	    case "TURN":
+		return Request.TURN;
+	    case "PASS":
+		return Request.PASS;
+	    case "MESSAGE":
+		packet = (struct { string text; }) {};
+		text_ (&packet);
+		return (Request.MESSAGE) packet;
+	    case "QUIT":
+		return Request.QUIT;
+	    case "":
+		raise request_closed ();
+	    default:
+		skipline (f);
+		raise invalid_request (w);
+	    }
 	}
     }
 }

--- rrnet.5c DELETED ---

--- rrparse.5c DELETED ---

--- rrproto.5c DELETED ---

--- rrserver.5c DELETED ---

--- rrservreq.5c DELETED ---