2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
5 Internal functions for environment variables handling.
8 #include "__arosc_privdata.h"
12 #include <proto/exec.h>
16 static __env_item
*__env_newvar(const char *name
, int valuesize
)
20 item
= malloc(sizeof(__env_item
));
23 item
->name
= strdup(name
);
24 if (!item
->name
) goto err2
;
26 item
->value
= malloc(valuesize
);
27 if (!item
->value
) goto err3
;
41 static __env_item
**internal_findvar(register const char *name
)
48 *curr
&& strcmp((*curr
)->name
, name
);
49 curr
= &((*curr
)->next
)
56 Allocates space for a variable with name 'name' returning a pointer to it.
57 If a variable with this name already exists then returns a pointer to that
60 Returns NULL on error.
62 __env_item
*__env_getvar(const char *name
, int valuesize
)
64 register __env_item
**curr
;
66 curr
= internal_findvar(name
);
70 if (strlen((*curr
)->value
) < valuesize
)
73 (*curr
)->value
= malloc(valuesize
);
77 __env_item
*tmp
= (*curr
)->next
;
86 *curr
= __env_newvar(name
, valuesize
);
92 void __env_delvar(const char *name
)
94 register __env_item
**curr
;
96 curr
= internal_findvar(name
);
100 register __env_item
*tmp
= *curr
;
102 *curr
= (*curr
)->next
;