]> andersk Git - moira.git/blobdiff - lib/nfsparttype.c
Command line printer manipulation client, and build goo.
[moira.git] / lib / nfsparttype.c
index bebec4ce125bf7b3d948edc3c91862dd37f1fa3f..87e01e9ed8c08c1f72bb1c2fe5777d02fb600fee 100644 (file)
@@ -1,31 +1,25 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
+ * Deal with NFS partition types
  *
- *     $Log$
- *     Revision 1.1  1987-09-03 03:13:40  wesommer
- *     Initial revision
+ * 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 <sms.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;
 };
 
 /*
@@ -33,85 +27,93 @@ struct pair {
  */
 
 static struct pair fs_names[] = {
-    { SMS_FS_STUDENT, "Student" },
-    { SMS_FS_FACULTY, "Faculty/Project" },
-    { SMS_FS_FACULTY, "Faculty" },
-    { SMS_FS_FACULTY, "Project" },
-    { SMS_FS_STAFF, "Staff" },
-    { SMS_FS_MISC, "Other" },
-    /* 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 (cistrcmp(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);
 }
This page took 0.043962 seconds and 4 git commands to generate.