All pastes #498819 Raw Edit

Something

public text v1 · immutable
·published 2007-05-20 18:11 UTC
rendered paste body
#include <stdio.h>
#include <sys/types.h>
#include <sys/dir.h>
#include <sys/stat.h>
#include <string.h>

#include "stack.c"

#define proc_dir "/proc/acpi/video" 

void open_dir(char *directory)
{
   DIR *dir_ptr ; 
   int tmp ; 
   struct direct *dir_entry ;
   char string[10000] ; 
   struct stat Stat ; 

   if (directory)
   {
     dir_ptr = opendir(directory) ;
     if (dir_ptr) 
     {
       while ((dir_entry = readdir(dir_ptr)))
       {
           if (strcmp(dir_entry->d_name,".") && strcmp(dir_entry->d_name,"..") )
           {
              sprintf(string, "%s/%s",directory, dir_entry->d_name) ;
              tmp = stat(string, &Stat) ;
              if (S_ISDIR(Stat.st_mode)) 
                {
                   printf("%s\n", string) ; 
                   push(string) ; 
                }
           }
       }
     } 
  }
}

int main(int argc, char **argv)
{
   char *ptr ; 
   open_dir(argv[1])  ; 
   while (!is_empty() )
   {
       ptr = pop() ; 
       open_dir(ptr) ; 
   }
   free_stack_mem() ; 
   return 0 ; 
}