1 /* Based on ipsvd utilities written by Gerrit Pape <pape@smarden.org>
2 * which are released into public domain by the author.
3 * Homepage: http://smarden.sunsite.dk/ipsvd/
5 * Copyright (C) 2007 Denys Vlasenko.
7 * Licensed under GPLv2, see file LICENSE in this source tree.
11 #include "tcpudp_perhost.h"
13 struct hcc* FAST_FUNC ipsvd_perhost_init(unsigned c)
16 struct hcc *cc = xzalloc((c + 1) * sizeof(*cc));
17 cc[c].pid = -1; /* "end" marker */
21 unsigned FAST_FUNC ipsvd_perhost_add(struct hcc *cc, char *ip, unsigned maxconn, struct hcc **hccpp)
27 for (i = 0; cc[i].pid >= 0; ++i) {
32 if (strcmp(cc[i].ip, ip) == 0) {
37 if (freepos == -1) return 0;
38 if (conn <= maxconn) {
40 *hccpp = &cc[freepos];
45 void FAST_FUNC ipsvd_perhost_remove(struct hcc *cc, int pid)
48 for (i = 0; cc[i].pid >= 0; ++i) {
49 if (cc[i].pid == pid) {
58 //void ipsvd_perhost_free(struct hcc *cc)