~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/default.c

  • Committer: Monty Taylor
  • Date: 2008-09-15 17:24:04 UTC
  • Revision ID: monty@inaugust.com-20080915172404-ygh6hiyu0q7qpa9x
Removed strndup calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
const char *default_directories[MAX_DEFAULT_DIRS + 1];
49
49
 
50
50
static const char *f_extensions[]= { ".cnf", 0 };
 
51
#define NEWLINE "\n"
51
52
 
52
53
static int handle_default_option(void *in_ctx, const char *group_name,
53
54
                                 const char *option);
125
126
*/
126
127
 
127
128
int my_search_option_files(const char *conf_file, int *argc, char ***argv,
128
 
                           uint32_t *args_used, Process_option_func func,
 
129
                           uint *args_used, Process_option_func func,
129
130
                           void *func_ctx)
130
131
{
131
132
  const char **dirs, *forced_default_file, *forced_extra_defaults;
154
155
  if (my_defaults_group_suffix && func == handle_default_option)
155
156
  {
156
157
    /* Handle --defaults-group-suffix= */
157
 
    uint32_t i;
 
158
    uint i;
158
159
    const char **extra_groups;
159
 
    const uint32_t instance_len= strlen(my_defaults_group_suffix); 
 
160
    const uint instance_len= strlen(my_defaults_group_suffix); 
160
161
    struct handle_option_ctx *ctx= (struct handle_option_ctx*) func_ctx;
161
162
    char *ptr;
162
163
    TYPELIB *group= ctx->group;
168
169
    
169
170
    for (i= 0; i < group->count; i++)
170
171
    {
171
 
      uint32_t len;
 
172
      uint len;
172
173
      extra_groups[i]= group->type_names[i]; /** copy group */
173
174
      
174
175
      len= strlen(extra_groups[i]);
201
202
  }
202
203
  else if (dirname_length(conf_file))
203
204
  {
204
 
    if ((error= search_default_file(func, func_ctx, NULL, conf_file)) < 0)
 
205
    if ((error= search_default_file(func, func_ctx, NullS, conf_file)) < 0)
205
206
      goto err;
206
207
  }
207
208
  else
273
274
  {
274
275
    if (!(tmp= alloc_root(ctx->alloc, strlen(option) + 1)))
275
276
      return 1;
276
 
    if (insert_dynamic(ctx->args, (unsigned char*) &tmp))
 
277
    if (insert_dynamic(ctx->args, (uchar*) &tmp))
277
278
      return 1;
278
 
    my_stpcpy(tmp, option);
 
279
    stpcpy(tmp, option);
279
280
  }
280
281
 
281
282
  return 0;
371
372
  DYNAMIC_ARRAY args;
372
373
  TYPELIB group;
373
374
  bool found_print_defaults= 0;
374
 
  uint32_t args_used= 0;
 
375
  uint args_used= 0;
375
376
  int error= 0;
376
377
  MEM_ROOT alloc;
377
378
  char *ptr,**res;
386
387
  if (*argc >= 2 && !strcmp(argv[0][1],"--no-defaults"))
387
388
  {
388
389
    /* remove the --no-defaults argument and return only the other arguments */
389
 
    uint32_t i;
 
390
    uint i;
390
391
    if (!(ptr=(char*) alloc_root(&alloc,sizeof(alloc)+
391
392
                                 (*argc + 1)*sizeof(char*))))
392
393
      goto err;
516
517
*/
517
518
 
518
519
static char *get_argument(const char *keyword, size_t kwlen,
519
 
                          char *ptr, char *name, uint32_t line)
 
520
                          char *ptr, char *name, uint line)
520
521
{
521
522
  char *end;
522
523
 
585
586
  static const char include_keyword[]= "include";
586
587
  const int max_recursion_level= 10;
587
588
  FILE *fp;
588
 
  uint32_t line=0;
 
589
  uint line=0;
589
590
  bool found_group=0;
590
 
  uint32_t i;
 
591
  uint i;
591
592
  MY_DIR *search_dir;
592
593
  FILEINFO *search_file;
593
594
 
595
596
    return 0;                                   /* Ignore wrong paths */
596
597
  if (dir)
597
598
  {
598
 
    end=convert_dirname(name, dir, NULL);
 
599
    end=convert_dirname(name, dir, NullS);
599
600
    if (dir[0] == FN_HOMELIB)           /* Add . to filenames in home */
600
601
      *end++='.';
601
 
    strxmov(end,config_file,ext,NULL);
 
602
    strxmov(end,config_file,ext,NullS);
602
603
  }
603
604
  else
604
605
  {
605
 
    my_stpcpy(name,config_file);
 
606
    stpcpy(name,config_file);
606
607
  }
607
608
  fn_format(name,name,"","",4);
608
609
  {
721
722
      for ( ; my_isspace(&my_charset_utf8_general_ci,end[-1]) ; end--) ;
722
723
      end[0]=0;
723
724
 
724
 
      strmake(curr_gr, ptr, cmin((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
 
725
      strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1));
725
726
 
726
727
      /* signal that a new group is found */
727
728
      opt_handler(handler_ctx, curr_gr, NULL);
743
744
    for ( ; my_isspace(&my_charset_utf8_general_ci,end[-1]) ; end--) ;
744
745
    if (!value)
745
746
    {
746
 
      strmake(my_stpcpy(option,"--"),ptr, (size_t) (end-ptr));
 
747
      strmake(stpcpy(option,"--"),ptr, (size_t) (end-ptr));
747
748
      if (opt_handler(handler_ctx, curr_gr, option))
748
749
        goto err;
749
750
    }
769
770
        value++;
770
771
        value_end--;
771
772
      }
772
 
      ptr=my_stpncpy(my_stpcpy(option,"--"),ptr,(size_t) (end-ptr));
 
773
      ptr=stpncpy(stpcpy(option,"--"),ptr,(size_t) (end-ptr));
773
774
      *ptr++= '=';
774
775
 
775
776
      for ( ; value != value_end; value++)
876
877
          pos= my_defaults_extra_file;
877
878
        else
878
879
          continue;
879
 
        end= convert_dirname(name, pos, NULL);
 
880
        end= convert_dirname(name, pos, NullS);
880
881
        if (name[0] == FN_HOMELIB)      /* Add . to filenames in home */
881
882
          *end++='.';
882
 
        strxmov(end, conf_file, *ext, " ", NULL);
 
883
        strxmov(end, conf_file, *ext, " ", NullS);
883
884
        fputs(name,stdout);
884
885
      }
885
886
    }
938
939
 
939
940
  @details
940
941
    1. /etc/
941
 
    2. /etc/drizzle/
 
942
    2. /etc/mysql/
942
943
    3. --sysconfdir=<path> (compile-time option)
943
944
    4. getenv(DEFAULT_HOME_ENV)
944
945
    5. --defaults-extra-file=<path> (run-time option)
949
950
{
950
951
  memset(default_directories, 0, sizeof(default_directories));
951
952
  ADD_DIRECTORY("/etc/");
952
 
  ADD_DIRECTORY("/etc/drizzle/");
 
953
  ADD_DIRECTORY("/etc/mysql/");
953
954
#if defined(DEFAULT_SYSCONFDIR)
954
955
    ADD_DIRECTORY(DEFAULT_SYSCONFDIR);
955
956
#endif