Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
8220d3de
Commit
8220d3de
authored
Apr 22, 2006
by
Avuton Olrich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for the macro, use gitsetenv, thanks to normalperson, eleusis, jat
git-svn-id:
https://svn.musicpd.org/mpd/trunk@4098
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
3accf44a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
8 deletions
+34
-8
main.c
src/main.c
+34
-8
No files found.
src/main.c
View file @
8220d3de
...
...
@@ -67,17 +67,43 @@ typedef struct _Options {
int
updateDB
;
}
Options
;
/* Solaris has been reported to have no setenv
* putenv() will automatically overwrite, so
* the overwrite macro will go unused
/*
* from git-1.3.0, needed for solaris
*/
#ifndef setenv
#define setenv(name,value,overwrite) { \
char * tmp = NULL; \
sprintf(tmp,"%s=%s",name,value); \
putenv(tmp); \
int
setenv
(
const
char
*
name
,
const
char
*
value
,
int
replace
)
{
int
out
;
size_t
namelen
,
valuelen
;
char
*
envstr
;
if
(
!
name
||
!
value
)
return
-
1
;
if
(
!
replace
)
{
char
*
oldval
=
NULL
;
oldval
=
getenv
(
name
);
if
(
oldval
)
return
0
;
}
namelen
=
strlen
(
name
);
valuelen
=
strlen
(
value
);
envstr
=
malloc
((
namelen
+
valuelen
+
2
));
if
(
!
envstr
)
return
-
1
;
memcpy
(
envstr
,
name
,
namelen
);
envstr
[
namelen
]
=
'='
;
memcpy
(
envstr
+
namelen
+
1
,
value
,
valuelen
);
envstr
[
namelen
+
valuelen
+
1
]
=
0
;
out
=
putenv
(
envstr
);
/* putenv(3) makes the argument string part of the environment,
* and changing that string modifies the environment --- which
* means we do not own that storage anymore. Do not free
* envstr.
*/
return
out
;
}
#endif
/* setenv */
#endif
void
usage
(
char
*
argv
[])
{
ERROR
(
"usage:
\n
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment