Back to home page

darwin3

 
 

    


File indexing completed on 2024-12-17 18:36:48 UTC

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
cba009f524 Ed H*0001 /*************************************************  -*- mode: C -*-
                0002  */
                0003 
                0004 /*  Here, we get the definition of the FC_NAMEMANGLE() macro. */
                0005 #include "FC_NAMEMANGLE.h"
                0006 
                0007 #include <time.h>
                0008 #include <stdio.h>
                0009 #include <stdlib.h>
                0010 #include <unistd.h>
                0011 #include <assert.h>
                0012 #include <sys/stat.h>
                0013 #include <sys/types.h>
                0014 #include <sys/time.h>
61ada986c6 Cons*0015 #include <string.h>
1a7eca6776 Ed H*0016 void FC_NAMEMANGLE(mnccdir) ( int *nienc, int *ienc, int *idate )
cba009f524 Ed H*0017 {
1a7eca6776 Ed H*0018     char name[512], dname[512];
cba009f524 Ed H*0019     struct tm * tmp;
                0020     time_t tt;
1a7eca6776 Ed H*0021     int i, j, n, ntot, iyyyymmdd;
cba009f524 Ed H*0022     mode_t mode = 0x0;
1a7eca6776 Ed H*0023     char * cenc = 
                0024     {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.,+-=/~\0"};
                0025     int ncenc = 70;
cba009f524 Ed H*0026 
9705a0d5c6 Ed H*0027     n = ((*nienc) > 500) ? 500 : (*nienc);
cba009f524 Ed H*0028     tt = time(&tt);
                0029     tmp = localtime(&tt);
1a7eca6776 Ed H*0030     iyyyymmdd = tmp->tm_mday 
                0031     + 100*(tmp->tm_mon + 1 + 100*(1900+tmp->tm_year));
                0032     for (i=0; i<n; i++) {
                0033     /* printf("ienc = %d, %c\n", ienc[i], cenc[ienc[i] - 1]); */
                0034     name[i] = cenc[ienc[i] - 1];
                0035     }
                0036     name[n] = '\0';
                0037     /* printf("name = \"%s\", n = %d\n", name, n); */
cba009f524 Ed H*0038     for (i=1; i<10000; i++) {
1a7eca6776 Ed H*0039     if (*idate == 1) 
9705a0d5c6 Ed H*0040         snprintf(dname, 500, "%s%08d_%04d\0", name, iyyyymmdd, i);
1a7eca6776 Ed H*0041     else
9705a0d5c6 Ed H*0042         snprintf(dname, 500, "%s%04d\0", name, i);
cba009f524 Ed H*0043     mode = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH;
1a7eca6776 Ed H*0044     if (mkdir(dname, mode) == 0) {
cba009f524 Ed H*0045         break;
                0046     }
                0047     }
1a7eca6776 Ed H*0048     n = (int)(strlen(dname));
                0049     /* printf("dname = \"%s\", n = %d\n", dname, n); */
                0050     ntot = 0;
                0051     for (i=0; i<n; i++) {
                0052     for (j=0; j<ncenc; j++) {
                0053         if (cenc[j] == dname[i]) {
                0054         ienc[ntot] = j + 1;
                0055         ntot++;
                0056         break;
                0057         }
                0058     }
                0059     }
                0060     *nienc = ntot;
cba009f524 Ed H*0061 }
                0062 
                0063