void parse_openvpn_status(int unit){
FILE *fpi, *fpo;
char buf[512];
char *token;
sprintf(buf, "/etc/openvpn/server%d/status", unit);
fpi = fopen(buf, "r");
sprintf(buf, "/etc/openvpn/server%d/client_status", unit);
fpo = fopen(buf, "w");
if(fpi && fpo) {
while(!feof(fpi)){
CLEAR(buf);
if (!fgets(buf, sizeof(buf), fpi))
break;
if(!strncmp(buf, "CLIENT_LIST", 11)) {
//printf("%s", buf);
token = strtok(buf, ","); //CLIENT_LIST
token = strtok(NULL, ","); //Common Name
token = strtok(NULL, ","); //Real Address
fprintf(fpo, "%s ", token);
token = strtok(NULL, ","); //Virtual Address
fprintf(fpo, "%s ", token);
token = strtok(NULL, ","); //Bytes Received
token = strtok(NULL, ","); //Bytes Sent
token = strtok(NULL, ","); //Connected Since
token = strtok(NULL, ","); //Connected Since (time_t)
[B]token = strtok(NULL, ","); //Username, include'\n'[/B]
fprintf(fpo, "%s", token);
}
}
fclose(fpi);
fclose(fpo);
}
}