c user the getpass command to get the users password as it is secure. modified getstr so is the field is secure and there is an existing string a - will remove the data
e
s 00001/00000/00228
d D 1.3 95/07/06 14:49:16 tim 3 2
c forgot to include pwd.h, now fixed
e
s 00013/00000/00215
d D 1.2 95/07/06 14:12:37 tim 2 1
c getuname moved from talktopopconfig to talktopopconf so it is available to
c talktopop
e
s 00215/00000/00000
d D 1.1 95/07/06 14:00:28 tim 1 0
c
e
u
U
f e 0
t
T
I 1
/* this is a library of routines to read / write config files
and deal with passwords etc. */
/* the file format is
username
password
pop server name
number of output file to start with
delete flag
extract from start or end of mail file
verbose flag
max size of email to retrieve
max number of emails to retrieve
pop server name (e.g. pop-3)
pop protocol name (e.g. tcp)
*/
#include "talktopop.h"
#include <stdio.h>
#include <string.h>
I 4
#include <stdlib.h>
E 4
I 3
#include <pwd.h>
E 3
extern char popserver [] ;
extern char popname [] ;
extern char protname [] ;
extern char uname [] ;
extern char passwd [] ;
extern int filestartno ;
extern int dodel ;
extern int direction ;
extern int verbose ;
extern int maxsize ;
extern int maxemail ;
extern int hnset, unset, pwset ;
confinit()
{
strcpy(popserver, "") ;
strcpy(popname, POPNAME) ;
strcpy(protname, PROTNAME) ;
strcpy(uname, "") ;
strcpy(passwd, "") ;
filestartno = 0 ;
dodel - FALSE ;
direction = TRUE ;
verbose = FALSE ;
maxsize = MAXSIZE ;
maxemail = MAXCOUNT ;
hnset = unset = pwset = FALSE ;
}
readconf()
{
FILE * fd ;
char tmp[1024] ;
int ret ;
if ((fd = fopen(POPCONF, "r")) == NULL)
return ;
if (getline(fd, uname) == TRUE) /* username */
unset = TRUE ;
if (getline(fd, passwd) == TRUE) /* password */
pwset = TRUE ;
if (getline(fd, popserver) == TRUE) /* server name */
hnset = TRUE ;
if (getline(fd, tmp) == TRUE) /* output file start number */
filestartno = atoi(tmp) ;
if (getline(fd, tmp) == TRUE) /* delete flag */
{
if (tmp[0] == 'T')
dodel = TRUE ;
else
dodel = FALSE ;
}
if (getline(fd, tmp) == TRUE) /* start from begining or end of mail file */
{
if (tmp[0] == 'T')
direction = TRUE ;
else
direction = FALSE ;
}
if (getline(fd, tmp) == TRUE) /* be verbose or not */
{
if (tmp[0] == 'T')
verbose = TRUE ;
else
verbose = FALSE ;
}
if (getline(fd, tmp) == TRUE) /* max email size */
maxsize = atoi(tmp) ;
if (getline(fd, tmp) == TRUE) /* max emails to retrieve */
maxemail = atoi(tmp) ;
getline(fd, popname) ;
getline(fd, protname) ;
fclose(fd) ;
}
writeconf()
{
FILE * fd ;
if ((fd = fopen(POPCONF, "w")) == NULL)
{
printf("ERROR, Cant open %s to write pop output file\n") ;