/[xlog]/xlog/src/log.c
ViewVC logotype

Diff of /xlog/src/log.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.23 by pa4tu, Fri Oct 29 18:26:09 2004 UTC revision 1.24 by pa4tu, Mon Nov 22 20:07:43 2004 UTC
# Line 30  Line 30 
30  #define __USE_XOPEN  #define __USE_XOPEN
31  #include <time.h>  #include <time.h>
32    
 #if HAVE_DIRENT_H  
 #       include <dirent.h>  
 #       define NAMLEN(dirent) strlen((dirent)->d_name)  
 #else  
 #       define dirent direct  
 #       define NAMLEN(dirent) (dirent)->d_namlen  
 #       if HAVE_SYS_NDIR_H  
 #               include <sys/ndir.h>  
 #       endif  
 #       if HAVE_SYS_DIR_H  
 #               include <sys/dir.h>  
 #       endif  
 #       if HAVE_NDIR_H  
 #               include <ndir.h>  
 #       endif  
 #endif  
   
33  #include "callbacks_mainwindow_list.h"  #include "callbacks_mainwindow_list.h"
34  #include "gui_utils.h"  #include "gui_utils.h"
35  #include "utils.h"  #include "utils.h"
# Line 467  savelog (gpointer arg, gchar * logfile, Line 450  savelog (gpointer arg, gchar * logfile,
450  GString *  GString *
451  getlogs (gchar *path, gchar *patt)  getlogs (gchar *path, gchar *patt)
452  {  {
453          DIR *directory;          gchar *pattern;
         struct dirent *dirEntry;  
         gchar *filen, *pattern;  
454          GString *logs = g_string_new ("");          GString *logs = g_string_new ("");
455            const gchar *dirname;
456            GError *error  = NULL;
457            GDir *dir;
458    
459          directory = opendir (path);          dir = g_dir_open (path, 0, &error);
460          pattern = g_strdup_printf ("%s.xlog", patt);          pattern = g_strdup_printf ("%s.xlog", patt);
461          while (NULL != (dirEntry = readdir (directory)))          if (!error)
462          {          {
463                  filen = g_strdup (dirEntry->d_name);                  dirname = g_dir_read_name (dir);
464                  if (dirEntry->d_type == DT_REG) /* only regular files */                  while (dirname)
465                  {                  {
466                          if (g_pattern_match_simple (pattern, filen))                          if (g_pattern_match_simple (pattern, dirname))
467                          {                          {
468                                  if (g_str_has_suffix (filen, ".xlog"))                                  if (g_str_has_suffix (dirname, ".xlog"))
469                                  {                                  {
470                                          g_string_append (logs, dirEntry->d_name);                                          g_string_append (logs, dirname);
471                                          g_string_append_c (logs, '\n');                                          g_string_append_c (logs, '\n');
472                                  }                                  }
                                 g_free (filen);  
473                          }                          }
474                            dirname = g_dir_read_name (dir);
475                  }                  }
476                    g_dir_close (dir);
477          }          }
478          g_free (pattern);          g_free (pattern);
479          return (logs);          return (logs);

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26