void write_chap_secret(char *file) { FILE *fp; char *nv, *nvp, *b; char *username, *passwd; char namebuf[256], passwdbuf[256]; fp=fopen(file, "w"); if (fp==NULL) return; nv = nvp = strdup(nvram_safe_get("pptpd_clientlist")); if(nv) { while ((b = strsep(&nvp, "<")) != NULL) { if((vstrsep(b, ">", &username, &passwd)!=2)) continue; if(strlen(username)==0||strlen(passwd)==0) continue; fprintf(fp, "%s * %s *\n", pptp_encode(username, namebuf), pptp_encode(passwd, passwdbuf)); } free(nv); } fclose(fp); }
void write_chap_secret(char *file) { FILE *fp; char nv[MAXLEN_TCAPI_MSG], *nvp, *b; char *username, *passwd; char namebuf[256], passwdbuf[256]; int index = 1; char listname[32] = {0}; fp=fopen(file, "w"); if (fp==NULL) return; if( tcapi_get(VPN_DATA, "pptpd_clientlist", nv) == TCAPI_PROCESS_OK) { nvp = nv; while ((b = strsep(&nvp, "<")) != NULL) { if((vstrsep(b, ">", &username, &passwd)!=2)) continue; if(strlen(username)==0||strlen(passwd)==0) continue; fprintf(fp, "%s * %s *\n", pptp_encode(username, namebuf), pptp_encode(passwd, passwdbuf)); } } for(index = 1; index < 16; index++) { memset(nv, 0, sizeof(nv)); sprintf(listname, "pptpd_clientlist%d", index); if( tcapi_get(VPN_DATA, listname, nv) == TCAPI_PROCESS_OK) { nvp = nv; while ((b = strsep(&nvp, "<")) != NULL) { if((vstrsep(b, ">", &username, &passwd)!=2)) continue; if(strlen(username)==0||strlen(passwd)==0) continue; fprintf(fp, "%s * %s *\n", pptp_encode(username, namebuf), pptp_encode(passwd, passwdbuf)); } } } fclose(fp); }