1 |
/* This file is part of pxyservd (from pxys) |
2 |
* |
3 |
* This program is free software; you can redistribute it and/or |
4 |
* modify it under the terms of the GNU General Public License |
5 |
* as published by the Free Software Foundation; either version 2 |
6 |
* of the License, or (at your option) any later version. |
7 |
* |
8 |
* This program is distributed in the hope that it will be useful, |
9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 |
* GNU General Public License for more details. |
12 |
* |
13 |
* You should have received a copy of the GNU General Public License |
14 |
* along with this program; if not, write to the Free Software |
15 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
16 |
* |
17 |
* $Id: irc_yxx.h,v 1.1.1.1 2003/12/30 17:09:32 mbuna Exp $ |
18 |
*/ |
19 |
#ifndef INCLUDED_IRC_YXX_H |
20 |
#define INCLUDED_IRC_YXX_H |
21 |
|
22 |
#ifdef HAVE_CONFIG_H |
23 |
#include "config.h" |
24 |
#endif |
25 |
#include <sys/types.h> |
26 |
#include <peak/stdint.h> |
27 |
|
28 |
struct yxx { |
29 |
int server_n; |
30 |
int client_n; |
31 |
int bogus; |
32 |
}; |
33 |
|
34 |
struct stryxx { |
35 |
char server_sn[3]; |
36 |
char client_sn[4]; |
37 |
size_t length; |
38 |
}; |
39 |
|
40 |
typedef struct yxx yxx; |
41 |
typedef struct stryxx stryxx; |
42 |
|
43 |
extern yxx yxx_to_int(const char *numeric); |
44 |
extern void yxx_cut(const char *numeric, stryxx * outfnum); |
45 |
|
46 |
|
47 |
/* Methods for packing/unpacking a yxx numeric in a 32 bits integer |
48 |
*/ |
49 |
|
50 |
static inline uint32_t |
51 |
yxx_pack_int(int server_n, int client_n) |
52 |
{ |
53 |
return (uint32_t)(server_n << 18) + client_n; |
54 |
} |
55 |
|
56 |
static inline uint32_t |
57 |
yxx_pack(yxx x) |
58 |
{ |
59 |
return yxx_pack_int(x.server_n, x.client_n); |
60 |
} |
61 |
|
62 |
static inline yxx |
63 |
yxx_unpack(uint32_t n) |
64 |
{ |
65 |
yxx x; |
66 |
x.server_n = n >> 18; |
67 |
x.client_n = n & 0x0003ffff; |
68 |
x.bogus = 0; |
69 |
return x; |
70 |
} |
71 |
|
72 |
|
73 |
#endif /* INCLUDED_IRC_YXX_H */ |