#ident "$Id$"
-#include "defines.h"
#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
#include <sys/stat.h>
#include <stdlib.h>
-#include <limits.h>
#include <utime.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdio.h>
-#include <signal.h>
#include "alloc.h"
#include "atoi/getnum.h"
+#include "commonio.h"
+#include "defines.h"
#include "memzero.h"
#include "nscd.h"
-#include "sssd.h"
#ifdef WITH_TCB
#include <tcb.h>
#endif /* WITH_TCB */
#include "prototypes.h"
-#include "commonio.h"
#include "shadowlog_internal.h"
+#include "sssd.h"
#include "string/sprintf/snprintf.h"
goto cleanup_errno;
while (db->ops->fgets (buf, buflen, db->fp) == buf) {
- char *cp;
struct commonio_entry *p;
while ( (strrchr (buf, '\n') == NULL)
goto cleanup_buf;
}
}
- cp = strrchr (buf, '\n');
- if (NULL != cp) {
- *cp = '\0';
- }
+ *strchrnul(buf, '\n') = '\0';
line = strdup (buf);
if (NULL == line) {
*/
#include <config.h>
-#include "defines.h"
+
#include <stdio.h>
+#include <string.h>
+
+#include "defines.h"
#include "getdef.h"
#include "prototypes.h"
#include "string/strcpy/strtcpy.h"
#ident "$Id$"
+
/*
* This is now rather generic function which decides if "tty" is listed
* under "cfgin" in config (directly or indirectly). Fallback to default if
*/
while (fgets (buf, sizeof (buf), fp) != NULL) {
- /* Remove optional trailing '\n'. */
- buf[strcspn (buf, "\n")] = '\0';
+ *strchrnul(buf, '\n') = '\0';
if (strcmp (buf, tty) == 0) {
(void) fclose (fp);
return true;
#ident "$Id$"
-#include "prototypes.h"
-#include "defines.h"
+#include <ctype.h>
+#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
-#include <ctype.h>
-#include <errno.h>
+#include <string.h>
+
#ifdef USE_ECONF
#include <libeconf.h>
#endif
#include "alloc.h"
#include "atoi/str2i.h"
+#include "defines.h"
#include "getdef.h"
+#include "prototypes.h"
#include "shadowlog_internal.h"
#include "string/sprintf/xasprintf.h"
*s++ = '\0';
value = s + strspn (s, " \"\t"); /* next nonwhite */
- *(value + strcspn (value, "\"")) = '\0';
+ *strchrnul(value, '"') = '\0';
/*
* Store the value in def_table.
}
strcpy (sgrbuf, string);
-
- cp = strrchr (sgrbuf, '\n');
- if (NULL != cp) {
- *cp = '\0';
- }
+ *strchrnul(sgrbuf, '\n') = '\0';
/*
* There should be exactly 4 colon separated fields. Find
return NULL;
}
}
- cp = strrchr (buf, '\n');
- if (NULL != cp) {
- *cp = '\0';
- }
+ *strchrnul(buf, '\n') = '\0';
return (sgetsgent (buf));
}
return NULL;
#ident "$Id$"
-#include <sys/types.h>
-#include <stdio.h>
#include <pwd.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+
#include "defines.h"
-#include "prototypes.h"
#include "getdef.h"
+#include "prototypes.h"
#include "string/sprintf/snprintf.h"
return false;
}
for (found = false; !found && (fgets (buf, sizeof buf, fp) == buf);) {
- buf[strcspn (buf, "\n")] = '\0';
+ *strchrnul(buf, '\n') = '\0';
found = (strcmp (buf, pw->pw_shell) == 0) ||
(strcmp (buf, pw->pw_name) == 0);
}
#ident "$Id$"
-#include <stdio.h>
#include <ctype.h>
#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
#include "defines.h"
-#include "prototypes.h"
#include "port.h"
+#include "prototypes.h"
+
static FILE *ports;
* TTY devices.
*/
- buf[strcspn (buf, "\n")] = 0;
+ *strchrnul(buf, '\n') = '\0';
port.pt_names = ttys;
for (cp = buf, j = 0; j < PORT_TTY; j++) {
}
}
strcpy (grpbuf, buf);
-
- cp = strrchr (grpbuf, '\n');
- if (NULL != cp) {
- *cp = '\0';
- }
+ *strchrnul(grpbuf, '\n') = '\0';
for (cp = grpbuf, i = 0; (i < NFIELDS) && (NULL != cp); i++)
grpfields[i] = strsep(&cp, ":");
return NULL; /* fail if too long */
}
strcpy (spwbuf, string);
-
- cp = strrchr (spwbuf, '\n');
- if (NULL != cp) {
- *cp = '\0';
- }
+ *strchrnul(spwbuf, '\n') = '\0';
/*
* Tokenize the string into colon separated fields. Allow up to
#ident "$Id$"
-#include <sys/types.h>
-#include "prototypes.h"
-#include "defines.h"
#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
#include "atoi/str2i.h"
+#include "defines.h"
+#include "prototypes.h"
static FILE *shadow;
if (strlen (string) >= sizeof spwbuf)
return 0;
strcpy (spwbuf, string);
-
- cp = strrchr (spwbuf, '\n');
- if (NULL != cp)
- *cp = '\0';
+ *strchrnul(spwbuf, '\n') = '\0';
/*
* Tokenize the string into colon separated fields. Allow up to
for (cp = spwbuf, i = 0; *cp && i < FIELDS; i++) {
fields[i] = cp;
- while (*cp && *cp != ':')
- cp++;
-
+ cp = strchrnul(cp, ':');
if (*cp)
*cp++ = '\0';
}
struct spwd *fgetspent (FILE * fp)
{
- char buf[BUFSIZ];
- char *cp;
+ char buf[BUFSIZ];
if (NULL == fp) {
return (0);
if (fgets (buf, sizeof buf, fp) != NULL)
{
- cp = strchr (buf, '\n');
- if (NULL != cp) {
- *cp = '\0';
- }
+ *strchrnul(buf, '\n') = '\0';
return my_sgetspent (buf);
}
return 0;
#ident "$Id$"
#include <stdio.h>
-#include "prototypes.h"
+#include <string.h>
+
#include "defines.h"
#include "getdef.h"
+#include "prototypes.h"
+
+
/*
* ttytype - set ttytype from port to terminal type mapping database
*/
FILE *fp;
char buf[BUFSIZ];
const char *typefile;
- char *cp;
char type[1024] = "";
char port[1024];
continue;
}
- cp = strchr (buf, '\n');
- if (NULL != cp) {
- *cp = '\0';
- }
+ *strchrnul(buf, '\n') = '\0';
if ( (sscanf (buf, "%1023s %1023s", type, port) == 2)
&& (strcmp (line, port) == 0)) {
strcpy (tzbuf, def_tz);
} else {
- /* Remove optional trailing '\n'. */
- tzbuf[strcspn (tzbuf, "\n")] = '\0';
+ *strchrnul(tzbuf, '\n') = '\0';
}
if (NULL != fp) {
* values are used, everything else can be ignored.
*/
while (fgets (buf, sizeof buf, fp) == buf) {
- cp = strrchr (buf, '\n');
- if (NULL != cp) {
- *cp = '\0';
- }
+ *strchrnul(buf, '\n') = '\0';
cp = strchr (buf, '=');
if (NULL == cp) {