source: trunk/athena/bin/olc/server/olcd/list.c @ 2025

Revision 2025, 3.0 KB checked in by tjcoppet, 35 years ago (diff)
*** empty log message ***
Line 
1#include <olc/olc.h>
2#include <olcd.h>
3
4#define NBLOCKS 100
5
6list_knuckle(knuckle,data)
7     KNUCKLE *knuckle;
8     LIST *data;
9{
10  return(get_list_info(knuckle,data));
11}
12
13
14list_user_knuckles(knuckle,data,size)
15     KNUCKLE *knuckle;
16     LIST **data;
17     int *size;
18{
19  USER *user;
20  KNUCKLE **k_ptr;
21  LIST *d;
22  int n;
23
24  user = knuckle->user;
25 
26  /* Allocate the maximum amount. The extra k isn't worth getting
27   * paranoid about accurracy
28   */
29
30  d = (LIST *) malloc(sizeof(LIST) * (user->no_knuckles + 1));
31  if(d == (LIST *) NULL)
32    {
33      log_error("malloc fuckup: list user knuckles");
34      return(ERROR);
35    }
36  *data = d;
37  n = 0;
38
39  for (k_ptr = user->knuckles; *k_ptr != (KNUCKLE *) NULL; k_ptr++)
40    if(is_active((*k_ptr)))
41      {
42#ifdef TEST
43        printf("getting %s %d\n",(*k_ptr)->user->username,n);
44#endif TEST
45
46        get_list_info((*k_ptr),d++);
47        n++;
48      }
49  d->ustatus = END_OF_LIST;
50  d->ukstatus = END_OF_LIST;
51  *size = n;
52
53  return(SUCCESS);
54}
55
56list_redundant(knuckle)
57     KNUCKLE *knuckle;
58{
59
60printf("listing for %s %d\n",knuckle->user->username, knuckle->instance);
61if((is_connected(knuckle)) && (knuckle->question->owner == knuckle))
62printf("true\n");
63
64  if((is_connected(knuckle)) &&  (knuckle->question->owner != knuckle))
65    return(TRUE);
66  else
67    return(FALSE);
68}
69
70
71
72list_queue(queue,data,queues,topics,stati,name,size)
73     int queue;
74     LIST **data;
75     int queues;
76     int *topics;
77     int stati;
78     char *name;
79     int *size;
80{
81  KNUCKLE **k_ptr;
82  LIST *d;
83  int page = 1;
84  int n;
85
86  d = (LIST *) malloc(1024 * NBLOCKS);
87  if(d == (LIST *) NULL)
88    {
89      log_error("malloc error: list queue");
90      return(ERROR);
91    }
92  *data = d;
93  n = 0;
94
95#ifdef TEST
96  printf("list ststu: %d %s\n",stati,name);
97#endif TEST
98
99  for (k_ptr = Knuckle_List; *k_ptr != (KNUCKLE *) NULL; k_ptr++)
100    if(!list_redundant((*k_ptr)) && is_active((*k_ptr)))
101      {
102        if((stati != 0) && ((*k_ptr)->status != stati) &&
103           ((*k_ptr)->user->status != stati))
104          continue;
105
106        if(name != (char *) NULL)
107          if(*name != '\0')
108            if(!(string_equiv(name,(*k_ptr)->user->username,1)))
109              continue;
110
111        if((topics != (int *) NULL) && (has_question((*k_ptr))))
112          if(!is_topic(topics,(*k_ptr)->question->topic_code))
113            continue;
114
115        get_list_info((*k_ptr),d);
116#ifdef TEST
117        printf("putting %s %d\n",(*k_ptr)->user->username,n);
118        printf("sizes: %d  %d\n",(1024 * NBLOCKS * page), ((n-1) * sizeof(LIST)));
119        printf("status: %d title %s\n",d->ukstatus, d->user.title);
120        if(d->connected.uid >=0)
121          printf("connect: %s status: %d\n",d->connected.username, d->ckstatus);
122        if(d->nseen >= 0)
123          printf("question: %s \n",d->topic);
124
125#endif TEST
126        d++;
127        n++;
128        if((1024 * NBLOCKS * page) <= ((n-1) * sizeof(LIST)))
129          {
130            ++page;
131            d = (LIST *) realloc(d,1024 * NBLOCKS * page);
132            if(d == (LIST *) NULL)
133              {
134                log_error("realloc error: list queue");
135                return(ERROR);
136              }
137          }
138      }
139
140  d->ustatus = END_OF_LIST;
141  d->ukstatus = END_OF_LIST;
142  *size = n;
143
144#ifdef TEST
145  printf("%d elements in list\n",n);
146#endif TEST
147
148  return(SUCCESS);
149}
150
151
152
153
154
Note: See TracBrowser for help on using the repository browser.