Replace functions which called once with their bodies
[pidgin-git.git] / libpurple / protocols / zephyr / ZGetWGPort.c
blob4d8acb3a45184865431c1fee4fa17e00a2a20ce9
1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains source for the ZGetWGPort function.
4 * Created by: Robert French
6 * Copyright (c) 1987 by the Massachusetts Institute of Technology.
7 * For copying and distribution information, see the file
8 * "mit-copyright.h".
9 */
11 #include "internal.h"
13 int ZGetWGPort()
15 char *envptr, name[128];
16 FILE *fp;
17 int wgport;
18 #ifdef WIN32
19 long int buffsize= 128;
20 char tempdir[buffsize];
21 #endif
22 envptr = getenv("WGFILE");
23 if (!envptr) {
24 #ifdef WIN32
25 GetTempPath(buffsize,tempdir);
26 GetTempFileName(tempdir,"wg.",0,name);
27 #else
28 (void) sprintf(name, "/tmp/wg.%d", getuid());
29 #endif
30 envptr = name;
32 if (!(fp = fopen(envptr, "r")))
33 return (-1);
35 /* if fscanf fails, return -1 via wgport */
36 if (fscanf(fp, "%d", &wgport) != 1)
37 wgport = -1;
39 (void) fclose(fp);
41 return (wgport);