reindent-20030715
[openafs.git] / src / kauth / kalocalcell.c
index 435768f..42798bd 100644 (file)
@@ -14,7 +14,8 @@
 #include <afs/param.h>
 #endif
 
-RCSID("$Header$");
+RCSID
+    ("$Header$");
 
 #if defined(UKERNEL)
 #include "afs/pthread_glock.h"
@@ -58,7 +59,8 @@ RCSID("$Header$");
 static struct afsconf_dir *conf = 0;
 static char cell_name[MAXCELLCHARS];
 
-int ka_CellConfig (const char *dir)
+int
+ka_CellConfig(const char *dir)
 {
     int code;
 #ifdef UKERNEL
@@ -66,96 +68,83 @@ int ka_CellConfig (const char *dir)
     strcpy(cell_name, afs_LclCellName);
     return 0;
 #else /* UKERNEL */
-    LOCK_GLOBAL_MUTEX
-    if (conf) afsconf_Close(conf);
-    conf = afsconf_Open (dir);
+    LOCK_GLOBAL_MUTEX if (conf)
+         afsconf_Close(conf);
+    conf = afsconf_Open(dir);
     if (!conf) {
-       UNLOCK_GLOBAL_MUTEX
-       return KANOCELLS;
+       UNLOCK_GLOBAL_MUTEX return KANOCELLS;
     }
-    code = afsconf_GetLocalCell (conf, cell_name, sizeof(cell_name));
-    UNLOCK_GLOBAL_MUTEX
-    return code;
+    code = afsconf_GetLocalCell(conf, cell_name, sizeof(cell_name));
+    UNLOCK_GLOBAL_MUTEX return code;
 #endif /* UKERNEL */
 }
 
-char *ka_LocalCell (void)
-{   
-  int code;
+char *
+ka_LocalCell(void)
+{
+    int code;
 
-    LOCK_GLOBAL_MUTEX
-    if (conf) {
-       UNLOCK_GLOBAL_MUTEX
-       return cell_name;
+    LOCK_GLOBAL_MUTEX if (conf) {
+       UNLOCK_GLOBAL_MUTEX return cell_name;
     }
-
 #ifdef UKERNEL
     conf = afs_cdir;
     strcpy(cell_name, afs_LclCellName);
 #else /* UKERNEL */
-    if (conf = afsconf_Open (AFSDIR_CLIENT_ETC_DIRPATH)) {
-       code = afsconf_GetLocalCell (conf, cell_name, sizeof(cell_name));
+    if (conf = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH)) {
+       code = afsconf_GetLocalCell(conf, cell_name, sizeof(cell_name));
 /* leave conf open so we can lookup other cells */
 /* afsconf_Close (conf); */
     }
     if (!conf || code) {
        printf("** Can't determine local cell name!\n");
        conf = 0;
-       UNLOCK_GLOBAL_MUTEX
-       return 0;
+       UNLOCK_GLOBAL_MUTEX return 0;
     }
 #endif /* UKERNEL */
-    UNLOCK_GLOBAL_MUTEX
-    return cell_name;
+    UNLOCK_GLOBAL_MUTEX return cell_name;
 }
 
-int ka_ExpandCell (
-  char *cell,
-  char *fullCell,
-  int  *alocal)
+int
+ka_ExpandCell(char *cell, char *fullCell, int *alocal)
 {
-    int  local = 0;
-    int  code;
+    int local = 0;
+    int code;
     char cellname[MAXKTCREALMLEN];
     struct afsconf_cell cellinfo;      /* storage for cell info */
 
-    LOCK_GLOBAL_MUTEX
-    ka_LocalCell();                    /* initialize things */
+    LOCK_GLOBAL_MUTEX ka_LocalCell();  /* initialize things */
     if (!conf) {
-       UNLOCK_GLOBAL_MUTEX
-       return KANOCELLS;
+       UNLOCK_GLOBAL_MUTEX return KANOCELLS;
     }
 
     if ((cell == 0) || (strlen(cell) == 0)) {
        local = 1;
        cell = cell_name;
     } else {
-       cell = lcstring (cellname, cell, sizeof(cellname));
-       code = afsconf_GetCellInfo (conf, cell, 0, &cellinfo);
+       cell = lcstring(cellname, cell, sizeof(cellname));
+       code = afsconf_GetCellInfo(conf, cell, 0, &cellinfo);
        if (code) {
-           UNLOCK_GLOBAL_MUTEX
-           return KANOCELL;
+           UNLOCK_GLOBAL_MUTEX return KANOCELL;
        }
        cell = cellinfo.name;
     }
-    if (strcmp (cell, cell_name) == 0) local = 1;
+    if (strcmp(cell, cell_name) == 0)
+       local = 1;
 
-    if (fullCell) strcpy (fullCell, cell);
-    if (alocal) *alocal = local;
-    UNLOCK_GLOBAL_MUTEX
-    return 0;
-}    
+    if (fullCell)
+       strcpy(fullCell, cell);
+    if (alocal)
+       *alocal = local;
+    UNLOCK_GLOBAL_MUTEX return 0;
+}
 
-int ka_CellToRealm (
-  char *cell,
-  char *realm,
-  int  *local)
+int
+ka_CellToRealm(char *cell, char *realm, int *local)
 {
     int code;
 
-    LOCK_GLOBAL_MUTEX
-    code = ka_ExpandCell (cell, realm, local);
-    ucstring (realm, realm, MAXKTCREALMLEN);
-    UNLOCK_GLOBAL_MUTEX
-    return code;
+    LOCK_GLOBAL_MUTEX code = ka_ExpandCell(cell, realm, local);
+    ucstring(realm, realm, MAXKTCREALMLEN);
+    UNLOCK_GLOBAL_MUTEX return code;
 }