Print this page
make: fix GCC warnings


  22  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 
  27 #include <stdlib.h>
  28 #include <string.h>
  29 
  30 #include <vroot/vroot.h>
  31 #include <vroot/args.h>
  32 
  33 #include <string.h>
  34 #include <sys/param.h>
  35 #include <sys/file.h>
  36 
  37 #include <avo/intl.h>     /* for NOCATGETS */
  38 
  39 typedef struct {
  40         short           init;
  41         pathpt          vector;
  42         char            *env_var;
  43 } vroot_patht;
  44 
  45 typedef struct {
  46         vroot_patht     vroot;
  47         vroot_patht     path;
  48         char            full_path[MAXPATHLEN+1];
  49         char            *vroot_start;
  50         char            *path_start;
  51         char            *filename_start;
  52         int             scan_vroot_first;
  53         int             cpp_style_path;
  54 } vroot_datat, *vroot_datapt;
  55 
  56 static vroot_datat      vroot_data= {
  57         { 0, NULL, NOCATGETS("VIRTUAL_ROOT")},
  58         { 0, NULL, NOCATGETS("PATH")},
  59         "", NULL, NULL, NULL, 0, 1};
  60 
  61 void
  62 add_dir_to_path(register char *path, register pathpt *pointer, register int position)
  63 {
  64         register int            size= 0;
  65         register int            length;
  66         register char           *name;
  67         register pathcellpt     p;
  68         pathpt                  new_path;
  69 
  70         if (*pointer != NULL) {
  71                 for (p= &((*pointer)[0]); p->path != NULL; p++, size++);
  72                 if (position < 0)
  73                         position= size;}
  74         else
  75                 if (position < 0)
  76                         position= 0;
  77         if (position >= size) {
  78                 new_path= (pathpt)calloc((unsigned)(position+2), sizeof(pathcellt));
  79                 if (*pointer != NULL) {
  80                         memcpy((char *)new_path,(char *)(*pointer),  size*sizeof(pathcellt));
  81                         free((char *)(*pointer));};
  82                 *pointer= new_path;};


  90 }
  91 
  92 pathpt
  93 parse_path_string(register char *string, register int remove_slash)
  94 {
  95         register char           *p;
  96         pathpt                  result= NULL;
  97 
  98         if (string != NULL)
  99                 for (; 1; string= p+1) {
 100                         if (p= strchr(string, ':')) *p= 0;
 101                         if ((remove_slash == 1) && !strcmp(string, "/"))
 102                                 add_dir_to_path("", &result, -1);
 103                         else
 104                                 add_dir_to_path(string, &result, -1);
 105                         if (p) *p= ':';
 106                         else return(result);};
 107         return((pathpt)NULL);
 108 }
 109 
 110 char *
 111 get_vroot_name(void)
 112 {
 113         return(vroot_data.vroot.env_var);
 114 }
 115 
 116 char *
 117 get_path_name(void)
 118 {
 119         return(vroot_data.path.env_var);
 120 }
 121 
 122 void
 123 flush_path_cache(void)
 124 {
 125         vroot_data.path.init= 0;
 126 }
 127 
 128 void
 129 flush_vroot_cache(void)
 130 {
 131         vroot_data.vroot.init= 0;
 132 }
 133 
 134 void
 135 scan_path_first(void)
 136 {




  22  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 
  27 #include <stdlib.h>
  28 #include <string.h>
  29 
  30 #include <vroot/vroot.h>
  31 #include <vroot/args.h>
  32 
  33 #include <string.h>
  34 #include <sys/param.h>
  35 #include <sys/file.h>
  36 
  37 #include <avo/intl.h>     /* for NOCATGETS */
  38 
  39 typedef struct {
  40         short           init;
  41         pathpt          vector;
  42         const char      *env_var;
  43 } vroot_patht;
  44 
  45 typedef struct {
  46         vroot_patht     vroot;
  47         vroot_patht     path;
  48         char            full_path[MAXPATHLEN+1];
  49         char            *vroot_start;
  50         char            *path_start;
  51         char            *filename_start;
  52         int             scan_vroot_first;
  53         int             cpp_style_path;
  54 } vroot_datat, *vroot_datapt;
  55 
  56 static vroot_datat      vroot_data= {
  57         { 0, NULL, NOCATGETS("VIRTUAL_ROOT")},
  58         { 0, NULL, NOCATGETS("PATH")},
  59         "", NULL, NULL, NULL, 0, 1};
  60 
  61 void
  62 add_dir_to_path(const char *path, register pathpt *pointer, register int position)
  63 {
  64         register int            size= 0;
  65         register int            length;
  66         register char           *name;
  67         register pathcellpt     p;
  68         pathpt                  new_path;
  69 
  70         if (*pointer != NULL) {
  71                 for (p= &((*pointer)[0]); p->path != NULL; p++, size++);
  72                 if (position < 0)
  73                         position= size;}
  74         else
  75                 if (position < 0)
  76                         position= 0;
  77         if (position >= size) {
  78                 new_path= (pathpt)calloc((unsigned)(position+2), sizeof(pathcellt));
  79                 if (*pointer != NULL) {
  80                         memcpy((char *)new_path,(char *)(*pointer),  size*sizeof(pathcellt));
  81                         free((char *)(*pointer));};
  82                 *pointer= new_path;};


  90 }
  91 
  92 pathpt
  93 parse_path_string(register char *string, register int remove_slash)
  94 {
  95         register char           *p;
  96         pathpt                  result= NULL;
  97 
  98         if (string != NULL)
  99                 for (; 1; string= p+1) {
 100                         if (p= strchr(string, ':')) *p= 0;
 101                         if ((remove_slash == 1) && !strcmp(string, "/"))
 102                                 add_dir_to_path("", &result, -1);
 103                         else
 104                                 add_dir_to_path(string, &result, -1);
 105                         if (p) *p= ':';
 106                         else return(result);};
 107         return((pathpt)NULL);
 108 }
 109 
 110 const char *
 111 get_vroot_name(void)
 112 {
 113         return(vroot_data.vroot.env_var);
 114 }
 115 
 116 const char *
 117 get_path_name(void)
 118 {
 119         return(vroot_data.path.env_var);
 120 }
 121 
 122 void
 123 flush_path_cache(void)
 124 {
 125         vroot_data.path.init= 0;
 126 }
 127 
 128 void
 129 flush_vroot_cache(void)
 130 {
 131         vroot_data.vroot.init= 0;
 132 }
 133 
 134 void
 135 scan_path_first(void)
 136 {