File: update_group.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 (43 lines) | stat: -rw-r--r-- 964 bytes parent folder | download
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
#include <stdlib.h>
#include <stdio.h>

#include "npfile.h"
#include "npstringarray.h"
#include "npgroup.h"
#include "npnode.h"

int NP_Node::update_group( char *group )
{
   if ( group == NULL )
   {
      strcpy( error_message, "NP_Node: update_group(): "
              "NULL group name passed as argument." );
      return 1;
   }

   int i;
   NP_Group **pointer = groups;
   for( i = 0; i < total_groups; ++i )
   {
      if ( !strcmp( ( *pointer )->get_name(), group ))
         break;
      ++pointer;
   }
      
   if ( i == total_groups )
   {
      snprintf( error_message, sizeof error_message,
                "NP_Node: update_group(): no such group has been added to "
                "this node object: %s", group );
      return 1;
   }

   if ( ( *pointer )->update() )
   {
      snprintf( error_message, sizeof error_message, "NP_Tree: update_group():"
                " %s", ( *pointer )->get_error() );
      return 1;
   }
   
   return 0;
}