1 /* config.c - Functions which reads a config file to set the bot
2 * ===============================================================
4 * The `CONFIG_FILE' macro is set in `config.h', this macro
5 * sets the path where the config file is.
6 *******************************************************************/
14 struct _config
*set_config( void ){
16 struct _config
*config
= NULL
;
18 /* Now we open the `CONFIG_FILE'. If an error happend, show a
19 * message, and return NULL.
20 ****************************************************************/
21 c_file
= fopen( CONFIG_FILE
, "r" );
22 if( c_file
== (FILE *)NULL
){
23 printf("\n%s: %s\n", CONFIG_FILE
, strerror( errno
) );
24 return (struct _config
*)NULL
;
27 config
= (struct _config
*) malloc( sizeof(struct _config
) );
30 /* Now we read the `CONFIG_FILE' and store the info into
31 * the config structure.
32 ***************************************************************/
33 fscanf( c_file
, "server: %s\n", config
->irc_server
);
34 fscanf( c_file
, "port: %d\n", &config
->irc_port
);
35 fscanf( c_file
, "channel: %s\n", config
->irc_channel
);
36 fscanf( c_file
, "nick: %s\n", config
->irc_nick
);
38 fclose( c_file
); /* Close the `CONFIG_FILE' */