Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nadezhda Ivanova
OpenLDAP
Commits
926ba6cb
Commit
926ba6cb
authored
26 years ago
by
Kurt Zeilenga
Browse files
Options
Downloads
Patches
Plain Diff
New files from Autoconf branch.
parent
dd51f860
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libraries/liblutil/getopt.c
+102
-0
102 additions, 0 deletions
libraries/liblutil/getopt.c
libraries/liblutil/strdup.c
+19
-0
19 additions, 0 deletions
libraries/liblutil/strdup.c
libraries/liblutil/tempnam.c
+38
-0
38 additions, 0 deletions
libraries/liblutil/tempnam.c
with
159 additions
and
0 deletions
libraries/liblutil/getopt.c
0 → 100644
+
102
−
0
View file @
926ba6cb
/*
getopt.c
modified public-domain AT&T getopt(3)
modified by Kurt Zeilenga for inclusion into OpenLDAP
*/
#include
"portable.h"
#ifndef HAVE_GETOPT
#include
<stdio.h>
#include
<ac/string.h>
#include
<ac/unistd.h>
#ifdef HAVE_IO_H
#include
<io.h>
#endif
#ifndef STDERR_FILENO
#define STDERR_FILENO 2
#endif
int
opterr
=
1
;
int
optind
=
1
;
int
optopt
;
char
*
optarg
;
static
void
ERR
(
char
**
argv
,
char
*
s
,
char
c
)
{
char
errbuf
[
2
];
#ifdef DF_TRACE_DEBUG
printf
(
"DF_TRACE_DEBUG: static void ERR () in getopt.c
\n
"
);
#endif
if
(
opterr
)
{
errbuf
[
0
]
=
c
;
errbuf
[
1
]
=
'\n'
;
(
void
)
write
(
STDERR_FILENO
,
argv
[
0
],
strlen
(
argv
[
0
]));
(
void
)
write
(
STDERR_FILENO
,
s
,
strlen
(
s
));
(
void
)
write
(
STDERR_FILENO
,
errbuf
,
sizeof
errbuf
);
}
}
int
getopt
(
int
argc
,
char
**
argv
,
char
*
opts
)
{
static
int
sp
=
1
,
error
=
(
int
)
'?'
;
static
char
sw
=
'-'
,
eos
=
'\0'
,
arg
=
':'
;
register
char
c
,
*
cp
;
#ifdef DF_TRACE_DEBUG
printf
(
"DF_TRACE_DEBUG: int getopt () in getopt.c
\n
"
);
#endif
if
(
sp
==
1
)
if
(
optind
>=
argc
||
argv
[
optind
][
0
]
!=
sw
||
argv
[
optind
][
1
]
==
eos
)
return
EOF
;
else
if
(
strcmp
(
argv
[
optind
],
"--"
)
==
0
)
{
optind
++
;
return
EOF
;
}
c
=
argv
[
optind
][
sp
];
optopt
=
(
int
)
c
;
if
(
c
==
arg
||
(
cp
=
strchr
(
opts
,
c
))
==
NULL
)
{
ERR
(
argv
,
": illegal option--"
,
c
);
if
(
argv
[
optind
][
++
sp
]
==
eos
)
{
optind
++
;
sp
=
1
;
}
return
error
;
}
else
if
(
*++
cp
==
arg
)
{
if
(
argv
[
optind
][
sp
+
1
]
!=
eos
)
optarg
=
&
argv
[
optind
++
][
sp
+
1
];
else
if
(
++
optind
>=
argc
)
{
ERR
(
argv
,
": option requires an argument--"
,
c
);
sp
=
1
;
return
error
;
}
else
optarg
=
argv
[
optind
++
];
sp
=
1
;
}
else
{
if
(
argv
[
optind
][
++
sp
]
==
eos
)
{
sp
=
1
;
optind
++
;
}
optarg
=
NULL
;
}
return
(
int
)
c
;
}
#endif
/* HAVE_GETOPT */
This diff is collapsed.
Click to expand it.
libraries/liblutil/strdup.c
0 → 100644
+
19
−
0
View file @
926ba6cb
#include
"portable.h"
#ifndef HAVE_STRDUP
#include
<ac/string.h>
char
*
strdup
(
const
char
*
s
)
{
char
*
p
;
if
(
(
p
=
(
char
*
)
malloc
(
strlen
(
s
)
+
1
))
==
NULL
)
return
(
NULL
);
strcpy
(
p
,
s
);
return
(
p
);
}
#endif
/* !strdup */
This diff is collapsed.
Click to expand it.
libraries/liblutil/tempnam.c
0 → 100644
+
38
−
0
View file @
926ba6cb
#include
"portable.h"
#ifndef HAVE_TEMPNAME
#include
<ac/string.h>
char
*
tempnam
(
char
*
dir
,
char
*
pfx
)
{
char
*
s
;
if
(
dir
==
NULL
)
{
dir
=
"/tmp"
;
}
/*
* allocate space for dir + '/' + pfx (up to 5 chars) + 6 trailing 'X's + 0 byte
*/
if
((
s
=
(
char
*
)
malloc
(
strlen
(
dir
)
+
14
))
==
NULL
)
{
return
(
NULL
);
}
strcpy
(
s
,
dir
);
strcat
(
s
,
"/"
);
if
(
pfx
!=
NULL
)
{
strcat
(
s
,
pfx
);
}
strcat
(
s
,
"XXXXXX"
);
mktemp
(
s
);
if
(
*
s
==
'\0'
)
{
free
(
s
);
s
=
NULL
;
}
return
(
s
);
}
#endif
/* nextstep */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment