]>
jfr.im git - irc/gameservirc.git/blob - gameserv/config.cpp
6 void load_config_file(char *config
);
7 void unload_config_file();
9 /* Random Configuration Stuff Goes Here until I code it to load from a .conf file :)*/
11 char *s_GameServ
; // GameServ's nickname
12 char *gshost
; // GameServ's Hostname
13 char *gsident
; // GameServ's ident/username
14 char *servername
; // GameServ's Server
15 char *c_Forest
; // Forest channel
16 char *c_ForestTopic
; // Forest Channel Topic
17 char *adminpass
; // Administrator password
20 // Remote server stuff. This is used for the outgoing connection gameserv needs to make
22 char *remoteserver
; // Server to connect to
23 char *remoteport
; // Port to connect to on remoteserver
24 char *remotepass
; // Password for the server link
26 char *playerdata
; // File to store player data in
28 void unload_config_file()
41 delete [] c_ForestTopic
;
43 delete [] remoteserver
;
53 void load_config_file(char *config
)
55 char *buf
, *directive
, *value
;
64 cout
<< "Error opening " << config
<< endl
;
68 while (infile
.getline(buf
, 1024, '\n'))
70 cout
<< "Buf: " << buf
<< endl
;
72 if (buf
[0] == '#' || buf
[0] == ' ' || buf
[0] == '\0' || buf
[0] == '\n' || buf
[0] == '\r')
75 directive
= strtok(buf
, " ");
77 if (stricmp(directive
, "S_GAMESERV") == 0)
79 value
= strtok(NULL
, " ");
80 s_GameServ
= new char[strlen(value
) + 1];
81 strcpy(s_GameServ
, value
);
83 else if (stricmp(directive
, "GSHOST") == 0)
85 value
= strtok(NULL
, " ");
86 gshost
= new char[strlen(value
) + 1];
87 strcpy(gshost
, value
);
89 else if (stricmp(directive
, "GSIDENT") == 0)
91 value
= strtok(NULL
, " ");
92 gsident
= new char[strlen(value
) + 1];
93 strcpy(gsident
, value
);
95 else if (stricmp(directive
, "SERVERNAME") == 0)
97 value
= strtok(NULL
, " ");
98 servername
= new char[strlen(value
) + 1];
99 strcpy(servername
, value
);
101 else if (stricmp(directive
, "C_FOREST") == 0)
103 value
= strtok(NULL
, " ");
104 c_Forest
= new char[strlen(value
) + 1];
105 strcpy(c_Forest
, value
);
107 else if (stricmp(directive
, "C_FORESTTOPIC") == 0)
109 value
= strtok(NULL
, "");
110 c_ForestTopic
= new char[strlen(value
) + 1];
111 strcpy(c_ForestTopic
, value
);
113 else if (stricmp(directive
, "REMOTESERVER") == 0)
115 value
= strtok(NULL
, " ");
116 remoteserver
= new char[strlen(value
) + 1];
117 strcpy(remoteserver
, value
);
119 else if (stricmp(directive
, "REMOTEPORT") == 0)
121 value
= strtok(NULL
, " ");
122 remoteport
= new char[strlen(value
) + 1];
123 strcpy(remoteport
, value
);
125 else if (stricmp(directive
, "REMOTEPASS") == 0)
127 value
= strtok(NULL
, "");
128 remotepass
= new char[strlen(value
) + 1];
129 strcpy(remotepass
, value
);
131 else if (stricmp(directive
, "PLAYERDATA") == 0)
133 value
= strtok(NULL
, "");
134 playerdata
= new char[strlen(value
) + 1];
135 strcpy(playerdata
, value
);
137 else if (stricmp(directive
, "ADMINPASS") == 0)
139 value
= strtok(NULL
, "");
140 adminpass
= new char[strlen(value
) + 1];
141 strcpy(adminpass
, value
);
145 cout
<< "Unknown Directive. Buffer: " << buf
<< endl
;