2 * Copyright (C) 1995, 1997-1999 Jeffrey A. Uphoff
3 * Modified by Olaf Kirch, 1996.
4 * Modified by H.J. Lu, 1998.
10 * Simple list management for notify list
21 nlist_new(char *my_name, char *mon_name, int state)
25 if (!(new = (notify_list *) xmalloc(sizeof(notify_list))))
27 memset(new, 0, sizeof(*new));
29 NL_TIMES(new) = MAX_TRIES;
30 NL_STATE(new) = state;
31 if (!(NL_MY_NAME(new) = xstrdup(my_name))
32 || !(NL_MON_NAME(new) = xstrdup(mon_name)))
39 nlist_insert(notify_list **head, notify_list *entry)
41 notify_list *next = *head, *tail = entry;
43 /* Find end of list to be inserted */
54 nlist_insert_timer(notify_list **head, notify_list *entry)
56 /* Find first entry with higher timeout value */
57 while (*head && NL_WHEN(*head) <= NL_WHEN(entry))
58 head = &(*head)->next;
59 nlist_insert(head, entry);
63 nlist_remove(notify_list **head, notify_list *entry)
65 notify_list *prev = entry->prev,
74 entry->next = entry->prev = NULL;
78 nlist_clone(notify_list *entry)
82 new = nlist_new(NL_MY_NAME(entry), NL_MON_NAME(entry), NL_STATE(entry));
83 NL_MY_PROG(new) = NL_MY_PROG(entry);
84 NL_MY_VERS(new) = NL_MY_VERS(entry);
85 NL_MY_PROC(new) = NL_MY_PROC(entry);
86 NL_ADDR(new) = NL_ADDR(entry);
87 memcpy(NL_PRIV(new), NL_PRIV(entry), SM_PRIV_SIZE);
93 nlist_free(notify_list **head, notify_list *entry)
96 nlist_remove(head, entry);
97 if (NL_MY_NAME(entry))
98 free(NL_MY_NAME(entry));
99 if (NL_MON_NAME(entry))
100 free(NL_MON_NAME(entry));
105 nlist_kill(notify_list **head)
108 nlist_free(head, *head);
112 * Walk a list looking for a matching name in the NL_MON_NAME field.
115 nlist_gethost(notify_list *list, char *host, int myname)
119 for (lp = list; lp; lp = lp->next) {
120 if (matchhostname(host, myname? NL_MY_NAME(lp) : NL_MON_NAME(lp)))
124 return (notify_list *) NULL;