File: make.C

package info (click to toggle)
peruser 4b33-6
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,952 kB
  • ctags: 1,064
  • sloc: cpp: 22,367; perl: 2,733; makefile: 345; sh: 335
file content (99 lines) | stat: -rw-r--r-- 1,893 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "npthreads.h"

np_thread_node_t *NP_Threads::get_spool_beginning()
{
   return spool_beginning;
}

void NP_Threads::get_totals( int *totalp, int *headersp,
                             int *unseenp, int *requestsp )
{
   if ( totalp != NULL )
      *totalp = total;

   if ( headersp != NULL )
      *headersp = headers;

   if ( unseenp != NULL )
      *unseenp = unseen;

   if ( requestsp != NULL )
      *requestsp = requested;

   return;
}

np_thread_node_t *NP_Threads::get_tree( char *new_server, char *new_group,
                                        int hide_seen, int hide_headers,
                                        int destroy )
{
   if ( destroy && threads != NULL )
      clear();

   threads = NULL;

   if ( new_server == NULL )
   {
      strcpy( error_message, "NP_Threads: get_tree(): NULL server address "
              "passed as argument." );
      return NULL;
   }

   if ( server != NULL )
      free( server );

   if (( server = strdup( new_server )) == NULL )
   {
      perror( "strdup" );
      exit( 1 );
   }

   if ( new_group == NULL )
   {
      strcpy( error_message, "NP_Threads: get_tree(): NULL group name "
              "passed as argument." );
      return NULL;
   }

   if ( group != NULL )
      free( group );

   if (( group = strdup( new_group )) == NULL )
   {
      perror( "strdup" );
      exit( 1 );
   }

   if ( make( hide_seen, hide_headers ) )
      return NULL;
   
   return threads;
}

int NP_Threads::make( int hide_seen, int hide_headers )
{
   int result;
   
   if (( result = load( server, group, hide_seen, hide_headers )))
   {
      if ( result == 2 )
         return 0;

      return 1;
   }

   if (( result = sort()))
      return 1;

   if (( result = thread()))
      return 1;

   if (( result = fill_gaps()))
      return 1;

   return 0;
}