| 12
 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
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 
 | /*___INFO__MARK_BEGIN__*/
/*************************************************************************
 * 
 *  The Contents of this file are made available subject to the terms of
 *  the Sun Industry Standards Source License Version 1.2
 * 
 *  Sun Microsystems Inc., March, 2001
 * 
 * 
 *  Sun Industry Standards Source License Version 1.2
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.2 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 * 
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 * 
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 * 
 *   Copyright: 2001 by Sun Microsystems, Inc.
 * 
 *   All Rights Reserved.
 * 
 ************************************************************************/
/*___INFO__MARK_END__*/
/*
  This module is used for group building
 */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fnmatch.h>
#include "basis_types.h"
#include "sge.h"
#include "sgermon.h" 
#include "sge_string.h"
#include "sge_str.h"
#include "commlib.h"
#include "sge_log.h"
#include "sge_answer.h"
#include "sge_cqueue.h"
#include "sge_hostname.h"
#include "sge_eval_expression.h"
#include "sge_hgroup.h"
#include "sge_href.h"
#include "sge_object.h"
#include "sge_utility.h"
#include "msg_common.h"
#include "msg_sgeobjlib.h"
#define HGROUP_LAYER TOP_LAYER
/****** sgeobj/hgroup/hgroup_check_name() *************************************
*  NAME
*    hgroup_check_name() -- determine if the name is a valid hgroup name
*
*  SYNOPSIS
*     void check_hgroup_name(lList **answer_list, const char* name) 
*
*  FUNCTION
*     Determine if the given name is a valid hostgroup name. If not
*     add an approbiate error to the answer_list
*
*  INPUTS
*     lList **answer_list - answer list where errors are stored 
*     const char* name    - name of the hostgroup 
*
*  RESULT
*     bool - result 
*        true  -  name contains a valid name for a hostgroup
*        false - name is not a valid name for a hostrgroup
*
*  NOTES
*     MT-NOTE: check_hgroup_name() is not MT safe 
*
*  SEE ALSO
*     sgeobj/hgroup/is_hgroup_name
*******************************************************************************/
bool hgroup_check_name(lList **answer_list, const char* name)
{
   if (!is_hgroup_name(name)) {
      answer_list_add_sprintf(answer_list, STATUS_EUNKNOWN, 
                              ANSWER_QUALITY_ERROR, 
                              MSG_HGRP_INVALIDHOSTGROUPNAME_S, name);
      return false;
   }
   if (verify_str_key(
      answer_list,&name[1], MAX_VERIFY_STRING,
      "hostgroup", KEY_TABLE) != STATUS_OK) {
      return false;
   }
   return true;
}
/****** sgeobj/hgroup/hgroup_list_get_master_list() ***************************
*  NAME
*     hgroup_list_get_master_list() -- Returns master list 
*
*  SYNOPSIS
*     lList **hgroup_list_get_master_list(void) 
*
*  FUNCTION
*     Returns master list containing all existing hostgroup objects. 
*
*  INPUTS
*     void - none 
*
*  RESULT
*     lList** - HGRP_Type list 
*******************************************************************************/
lList **
hgroup_list_get_master_list(void) 
{
    /* depending on the setting, we want to return the local thread setting and
       not the global master list. The object_type_get_master_list knows, which
       one to get */
    return object_type_get_master_list(SGE_TYPE_HGROUP);
}
/****** sgeobj/hgroup/hgroup_list_locate() ************************************
*  NAME
*     hgroup_list_locate() -- Find a group by name 
*
*  SYNOPSIS
*     lListElem* hgroup_list_locate(const lList *this_list, 
*                                      const char *group) 
*
*  FUNCTION
*     Find a 'group' in 'this_list'. 
*
*  INPUTS
*     const lList *this_list - HGRP_Type list 
*     const char *group      - group name 
*
*  RESULT
*     lListElem* - found element or NULL 
******************************************************************************/
lListElem *
hgroup_list_locate(const lList *this_list, const char *group) 
{
   lListElem *ret = NULL;
   
   DENTER(HGROUP_LAYER, "hgroup_list_locate");
   ret = lGetElemHost(this_list, HGRP_name, group);
   DEXIT;
   return ret;
}
/****** sgeobj/hgroup/hgroup_create() *****************************************
*  NAME
*     hgroup_create() -- Create a new hgroup. 
*
*  SYNOPSIS
*     lListElem* 
*     hgroup_create(lList **answer_list, const char *name, 
*                   lList *href_or_groupref) 
*
*  FUNCTION
*     Create a new hostgroup.
*
*  INPUTS
*     lList **answer_list     - AN_Type list 
*     const char *name        - name 
*     lList *href_or_groupref - list of hosts for this hgroup 
*     bool is_name_validate   - if true, the hgrp name is validated. Should be done all the time,
*                               there is only one case in qconf in that the name has to be ignored.
*
*  RESULT
*     lListElem* - new element or NULL 
*******************************************************************************/
lListElem *
hgroup_create(lList **answer_list, const char *name, lList *href_or_groupref, bool is_name_validate)
{
   lListElem *ret = NULL;  /* HGRP_Type */
   DENTER(HGROUP_LAYER, "hgroup_create");
   if (name != NULL) {
      if(!is_name_validate || hgroup_check_name(answer_list, name) ) {
         ret = lCreateElem(HGRP_Type);
         if (ret != NULL) {
            lSetHost(ret, HGRP_name, name);
            lSetList(ret, HGRP_host_list, href_or_groupref);
         } else {
            SGE_ADD_MSG_ID(sprintf(SGE_EVENT, 
                                   MSG_MEM_MEMORYALLOCFAILED_S, SGE_FUNC));
            answer_list_add(answer_list, SGE_EVENT, 
                            STATUS_EMALLOC, ANSWER_QUALITY_ERROR);
         }
     }
   } else {
      SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_INAVLID_PARAMETER_IN_S, SGE_FUNC));
      answer_list_add(answer_list, SGE_EVENT,
                      STATUS_ERROR1, ANSWER_QUALITY_ERROR);
   }
   DEXIT;
   return ret; 
}
/****** sgeobj/hgroup/hgroup_add_references() *********************************
*  NAME
*     hgroup_add_references() -- Add a host or group reference 
*
*  SYNOPSIS
*     bool hgroup_add_references(lListElem *this_elem, 
*                                lList **answer_list, 
*                                const lList *href_or_groupref) 
*
*  FUNCTION
*     Add a host or group reference. 
*
*  INPUTS
*     lListElem *this_elem          - HGRP_Type elem
*     lList **answer_list           - AN_Type list 
*     const lList *href_or_groupref - HR_Type list
*
*  RESULT
*     bool - error state
*        true  - Success
*        false - Error 
******************************************************************************/
bool 
hgroup_add_references(lListElem *this_elem, lList **answer_list, 
                      const lList *href_or_groupref) 
{
   bool ret = true;
   DENTER(HGROUP_LAYER, "hgroup_add_references");
   if (this_elem != NULL && href_or_groupref != NULL) {
      lList *href_list = NULL;   /* HR_Type */
      lListElem *href;           /* HR_Type */
      lXchgList(this_elem, HGRP_host_list, &href_list);
      for_each(href, href_or_groupref) {
         const char *name = lGetHost(href, HR_name);
   
         ret &= href_list_add(&href_list, answer_list, name);
         if (!ret) {
            break;
         }
      } 
      lXchgList(this_elem, HGRP_host_list, &href_list);
   } else {
      SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_INAVLID_PARAMETER_IN_S, SGE_FUNC));
      answer_list_add(answer_list, SGE_EVENT,
                      STATUS_ERROR1, ANSWER_QUALITY_ERROR);
      ret = false;
   }
   DRETURN(ret);
}
/****** sgeobj/hgroup/hgroup_find_all_references() ****************************
*  NAME
*     hgroup_find_all_references() -- Find referenced host and groups 
*
*  SYNOPSIS
*     bool 
*     hgroup_find_all_references(const lListElem *this_elem, 
*                                lList **answer_list, lList *master_list, 
*                                lList **used_hosts, lList **used_groups) 
*
*  FUNCTION
*     Find directly or indirectly referenced hgroup names. 
*     'master_list' has to be the list of all existing hgroups.
*     'used_hosts' and 'used_groups' will contain the names of
*     hosts and groups referenced by 'this_elem'.
*
*  INPUTS
*     const lListElem *this_elem - HGRP_Type 
*     lList **answer_list        - AN_Type list 
*     const lList *master_list   - HGRP_Type list 
*     lList **used_hosts         - HR_Type list 
*     lList **used_groups        - HR_Type list 
*
*  RESULT
*     bool - error state
*        true  - Success
*        false - Error
*
* BUGS
*     Extremely poor performance. Try not to use this function.
******************************************************************************/
bool 
hgroup_find_all_references(const lListElem *this_elem, lList **answer_list,
                           const lList *master_list, lList **used_hosts,
                           lList **used_groups)
{
   bool ret = true;
   DENTER(HGROUP_LAYER, "hgroup_find_all_references");
   if (this_elem != NULL && master_list != NULL) {
      lList *href_list = NULL;   /* HR_Type */
      const char *name;
      name = lGetHost(this_elem, HGRP_name);
      ret &= href_list_add(&href_list, answer_list, name);
      if (ret) {
         DTRACE;
         ret &= href_list_find_all_references(href_list, answer_list, 
                                              master_list, used_hosts, 
                                              used_groups);
      }
      lFreeList(&href_list);
   }
   DRETURN(ret);
}
/****** sgeobj/hgroup/hgroup_find_references() ********************************
*  NAME
*     hgroup_find_references() -- find directly referenced hosts and groups 
*
*  SYNOPSIS
*     bool 
*     hgroup_find_references(const lListElem *this_elem, 
*                            lList **answer_list, 
*                            lList *master_list, 
*                            lList **used_hosts, 
*                            lList **used_groups) 
*
*  FUNCTION
*     Find all hgroups which are directly referenced by 'this_elem'
*     'master_list' has to be the list of all existing hgroups.
*     'used_hosts' and 'used_groups' will contain the names of
*     hosts and groups after a call to this function.
*
*  INPUTS
*     const lListElem *this_elem - HGRP_Type 
*     lList **answer_list        - AN_Type 
*     const lList *master_list   - HGRP_Type 
*     lList **used_hosts         - HR_Type 
*     lList **used_groups        - HR_Type 
*
*  RESULT
*     bool - Error state
*        true  - Success
*        false - Error
*******************************************************************************/
bool 
hgroup_find_references(const lListElem *this_elem, lList **answer_list,
                       const lList *master_list, lList **used_hosts,
                       lList **used_groups)
{
   bool ret = true;
   DENTER(HGROUP_LAYER, "hgroup_find_all_references");
   if (this_elem != NULL && master_list != NULL) {
      const char *name = lGetHost(this_elem, HGRP_name);
      lList *href_list = NULL;   /* HR_Type */
      ret &= href_list_add(&href_list, answer_list, name);
      if (ret) {
         ret &= href_list_find_references(href_list, answer_list, master_list, 
                                          used_hosts, used_groups);
      }
      lFreeList(&href_list);
   }
   DRETURN(ret);
}
/****** sgeobj/hgroup/hgroup_find_all_referencees() ***************************
*  NAME
*     hgroup_find_all_referencees() -- find groups refering to this group 
*
*  SYNOPSIS
*     bool 
*     hgroup_find_all_referencees(const lListElem *this_elem, 
*                                 lList **answer_list, 
*                                 lList *master_list, 
*                                 lList **occupants_groups) 
*
*  FUNCTION
*     Find all hostgroups from 'master_list' which reference the
*     hostgroup 'this_elem'. The name of these hostgroups will be
*     returned in the hreference list 'occupants_groups'.
*     'answer_list' will contain error messages if the function is
*     not successfull
*      
*
*  INPUTS
*     const lListElem *this_elem - HGRP_Type element 
*     lList **answer_list        - AN_Type list 
*     const lList *master_list   - list of all existing HGRP_Type elements 
*     lList **occupants_groups   - HR_Type list 
*
*  RESULT
*     bool - exit state
*        true  - Success
*        false - Error 
*******************************************************************************/
bool 
hgroup_find_all_referencees(const lListElem *this_elem, 
                            lList **answer_list, const lList *master_list, 
                            lList **occupants_groups)
{
   bool ret = true;
   DENTER(HGROUP_LAYER, "hgroup_find_all_referencees");
   if (this_elem != NULL && occupants_groups != NULL) {
      lList *href_list = NULL;
      const char *name;
      name = lGetHost(this_elem, HGRP_name);
      ret &= href_list_add(&href_list, answer_list, name);
      if (ret) {
         ret &= href_list_find_all_referencees(href_list, answer_list,
                                             master_list, occupants_groups);
      }
      lFreeList(&href_list);
   }
   DEXIT;
   return ret;
}
/****** sgeobj/hgroup/hgroup_find_referencees() *********************************
*  NAME
*     hgroup_find_referencees() -- Find groups refering to this group 
*
*  SYNOPSIS
*     bool 
*     hgroup_find_referencees(const lListElem *this_elem, 
*                             lList **answer_list, 
*                             lList *master_list, 
*                             lList **occupants_groups) 
*
*  FUNCTION
*     Find all hostgroups from 'master_list' which reference the
*     hostgroup 'this_elem'. The name of these hostgroups will be
*     returned in the hreference list 'occupants_groups'.
*     'answer_list' will contain error messages if the function is
*     not successfull 
*
*  INPUTS
*     const lListElem *this_elem        - HGRP_Type 
*     lList **answer_list               - AN_Type 
*     const lList *master_hgroup_list   - HGRP_Type master list 
*     const lList *master_cqueue_list   - CQ_Type
*     lList **occupants_groups          - HR_Type 
*     lList **occupants_queues          - ST_Type
*
*  RESULT
*     bool - Error state
*        true  - Success
*        false - Error
*******************************************************************************/
bool 
hgroup_find_referencees(const lListElem *this_elem, 
                        lList **answer_list,
                        const lList *master_hgroup_list, 
                        const lList *master_cqueue_list,
                        lList **occupants_groups,
                        lList **occupants_queues)
{
   bool ret = true;
   DENTER(HGROUP_LAYER, "hgroup_find_all_referencees");
   if (this_elem != NULL) {
      if (occupants_groups != NULL) {
         const char *name = lGetHost(this_elem, HGRP_name);
         lList *href_list = NULL;
         ret &= href_list_add(&href_list, answer_list, name);
         if (ret) {
            ret &= href_list_find_referencees(href_list, answer_list,
                                              master_hgroup_list, 
                                              occupants_groups);
         }
         lFreeList(&href_list);
      }
      if (ret && occupants_queues != NULL) {
         ret &= cqueue_list_find_hgroup_references(master_cqueue_list, 
                                                   answer_list,
                                                   this_elem, 
                                                   occupants_queues);
      }
   }
   DEXIT;
   return ret;
}
/****** sgeobj/hgroup/hgroup_list_exists() *************************************
*  NAME
*     hgroup_list_exists() -- Do hostgroups really exist. 
*
*  SYNOPSIS
*     bool 
*     hgroup_list_exists(const lList *this_list, 
*                        lList **answer_list, 
*                        const lList *href_list) 
*
*  FUNCTION
*     This functions returns true if all hostgroups given by the parameter
*     "href_list" exist in "this_list". If one or more objects are missing
*     a corresponding error message will be returned via "answer_list".
*
*  INPUTS
*     const lList *this_list - HGRP_Type
*     lList **answer_list    - AN_Type 
*     const lList *href_list - HR_Type 
*
*  RESULT
*     bool - true or false
*******************************************************************************/
bool
hgroup_list_exists(const lList *this_list, lList **answer_list,
                   const lList *href_list)
{
   bool ret = true;
   DENTER(HGROUP_LAYER, "hgroup_list_exists");
   if (href_list != NULL && this_list != NULL) {
      lListElem *href;
      for_each(href, href_list) {
         const char *name = lGetHost(href, HR_name);
         if (is_hgroup_name(name)) {
            lListElem *hgroup = hgroup_list_locate(this_list, name);
         
            if (hgroup == NULL) {
               ret = false;
               SGE_ADD_MSG_ID(sprintf(SGE_EVENT, 
                              MSG_SGETEXT_DOESNOTEXIST_SS, "host group", name));
               answer_list_add(answer_list, SGE_EVENT,
                               STATUS_EEXIST, ANSWER_QUALITY_ERROR);
               break;      
            }
         }
      }
   }
   DEXIT;
   return ret;
}
/****** sgeobj/hgroup/hgroup_list_find_matching_and_resolve() *****************
*  NAME
*     hgroup_list_find_matching_and_resolve() -- Finds hostnames 
*
*  SYNOPSIS
*     bool 
*     hgroup_list_find_matching_and_resolve(const lList *this_list, 
*                                           lList **answer_list, 
*                                           const char *hgroup_pattern, 
*                                           lList **used_hosts) 
*
*  FUNCTION
*    Selects all hostgroups of "this_list" which match the pattern 
*    "hgroup_pattern". All hostnames which are directly or indirectly
*     referenced will be added to "used_hosts"
*
*  INPUTS
*     const lList *this_list     - HGRP_Type 
*     lList **answer_list        - AN_Type 
*     const char *hgroup_pattern - fnmatch pattern 
*     lList **used_hosts         - HR_Type 
*
*  RESULT
*     bool - error state
*        true  - Success
*        false - Error
*******************************************************************************/
bool
hgroup_list_find_matching_and_resolve(const lList *this_list,
                                      lList **answer_list,
                                      const char *hgroup_pattern,
                                      lList **used_hosts) 
{
   bool ret = true;
   DENTER(HGROUP_LAYER, "hgroup_list_find_matching_and_resolve");
   if (this_list != NULL && hgroup_pattern != NULL) {
      lListElem *hgroup;
      for_each(hgroup, this_list) {
         const char *hgroup_name = lGetHost(hgroup, HGRP_name);
         
         /* use hostgroup expression */
         if (!sge_eval_expression(TYPE_HOST,hgroup_pattern, hgroup_name, NULL)) {
            lList *tmp_used_hosts = NULL;
            lListElem *tmp_href = NULL;
            ret = hgroup_find_all_references(hgroup, NULL, this_list,
                                             &tmp_used_hosts, NULL);
            for_each(tmp_href, tmp_used_hosts) {
               if (used_hosts != NULL) {
                  const char *hostname = lGetHost(tmp_href, HR_name);
                  lAddElemHost(used_hosts, HR_name, hostname, HR_Type);
               }
            }
            lFreeList(&tmp_used_hosts);
         }
      }
   }
   DEXIT;
   return ret;
}
/****** sgeobj/hgroup/hgroup_list_find_matching() *****************************
*  NAME
*     hgroup_list_find_matching() -- Find hgroups which match pattern 
*
*  SYNOPSIS
*     bool 
*     hgroup_list_find_matching(const lList *this_list, 
*                               lList **answer_list, 
*                               const char *hgroup_pattern, 
*                               lList **href_list) 
*
*  FUNCTION
*    Selects all hostgroups of "this_list" which match the pattern 
*    "hgroup_pattern". All matching hostgroup names will be added to
*    "href_list"
*
*  INPUTS
*     const lList *this_list     - HGRP_Type list 
*     lList **answer_list        - AN_Type list 
*     const char *hgroup_pattern - hostgroup pattern 
*     lList **used_hosts         - HR_Type list  
*
*  RESULT
*     bool - error state
*        true  - success
*        false - error
*******************************************************************************/
bool
hgroup_list_find_matching(const lList *this_list, lList **answer_list,
                          const char *hgroup_pattern, lList **href_list) 
{
   bool ret = true;
   DENTER(HGROUP_LAYER, "hgroup_list_find_matching");
   if (this_list != NULL && hgroup_pattern != NULL) {
      lListElem *hgroup;
      for_each(hgroup, this_list) {
         const char *hgroup_name = lGetHost(hgroup, HGRP_name);
   /* use hostgroup expression */
         if (!sge_eval_expression(TYPE_HOST,hgroup_pattern, hgroup_name, NULL)) {
            if (href_list != NULL) {
               lAddElemHost(href_list, HR_name, hgroup_name, HR_Type);
            }
         }
      }
   }
   DEXIT;
   return ret;
}
 |