/* $Header: /CVSROOT/debris/cmds/md5sum.c,v 1.3 2005/08/15 01:04:52 tino Exp $ * * DebRIS: DEBian Remote Install Scripter * *md5sum ... * * $Log: md5sum.c,v $ * Revision 1.3 2005/08/15 01:04:52 tino * all functions now have a prefix (dris_) * * Revision 1.2 2005/08/13 22:59:12 tino * additional functions, see ChangeLog * * Revision 1.1 2005/07/25 03:01:27 tino * added */ static int driscmd_md5sum(char *args) { char *file; int ret; ret = 0; while ((file=dris_nextarg(&args))!=0) { int fd, got; char buf[BUFSIZ*10]; if ((fd=open(file, O_RDONLY))<0) { ret = dris_err("md5sum: cannot open %s", file); continue; } dris_md5_init(); while ((got=dris_readall(fd, buf, sizeof buf))>0) dris_md5_add(buf, got); if (got<0) ret = dris_err("md5sum: read error %s", file); else dris_out("%s %s\n", dris_md5_get(), file); if (close(fd)) ret = dris_err("md5sum: cannot close %s", file); } return ret; }