/* Module for low level subroutine */
/* */
/********************************************************/
+#include <sys/stat.h>
#include <sys/time.h>
#include <dirent.h>
#include <errno.h>
*/
/********************************************************/
/* */
+/* Procedure to create directory with all up */
+/* directories if they are missing. */
+/* Return true if successfull. */
+/* */
+/********************************************************/
+PUBLIC _Bool rou_do_mkpdir(char *dirpath)
+
+{
+#define OPEP "subrou.c:rou_do_mkpdir,"
+_Bool done;
+int taille;
+char *ptr;
+char locdir[PATH_MAX];
+int phase;;
+_Bool proceed;
+
+done=false;
+(void) strcpy(locdir,dirpath);
+ptr=(char *)0;
+taille=strlen(locdir);
+phase=0;
+proceed=(taille>0);
+while (proceed==true) {
+ switch (phase) {
+ case 0 : //make sur directory is starting with /
+ if (locdir[0]!='/') {
+ (void) rou_alert(0,"%s, <%s> is not a directory name (Bug?)",OPEP,locdir);
+ phase=999; //Trouble No need to go further!
+ }
+ break;
+ case 1 : //cleaning directory ending buy '/'
+ taille--;
+ if ((taille>1)&&(locdir[taille]=='/'))
+ locdir[taille]='\000';
+ break;
+ case 2 : //is directory existing?
+ DIR *dirp;
+
+ if ((dirp=opendir(locdir))!=(DIR *)0) {
+ (void) closedir(dirp);
+ done=true;
+ phase=999; //No need to go further
+ }
+ break;
+ case 3 : //is directory up existing?
+ if ((ptr=strrchr(locdir,'/'))!=(char *)0) {
+ *ptr='\000';
+ if (rou_do_mkpdir(locdir)==false)
+ phase=999; //unable to create up directory!
+ }
+ break;
+ case 4 : //creating the requested directory
+ if (mkdir(dirpath,0755)<0) {
+ (void) rou_alert(0,"%s, unable to create directory <%s> (error=<%s>)",
+ OPEP,dirpath,strerror(errno));
+ phase=999; //unable to create directory!
+ }
+ break;
+ case 5 : //everything fine
+ done=true;
+ break;
+ default : //SAFE Guard
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+return done;
+
+#undef OPEP
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
/* Procedure to return the time difference between */
/* current real-time at nano-second level and */
/* time reference. */
//procedure to assign memory according a format and parameter list
extern int rou_asprintf(char **str,const char *fmt,...);
+//procedure to create needed subdirectory
+extern _Bool rou_do_mkpdir(char *dirpath);
+
//procedure to get the time difference between the current
//time and a TIMESPEC starttime
extern unsigned rou_getdifftime(TIMESPEC *start);