1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- /**
- * saop: smtp authentication over pop3
- * Copyright (C) 2007 Juan José Gutiérrez de Quevedo <juanjo@iteisa.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * @author Juan José Gutiérrez de Quevedo <juanjo@iteisa.com>
- */
- #include "config.h"
- void read_config(char *file,struct config_t *config)
- {
- char line[1024]={0};
- FILE *f;
- unsigned long i,j;
- if(NULL==(f=fopen(file,"r")))
- {
- printf("No config file found, continuing with defaults.\n");
- return;
- }
- while(!feof(f))
- {
- fgets(line,sizeof(line),f);
- if(!feof(f)&&'#'!=line[0]&&'\0'!=line[0]&&'\r'!=line[0]&&'\n'!=line[0])
- {
- for(i=0,j=0;i<strlen(line);i++)
- if(!isspace(line[i])&&'\r'!=line[i]&&'\n'!=line[i])
- line[j++]=line[i];
- line[j]='\0';
- #define PROCESS_CONFIG_OPTION_STR(x) if(!cmp(line,#x "=")) strncpy(config->x,line+strlen(#x "="),sizeof(config->x)); else
- #define PROCESS_CONFIG_OPTION_INT(x) if(!cmp(line,#x "=")) config->x=atoi(line+strlen(#x "=")); else
- #define PROCESS_CONFIG_OPTION_BOOL(x) if(!cmp(line,#x "=")) config->x=cmp(line+strlen(#x "="),"true")?0:1; else
- #ifndef WIN32
- PROCESS_CONFIG_OPTION_BOOL(background)
- PROCESS_CONFIG_OPTION_BOOL(drop_privileges)
- PROCESS_CONFIG_OPTION_STR(user)
- PROCESS_CONFIG_OPTION_STR(group)
- PROCESS_CONFIG_OPTION_STR(chroot)
- #endif /* WIN32 */
- PROCESS_CONFIG_OPTION_INT(listen_port)
- PROCESS_CONFIG_OPTION_STR(smtp_server)
- PROCESS_CONFIG_OPTION_INT(smtp_port)
- PROCESS_CONFIG_OPTION_STR(auth_server)
- PROCESS_CONFIG_OPTION_INT(auth_port)
- PROCESS_CONFIG_OPTION_STR(auth_file)
- PROCESS_CONFIG_OPTION_STR(local_domains)
- PROCESS_CONFIG_OPTION_STR(auth_method)
- printf("Option line %s not recognized\n",line); /* keep in mind this line comes after an else, so it won't get executed normally */
- }
- }
- fclose(f);
- }
|