-/*
- * $Source$
- * $Author$
- * $Header$
+/* $Id$
+ *
+ * Deal with NFS partition types
*
- * Copyright (C) 1987 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
*
*/
-#ifndef lint
-static char *rcsid_nfsparttype_c = "$Header$";
-#endif lint
-
#include <mit-copyright.h>
#include <moira.h>
+
#include <stdio.h>
-#include <strings.h>
-#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
-extern char *strsave();
-extern char *strtrim();
+RCSID("$Header$");
struct pair {
- int type;
- char *name;
+ int type;
+ char *name;
};
/*
*/
static struct pair fs_names[] = {
- { MR_FS_STUDENT, "Student" },
- { MR_FS_FACULTY, "Faculty" },
- { MR_FS_STAFF, "Staff" },
- { MR_FS_MISC, "Other" },
- { MR_FS_GROUPQUOTA, "GroupQuota" },
- /* Insert new entries before the 0,0 pair */
- { 0, 0 },
+ { MR_FS_STUDENT, "Student" },
+ { MR_FS_FACULTY, "Faculty" },
+ { MR_FS_STAFF, "Staff" },
+ { MR_FS_MISC, "Other" },
+ { MR_FS_GROUPQUOTA, "GroupQuota" },
+ /* Insert new entries before the 0,0 pair */
+ { 0, 0 },
};
/*
* Given a numeric string containing a filesystem status value, return
* a string indicating what allocation type it is.
*/
-char *
-format_filesys_type(fs_status)
- char *fs_status;
+char *format_filesys_type(char *fs_status)
{
- char buf[BUFSIZ];
- register struct pair *pp;
-
- int n_names = 0;
- int stat = atoi(fs_status);
-
- buf[0] = '\0';
+ char buf[BUFSIZ];
+ struct pair *pp;
+
+ int n_names = 0;
+ int stat = atoi(fs_status);
- for (pp = fs_names; pp->type; pp++) {
- if (stat & pp->type) {
- if (n_names) (void) strcat(buf, ", ");
- (void) strcat(buf, pp->name);
- n_names++;
- stat &= ~pp->type;
+ buf[0] = '\0';
+
+ for (pp = fs_names; pp->type; pp++)
+ {
+ if (stat & pp->type)
+ {
+ if (n_names)
+ strcat(buf, ", ");
+ strcat(buf, pp->name);
+ n_names++;
+ stat &= ~pp->type;
}
}
- if (stat) {
- char buf1[100];
-
- if (n_names) (void) strcat (buf, ", ");
- (void) sprintf(buf1, "Unknown bits 0x%x", stat);
- (void) strcat (buf, buf1);
+ if (stat)
+ {
+ char buf1[100];
+
+ if (n_names)
+ strcat(buf, ", ");
+ sprintf(buf1, "Unknown bits 0x%x", stat);
+ strcat(buf, buf1);
}
- if (!n_names) (void) strcpy(buf, "none");
- return strsave(buf);
+ if (!n_names)
+ strcpy(buf, "none");
+ return strdup(buf);
}
/*
* Given a string describing a filesystem allocation type, return the
* numeric value.
*/
-char *
-parse_filesys_type(fs_type_name)
- char *fs_type_name;
+char *parse_filesys_type(char *fs_type_name)
{
- register struct pair *pp;
- register char *cp = fs_type_name;
- char temp[BUFSIZ];
- int flags = 0;
-
- do {
- /* Copy next component of type to temp */
- char *t = index (cp, ',');
- if (t) {
- bcopy(cp, temp, t-cp);
- temp[t-cp]='\0';
- cp = t + 1; /* one after the comma */
- } else {
- (void) strcpy(temp, cp);
- cp = NULL;
+ struct pair *pp;
+ char *cp = fs_type_name;
+ char temp[BUFSIZ];
+ int flags = 0;
+
+ do
+ {
+ /* Copy next component of type to temp */
+ char *t = strchr(cp, ',');
+ if (t)
+ {
+ memcpy(temp, cp, t - cp);
+ temp[t - cp] = '\0';
+ cp = t + 1; /* one after the comma */
+ }
+ else
+ {
+ strcpy(temp, cp);
+ cp = NULL;
}
- t = strtrim(temp); /* nuke leading and trailing whitespace */
+ t = strtrim(temp); /* nuke leading and trailing whitespace */
- for (pp = fs_names; pp->type; pp++) {
- if (strcasecmp(pp->name, t) == 0) {
- flags |= pp->type;
- break;
+ for (pp = fs_names; pp->type; pp++)
+ {
+ if (!strcasecmp(pp->name, t))
+ {
+ flags |= pp->type;
+ break;
}
}
- } while (cp);
- (void) sprintf(temp, "%d", flags);
- return strsave(temp);
+ }
+ while (cp);
+ sprintf(temp, "%d", flags);
+ return strdup(temp);
}