40 #define NEW_XFILES_DATA   1    58 static pthread_mutex_t mutex_fext = PTHREAD_MUTEX_INITIALIZER;
    60 #define FEXT_LOCK()         MUTEX_LOCK(&mutex_fext)    61 #define FEXT_UNLOCK()       MUTEX_UNLOCK(&mutex_fext)    74   if ((x_jfext = realloc(j_fext, x_sz_fext * 
sizeof (
fext_rec)))) {
    78       memset(j_fext + i, 0, 
sizeof (
fext_rec));
   125 static char       **sorted_ext = NULL;
   138   if (a == NULL && b == NULL)
   162   char               *ptr, *s, *ts = NULL;
   167   memset(env_ext, 0, 
sizeof (env_ext));
   168   if ((ts = strdup(str)) == NULL) {
   173   for (s = strtok_r(ts, 
", \t\r\n", &ptr); s != NULL;
   174        s = strtok_r(NULL, 
", \t\r\n", &ptr)) {
   177     env_ext[n++] = strdup(s);
   185     ZE_MessageInfo(19, 
"** Environnement defined X-Files file extensions");
   186     for (i = 0; i < n; i++)
   198   char                sin[2048], sout[2048];
   204     if ((envext = getenv(
"FILE_EXT")) != NULL) {
   207       ZE_MessageInfo(11, 
"Using environnement FILE_EXT (%s) to define X-FILES",
   212         sorted_ext = env_ext;
   217     if (sorted_ext == NULL) {
   220       ZE_MessageInfo(11, 
"Using default FILE_EXT (%s) to define X-FILES",
   225         sorted_ext = env_ext;
   231     if (p != NULL && *p != NULL) {
   232       strlcpy(sin, *p, 
sizeof (sin));
   234         sprintf(sin, 
"%s|%s", sin, *p);
   236     sprintf(sout, 
"[.](%s)$", sin);
   251   char                sin[2048], sout[2048];
   263     char              **p = sorted_ext;
   265     for (p = sorted_ext; *p != NULL; p++)
   270     if (strcasecmp(j_fext[0].
expr, 
"NONE") != 0) {
   271       memset(sin, 0, 
sizeof (sin));
   272       for (i = 0; i < 
nb_fext; i++) {
   273         if (strlen(sin) > 0) {
   274           strlcat(sin, 
"|", 
sizeof (sin));
   275           strlcat(sin, j_fext[i].expr, 
sizeof (sin));
   277           strlcpy(sin, j_fext[i].expr, 
sizeof (sin));
   279       snprintf(sout, 
sizeof (sout), 
"[.](%s)$", sin);
   281       strlcpy(sout, 
"^$", 
sizeof (sout));
   306     strlcpy(line, 
"", 
sizeof (line));
   307     for (i = 0; i < 
nb_fext; i++) {
   308       snprintf(temp, 
sizeof (temp), 
"%-5s ", j_fext[i].
expr);
   310       if (strlen(line) + 16 > 64) {
   312         strlcpy(line, 
"", 
sizeof (line));
   315     if (strlen(line) > 0)
   323     strlcpy(line, 
"", 
sizeof (line));
   324     for (; *p != NULL; p++) {
   325       snprintf(temp, 
sizeof (temp), 
"%-5s ", *p);
   327       if (strlen(line) + 16 > 64) {
   329         strlcpy(line, 
"", 
sizeof (line));
   332     if (strlen(line) > 0)
   348   if ((fname == NULL) || (strlen(fname) == 0))
   355   if (regcomp(&re, 
ZE_FILE_EXT, REG_ICASE | REG_EXTENDED) == 0) {
   356     res = (regexec(&re, fname, (
size_t) 0, NULL, 0) == 0);
   381 #define XFILE_INITIALIZER  {"", "", "", 0, FALSE, 0, 0}   387 static pthread_mutex_t st_mutex = PTHREAD_MUTEX_INITIALIZER;
   389 #define DATA_LOCK()        MUTEX_LOCK(&st_mutex)   390 #define DATA_UNLOCK()      MUTEX_UNLOCK(&st_mutex)   402   printf(
"Let's dump x-files_table : \n");
   406       printf(
"-> %s %-20s %7ld/%7ld : %s\n",
   426   if ((r = strcasecmp(a->
expr, b->
expr)) != 0)
   429   return strcasecmp(a->
mime, b->
mime);
   442   char               *k = (
char *) vk;
   443   char               *v = (
char *) vv;
   445   if ((k == NULL) || (v == NULL))
   448   memset(&r, 0, 
sizeof (r));
   464     char               *ts = strdup(v);
   467       for (s = strtok_r(ts, 
";", &ptr); s != NULL;
   468            s = strtok_r(NULL, 
";", &ptr)) {
   471         if (
zeStrRegex(s, 
"^SIZE=[0-9]*[km]?,[0,9]*[km]?", &pi, NULL, 
TRUE)) {
   472           char               *ps, *pmin, *pmax;
   475           pmin = 
strchr(ps, 
'=') + 1;
   476           pmax = 
strchr(ps, 
',') + 1;
   478           ps = pmin + strspn(pmin, 
"0123456789");
   479           if ((*ps == 
'm') || (*ps == 
'M') || (*ps == 
'k') | (*ps == 
'K'))
   482           ps = pmax + strspn(pmax, 
"0123456789");
   483           if ((*ps == 
'm') || (*ps == 
'M') || (*ps == 
'k') | (*ps == 
'K'))
   487           if (strlen(pmin) > 0)
   490           if (strlen(pmax) > 0)
   510           for (i = 0; i < argc; i++) {
   513             if (*argv[i] == 
'!') {
   518               flags |= (no ? 0 : X_NOTIFY);
   526             (s, 
"^ACTION=(notify|discard|reject|ok)$", NULL, NULL, 
TRUE)) {
   581   static int          htbl_ok = 
FALSE;
   586   if (htbl_ok == 
FALSE) {
   587     memset(&htbl, 0, 
sizeof (htbl));
   607 #define XFILES_DEFAULT     1   608 #define XFILES_TNEF        2   609 #define XFILES_CLSID       3   620 #define FNAME_TNEF    "winmail.dat"   621 #define FNAME_CLSID   \   622        "[{]?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}[}]?$"   677           sf = (q->
max != 0 ? q->
max : LONG_MAX);
   682             if (msgsize < si || msgsize > sf)
   696           if (saction != NULL && bufsize > 0)
 
bool check_filename_xfile(char *fname)
void * zeTable_Get_Next_Ptr(zeTbl_T *)
bool zeStrRegex(char *, char *, long *, long *, bool)
bool load_xfiles_table(char *cfdir, char *fname)
#define FD_PRINTF(fdp,...)
void * zeTable_Get_First_Ptr(zeTbl_T *)
int zeStr2Tokens(char *, int, char **, char *)
bool read_conf_data_file(char *cfdir, char *fname, char *dfile, read_conf_data_file_F func)
void init_default_file_extensions()
int zeTable_Clear(zeTbl_T *)
long zeStr2long(char *s, int *error, long dval)
int zeTable_Add(zeTbl_T *, void *)
int sort_extensions(const void *a, const void *b)
int zm_RdTextFile(char *, int, int, char *, int(*)(void *, void *))
int zeTable_Get_First(zeTbl_T *, void *)
#define ZE_MessageInfo(level,...)
#define XFILE_INITIALIZER
#define ZE_LogSysError(...)
int zeTable_Get_Next(zeTbl_T *, void *)
int extract_extensions(char *str)
#define ZE_LogMsgWarning(level,...)
int zeTable_Init(zeTbl_T *, size_t, int, int(*)(const void *, const void *))
#define STRCASEEQUAL(a, b)
int get_id_by_name(name2id_T *, char *)
bool check_xfiles(char *fname, char *mime, size_t msgsize, char *saction, size_t bufsize)
void init_file_extension_regex()
void list_filename_extensions(int fd)