[Pkg-shadow-commits] r2168 - in upstream/trunk: . lib
nekral-guest at alioth.debian.org
nekral-guest at alioth.debian.org
Fri Jun 13 21:35:23 UTC 2008
Author: nekral-guest
Date: 2008-06-13 21:35:22 +0000 (Fri, 13 Jun 2008)
New Revision: 2168
Modified:
upstream/trunk/ChangeLog
upstream/trunk/lib/getdef.c
upstream/trunk/lib/getdef.h
Log:
* lib/getdef.h, lib/getdef.c: Add getdef_ulong().
* lib/getdef.c: Added TODOs because of lack of error checking.
* lib/getdef.c: The size argument of fgets is an int, not a
size_t.
* lib/getdef.c: Avoid multi-statements lines.
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2008-06-13 21:31:23 UTC (rev 2167)
+++ upstream/trunk/ChangeLog 2008-06-13 21:35:22 UTC (rev 2168)
@@ -1,5 +1,13 @@
2008-06-13 Nicolas François <nicolas.francois at centraliens.net>
+ * lib/getdef.h, lib/getdef.c: Add getdef_ulong().
+ * lib/getdef.c: Added TODOs because of lack of error checking.
+ * lib/getdef.c: The size argument of fgets is an int, not a
+ size_t.
+ * lib/getdef.c: Avoid multi-statements lines.
+
+2008-06-13 Nicolas François <nicolas.francois at centraliens.net>
+
* src/id.c: Make sure malloc receives a size_t.
* src/id.c: Use a %lu format and cast group and user IDs to
unsigned long integers.
Modified: upstream/trunk/lib/getdef.c
===================================================================
--- upstream/trunk/lib/getdef.c 2008-06-13 21:31:23 UTC (rev 2167)
+++ upstream/trunk/lib/getdef.c 2008-06-13 21:35:22 UTC (rev 2168)
@@ -203,6 +203,7 @@
}
return (int) strtol (d->value, (char **) NULL, 0);
+ /* TODO: check for errors */
}
@@ -228,6 +229,7 @@
}
return (unsigned int) strtoul (d->value, (char **) NULL, 0);
+ /* TODO: check for errors */
}
@@ -253,9 +255,34 @@
}
return strtol (d->value, (char **) NULL, 0);
+ /* TODO: check for errors */
}
+/*
+ * getdef_ulong - get unsigned long numerical value from table of definitions
+ *
+ * Returns numeric value of specified item, else the "dflt" value if
+ * the item is not defined. Octal (leading "0") and hex (leading "0x")
+ * values are handled.
+ */
+unsigned long getdef_ulong (const char *item, unsigned int dflt)
+{
+ struct itemdef *d;
+
+ if (!def_loaded) {
+ def_load ();
+ }
+
+ d = def_find (item);
+ if ((NULL == d) || (NULL == d->value)) {
+ return dflt;
+ }
+
+ return (unsigned long) strtoul (d->value, (char **) NULL, 0);
+ /* TODO: check for errors */
+}
+
/*
* putdef_str - override the value read from /etc/login.defs
* (also used when loading the initial defaults)
@@ -364,17 +391,18 @@
/*
* Go through all of the lines in the file.
*/
- while (fgets (buf, sizeof (buf), fp) != NULL) {
+ while (fgets (buf, (int) sizeof (buf), fp) != NULL) {
/*
* Trim trailing whitespace.
*/
- for (i = strlen (buf) - 1; i >= 0; --i) {
+ for (i = (int) strlen (buf) - 1; i >= 0; --i) {
if (!isspace (buf[i])) {
break;
}
}
- buf[++i] = '\0';
+ i++;
+ buf[i] = '\0';
/*
* Break the line into two fields.
Modified: upstream/trunk/lib/getdef.h
===================================================================
--- upstream/trunk/lib/getdef.h 2008-06-13 21:31:23 UTC (rev 2167)
+++ upstream/trunk/lib/getdef.h 2008-06-13 21:35:22 UTC (rev 2168)
@@ -36,6 +36,7 @@
extern bool getdef_bool (const char *);
extern long getdef_long (const char *, long);
extern int getdef_num (const char *, int);
+extern unsigned int getdef_ulong (const char *, unsigned long);
extern unsigned int getdef_unum (const char *, unsigned int);
extern char *getdef_str (const char *);
extern int putdef_str (const char *, const char *);
More information about the Pkg-shadow-commits
mailing list