diff options
Diffstat (limited to 'ws2a/gencaptcha.c')
| -rw-r--r-- | ws2a/gencaptcha.c | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/ws2a/gencaptcha.c b/ws2a/gencaptcha.c index 7073362..8141ee5 100644 --- a/ws2a/gencaptcha.c +++ b/ws2a/gencaptcha.c @@ -56,7 +56,7 @@ int main(){ int barraldis1 = rand()%10; int barraldis2 = rand()%10; - int arcdis = rand()%100; + int arcdis = (rand()%99)+1; char command[1024]; sprintf(command,"convert -background white -fill black -pointsize 48 label:\"%s\" \"../ws2a/captchas/%s.png\"",randwords,randwords); system(command); @@ -64,20 +64,39 @@ int main(){ system(command); sprintf(command,"convert \"../ws2a/captchas/%s.png\" -virtual-pixel White -distort Arc %d \"../ws2a/captchas/%s.png\"",randwords,arcdis,randwords); system(command); - + sleep(1); FILE* imgfile; char filepath[100]; - sprintf(filepath,"../ws2a/captchas/%s.png",randwords); - imgfile = fopen(filepath,"r"); + sprintf(filepath,"..\\ws2a\\captchas\\%s.png",randwords); + //printf("Filepath:%s",filepath); + imgfile = fopen(filepath,"rb"); if(imgfile == NULL){ printf("Unable to open file!"); return 1; } - while(!feof(imgfile)){ - char c = fgetc(imgfile); - if(feof(imgfile)){ - return 0; - } - putchar(c); + fseek(imgfile,0,SEEK_END); + unsigned long filelen = ftell(imgfile); + //printf("File length:%lu",filelen); + fseek(imgfile,0,SEEK_SET); + //fwrite(imgfile,1,filelen,stdout); + + char* buffer = malloc(filelen+1); + if(buffer == NULL){ + printf("Memory error!"); + return 1; + } + fread(buffer, filelen, 1, imgfile); + int i = 0; + while(i < filelen){ + printf("%c",buffer[i]); + i++; + } + free(buffer); + /* + char c; + while((c = fgetc(imgfile)) && !feof(imgfile)){ + printf("char is:something\n",c); + //putchar(c); } + */ } |
