]> git.pond.sub.org Git - empserver/blob - src/lib/gen/hpux.c
Import of Empire 4.2.12
[empserver] / src / lib / gen / hpux.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                           Ken Stevens, Steve McClure
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  *  ---
21  *
22  *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23  *  related information and legal notices. It is expected that any future
24  *  projects/authors will amend these files as needed.
25  *
26  *  ---
27  *
28  *  hpux.c: Things specific to hpux
29  * 
30  *  Known contributors to this file:
31  *     
32  */
33
34 #include "misc.h"
35
36 #ifdef hpux
37 #include <stdio.h>
38
39 setbuffer(fp, buf, size)
40         FILE    *fp;
41         s_char  *buf;
42         int     size;
43 {
44         if (size > BUFSIZ)
45                 setbuf(fp, buf);
46         /* XXX else report error */
47 }
48
49 s_char *
50 rindex(sp, c)
51         register s_char *sp;
52         register int c;
53 {
54         register s_char *r;
55
56         r = NULL;
57         do {
58                 if (*sp == c)
59                         r = sp;
60         } while (*sp++);
61         return r;
62 }
63
64 s_char *
65 index(sp, c)
66         register s_char *sp;
67         register int c;
68 {
69         do {
70                 if (*sp == c)
71                         return (sp);
72         } while (*sp++);
73         return NULL;
74 }
75
76 int
77 ffs(marg)
78         register unsigned marg;
79 {
80         register unsigned bval;
81         register int i;
82
83         if (marg == 0)
84                 return 0;
85         for (bval=1, i=1; i <= 32; i++, bval <<= 1)
86                 if (marg & bval)
87                         return i;
88         return 0;
89 }
90 #endif