[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] clean up config.c so it doesn"t expose as much
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
config.c or.h
Log Message:
clean up config.c so it doesn't expose as much
Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- config.c 23 Aug 2003 10:09:25 -0000 1.39
+++ config.c 8 Sep 2003 05:16:18 -0000 1.40
@@ -4,8 +4,32 @@
#include "or.h"
+/* enumeration of types which option values can take */
+#define CONFIG_TYPE_STRING 0
+#define CONFIG_TYPE_CHAR 1
+#define CONFIG_TYPE_INT 2
+#define CONFIG_TYPE_LONG 3
+#define CONFIG_TYPE_DOUBLE 4
+#define CONFIG_TYPE_BOOL 5
+
+#define CONFIG_LINE_MAXLEN 1024
+
+struct config_line {
+ char *key;
+ char *value;
+ struct config_line *next;
+};
+
+static FILE *config_open(const unsigned char *filename);
+static int config_close(FILE *f);
+static struct config_line *config_get_commandlines(int argc, char **argv);
+static struct config_line *config_get_lines(FILE *f);
+static void config_free_lines(struct config_line *front);
+static int config_compare(struct config_line *c, char *key, int type, void *arg);
+static void config_assign(or_options_t *options, struct config_line *list);
+
/* open configuration file for reading */
-FILE *config_open(const unsigned char *filename) {
+static FILE *config_open(const unsigned char *filename) {
assert(filename);
if (strspn(filename,CONFIG_LEGAL_FILENAME_CHARACTERS) != strlen(filename)) {
/* filename has illegal letters */
@@ -15,12 +39,12 @@
}
/* close configuration file */
-int config_close(FILE *f) {
+static int config_close(FILE *f) {
assert(f);
return fclose(f);
}
-struct config_line *config_get_commandlines(int argc, char **argv) {
+static struct config_line *config_get_commandlines(int argc, char **argv) {
struct config_line *new;
struct config_line *front = NULL;
char *s;
@@ -51,7 +75,7 @@
/* parse the config file and strdup into key/value strings. Return list.
* Warn and ignore mangled lines. */
-struct config_line *config_get_lines(FILE *f) {
+static struct config_line *config_get_lines(FILE *f) {
struct config_line *new;
struct config_line *front = NULL;
char line[CONFIG_LINE_MAXLEN];
@@ -110,7 +134,7 @@
return front;
}
-void config_free_lines(struct config_line *front) {
+static void config_free_lines(struct config_line *front) {
struct config_line *tmp;
while(front) {
@@ -123,7 +147,7 @@
}
}
-int config_compare(struct config_line *c, char *key, int type, void *arg) {
+static int config_compare(struct config_line *c, char *key, int type, void *arg) {
int i;
if(strncasecmp(c->key,key,strlen(c->key)))
@@ -154,7 +178,7 @@
return 1;
}
-void config_assign(or_options_t *options, struct config_line *list) {
+static void config_assign(or_options_t *options, struct config_line *list) {
/* iterate through list. for each item convert as appropriate and assign to 'options'. */
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- or.h 7 Sep 2003 10:24:40 -0000 1.114
+++ or.h 8 Sep 2003 05:16:18 -0000 1.115
@@ -94,7 +94,7 @@
#include "../common/log.h"
#include "../common/util.h"
-#define RECOMMENDED_SOFTWARE_VERSIONS "0.0.2pre8"
+#define RECOMMENDED_SOFTWARE_VERSIONS "0.0.2pre7,0.0.2pre8"
#define MAXCONNECTIONS 1000 /* upper bound on max connections.
can be lowered by config file */
@@ -191,8 +191,6 @@
#define RELAY_HEADER_SIZE 8
-#define RELAY_STATE_RESOLVING
-
/* default cipher function */
#define DEFAULT_CIPHER CRYPTO_CIPHER_AES_CTR
/* Used to en/decrypt onion skins */
@@ -224,25 +222,9 @@
#define CELL_PAYLOAD_SIZE 248
#define CELL_NETWORK_SIZE 256
-/* enumeration of types which option values can take */
-#define CONFIG_TYPE_STRING 0
-#define CONFIG_TYPE_CHAR 1
-#define CONFIG_TYPE_INT 2
-#define CONFIG_TYPE_LONG 3
-#define CONFIG_TYPE_DOUBLE 4
-#define CONFIG_TYPE_BOOL 5
-
-#define CONFIG_LINE_MAXLEN 1024
-
/* legal characters in a filename */
#define CONFIG_LEGAL_FILENAME_CHARACTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/"
-struct config_line {
- char *key;
- char *value;
- struct config_line *next;
-};
-
typedef uint16_t aci_t;
/* cell definition */
@@ -320,9 +302,10 @@
*/
crypto_pk_env_t *pkey; /* public RSA key for the other side */
-#ifndef TOR_TLS
/* Used only by OR connections: */
-
+#ifdef TOR_TLS
+ tor_tls *tls;
+#else
/* link encryption */
crypto_cipher_env_t *f_crypto;
crypto_cipher_env_t *b_crypto;
@@ -441,10 +424,6 @@
uint8_t state;
-// unsigned char *onion; /* stores the onion when state is CONN_STATE_OPEN_WAIT */
-// uint32_t onionlen; /* total onion length */
-// uint32_t recvlen; /* length of the onion so far */
-
void *next;
};
@@ -583,24 +562,6 @@
void command_process_connected_cell(cell_t *cell, connection_t *conn);
/********************************* config.c ***************************/
-
-/* open configuration file for reading */
-FILE *config_open(const unsigned char *filename);
-
-/* close configuration file */
-int config_close(FILE *f);
-
-struct config_line *config_get_commandlines(int argc, char **argv);
-
-/* parse the config file and strdup into key/value strings. Return list.
- * * * Warn and ignore mangled lines. */
-struct config_line *config_get_lines(FILE *f);
-
-void config_free_lines(struct config_line *front);
-
-int config_compare(struct config_line *c, char *key, int type, void *arg);
-
-void config_assign(or_options_t *options, struct config_line *list);
/* return 0 if success, <0 if failure. */
int getconfig(int argc, char **argv, or_options_t *options);