[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Add a "router_add_exit_policy_from_string" function.



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv23186

Modified Files:
	routers.c 
Log Message:
Add a "router_add_exit_policy_from_string" function.

Index: routers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routers.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- routers.c	7 Oct 2003 16:56:27 -0000	1.70
+++ routers.c	7 Oct 2003 22:09:09 -0000	1.71
@@ -946,6 +946,29 @@
   }
 }
 
+int router_add_exit_policy_from_string(routerinfo_t *router,
+                                       char *s)
+{
+  directory_token_t tok;
+  char *tmp, *cp;
+  int r;
+
+  tmp = cp = tor_strdup(s);
+  if (router_get_next_token(&cp, &tok)) {
+    log_fn(LOG_WARNING, "Error reading exit policy: %s", tok.val.error);
+    free(tmp);
+    return -1;                                                        
+  }
+  if (tok.tp != K_ACCEPT && tok.tp != K_REJECT) {
+    log_fn(LOG_WARNING, "Expected 'accept' or 'reject'.");
+    free(tmp);
+    return -1;
+  }
+  r = router_add_exit_policy(router, &tok);
+  free(tmp);
+  return r;
+}
+
 static int router_add_exit_policy(routerinfo_t *router, 
                                   directory_token_t *tok) {
   struct exit_policy_t *tmpe, *newe;