psmile_io_scandir.c File Reference

#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include "PSMILe_f2c.h"
Include dependency graph for psmile_io_scandir.c:

Go to the source code of this file.

Defines

#define __SYSV
#define __MYALPHASORT   alphasort

Functions/Subroutines

void __psmile_io_scandir (char *basename, int len_of_basename, char *file_list, int len_of_list_entry, int len_of_list, int *no_of_files, int *ierror)
void __psmile_io_scandir_no_of_files (char *basename, int len_of_basename, int *no_of_files, int *ierror)
void psmile_io_scandir (char *basename, char *file_list, int *len_of_list, int *no_of_files, int *ierror, int len_of_basename, int len_of_list_entry)
void psmile_io_scandir_no_of_files (char *basename, int *no_of_files, int *ierror, int len_of_basename)

Define Documentation

#define __MYALPHASORT   alphasort

Definition at line 32 of file psmile_io_scandir.c.

Referenced by __psmile_io_scandir(), and __psmile_io_scandir_no_of_files().

#define __SYSV

Definition at line 1 of file psmile_io_scandir.c.


Function Documentation

void __psmile_io_scandir ( char *  basename,
int  len_of_basename,
char *  file_list,
int  len_of_list_entry,
int  len_of_list,
int *  no_of_files,
int *  ierror 
)

Definition at line 45 of file psmile_io_scandir.c.

References __MYALPHASORT, and n.

Referenced by psmile_io_scandir().

00051                                         {
00052 /*
00053   !LOCAL VARIABLES:
00054 #if defined(__SYSV) || defined(__Linux)
00055            struct dirent **namelist;
00056 #else
00057            struct direct **namelist;
00058 #endif
00059            int n, entry=0;
00060            int offset=len_of_list_entry;
00061            size_t len=len_of_basename;
00062 
00063   !DESCRIPTION:
00064    Routine lists all files of a given basename in the current directory.
00065 
00066   !REVISION HISTORY:
00067 
00068     Date      Programmer   Description
00069   ----------  ----------   -----------
00070   31.10.03    R. Vogelsang created
00071   
00072 //EOP
00073 */
00074            static char mycvs[80]="$Id: psmile_io_scandir.c 2325 2010-04-21 15:00:07Z valcke $";
00075 
00076 #if defined(__SYSV) || defined(__Linux)
00077            struct dirent **namelist;
00078 #else
00079            struct direct **namelist;
00080 #endif
00081            int n, entry=0;
00082            int offset=len_of_list_entry;
00083            size_t len=len_of_basename;
00084 
00085            printf("%s %d %d %d \n",basename ,len_of_basename,len_of_list_entry,len_of_list);
00086            
00087 
00088 #if defined(__SYSV) || defined(__Linux)
00089            n = scandir(".", &namelist, 0, __MYALPHASORT);
00090 #else
00091            n = scandir(".", &namelist, 0, __MYALPHASORT);
00092 #endif
00093            if (n < 0) {
00094                perror("psmile_io_scandir: The directory contains no files!");
00095                *ierror=999;
00096            } else {
00097                while(n--) {
00098                    if( ! strncmp(basename,namelist[n]->d_name,len)){
00099 /*          printf("%s\n", namelist[n]->d_name);*/
00100                         if( entry < len_of_list ) {
00101                           strncpy(file_list + entry * offset
00102                                  ,namelist[n]->d_name
00103                                  ,strlen(namelist[n]->d_name));
00104                         }
00105                         entry++;
00106                     }       
00107                    free(namelist[n]);
00108                }
00109                free(namelist);
00110            }
00111            *no_of_files=entry;
00112        }

Here is the caller graph for this function:

void __psmile_io_scandir_no_of_files ( char *  basename,
int  len_of_basename,
int *  no_of_files,
int *  ierror 
)

Definition at line 113 of file psmile_io_scandir.c.

References __MYALPHASORT, and n.

Referenced by psmile_io_scandir_no_of_files().

00116                                         {
00117 #if defined(__SYSV) || defined(__Linux)
00118            struct dirent **namelist;
00119 #else
00120            struct direct **namelist;
00121 #endif
00122            int n, entry=0;
00123            size_t len=len_of_basename;
00124            printf("%s %d \n",basename ,len_of_basename);
00125            
00126 
00127 #if defined(__SYSV) || defined(__Linux)
00128            n = scandir(".", &namelist, 0, __MYALPHASORT);
00129 #else
00130            n = scandir(".", &namelist, 0, __MYALPHASORT);
00131 #endif
00132            if (n < 0) {
00133                perror("psmile_io_scandir: The directory contains no files!");
00134                *ierror=999;
00135            } else {
00136                while(n--) {
00137                    if( ! strncmp(basename,namelist[n]->d_name,len)){
00138 /*          printf("%s\n", namelist[n]->d_name);*/
00139                         entry++;
00140                     }       
00141                    free(namelist[n]);
00142                }
00143                free(namelist);
00144            }
00145            *no_of_files=entry;
00146        }

Here is the caller graph for this function:

void psmile_io_scandir ( char *  basename,
char *  file_list,
int *  len_of_list,
int *  no_of_files,
int *  ierror,
int  len_of_basename,
int  len_of_list_entry 
)

Definition at line 149 of file psmile_io_scandir.c.

References __psmile_io_scandir().

Referenced by psmile_open_file_byid().

00155                                                   {
00156 
00157             __psmile_io_scandir( basename
00158                               , len_of_basename
00159                               , file_list
00160                   , len_of_list_entry
00161                   ,*len_of_list
00162                   , no_of_files
00163                   , ierror);
00164 
00165        }

Here is the call graph for this function:

Here is the caller graph for this function:

void psmile_io_scandir_no_of_files ( char *  basename,
int *  no_of_files,
int *  ierror,
int  len_of_basename 
)

Definition at line 166 of file psmile_io_scandir.c.

References __psmile_io_scandir_no_of_files().

Referenced by psmile_open_file_byid().

00169                                                 {
00170 
00171             __psmile_io_scandir_no_of_files( basename
00172                               , len_of_basename
00173                   , no_of_files
00174                   , ierror);
00175 
00176        }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1