|
本帖最后由 fugq0fff 于 2010-5-4 13:04 编辑
跟这个c语言一样功能的脚本怎么写 不好意思昨天没有看清楚发错了 sh的脚本 现在重发
#include <stdio.h>
#include <stdlib.h>
#define MAX 1024
int checkpsw(char *username, char *password)
{
FILE *f;
char user[MAX+2], pass[MAX+2], active[MAX+2];
/* printf("%s,%s\n",username,password); */
if (!(f=fopen("up.dll", "r")))
{
perror("Open PASSWORD file error");
printf("Use up.dll as the password file\n");
printf("checkpsw for OpenVPN@WIN by ELM <wzk#wenzk.net>.\n");
return(1);
}
while(!feof(f))
{
fscanf(f,"%s %s %s\n",user,pass,active);
/* printf("user:%s pass:%s active:%s\n",user, pass, active); */
if (!strcmp(username,user) && !strcmp(password,pass) && !strcmp(active,"1"))
{
/* printf("OK\n"); */
fclose(f);
return (0);
}
}
fclose(f);
return (1);
}
void main()
{
int status;
/* printf("%s,%s",getenv("USERNAME"),getenv("PASSWORD")); */
status=checkpsw(getenv("USERNAME"),getenv("PASSWORD"));
return (status);
} |
|