+static int getparam_select(const char *param,struct select_list *options,int noptions,char *buf,int *value)
+{
+ int plen;
+ char *str;
+ int i;
+
+ plen=strlen(param);
+ if (strncmp(buf,param,plen) != 0) return(0);
+ buf+=plen;
+ if ((unsigned char)*buf>' ') return(0);
+ while (*buf && (unsigned char)*buf<=' ') buf++;
+
+ str=buf;
+ while (*buf && (unsigned char)*buf>' ' && *buf!=';') buf++;
+ *buf='\0';
+ for (i=0 ; i<noptions && strcasecmp(str,options[i].name) ; i++);
+ if (i>=noptions) {
+ debuga(__FILE__,__LINE__,_("Unknown value \"%s\" for parameter \"%s\"\n"),str,param);
+ exit(EXIT_FAILURE);
+ }
+ *value=options[i].value;
+ return(1);
+}
+
+static int getparam_userlimit(const char *param,char *buf)
+{
+ int plen;
+ char *file_begin,*file_end;
+ int limit;
+ int digit;
+ char *str;
+ int i;
+ enum PerUserOutputEnum output;
+ const struct
+ {
+ const char *name;
+ enum PerUserOutputEnum value;
+ } output_types[]=
+ {
+ {"id",PUOE_UserId},
+ {"ip",PUOE_UserIp},
+ };
+
+ plen=strlen(param);
+ if (strncmp(buf,param,plen) != 0) return(0);
+ buf+=plen;
+ if ((unsigned char)*buf>' ') return(0);
+ while (*buf && (unsigned char)*buf<=' ') buf++;
+
+ /*
+ options are made of a file name, an integer limit and an optional
+ integer flag. The file name may contain spaces. We keep searching
+ until a valid number is found after a space.
+ */
+ file_begin=buf;
+ do {
+ while (*buf && (unsigned char)*buf>' ') buf++;
+ if (*buf!=' ') {
+ debuga(__FILE__,__LINE__,_("Missing limit in per_user_limit\n"));
+ exit(EXIT_FAILURE);
+ }
+ file_end=buf;
+ while (*buf && (unsigned char)*buf<=' ') buf++;
+ limit=0;
+ while (*buf && isdigit(*buf)) {
+ digit=*buf-'0';
+ if (limit>=(INT_MAX-digit)/10) break;
+ limit=limit*10+digit;
+ buf++;
+ }
+ } while (*buf && *buf!=' ');
+
+ output=PUOE_UserId;
+ if (*buf==' ') {
+ while (*buf && (unsigned char)*buf<=' ') buf++;
+ str=buf;
+ while (*buf && (unsigned char)*buf>' ') buf++;
+ *buf='\0';
+ for (i=sizeof(output_types)/sizeof(output_types[0])-1 ; i>=0 ; i--)
+ if (strcasecmp(output_types[i].name,str)==0) {
+ output=output_types[i].value;
+ break;
+ }
+ if (i<0) {
+ debuga(__FILE__,__LINE__,_("Invalid output type in per_user_limit\n"));
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ if (PerUserLimitsNumber>=MAX_USER_LIMITS) {
+ debuga(__FILE__,__LINE__,_("Too many per_user_limit\n"));
+ exit(EXIT_FAILURE);
+ }
+ *file_end='\0';
+ safe_strcpy(PerUserLimits[PerUserLimitsNumber].File,file_begin,sizeof(PerUserLimits[PerUserLimitsNumber].File));
+ PerUserLimits[PerUserLimitsNumber].Limit=limit;
+ PerUserLimits[PerUserLimitsNumber].Output=output;
+ PerUserLimitsNumber++;
+
+ return(1);
+}
+
+static void ccharset(char *CharSet)
+{
+ if (strcmp(CharSet,"Latin2") == 0) strcpy(CharSet,"ISO-8859-2");
+ else if (strcmp(CharSet,"Latin3") == 0) strcpy(CharSet,"ISO-8859-3");
+ else if (strcmp(CharSet,"Latin4") == 0) strcpy(CharSet,"ISO-8859-4");
+ else if (strcmp(CharSet,"Cyrillic") == 0) strcpy(CharSet,"ISO-8859-5");
+ else if (strcmp(CharSet,"Arabic") == 0) strcpy(CharSet,"ISO-8859-6");
+ else if (strcmp(CharSet,"Greek") == 0) strcpy(CharSet,"ISO-8859-7");
+ else if (strcmp(CharSet,"Hebrew") == 0) strcpy(CharSet,"ISO-8859-8");
+ else if (strcmp(CharSet,"Latin5") == 0) strcpy(CharSet,"ISO-8859-9");
+ else if (strcmp(CharSet,"Latin6") == 0) strcpy(CharSet,"ISO-8859-10");
+ else if (strcmp(CharSet,"Japan") == 0) strcpy(CharSet,"EUC-JP");
+ else if (strcmp(CharSet,"Koi8-r") == 0) strcpy(CharSet,"KOI8-R");
+ /*
+ * Any other encoding name is left unchanged.
+ */
+ return;
+}
+