#include #include #include #include "configfile.h" #include "fi.h" #include "ft.h" #define OPT_CONF_A 1 #define OPT_CONF_D 2 void showpclent(pclent) const PCLENT *pclent; { PCLEUID *euid; PCLEGID *egid; int i, mask; /* mask */ if (pclent->pcl_marks & PCL_MMATCH) { mask=pclent->pcl_opt; (void)printf("+%c%c%c%c%c%c%c%c%c", ((mask & FI_MINO) ? 'i': '-'), ((mask & FI_MNLINK) ? 'l': '-'), ((mask & FI_MUID) ? 'u': '-'), ((mask & FI_MGID) ? 'g': '-'), ((mask & FI_MMODE) ? 'm': '-'), ((mask & FI_MSIZE) ? 's': '-'), ((mask & FI_MFLAGS) ? 'f': '-'), ((mask & FI_MCTIME) ? 't': '-'), ((mask & FI_MSHA) ? 'c': '-')); } else { (void)printf("+N "); } (void)printf(" %c%c\n", ((pclent->pcl_marks & PCL_MSTOP) ? 'S' : '-'), ((pclent->pcl_marks & PCL_MINH) ? 'I' : '-')); /* name */ for (i=0; ipcl_namesize; ++i) { (void)printf("\tname:%s;\n", pclent->pcl_name[i]); } #if ENABLE_REGEX /* namere */ for (i=0; ipcl_enamesize; ++i) { (void)printf("\tnamere:%s;\n", pclent->pcl_pattern[i]); } #endif /* euid */ for (i=0; ipcl_euidsize; ++i) { euid=&pclent->pcl_euid[i]; switch (euid->pcl_type) { case PCLEUID_S: (void)printf("\tuid:%d\n", euid->pcl_luid); break; case PCLEUID_L: (void)printf("\tuid:%d-\n", euid->pcl_luid); break; case PCLEUID_R: (void)printf("\tuid:-%d\n", euid->pcl_ruid); break; case PCLEUID_LR: (void)printf("\tuid:%d-%d\n", euid->pcl_luid, euid->pcl_ruid); break; } } /* egid */ for (i=0; ipcl_egidsize; ++i) { egid=&pclent->pcl_egid[i]; switch (egid->pcl_type) { case PCLEGID_S: (void)printf("\tgid:%d\n", egid->pcl_lgid); break; case PCLEGID_L: (void)printf("\tgid:%d-\n", egid->pcl_lgid); break; case PCLEGID_R: (void)printf("\tgid:-%d\n", egid->pcl_rgid); break; case PCLEGID_LR: (void)printf("\tgid:%d-%d\n", egid->pcl_lgid, egid->pcl_rgid); break; } } /* type */ if (pclent->pcl_type) { (void)printf("\ttype:%c%c%c%c%c%c%c\n", ((pclent->pcl_type & PCL_TF) ? 'f' : '-'), ((pclent->pcl_type & PCL_TC) ? 'c' : '-'), ((pclent->pcl_type & PCL_TD) ? 'd' : '-'), ((pclent->pcl_type & PCL_TB) ? 'b' : '-'), ((pclent->pcl_type & PCL_TR) ? 'r' : '-'), ((pclent->pcl_type & PCL_TL) ? 'l' : '-'), ((pclent->pcl_type & PCL_TS) ? 's' : '-')); } } void showpcl(pcl, inh) const PCL *pcl; int inh; { PCLENT *pclent; int i; for (i=0; ipcl_size; ++i) { pclent=&pcl->pcl_entries[i]; if (inh && !(pclent->pcl_marks & PCL_MINH)) continue; showpclent(pclent); } (void)printf("\n"); } int trshowpcl(ftent, sp) FTENT *ftent; void *sp; { if (ftent->ft_data) { (void)printf("@%s;\n", ftent->ft_path); showpcl((PCL *)(ftent->ft_data), 0); } return (0); } void usage(void) { (void)fprintf(stderr, "usage: fswconf [-a | -d dir] [-c file]\n"); exit (1); } int main(argc, argv) int argc; const char *const *argv; { char p_config[PATH_MAX+1], p_dir[PATH_MAX+1]; int ch, opr, inh; PCL *pcl; PCLT *pclt; (void)strncpy(p_config, "/usr/local/etc/fswatch.conf", PATH_MAX); opr=OPT_CONF_A; while ((ch=getopt(argc, (char *const *)argv, "ac:d:"))!=-1) { switch (ch) { case 'a': opr=OPT_CONF_A; break; case 'c': (void)strncpy(p_config, optarg, PATH_MAX); p_config[PATH_MAX-1]=(char)0x0; break; case 'd': (void)strncpy(p_dir, optarg, PATH_MAX); p_dir[PATH_MAX-1]=(char)0x0; opr=OPT_CONF_D; break; default: usage(); break; } } argc-=optind; argv+=optind; if (0