DragonFly submit List (threaded) for 2005-02
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Patch to getcap facility
Okay, I think I may finally have figured out how to post to this list. I
sent these before, but didn't realize I needed to be subscribed for them
to be accepted (actually, based on the comments shown on your "cleanup"
page, I had no idea I was submitting to a mailing list at all...call me
naive).
This patch adds const attributes to the getcap facility in preparation
for my WARNS6 patch to getty, which follows this post.
diff -u lib/libc/gen/getcap.3.orig lib/libc/gen/getcap.3
--- lib/libc/gen/getcap.3.orig 2005-02-23 06:23:44.000000000 -0800
+++ lib/libc/gen/getcap.3 2005-02-23 06:27:26.000000000 -0800
@@ -56,23 +56,23 @@
.Sh SYNOPSIS
.In stdlib.h
.Ft int
-.Fn cgetent "char **buf" "char **db_array" "char *name"
+.Fn cgetent "char **buf" "const char *const *db_array" "const char *name"
.Ft int
-.Fn cgetset "char *ent"
+.Fn cgetset "const char *ent"
.Ft int
-.Fn cgetmatch "char *buf" "char *name"
+.Fn cgetmatch "const char *buf" "const char *name"
.Ft char *
-.Fn cgetcap "char *buf" "char *cap" "int type"
+.Fn cgetcap "char *buf" "const char *cap" "const int type"
.Ft int
-.Fn cgetnum "char *buf" "char *cap" "long *num"
+.Fn cgetnum "char *buf" "const char *cap" "long *num"
.Ft int
-.Fn cgetstr "char *buf" "char *cap" "char **str"
+.Fn cgetstr "char *buf" "const char *cap" "char **str"
.Ft int
-.Fn cgetustr "char *buf" "char *cap" "char **str"
+.Fn cgetustr "char *buf" "const char *cap" "char **str"
.Ft int
-.Fn cgetfirst "char **buf" "char **db_array"
+.Fn cgetfirst "char **buf" "const char *const *db_array"
.Ft int
-.Fn cgetnext "char **buf" "char **db_array"
+.Fn cgetnext "char **buf" "const char *const *db_array"
.Ft int
.Fn cgetclose "void"
.Sh DESCRIPTION
diff -u lib/libc/gen/getcap.c.orig lib/libc/gen/getcap.c
--- lib/libc/gen/getcap.c.orig 2005-02-23 05:05:00.000000000 -0800
+++ lib/libc/gen/getcap.c 2005-02-23 06:17:51.000000000 -0800
@@ -68,9 +68,9 @@
static char *toprec; /* Additional record specified by cgetset() */
static int gottoprec; /* Flag indicating retrieval of toprecord */
-static int cdbget (DB *, char **, char *);
-static int getent (char **, u_int *, char **, int, char *, int,
char *);
-static int nfcmp (char *, char *);
+static int cdbget (DB *, char **, const char *);
+static int getent (char **, u_int *, const char *const *, int,
const char *, const int, const char *);
+static int nfcmp (const char *, char *);
/*
* Cgetset() allows the addition of a user specified buffer to be added
@@ -78,8 +78,7 @@
* virtual database. 0 is returned on success, -1 on failure.
*/
int
-cgetset(ent)
- char *ent;
+cgetset(const char *ent)
{
if (ent == NULL) {
if (toprec)
@@ -111,13 +110,11 @@
* return NULL.
*/
char *
-cgetcap(buf, cap, type)
- char *buf, *cap;
- int type;
+cgetcap(char *buf, const char *cap, const int type)
{
- char *bp, *cp;
+ char *bp = buf;
+ const char *cp;
- bp = buf;
for (;;) {
/*
* Skip past the current capability field - it's either the
@@ -163,8 +160,7 @@
* reference loop is detected.
*/
int
-cgetent(buf, db_array, name)
- char **buf, **db_array, *name;
+cgetent(char **buf, const char *const *db_array, const char *name)
{
u_int dummy;
@@ -190,13 +186,13 @@
* MAX_RECURSION.
*/
static int
-getent(cap, len, db_array, fd, name, depth, nfield)
- char **cap, **db_array, *name, *nfield;
- u_int *len;
- int fd, depth;
+getent(char **cap, u_int *len, const char *const *db_array, int fd,
const char *name,
+ const int depth, const char *nfield)
{
DB *capdbp;
- char *r_end, *rp, **db_p;
+ char *rp;
+ const char *r_end;
+ const char *const *db_p;
int myfd, eof, foundit, retval, clen;
char *record, *cbuf;
int tc_not_resolved;
@@ -537,13 +533,11 @@
}
static int
-cdbget(capdbp, bp, name)
- DB *capdbp;
- char **bp, *name;
+cdbget(DB *capdbp, char **bp, const char *name)
{
DBT key, data;
- key.data = name;
+ key.data = (void *)name;
key.size = strlen(name);
for (;;) {
@@ -572,15 +566,14 @@
* record buf, -1 if not.
*/
int
-cgetmatch(buf, name)
- char *buf, *name;
+cgetmatch(const char *buf, const char *name)
{
- char *np, *bp;
+ const char *np;
+ const char *bp = buf;
/*
* Start search at beginning of record.
*/
- bp = buf;
for (;;) {
/*
* Try to match a record name.
@@ -614,8 +607,7 @@
int
-cgetfirst(buf, db_array)
- char **buf, **db_array;
+cgetfirst(char **buf, const char *const *db_array)
{
(void)cgetclose();
return (cgetnext(buf, db_array));
@@ -623,7 +615,7 @@
static FILE *pfp;
static int slash;
-static char **dbp;
+static const char *const *dbp;
int
cgetclose()
@@ -644,9 +636,7 @@
* upon returning an entry with more remaining, and -1 if an error occurs.
*/
int
-cgetnext(bp, db_array)
- char **bp;
- char **db_array;
+cgetnext(char **bp, const char *const *db_array)
{
size_t len;
int done, hadreaderr, i, savederrno, status;
@@ -784,9 +774,7 @@
* allocation failure).
*/
int
-cgetstr(buf, cap, str)
- char *buf, *cap;
- char **str;
+cgetstr(char *buf, const char *cap, char **str)
{
u_int m_room;
char *bp, *mp;
@@ -913,8 +901,7 @@
* error was encountered (storage allocation failure).
*/
int
-cgetustr(buf, cap, str)
- char *buf, *cap, **str;
+cgetustr(char *buf, const char *cap, char **str)
{
u_int m_room;
char *bp, *mp;
@@ -982,9 +969,7 @@
* numeric capability couldn't be found.
*/
int
-cgetnum(buf, cap, num)
- char *buf, *cap;
- long *num;
+cgetnum(char *buf, const char *cap, long *num)
{
long n;
int base, digit;
@@ -1046,8 +1031,7 @@
* Compare name field of record.
*/
static int
-nfcmp(nf, rec)
- char *nf, *rec;
+nfcmp(const char *nf, char *rec)
{
char *cp, tmp;
int ret;
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]