OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [argz/] [envz_merge.c] - Blame information for rev 262

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/* Copyright (C) 2002 by  Red Hat, Incorporated. All rights reserved.
2
 *
3
 * Permission to use, copy, modify, and distribute this software
4
 * is freely granted, provided that this notice is preserved.
5
 */
6
 
7
#include <errno.h>
8
#include <sys/types.h>
9
#include <string.h>
10
#include <stdlib.h>
11
#include <argz.h>
12
#include <envz.h>
13
 
14
error_t
15
_DEFUN (envz_merge, (envz, envz_len, envz2, envz2_len, override),
16
       char **envz _AND
17
       size_t *envz_len _AND
18
       const char *envz2 _AND
19
       size_t envz2_len _AND
20
       int override)
21
{
22
  char *entry = NULL;
23
  char *name_str = NULL;
24
  char *val_str = NULL;
25
  char *name_iter = NULL;
26
  int retval = 0;
27
 
28
  while((entry = argz_next((char *)envz2, envz2_len, entry)) && !retval)
29
    {
30
      if (!override)
31
        {
32
          name_str = strdup (entry);
33
          name_iter = strchr(name_str, '=');
34
          if(name_iter)
35
            *name_iter = '\0';
36
 
37
          if(!envz_entry(*envz, *envz_len, name_str))
38
            {
39
              retval = argz_add(envz, envz_len, entry);
40
            }
41
          free(name_str);
42
        }
43
      else
44
        {
45
          name_str = strdup (entry);
46
          name_iter = strchr(name_str, '=');
47
          if(name_iter)
48
            {
49
              *name_iter = '\0';
50
              val_str = name_iter + 1;
51
            }
52
          else
53
            {
54
              val_str = NULL;
55
            }
56
 
57
          retval = envz_add(envz, envz_len, name_str, val_str);
58
        }
59
    }
60
  return retval;
61
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.