slurm_hostlist_create(3) slurm_hostlist_destroy

SYNTAX

#include <slurm/slurm.h>

hostlist_t slurm_hostlist_create (
       char *node_list

);

char * slurm_hostlist_shift (
       hostlist_t host_list

);

void slurm_hostlist_destroy (
       hostlist_t host_list

);

ARGUMENTS

node_list
A list of nodes as returned by the slurm_job_step_create functions. The returned value may include a simple range format to describe numeric ranges of values and/or multiple numeric values (e.g. "linux[1-3,6]" represents "linux1", "linux2", "linux3", and "linux6").
host_list
A hostlist created by the slurm_hostlist_create function.

DESCRIPTION

slurm_hostlist_create creates a database of node names from a range format describing node names. Use slurm_hostlist_destroy to release storage associated with the database when no longer required.

slurm_hostlist_shift extracts the first entry from the host list database created by the slurm_hostlist_create function.

slurm_hostlist_destroy releases storage associated with a database created by slurm_hostlist_create when no longer required.

RETURN VALUE

slurm_hostlist_create returns the host list database or NULL if memory can not be allocated for the database.

slurm_hostlist_shift returns a character string or NULL if no entries remain in the database.

EXAMPLE

#include <stdio.h>
#include <hostlist.h>
#include <slurm.h>

int main (int argc, char *argv[])
{
       hostlist_t my_hostlist;

       char *hostnames, *host;

       /* generate a list of hostnames, possibly using a */

       /* slurm job step creation function */

       my_hostlist = slurm_hostlist_create (hostnames);

       if (my_hostlist == NULL) {

               fprintf (stderr, "No memory\n");

               exit (1);

       }

       while ( (host = slurm_hostlist_shift(my_hostlist)) )

               printf ("host = %s\n", host);

       slurm_hostlist_destroy (my_hostlist) ;

       exit (0);

}

NOTE

These functions are included in the libslurm library, which must be linked to your process for use (e.g. "cc -lslurm myprog.c").

COPYING

Copyright (C) 2002-2006 The Regents of the University of California. Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). CODE-OCEC-09-009. All rights reserved.

This file is part of Slurm, a resource management program. For details, see <http://slurm.schedmd.com/>.

Slurm is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Slurm is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.