Fix some of the things that break compilation on Windows.
[openafs.git] / src / util / get_krbrlm.c
1 /*
2  * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute of Technology.
3  * For copying and distribution information, please see the file <mit-copyright.h>.
4  */
5
6 #include <afsconfig.h>
7 #include <afs/param.h>
8
9 RCSID("$Header$");
10
11 #include <stdio.h>
12 #include "afsutil.h"
13
14 /*
15  * Specialized version of the kerberos krb_get_lrealm function.
16  * krb_get_lrealm takes a pointer to a string, and a number, n.  It fills
17  * in the string, r, with the name of the nth realm specified on the
18  * first line of the kerberos config file (KRB_CONF, defined in "krb.h").
19  * It returns 0 (KSUCCESS) on success, and KFAILURE on failure. 
20  *
21  * On the kerberos version if the config file does not exist, and if n=1, a 
22  * successful return will occur with r = KRB_REALM (also defined in "krb.h").
23  *
24  */
25 #define KSUCCESS        0
26 #define KFAILURE        -1
27
28 afs_krb_get_lrealm(r,n)
29     char *r;
30     int n;
31 {
32     FILE *cnffile, *fopen();
33
34     if (n > 1)
35         return(KFAILURE);  /* Temporary restriction */
36
37     if ((cnffile = fopen(AFSDIR_SERVER_KCONF_FILEPATH, "r")) == NULL) {
38         return(KFAILURE);
39     }
40     if (fscanf(cnffile,"%s",r) != 1) {
41         (void) fclose(cnffile);
42         return(KFAILURE);
43     }
44     (void) fclose(cnffile);
45     return(KSUCCESS);
46 }