/[mailutils]/mailutils/mh/folder.c
ViewVC logotype

Diff of /mailutils/mh/folder.c

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

revision 1.2 by gray, Mon Sep 23 07:50:44 2002 UTC revision 1.3 by gray, Tue Sep 24 14:15:36 2002 UTC
# Line 254  _scan (const char *name, int depth) Line 254  _scan (const char *name, int depth)
254    info.name = strdup (name);    info.name = strdup (name);
255    while ((entry = readdir (dir)))    while ((entry = readdir (dir)))
256      {      {
257        switch (entry->d_name[0])        if (entry->d_name[0] == '.')
258          {          {
         case '.':  
259            if (strcmp (entry->d_name, mh_seq_name) == 0)            if (strcmp (entry->d_name, mh_seq_name) == 0)
260              read_seq_file (&info, name, entry->d_name);              read_seq_file (&info, name, entry->d_name);
261            break;          }
262                    else if (entry->d_name[0] != ',')
263          case ',':          {
           continue;  
   
         case '0':case '1':case '2':case '3':case '4':  
         case '5':case '6':case '7':case '8':case '9':  
           uid = strtoul (entry->d_name, &p, 10);  
           if (*p)  
             info.others++;  
           else  
             {  
               info.message_count++;  
               if (info.min == 0 || uid < info.min)  
                 info.min = uid;  
               if (uid > info.max)  
                 info.max = uid;  
             }  
           break;  
   
         default:  
264            asprintf (&p, "%s/%s", name, entry->d_name);            asprintf (&p, "%s/%s", name, entry->d_name);
265            if (stat (p, &st) < 0)            if (stat (p, &st) < 0)
266              {              mh_error ("can't stat %s: %s", p, strerror (errno));
               mh_error ("can't stat %s: %s", p, strerror (errno));  
               info.others++;  
             }  
267            else if (S_ISDIR (st.st_mode))            else if (S_ISDIR (st.st_mode))
268              {              {
269                  info.others++;
270                _scan (p, depth+1);                _scan (p, depth+1);
271              }              }
272            else            else
273              /* Invalid entry. */              {
274              info.others++;                char *endp;
275            free (p);                uid = strtoul (entry->d_name, &endp, 10);
276                  if (*endp)
277                    info.others++;
278                  else
279                    {
280                      info.message_count++;
281                      if (info.min == 0 || uid < info.min)
282                        info.min = uid;
283                      if (uid > info.max)
284                        info.max = uid;
285                    }
286                }
287          }          }
288              }
289      
290      if (info.cur)
291        {
292          asprintf (&p, "%s/%lu", name, (unsigned long) info.cur);
293          if (stat (p, &st) < 0 || !S_ISREG (st.st_mode))
294            info.cur = 0;
295          free (p);
296      }      }
297    closedir (dir);    closedir (dir);
298    install_folder_info (name, &info);    if (depth > 0)
299        install_folder_info (name, &info);
300  }  }
301            
302  static void  static void
# Line 309  print_all () Line 307  print_all ()
307    for (info = folder_info; info < end; info++)    for (info = folder_info; info < end; info++)
308      {      {
309        int len = strlen (info->name);        int len = strlen (info->name);
310        printf ("%s", info->name);        if (len < 22)
311            printf ("%22.22s", info->name);
312          else
313            printf ("%s", info->name);
314          
315        if (strcmp (info->name, current_folder) == 0)        if (strcmp (info->name, current_folder) == 0)
316          {          printf ("+");
317            printf ("+");        else
318            len++;          printf (" ");
319          }        
   
       for (; len < 20; len++)  
         putchar (' ');  
   
320        if (info->message_count)        if (info->message_count)
321          {          {
322            printf (" has %4lu messages (%4lu-%4lu)",            printf (info->message_count == 1 ?
323                      " has %4lu message  (%4lu-%4lu)" :
324                      " has %4lu messages (%4lu-%4lu)",
325                    (unsigned long) info->message_count,                    (unsigned long) info->message_count,
326                    (unsigned long) info->min,                    (unsigned long) info->min,
327                    (unsigned long) info->max);                    (unsigned long) info->max);
328            if (info->cur)            if (info->cur)
329              printf ("; cur=%4lu", (unsigned long) info->cur);              printf ("; cur=%4lu", (unsigned long) info->cur);
   
           if (info->others)  
             {  
               if (!info->cur)  
                 printf (";           ");  
               else  
                 printf ("; ");  
               printf ("(others)");  
             }  
           printf (".\n");  
330          }          }
331        else        else
332          {          {
333            printf (" has no messages.\n");            printf (" has no messages");
334            }
335          
336          if (info->others)
337            {
338              if (!info->cur)
339                printf (";           ");
340              else
341                printf ("; ");
342              printf ("(others)");
343          }          }
344          printf (".\n");
345      }      }
346  }  }
347    
# Line 374  action_print () Line 374  action_print ()
374    if (show_all)    if (show_all)
375      {      {
376        _scan (mu_path_folder_dir, 0);        _scan (mu_path_folder_dir, 0);
       folder_info_count--; /* do not count folder directory */  
377      }      }
378    else    else
379      {      {
# Line 398  action_print () Line 397  action_print ()
397        print_all ();        print_all ();
398    
399        if (print_total)        if (print_total)
400          printf ("%24.24s=%4lu messages in %4lu folders\n",          printf ("\n%24.24s=%4lu messages in %4lu folders\n",
401                  "TOTAL",                  "TOTAL",
402                  (unsigned long) message_count,                  (unsigned long) message_count,
403                  (unsigned long) folder_info_count);                  (unsigned long) folder_info_count);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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