Browse Source

Formatting update

Eric Andersen 23 years ago
parent
commit
e2aa1f4fa9

+ 33 - 0
libc/pwd_grp/.indent.pro

@@ -0,0 +1,33 @@
+--blank-lines-after-declarations
+--blank-lines-after-procedures
+--break-before-boolean-operator
+--no-blank-lines-after-commas
+--braces-on-if-line
+--braces-on-struct-decl-line
+--comment-indentation25
+--declaration-comment-column25
+--no-comment-delimiters-on-blank-lines
+--cuddle-else
+--continuation-indentation4
+--case-indentation0
+--else-endif-column33
+--space-after-cast
+--line-comments-indentation0
+--declaration-indentation1
+--dont-format-first-column-comments
+--dont-format-comments
+--honour-newlines
+--indent-level4
+/* changed from 0 to 4 */
+--parameter-indentation4
+--line-length78 /* changed from 75 */
+--continue-at-parentheses
+--no-space-after-function-call-names
+--dont-break-procedure-type
+--dont-star-comments
+--leave-optional-blank-lines
+--dont-space-special-semicolon
+--tab-size4
+/* additions by Mark */
+--case-brace-indentation0
+--leave-preprocessor-space

+ 122 - 118
libc/pwd_grp/__getgrent.c

@@ -29,140 +29,144 @@
  * getgrent() except that it is passed a file descriptor.  getgrent()
  * is just a wrapper for this function.
  */
-struct group *
-__getgrent(int grp_fd)
+struct group *__getgrent(int grp_fd)
 {
-#ifndef GR_SCALE_DYNAMIC  
-  static char line_buff[GR_MAX_LINE_LEN];
-  static char * members[GR_MAX_MEMBERS];
+#ifndef GR_SCALE_DYNAMIC
+	static char line_buff[GR_MAX_LINE_LEN];
+	static char *members[GR_MAX_MEMBERS];
 #else
-  static char * line_buff = NULL;
-  static char ** members = NULL;
-  short line_index;
-  short buff_size;
+	static char *line_buff = NULL;
+	static char **members = NULL;
+	short line_index;
+	short buff_size;
 #endif
-  static struct group group;
-  register char * ptr;
-  char * field_begin;
-  short member_num;
-  char * endptr;
-  int line_len;
+	static struct group group;
+	register char *ptr;
+	char *field_begin;
+	short member_num;
+	char *endptr;
+	int line_len;
 
 
-  /* We use the restart label to handle malformatted lines */
-restart:
+	/* We use the restart label to handle malformatted lines */
+  restart:
 #ifdef GR_SCALE_DYNAMIC
-  line_index=0;
-  buff_size=256;
+	line_index = 0;
+	buff_size = 256;
 #endif
 
 #ifndef GR_SCALE_DYNAMIC
-  /* Read the line into the static buffer */
-  if ((line_len=read(grp_fd, line_buff, GR_MAX_LINE_LEN))<=0)
-    return NULL;
-  field_begin=strchr(line_buff, '\n');
-  if (field_begin!=NULL)
-    lseek(grp_fd, (long) (1+field_begin-(line_buff+line_len)), SEEK_CUR);
-  else /* The line is too long - skip it :-\ */
-    {
-      do { if ((line_len=read(grp_fd, line_buff, GR_MAX_LINE_LEN))<=0)
-	return NULL;
-      } while (!(field_begin=strchr(line_buff, '\n')));
-      lseek(grp_fd, (long) ((field_begin-line_buff)-line_len+1), SEEK_CUR);
-      goto restart;
-    }
-  if (*line_buff=='#' || *line_buff==' ' || *line_buff=='\n' ||
-      *line_buff=='\t')
-    goto restart;
-  *field_begin='\0';
-
-#else /* !GR_SCALE_DYNAMIC */
-  line_buff=realloc(line_buff, buff_size);
-  while (1)
-    {
-      if ((line_len=read(grp_fd, line_buff+line_index,
-			 buff_size-line_index))<=0)
-	  return NULL;
-      field_begin=strchr(line_buff, '\n');
-      if (field_begin!=NULL)
-	{
-	  lseek(grp_fd, (long) (1+field_begin-(line_len+line_index+line_buff)),
-		SEEK_CUR);
-	  *field_begin='\0';
-	  if (*line_buff=='#' || *line_buff==' ' || *line_buff=='\n' ||
-	      *line_buff=='\t')
-	    goto restart;
-	  break;
+	/* Read the line into the static buffer */
+	if ((line_len = read(grp_fd, line_buff, GR_MAX_LINE_LEN)) <= 0)
+		return NULL;
+	field_begin = strchr(line_buff, '\n');
+	if (field_begin != NULL)
+		lseek(grp_fd, (long) (1 + field_begin - (line_buff + line_len)),
+			  SEEK_CUR);
+	else {						/* The line is too long - skip it :-\ */
+
+		do {
+			if ((line_len = read(grp_fd, line_buff, GR_MAX_LINE_LEN)) <= 0)
+				return NULL;
+		} while (!(field_begin = strchr(line_buff, '\n')));
+		lseek(grp_fd, (long) ((field_begin - line_buff) - line_len + 1),
+			  SEEK_CUR);
+		goto restart;
 	}
-      else /* Allocate some more space */
-	{
-	  line_index=buff_size;
-	  buff_size+=256;
-	  line_buff=realloc(line_buff, buff_size);
+	if (*line_buff == '#' || *line_buff == ' ' || *line_buff == '\n' ||
+		*line_buff == '\t')
+		goto restart;
+	*field_begin = '\0';
+
+#else							/* !GR_SCALE_DYNAMIC */
+	line_buff = realloc(line_buff, buff_size);
+	while (1) {
+		if ((line_len = read(grp_fd, line_buff + line_index,
+							 buff_size - line_index)) <= 0)
+			return NULL;
+		field_begin = strchr(line_buff, '\n');
+		if (field_begin != NULL) {
+			lseek(grp_fd,
+				  (long) (1 + field_begin -
+						  (line_len + line_index + line_buff)), SEEK_CUR);
+			*field_begin = '\0';
+			if (*line_buff == '#' || *line_buff == ' '
+				|| *line_buff == '\n' || *line_buff == '\t')
+				goto restart;
+			break;
+		} else {				/* Allocate some more space */
+
+			line_index = buff_size;
+			buff_size += 256;
+			line_buff = realloc(line_buff, buff_size);
+		}
 	}
-    }
-#endif /* GR_SCALE_DYNAMIC */
+#endif							/* GR_SCALE_DYNAMIC */
 
-  /* Now parse the line */
-  group.gr_name=line_buff;
-  ptr=strchr(line_buff, ':');
-  if (ptr==NULL) goto restart;
-  *ptr++='\0';
+	/* Now parse the line */
+	group.gr_name = line_buff;
+	ptr = strchr(line_buff, ':');
+	if (ptr == NULL)
+		goto restart;
+	*ptr++ = '\0';
 
-  group.gr_passwd=ptr;
-  ptr=strchr(ptr, ':');
-  if (ptr==NULL) goto restart;
-  *ptr++='\0';
+	group.gr_passwd = ptr;
+	ptr = strchr(ptr, ':');
+	if (ptr == NULL)
+		goto restart;
+	*ptr++ = '\0';
 
-  field_begin=ptr;
-  ptr=strchr(ptr, ':');
-  if (ptr==NULL) goto restart;
-  *ptr++='\0';
+	field_begin = ptr;
+	ptr = strchr(ptr, ':');
+	if (ptr == NULL)
+		goto restart;
+	*ptr++ = '\0';
 
-  group.gr_gid=(gid_t) strtoul(field_begin, &endptr, 10);
-  if (*endptr!='\0') goto restart;
+	group.gr_gid = (gid_t) strtoul(field_begin, &endptr, 10);
+	if (*endptr != '\0')
+		goto restart;
 
-  member_num=0;
-  field_begin=ptr;
+	member_num = 0;
+	field_begin = ptr;
 
 #ifndef GR_SCALE_DYNAMIC
-  while ((ptr=strchr(ptr, ','))!=NULL)
-    {
-      *ptr='\0';
-      ptr++;
-      members[member_num]=field_begin;
-      field_begin=ptr;
-      member_num++;
-    }
-  if (*field_begin=='\0')
-    members[member_num]=NULL;
-  else
-    {
-      members[member_num]=field_begin;
-      members[member_num+1]=NULL;
-    }
-#else /* !GR_SCALE_DYNAMIC */
-  if (members!=NULL)
-    free (members);
-  members=(char **) malloc(1*sizeof(char *));
-  while ((ptr=strchr(ptr, ','))!=NULL)
-    {
-      *ptr='\0';
-      ptr++;
-      members[member_num]=field_begin;
-      field_begin=ptr;
-      member_num++;
-      members=(char **)realloc((void *)members, (member_num+1)*sizeof(char *));
-    }
-  if (*field_begin=='\0')
-      members[member_num]=NULL;
-  else
-    {
-      members[member_num]=field_begin;
-      members[member_num+1]=NULL;
-    }
-#endif /* GR_SCALE_DYNAMIC */
-
-  group.gr_mem=members;
-  return &group;
+	while ((ptr = strchr(ptr, ',')) != NULL) {
+		*ptr = '\0';
+		ptr++;
+		members[member_num] = field_begin;
+		field_begin = ptr;
+		member_num++;
+	}
+	if (*field_begin == '\0')
+		members[member_num] = NULL;
+	else {
+		members[member_num] = field_begin;
+		members[member_num + 1] = NULL;
+	}
+#else							/* !GR_SCALE_DYNAMIC */
+	if (members != NULL)
+		free(members);
+	members = (char **) malloc(1 * sizeof(char *));
+
+	while ((ptr = strchr(ptr, ',')) != NULL) {
+		*ptr = '\0';
+		ptr++;
+		members[member_num] = field_begin;
+		field_begin = ptr;
+		member_num++;
+		members =
+			(char **) realloc((void *) members,
+
+							  (member_num + 1) * sizeof(char *));
+	}
+	if (*field_begin == '\0')
+		members[member_num] = NULL;
+	else {
+		members[member_num] = field_begin;
+		members[member_num + 1] = NULL;
+	}
+#endif							/* GR_SCALE_DYNAMIC */
+
+	group.gr_mem = members;
+	return &group;
 }

+ 7 - 9
libc/pwd_grp/fgetgrent.c

@@ -22,14 +22,12 @@
 #include <errno.h>
 #include <grp.h>
 
-struct group *
-fgetgrent(FILE * file)
+struct group *fgetgrent(FILE * file)
 {
-  if (file==NULL)
-    {
-      errno=EINTR;
-      return NULL;
-    }
-  
-  return __getgrent(fileno(file));
+	if (file == NULL) {
+		errno = EINTR;
+		return NULL;
+	}
+
+	return __getgrent(fileno(file));
 }

+ 6 - 8
libc/pwd_grp/fgetpwent.c

@@ -22,14 +22,12 @@
 #include <stdio.h>
 #include <pwd.h>
 
-struct passwd *
-fgetpwent(FILE * file)
+struct passwd *fgetpwent(FILE * file)
 {
-  if (file==NULL)
-    {
-      errno=EINTR;
-      return NULL;
-    }
+	if (file == NULL) {
+		errno = EINTR;
+		return NULL;
+	}
 
-  return __getpwent(fileno(file));
+	return __getpwent(fileno(file));
 }

+ 12 - 18
libc/pwd_grp/getgrgid.c

@@ -23,26 +23,20 @@
 #include <fcntl.h>
 #include <grp.h>
 
-struct group *
-getgrgid(const gid_t gid)
+struct group *getgrgid(const gid_t gid)
 {
-  struct group * group;
-  int grp_fd;
+	struct group *group;
+	int grp_fd;
 
-  if ((grp_fd=open("/etc/group", O_RDONLY))<0)
-    return NULL;
+	if ((grp_fd = open("/etc/group", O_RDONLY)) < 0)
+		return NULL;
 
-  while ((group=__getgrent(grp_fd))!=NULL)
-    if (group->gr_gid==gid)
-      {
-	close(grp_fd);
-	return group;
-      }
+	while ((group = __getgrent(grp_fd)) != NULL)
+		if (group->gr_gid == gid) {
+			close(grp_fd);
+			return group;
+		}
 
-  close(grp_fd);
-  return NULL;
+	close(grp_fd);
+	return NULL;
 }
-
-
-
-

+ 16 - 19
libc/pwd_grp/getgrnam.c

@@ -24,28 +24,25 @@
 #include <fcntl.h>
 #include <grp.h>
 
-struct group *
-getgrnam(const char * name)
+struct group *getgrnam(const char *name)
 {
-  int grp_fd;
-  struct group * group;
+	int grp_fd;
+	struct group *group;
 
-  if (name==NULL)
-    {
-      errno=EINVAL;
-      return NULL;
-    }
+	if (name == NULL) {
+		errno = EINVAL;
+		return NULL;
+	}
 
-  if ((grp_fd=open("/etc/group", O_RDONLY))<0)
-    return NULL;
+	if ((grp_fd = open("/etc/group", O_RDONLY)) < 0)
+		return NULL;
 
-  while ((group=__getgrent(grp_fd))!=NULL)
-    if (!strcmp(group->gr_name, name))
-      {
-	close(grp_fd);
-	return group;
-      }
+	while ((group = __getgrent(grp_fd)) != NULL)
+		if (!strcmp(group->gr_name, name)) {
+			close(grp_fd);
+			return group;
+		}
 
-  close(grp_fd);
-  return NULL;
+	close(grp_fd);
+	return NULL;
 }

+ 20 - 25
libc/pwd_grp/getpw.c

@@ -23,29 +23,24 @@
 #include <stdio.h>
 #include <pwd.h>
 
-int
-getpw(uid_t uid, char *buf)
+int getpw(uid_t uid, char *buf)
 {
-  struct passwd * passwd;
-
-  if (buf==NULL)
-    {
-      errno=EINVAL;
-      return -1;
-    }
-  if ((passwd=getpwuid(uid))==NULL)
-    return -1;
-
-  if (sprintf(buf, "%s:%s:%u:%u:%s:%s:%s", passwd->pw_name, passwd->pw_passwd,
-	  passwd->pw_gid, passwd->pw_uid, passwd->pw_gecos,
-	  passwd->pw_dir, passwd->pw_shell)<0)
-    {
-      errno=ENOBUFS;
-      return -1;
-    }
-
-  return 0;
-}  
-
-
-
+	struct passwd *passwd;
+
+	if (buf == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+	if ((passwd = getpwuid(uid)) == NULL)
+		return -1;
+
+	if (sprintf
+		(buf, "%s:%s:%u:%u:%s:%s:%s", passwd->pw_name, passwd->pw_passwd,
+		 passwd->pw_gid, passwd->pw_uid, passwd->pw_gecos, passwd->pw_dir,
+		 passwd->pw_shell) < 0) {
+		errno = ENOBUFS;
+		return -1;
+	}
+
+	return 0;
+}

+ 16 - 19
libc/pwd_grp/getpwnam.c

@@ -25,28 +25,25 @@
 #include <pwd.h>
 
 
-struct passwd *
-getpwnam(const char * name)
+struct passwd *getpwnam(const char *name)
 {
-  int passwd_fd;
-  struct passwd * passwd;
+	int passwd_fd;
+	struct passwd *passwd;
 
-  if (name==NULL)
-    {
-      errno=EINVAL;
-      return NULL;
-    }
+	if (name == NULL) {
+		errno = EINVAL;
+		return NULL;
+	}
 
-  if ((passwd_fd=open("/etc/passwd", O_RDONLY))<0)
-    return NULL;
+	if ((passwd_fd = open("/etc/passwd", O_RDONLY)) < 0)
+		return NULL;
 
-  while ((passwd=__getpwent(passwd_fd))!=NULL)
-    if (!strcmp(passwd->pw_name, name))
-      {
-	close(passwd_fd);
-	return passwd;
-      }	  
+	while ((passwd = __getpwent(passwd_fd)) != NULL)
+		if (!strcmp(passwd->pw_name, name)) {
+			close(passwd_fd);
+			return passwd;
+		}
 
-  close(passwd_fd);
-  return NULL;
+	close(passwd_fd);
+	return NULL;
 }

+ 12 - 14
libc/pwd_grp/getpwuid.c

@@ -23,22 +23,20 @@
 #include <fcntl.h>
 #include <pwd.h>
 
-struct passwd *
-getpwuid(uid_t uid)
+struct passwd *getpwuid(uid_t uid)
 {
-  int passwd_fd;
-  struct passwd * passwd;
+	int passwd_fd;
+	struct passwd *passwd;
 
-  if ((passwd_fd=open("/etc/passwd", O_RDONLY))<0)
-    return NULL;
+	if ((passwd_fd = open("/etc/passwd", O_RDONLY)) < 0)
+		return NULL;
 
-  while ((passwd=__getpwent(passwd_fd))!=NULL)
-    if (passwd->pw_uid==uid)
-      {
-	close(passwd_fd);
-	return passwd;
-      }
+	while ((passwd = __getpwent(passwd_fd)) != NULL)
+		if (passwd->pw_uid == uid) {
+			close(passwd_fd);
+			return passwd;
+		}
 
-  close (passwd_fd);
-  return NULL;
+	close(passwd_fd);
+	return NULL;
 }

+ 13 - 18
libc/pwd_grp/grent.c

@@ -28,30 +28,25 @@
 #include <fcntl.h>
 #include <grp.h>
 
-static int grp_fd=-1;
+static int grp_fd = -1;
 
-void
-setgrent(void)
+void setgrent(void)
 {
-  if (grp_fd!=-1)
-    close(grp_fd);
-  grp_fd=open("/etc/group", O_RDONLY);
+	if (grp_fd != -1)
+		close(grp_fd);
+	grp_fd = open("/etc/group", O_RDONLY);
 }
 
-void
-endgrent(void)
+void endgrent(void)
 {
- if (grp_fd!=-1)
-   close(grp_fd);
- grp_fd=-1;
+	if (grp_fd != -1)
+		close(grp_fd);
+	grp_fd = -1;
 }
 
-struct group *
-getgrent(void)
+struct group *getgrent(void)
 {
-  if (grp_fd==-1)
-    return NULL;
-  return __getgrent(grp_fd);
+	if (grp_fd == -1)
+		return NULL;
+	return __getgrent(grp_fd);
 }
-
-

+ 33 - 39
libc/pwd_grp/initgroups.c

@@ -24,57 +24,51 @@
 #include <grp.h>
 #include "config.h"
 
-int
-initgroups(__const char * user, gid_t gid)
+int initgroups(__const char *user, gid_t gid)
 {
-  register struct group * group;
+	register struct group *group;
+
 #ifndef GR_DYNAMIC_GROUP_LIST
-  gid_t group_list[GR_MAX_GROUPS];
+	gid_t group_list[GR_MAX_GROUPS];
 #else
-  gid_t * group_list=NULL;
+	gid_t *group_list = NULL;
 #endif
-  register char ** tmp_mem;
-  int num_groups;
-  int grp_fd;
+	register char **tmp_mem;
+	int num_groups;
+	int grp_fd;
 
 
-  if ((grp_fd=open("/etc/group", O_RDONLY))<0)
-    return -1;
+	if ((grp_fd = open("/etc/group", O_RDONLY)) < 0)
+		return -1;
 
-  num_groups=0;
+	num_groups = 0;
 #ifdef GR_DYNAMIC_GROUP_LIST
-  group_list=(gid_t *) realloc(group_list, 1);
+	group_list = (gid_t *) realloc(group_list, 1);
 #endif
-  group_list[num_groups]=gid;
+	group_list[num_groups] = gid;
 #ifndef GR_DYNAMIC_GROUP_LIST
-  while (num_groups<GR_MAX_GROUPS &&
-	 (group=__getgrent(grp_fd))!=NULL)
+	while (num_groups < GR_MAX_GROUPS &&
+		   (group = __getgrent(grp_fd)) != NULL)
 #else
-  while ((group=__getgrent(grp_fd))!=NULL)
-#endif      
-    {
-      if (group->gr_gid!=gid);
-        {
-	  tmp_mem=group->gr_mem;
-	  while(*tmp_mem!=NULL)
-	    {
-	      if (!strcmp(*tmp_mem, user))
+	while ((group = __getgrent(grp_fd)) != NULL)
+#endif
+	{
+		if (group->gr_gid != gid);
 		{
-		  num_groups++;
-#ifdef GR_DYNAMIC_GROUP_LIST  
-		  group_list=(gid_t *)realloc(group_list,
-					      num_groups*sizeof(gid_t *));
-#endif		  
-		  group_list[num_groups]=group->gr_gid;
+			tmp_mem = group->gr_mem;
+			while (*tmp_mem != NULL) {
+				if (!strcmp(*tmp_mem, user)) {
+					num_groups++;
+#ifdef GR_DYNAMIC_GROUP_LIST
+					group_list = (gid_t *) realloc(group_list, num_groups *
+						sizeof(gid_t *));
+#endif
+					group_list[num_groups] = group->gr_gid;
+				}
+				tmp_mem++;
+			}
 		}
-	      tmp_mem++;
-	    }
 	}
-    }
-  close(grp_fd);
-  return setgroups(num_groups, group_list);
+	close(grp_fd);
+	return setgroups(num_groups, group_list);
 }
-
-
-
-

+ 11 - 12
libc/pwd_grp/putpwent.c

@@ -22,18 +22,17 @@
 #include <errno.h>
 #include <pwd.h>
 
-int
-putpwent(const struct passwd * passwd, FILE * f)
+int putpwent(const struct passwd *passwd, FILE * f)
 {
-  if (passwd == NULL || f == NULL)
-    {
-      errno=EINVAL;
-      return -1;
-    }
-  if (fprintf(f, "%s:%s:%u:%u:%s:%s:%s\n", passwd->pw_name, passwd->pw_passwd,
-	  passwd->pw_gid, passwd->pw_uid, passwd->pw_gecos,
-	  passwd->pw_dir, passwd->pw_shell)<0)
-      return -1;
+	if (passwd == NULL || f == NULL) {
+		errno = EINVAL;
+		return -1;
+	}
+	if (fprintf
+		(f, "%s:%s:%u:%u:%s:%s:%s\n", passwd->pw_name, passwd->pw_passwd,
+		 passwd->pw_gid, passwd->pw_uid, passwd->pw_gecos, passwd->pw_dir,
+		 passwd->pw_shell) < 0)
+		return -1;
 
-  return 0;
+	return 0;
 }

+ 12 - 18
libc/pwd_grp/pwent.c

@@ -33,30 +33,24 @@
 /* file descriptor for the password file currently open */
 static int pw_fd = -1;
 
-void
-setpwent(void)
+void setpwent(void)
 {
-  if (pw_fd!=-1)
-    close(pw_fd);
+	if (pw_fd != -1)
+		close(pw_fd);
 
-  pw_fd=open("/etc/passwd", O_RDONLY);
+	pw_fd = open("/etc/passwd", O_RDONLY);
 }
 
-void
-endpwent(void)
+void endpwent(void)
 {
-  if (pw_fd!=-1)
-    close(pw_fd);
-  pw_fd=-1;
+	if (pw_fd != -1)
+		close(pw_fd);
+	pw_fd = -1;
 }
 
-struct passwd *
-getpwent(void)
+struct passwd *getpwent(void)
 {
-  if (pw_fd!=-1)
-    return (__getpwent(pw_fd));
-  return NULL;  
+	if (pw_fd != -1)
+		return (__getpwent(pw_fd));
+	return NULL;
 }
-
-
-