X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=listati%2FComputeValues.c;fp=listati%2FComputeValues.c;h=bc11c2850a7c965b1e13768f781bec8e5491ea05;hp=0000000000000000000000000000000000000000;hb=06661f47754a536098afe2b30cb04469918f2fa3;hpb=bdf6e88eeb9b3aef06d57930ec8b89083639e56d diff --git a/listati/ComputeValues.c b/listati/ComputeValues.c new file mode 100644 index 0000000..bc11c28 --- /dev/null +++ b/listati/ComputeValues.c @@ -0,0 +1,23 @@ +/* Routine to compute directory properties inside DirScan */ +int ComputeValues(struct dirent * direntry) +{ + struct stat data; + stat(direntry->d_name, &data); /* get stat data */ + shmptr->tot_size += data.st_size; + shmptr->tot_files++; + if (S_ISREG(data.st_mode)) shmptr->tot_regular++; + if (S_ISFIFO(data.st_mode)) shmptr->tot_fifo++; + if (S_ISLNK(data.st_mode)) shmptr->tot_link++; + if (S_ISDIR(data.st_mode)) shmptr->tot_dir++; + if (S_ISBLK(data.st_mode)) shmptr->tot_block++; + if (S_ISCHR(data.st_mode)) shmptr->tot_char++; + if (S_ISSOCK(data.st_mode)) shmptr->tot_sock++; + return 0; +} +/* Signal Handler to manage termination */ +void HandSIGTERM(int signo) { + MutexLock(mutex); + ShmRemove(key, shmptr); + MutexRemove(mutex); + exit(0); +}