reindent-20030715
[openafs.git] / src / uss / uss_ptserver.c
index 1747f0d..98c47c8 100644 (file)
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID("$Header$");
+RCSID
+    ("$Header$");
 
-#include "uss_ptserver.h"      /*Module interface*/
-#include <afs/ptclient.h>      /*Protection Server client interface*/
-#include <afs/pterror.h>       /*Protection Server error codes*/
-#include <afs/com_err.h>       /*Error code xlation*/
+#include "uss_ptserver.h"      /*Module interface */
+#include <afs/ptclient.h>      /*Protection Server client interface */
+#include <afs/pterror.h>       /*Protection Server error codes */
+#include <afs/com_err.h>       /*Error code xlation */
 
 
 #undef USS_PTSERVER_DB
@@ -40,7 +41,7 @@ extern int line;
 /*
  * ------------------------ Private globals -----------------------
  */
-static int initDone = 0;               /*Module initialized?*/
+static int initDone = 0;       /*Module initialized? */
 
 
 /*-----------------------------------------------------------------------
@@ -64,40 +65,40 @@ static int initDone = 0;            /*Module initialized?*/
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-static afs_int32 InitThisModule()
+static afs_int32
+InitThisModule()
+{                              /*InitThisModule */
 
-{ /*InitThisModule*/
-
-    static char rn[] =
-       "uss_ptserver:InitThisModule";  /*Routine name*/
-    register afs_int32 code;                   /*Return code*/
+    static char rn[] = "uss_ptserver:InitThisModule";  /*Routine name */
+    register afs_int32 code;   /*Return code */
 
     /*
      * Only once, guys.
      */
     if (initDone)
-       return(0);
+       return (0);
 
     /*
      * Connect up with the Protection Server.
      */
 #ifdef USS_PTSERVER_DB
-    printf("%s: Initializing Protection Server: security=1, confdir = '%s', cell = '%s'\n",
-          rn, uss_ConfDir, uss_Cell);
+    printf
+       ("%s: Initializing Protection Server: security=1, confdir = '%s', cell = '%s'\n",
+        rn, uss_ConfDir, uss_Cell);
 #endif /* USS_PTSERVER_DB */
-    code = pr_Initialize(1,            /*Security level*/
-                        uss_ConfDir,   /*Config directory*/
-                        uss_Cell);     /*Cell to touch*/
+    code = pr_Initialize(1,    /*Security level */
+                        uss_ConfDir,   /*Config directory */
+                        uss_Cell);     /*Cell to touch */
     if (code) {
        com_err(uss_whoami, code,
                "while initializing Protection Server library");
-       return(code);
+       return (code);
     }
 
     initDone = 1;
-    return(0);
+    return (0);
 
-} /*InitThisModule*/
+}                              /*InitThisModule */
 
 
 /*-----------------------------------------------------------------------
@@ -111,40 +112,41 @@ static afs_int32 InitThisModule()
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-afs_int32 uss_ptserver_AddUser(a_user, a_uid)
-    char *a_user;
-    char *a_uid;
+afs_int32
+uss_ptserver_AddUser(a_user, a_uid)
+     char *a_user;
+     char *a_uid;
+
+{                              /*uss_ptserver_AddUser */
 
-{ /*uss_ptserver_AddUser*/
+    afs_int32 code;            /*Various return codes */
+    afs_int32 id = uss_DesiredUID;     /*ID desired for user, if any */
+    afs_int32 mappedUserID;    /*ID user already has */
 
-    afs_int32 code;                            /*Various return codes*/
-    afs_int32 id = uss_DesiredUID;             /*ID desired for user, if any*/
-    afs_int32 mappedUserID;                    /*ID user already has*/
-    
     if (uss_verbose) {
-       fprintf(stderr, "Adding user '%s' to the Protection DB\n",
-               a_user);
+       fprintf(stderr, "Adding user '%s' to the Protection DB\n", a_user);
        if (id)
            fprintf(stderr, "\t[Presetting uid to %d]\n", id);
     }
-    
+
     /*
      * Make sure we're initialized before doing anything.
      */
     if (!initDone) {
        code = InitThisModule();
        if (code)
-           return(code);
+           return (code);
     }
-    
+
     /*
      * If this is a dry run, we still need to setup the uid before
      * returning.
      */
     if (uss_DryRun) {
-       fprintf(stderr, "\t[Dry run - user %d not created]\n", uss_DesiredUID);
+       fprintf(stderr, "\t[Dry run - user %d not created]\n",
+               uss_DesiredUID);
        sprintf(a_uid, "%d", uss_DesiredUID);
-       return(0);
+       return (0);
     }
 
     /*
@@ -152,7 +154,7 @@ afs_int32 uss_ptserver_AddUser(a_user, a_uid)
      */
     code = pr_CreateUser(a_user, &id);
     if (code) {
-       if (code == PREXIST || code == PRIDEXIST)  {
+       if (code == PREXIST || code == PRIDEXIST) {
            if (code == PREXIST)
                fprintf(stderr,
                        "%s: Warning: '%s' already in the Protection DB\n",
@@ -176,43 +178,41 @@ afs_int32 uss_ptserver_AddUser(a_user, a_uid)
            if (code = pr_SNameToId(a_user, &mappedUserID)) {
                com_err(uss_whoami, code,
                        "while getting uid from Protection Server");
-               return(code);
+               return (code);
            }
            if (mappedUserID == ANONYMOUSID) {
                fprintf(stderr,
                        "%s: User '%s' unknown, yet given id (%d) already has a mapping!\n",
                        uss_whoami, a_user, id);
-               return(PRIDEXIST);
+               return (PRIDEXIST);
            }
            if (id == 0)
                id = mappedUserID;
-           else
-               if (mappedUserID != id) {
-                   fprintf(stderr,
-                           "%s: User '%s' already has id %d; won't assign id %d\n",
-                           uss_whoami, a_user, mappedUserID, id);
-                   return(PRIDEXIST);
-               }
-       }
-       else {
+           else if (mappedUserID != id) {
+               fprintf(stderr,
+                       "%s: User '%s' already has id %d; won't assign id %d\n",
+                       uss_whoami, a_user, mappedUserID, id);
+               return (PRIDEXIST);
+           }
+       } else {
            /*
             * Got a fatal error.
             */
            com_err(uss_whoami, code, "while accessing Protection Server");
-           return(code);
+           return (code);
        }
-    } /*Create the user's protection entry*/
-    
+    }
+    /*Create the user's protection entry */
     sprintf(a_uid, "%d", id);
     if (uss_verbose)
        fprintf(stderr, "The uid for user '%s' is %s\n", a_user, a_uid);
-    
+
     /*
      * Return sweetness & light.
      */
-    return(0);
+    return (0);
 
-} /*uss_ptserver_AddUser*/
+}                              /*uss_ptserver_AddUser */
 
 
 /*-----------------------------------------------------------------------
@@ -225,27 +225,28 @@ afs_int32 uss_ptserver_AddUser(a_user, a_uid)
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-afs_int32 uss_ptserver_DelUser(a_name)
-    char *a_name;
+afs_int32
+uss_ptserver_DelUser(a_name)
+     char *a_name;
 
-{ /*uss_ptserver_DelUser*/
+{                              /*uss_ptserver_DelUser */
+
+    afs_int32 code;            /*Various return codes */
 
-    afs_int32 code;                            /*Various return codes*/
-    
     /*
      * Make sure we're initialized before doing anything.
      */
     if (!initDone) {
        code = InitThisModule();
        if (code)
-           return(code);
+           return (code);
     }
 
     if (uss_DryRun) {
        fprintf(stderr,
                "\t[Dry run - user '%s' not deleted from Protection DB]\n",
                a_name);
-       return(0);
+       return (0);
     }
 
     if (uss_verbose)
@@ -257,7 +258,7 @@ afs_int32 uss_ptserver_DelUser(a_name)
      */
     code = pr_Delete(a_name);
     if (code) {
-       if (code == PRNOENT)  {
+       if (code == PRNOENT) {
            /*
             * There's no entry for that user in the Protection DB,
             * so our job is done.
@@ -265,20 +266,21 @@ afs_int32 uss_ptserver_DelUser(a_name)
            fprintf(stderr,
                    "%s: Warning: User '%s' not found in Protection DB\n",
                    uss_whoami, a_name);
-       } /*User not registered*/
+       } /*User not registered */
        else {
            com_err(uss_whoami, code,
                    "while deleting user from Protection DB");
-           return(code);
-       } /*Fatal PTS error*/
-    } /*Error in deletion*/
-    
+           return (code);
+       }                       /*Fatal PTS error */
+    }
+
+    /*Error in deletion */
     /*
      * Return sweetness & light.
      */
-    return(0);
+    return (0);
 
-} /*uss_ptserver_DelUser*/
+}                              /*uss_ptserver_DelUser */
 
 
 /*-----------------------------------------------------------------------
@@ -291,14 +293,15 @@ afs_int32 uss_ptserver_DelUser(a_name)
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-afs_int32 uss_ptserver_XlateUser(a_user, a_uidP)
-    char *a_user;
-    afs_int32 *a_uidP;
+afs_int32
+uss_ptserver_XlateUser(a_user, a_uidP)
+     char *a_user;
+     afs_int32 *a_uidP;
 
-{ /*uss_ptserver_XlateUser*/
+{                              /*uss_ptserver_XlateUser */
 
-    static char rn[] = "uss_ptserver_XlateUser"; /*Routine name*/
-    register afs_int32 code;                            /*Various return codes*/
+    static char rn[] = "uss_ptserver_XlateUser";       /*Routine name */
+    register afs_int32 code;   /*Various return codes */
 
     if (uss_verbose)
        fprintf(stderr, "Translating user '%s' via the Protection DB\n",
@@ -310,7 +313,7 @@ afs_int32 uss_ptserver_XlateUser(a_user, a_uidP)
     if (!initDone) {
        code = InitThisModule();
        if (code)
-           return(code);
+           return (code);
     }
 
     /*
@@ -324,13 +327,12 @@ afs_int32 uss_ptserver_XlateUser(a_user, a_uidP)
     code = pr_SNameToId(a_user, a_uidP);
     if (code) {
        com_err(uss_whoami, code, "while getting uid from Protection DB");
-       return(code);
+       return (code);
     }
     if (*a_uidP == ANONYMOUSID) {
-       fprintf(stderr,
-               "%s: No entry for user '%s' in the Protection DB\n",
+       fprintf(stderr, "%s: No entry for user '%s' in the Protection DB\n",
                uss_whoami, a_user);
-       return(code);
+       return (code);
     }
 
     /*
@@ -339,6 +341,6 @@ afs_int32 uss_ptserver_XlateUser(a_user, a_uidP)
 #ifdef USS_PTSERVER_DB
     printf("%s: User '%s' maps to uid %d\n", rn, a_user, *a_uidP);
 #endif /* USS_PTSERVER_DB */
-    return(0);
+    return (0);
 
-} /*uss_ptserver_XlateUser*/
+}                              /*uss_ptserver_XlateUser */