Deleted Added
full compact
iplist.c (31953) iplist.c (31962)
1/*-
2 * Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1997 Brian Somers <brian@Awfulhak.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: iplist.c,v 1.2 1997/12/21 12:11:06 brian Exp $
26 * $Id: iplist.c,v 1.3 1997/12/23 22:38:54 brian Exp $
27 */
28
29#include <sys/types.h>
30#include <netinet/in.h>
31#include <arpa/inet.h>
32
33#include <stdlib.h>
34#include <string.h>

--- 109 unchanged lines hidden (view full) ---

144 list->cur.pos++;
145
146 return list->cur.ip;
147}
148
149int
150iplist_setsrc(struct iplist *list, const char *src)
151{
27 */
28
29#include <sys/types.h>
30#include <netinet/in.h>
31#include <arpa/inet.h>
32
33#include <stdlib.h>
34#include <string.h>

--- 109 unchanged lines hidden (view full) ---

144 list->cur.pos++;
145
146 return list->cur.ip;
147}
148
149int
150iplist_setsrc(struct iplist *list, const char *src)
151{
152 strncpy(list->src, src, sizeof(list->src)-1);
153 list->src[sizeof(list->src)-1] = '\0';
152 strncpy(list->src, src, sizeof list->src - 1);
153 list->src[sizeof list->src - 1] = '\0';
154 list->cur.srcptr = list->src;
155 do {
156 if (iplist_nextrange(list))
157 list->nItems += list->cur.nItems;
158 else
159 return 0;
160 } while (list->cur.srcptr != list->src);
161 return 1;

--- 44 unchanged lines hidden (view full) ---

206
207int
208iplist_ip2pos(struct iplist *list, struct in_addr ip)
209{
210 struct iplist_cur cur;
211 int f, result;
212
213 result = -1;
154 list->cur.srcptr = list->src;
155 do {
156 if (iplist_nextrange(list))
157 list->nItems += list->cur.nItems;
158 else
159 return 0;
160 } while (list->cur.srcptr != list->src);
161 return 1;

--- 44 unchanged lines hidden (view full) ---

206
207int
208iplist_ip2pos(struct iplist *list, struct in_addr ip)
209{
210 struct iplist_cur cur;
211 int f, result;
212
213 result = -1;
214 memcpy(&cur, &list->cur, sizeof(cur));
214 memcpy(&cur, &list->cur, sizeof cur);
215
216 for (iplist_first(list), f = 0; f < list->nItems; f++)
217 if (iplist_next(list).s_addr == ip.s_addr) {
218 result = list->cur.pos;
219 break;
220 }
221
215
216 for (iplist_first(list), f = 0; f < list->nItems; f++)
217 if (iplist_next(list).s_addr == ip.s_addr) {
218 result = list->cur.pos;
219 break;
220 }
221
222 memcpy(&list->cur, &cur, sizeof(list->cur));
222 memcpy(&list->cur, &cur, sizeof list->cur);
223 return result;
224}
223 return result;
224}