2004/Dec/28

#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <scanner.h>
#include <VFinger.h>
#include <string.h>
#include <pwd.h>
#include <sys/stat.h>


struct scanner_info* scanner = &scanner_AFS4000;
int save_file(char *name, unsigned char *image)
{

int ret = 0;
FILE *file = NULL;



file = fopen (name, "wb");
if (file == NULL)
{
ret = -1;
return ret;
}
int len = 96*96;
fwrite((BYTE *)image,1,len,file);
fclose (file);
return ret;


}
int main(int argc, char *argv[])
{

const char *user = "nobody";
struct passwd *pw;
int uid;

pid_t pid;

if(argc == 2) {
user = argv[1];
}

if(argc > 2 || argc == 1) {
fprintf(stderr, "Usage: addllfsuser [user]\n");
exit(1);
}
pid = fork();
switch(pid)
{
case -1:
perror("fork failed");
exit(1);
case 0:
/* useradd XXX */
execl("/usr/sbin/adduser","adduser","--disabled-password","--gecos",user,user,0);
break;
default:

fprintf(stdout,"Please scan your finger \n");
/* get image from device */
int i = scanner -> init();
int dpi = scanner -> dpi;
char *name = scanner -> name;
char *imageFromScanner;
int w1,h1;
char tmpfile[5];
char filename[256]="";
char symname[256]="";

do
{
imageFromScanner = scanner -> read(&w1, &h1);

}while(imageFromScanner == NULL);
/* select UID from /etc/passwd where user = XXX */
pw = getpwnam(user);
uid = pw->pw_uid;
sprintf(tmpfile,"%d",uid);
strcat(filename,"/etc/llfs/");
strcat(filename,tmpfile);


/* save image file and the filename is /etc/llfs/UID */
save_file(filename,imageFromScanner);
/* create symlink */
strcat(symname,"/etc/llfs/");
strcat(symname,pw->pw_name);
if(chmod(filename,S_IRUSR)==-1)
fprintf(stdout,"chmod file error \n");
symlink(filename,symname);
/* close scanner */
scanner -> close();
break;
}
fprintf(stdout,"your UID is %d\n",uid);
fprintf(stdout,"add fingerprint success\n");
return 0;
}

Comment

Comment:

Tweet


hlrizF <a href="http://hjrijjzeqclf.com/">hjrijjzeqclf</a>, [url=http://zhdindxmrutf.com/]zhdindxmrutf[/url], [link=http://eqvtgmtqyixo.com/]eqvtgmtqyixo[/link], http://clghmdddplmf.com/
#24 by MXGViprGj (89.28.14.35) At 2010-10-20 14:43,
L4FBL2 <a href="http://vefnfjymtxfr.com/">vefnfjymtxfr</a>, [url=http://woursrkshxcl.com/]woursrkshxcl[/url], [link=http://zkaityqaumlf.com/]zkaityqaumlf[/link], http://vczrqqkvxzuu.com/
#23 by JHUtxOLJxKVgRO (95.220.185.210) At 2010-08-06 17:52,
eIJ4lf <a href="http://vetyoufhlbfn.com/">vetyoufhlbfn</a>, [url=http://vjqjrussqgkb.com/]vjqjrussqgkb[/url], [link=http://mwltnfonatfs.com/]mwltnfonatfs[/link], http://olvaggrytsnn.com/
#22 by mhbUHEJtqVIJv (201.56.92.226) At 2010-07-13 14:32,
Very nice site! cheap cialis http://ypxoiea.com/qyrvqq/4.html
#21 by owuuwotu (212.56.212.210) At 2010-05-04 21:54,
Very nice site! [url=http://ypxoiea.com/qyrvqq/2.html]cheap cialis[/url]
#20 by eiweprty (222.161.137.205) At 2010-05-04 21:54,
Hello! cegdeec interesting cegdeec site!
#19 by poorrtur (212.56.212.202) At 2010-05-04 21:50,
Very nice site! is it yours too http://yieapxo.com/qroxvvq/4.html
#17 by etieypee (96.31.86.184) At 2010-02-22 12:52,
Very nice site!
#18 by etieypee (96.31.86.184) At 2010-02-22 12:52,
Very nice site! [url=http://yieapxo.com/qroxvvq/2.html]is it yours too[/url]
#16 by etieypee (96.31.86.184) At 2010-02-22 12:52,
Hi! OjzhmIc [url=http://frsaep.com/]OcUOAh[/url]
#15 by gYEpuMjf (91.214.45.46) At 2010-01-20 17:18,
Hi! FISkHM
#14 by hTWQdopc (91.214.45.46) At 2010-01-09 20:45,
Hi! XxmYaSnn
#13 by FTCRYWfz (91.214.45.46) At 2010-01-09 17:54,
Hi! SMhBSbP
#12 by hkaOJiqB (91.214.45.46) At 2010-01-09 17:30,
Hi! TqeybmJ
#11 by XNeosVoV (91.214.45.47) At 2010-01-09 15:24,
watch naruto online!!
#10 by naruto episodes (124.157.189.199) At 2010-01-03 17:46,
hi all !!
#9 by sears parts (124.157.191.197) At 2009-12-03 13:10,
Que se ra
#8 by scratch and dent (124.157.236.46) At 2009-11-12 04:49,
ขอบคุณค่ะ
#7 by โหลดเพลง (124.157.236.176) At 2009-10-06 01:49,
Que
#6 by sera (124.157.236.176) At 2009-10-03 17:10,
ดีๆ
#5 by ดีๆ (124.157.236.229) At 2009-09-22 06:04,
ขอบคุณจ้า
#4 by parts (124.157.236.229) At 2009-09-21 07:12,
ขอบคุณจ้า
#3 by ดาวโหลดเพลง (124.157.236.219) At 2009-09-09 12:13,
Google is the best search engine
#2 by KvASRXBs (85.255.114.133) At 2007-03-02 18:15,
หวัดดีคับ
ผมกำลังทำ project จบป.ตรีในเรื่องของ fingerprint ผมอยากได้คำแนะนำมาก ถ้าไม่เป็นการรบกวนช่วยฝาก email ของท่านมาที่ chief_neo@hotmail.com ได้ไหมคับ
#1 by chief (58.147.29.184) At 2006-07-17 13:41,