/*! \fn void read_usertab(const char *UserTabFile)
-Read the content fo the \a UserTabFile and store it for further use with get_usertab_name().
+Read the content of the \a UserTabFile and store it for further use with get_usertab_name().
The file contains the IP address or ID of the user then some spaces and the real name of the user.
+
+Any trailing space or tabulation is removed from the real name. The user ID or IP cannot contain
+a space or a tabulation but it may contain any other character, including the colon that was
+forbidden in the past. That change was made to allow IPv6 addresses.
+
The file may contain comments if the line starts with a #.
\param UserTabFile The name of the file to read. If it is empty, the function does nothing.
char bufy[MAXLEN];
int z2;
int z1;
+ int i;
if (UserTabFile[0] != '\0') {
if(debug) {
fprintf(stderr, "SARG ERROR: %s",text[87]);
exit(1);
}
- strcpy(userfile,":");
+ strcpy(userfile,"\t");
z2=1;
while(fgets(buf,sizeof(buf),fp_usr)!=NULL) {
if (buf[0]=='#') continue;
- buf[strlen(buf)-1]='\0';
- if(strstr(buf,"\r") != 0) buf[strlen(buf)-1]='\0';
+ for (i=strlen(buf)-1 ; i>=0 && (unsigned char)buf[i]<=' ' ; i--) buf[i]=0;
if (getword_multisep(bufy,sizeof(bufy),buf,' ')<0) {
printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",UserTabFile);
exit(1);
}
for(z1=0; bufy[z1]; z1++)
userfile[z2++]=bufy[z1];
- userfile[z2++]='|';
+ userfile[z2++]='\n';
for(z1=0; buf[z1]; z1++)
userfile[z2++]=buf[z1];
- userfile[z2++]=':';
+ userfile[z2++]='\t';
}
userfile[z2]=0;
fclose(fp_usr);
strncpy(name,user,namelen);
name[namelen]=0;
} else {
- sprintf(warea,":%s|",user);
+ sprintf(warea,"\t%s\n",user);
if((str=(char *) strstr(userfile,warea)) == (char *) NULL ) {
strncpy(name,user,namelen);
name[namelen]=0;
} else {
- str=strchr(str+1,'|');
+ str=strchr(str+1,'\n');
str++;
- for(z1=0; *str != ':' && z1<namelen ; z1++) {
+ for(z1=0; *str != '\t' && z1<namelen ; z1++) {
name[z1]=*str++;
}
name[z1]=0;