Revision 13635,
1.2 KB
checked in by danw, 25 years ago
(diff) |
NEOS clients, from athena/lib/neos/clients
|
Line | |
---|
1 | /********************************************************************** |
---|
2 | * File Exchange client module to get sorted array from Paperlist |
---|
3 | * |
---|
4 | * $Id: array.c,v 1.1 1999-09-28 22:10:55 danw Exp $ |
---|
5 | * |
---|
6 | * Copyright 1989, 1990 by the Massachusetts Institute of Technology. |
---|
7 | * |
---|
8 | * For copying and distribution information, please see the file |
---|
9 | * <mit-copyright.h>. |
---|
10 | **********************************************************************/ |
---|
11 | |
---|
12 | #include <mit-copyright.h> |
---|
13 | |
---|
14 | #ifndef lint |
---|
15 | static char rcsid_array_c[] = "$Id: array.c,v 1.1 1999-09-28 22:10:55 danw Exp $"; |
---|
16 | #endif /* lint */ |
---|
17 | |
---|
18 | #include <fx/fxcl.h> |
---|
19 | #include <fx/memory.h> |
---|
20 | |
---|
21 | /* Another client module must define comparator for sorting */ |
---|
22 | int compar(); |
---|
23 | |
---|
24 | /* |
---|
25 | * get_array -- fill in the array of papers to collect |
---|
26 | */ |
---|
27 | |
---|
28 | get_array(list, ppp) |
---|
29 | Paperlist list; |
---|
30 | Paper ***ppp; |
---|
31 | { |
---|
32 | Paperlist node; |
---|
33 | int i = 0, count = 0; |
---|
34 | |
---|
35 | /* Count papers in list */ |
---|
36 | for(node = list; node; node = node->next) i++; |
---|
37 | |
---|
38 | if (i == 0) return(0); |
---|
39 | |
---|
40 | *ppp = NewArray(Paper *, i); |
---|
41 | if (!*ppp) return(0); |
---|
42 | |
---|
43 | /* Put papers into sorted array */ |
---|
44 | for(node = list; node; node = node->next) |
---|
45 | (*ppp)[count++] = &node->p; |
---|
46 | qsort((char *) *ppp, count, sizeof(Paper *), compar); |
---|
47 | |
---|
48 | return(count); |
---|
49 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.