]>
jfr.im git - irc/gameservirc.git/blob - gameserv/config.cpp
6 void load_config_file(char *config
);
7 void unload_config_file();
8 int stricmp(const char *s1
, const char *s2
);
9 int strnicmp(const char *s1
, const char *s2
, size_t len
);
11 /* Random Configuration Stuff Goes Here until I code it to load from a .conf file :)*/
13 char *s_GameServ
; // GameServ's nickname
14 char *gshost
; // GameServ's Hostname
15 char *gsident
; // GameServ's ident/username
16 char *servername
; // GameServ's Server
17 char *c_Forest
; // Forest channel
18 char *c_ForestTopic
; // Forest Channel Topic
21 // Remote server stuff. This is used for the outgoing connection gameserv needs to make
23 char *remoteserver
; // Server to connect to
24 char *remoteport
; // Port to connect to on remoteserver
25 char *remotepass
; // Password for the server link
27 char *playerdata
; // File to store player data in
29 void unload_config_file()
52 void load_config_file(char *config
)
54 char *buf
, *directive
, *value
;
63 cerr
<< "Error opening " << config
<< endl
;
67 while (infile
.getline(buf
, 1024, '\n'))
69 cout
<< "Buf: " << buf
<< endl
;
71 if (buf
[0] == '#' || buf
[0] == ' ' || buf
[0] == '\0')
74 directive
= strtok(buf
, " ");
76 if (stricmp(directive
, "S_GAMESERV") == 0)
78 value
= strtok(NULL
, " ");
79 s_GameServ
= new char[strlen(value
) + 1];
80 strcpy(s_GameServ
, value
);
82 else if (stricmp(directive
, "GSHOST") == 0)
84 value
= strtok(NULL
, " ");
85 gshost
= new char[strlen(value
) + 1];
86 strcpy(gshost
, value
);
88 else if (stricmp(directive
, "GSIDENT") == 0)
90 value
= strtok(NULL
, " ");
91 gsident
= new char[strlen(value
) + 1];
92 strcpy(gsident
, value
);
94 else if (stricmp(directive
, "SERVERNAME") == 0)
96 value
= strtok(NULL
, " ");
97 servername
= new char[strlen(value
) + 1];
98 strcpy(servername
, value
);
100 else if (stricmp(directive
, "C_FOREST") == 0)
102 value
= strtok(NULL
, " ");
103 c_Forest
= new char[strlen(value
) + 1];
104 strcpy(c_Forest
, value
);
106 else if (stricmp(directive
, "C_FORESTTOPIC") == 0)
108 value
= strtok(NULL
, "");
109 c_ForestTopic
= new char[strlen(value
) + 1];
110 strcpy(c_ForestTopic
, value
);
112 else if (stricmp(directive
, "REMOTESERVER") == 0)
114 value
= strtok(NULL
, " ");
115 remoteserver
= new char[strlen(value
) + 1];
116 strcpy(remoteserver
, value
);
118 else if (stricmp(directive
, "REMOTEPORT") == 0)
120 value
= strtok(NULL
, " ");
121 remoteport
= new char[strlen(value
) + 1];
122 strcpy(remoteport
, value
);
124 else if (stricmp(directive
, "REMOTEPASS") == 0)
126 value
= strtok(NULL
, "");
127 remotepass
= new char[strlen(value
) + 1];
128 strcpy(remotepass
, value
);
130 else if (stricmp(directive
, "PLAYERDATA") == 0)
132 value
= strtok(NULL
, "");
133 playerdata
= new char[strlen(value
) + 1];
134 strcpy(playerdata
, value
);
138 cerr
<< "Unknown Directive. Buffer: " << buf
<< endl
;