Autodocs for `Grid Engine Utility Library'


Next: , Up: (dir)


1 cgroup


1.1 get_cgroup_double_value

NAME
          cgroup/get_cgroup_double_value -- return a cgroup attribute

SYNOPSIS
          bool get_cgroup_double_value(const char *cgroup, const char *attrib,
                                       double *value)

FUNCTION
          Return a cgroup attribute, where the value is expected to be compatible
          with type double.

INPUTS
          cgroup - filename of cgroup
          attrib - attribute to return
          value  - returned value

RESULT
          true on success / false on failure


2 lib


2.1 lock


2.1.1 sge_fifo_lock

NAME
          sge_fifo_lock() -- acquire a read/write lock

SYNOPSIS
          bool sge_fifo_lock(sge_fifo_rw_lock_t *lock, bool is_reader)

FUNCTION
          A call to this function acquires either a read or a write lock
          depending on the value of "is_reader".
          
          If the value of "is_reader" is "true" the function returns as soon
          as it gets the read lock. This is the case if there is noone
          currently holding the write lock and if there was noone previously
          trying to get the write lock.
          
          If the value of "is_reader" is "false" then the function returns
          as soon as it gets the write lock. This is only the case if there
          is noone holding a read or write lock and only if there was noone
          else who tried to get the read or write lock.
          
          A thread my hold multiple concurrent read locks. If so the
          corresponding sge_fifo_unlock() function has to be called once
          for each lock obtained.
          
          Multiple threads might obtain a read lock whereas only one thread
          can have the write lock at the same time.
          
          Threads which can't acquire a read or write lock block till the
          lock is available. A certain number of blocking threads (defined by
          the define FIFO_LOCK_QUEUE_LENGTH) wait in a queue so that
          each of those threads has a chance to get the lock.
          
          If more than FIFO_LOCK_QUEUE_LENGTH threads try to get the lock
          it might happen that then there are threads which will never
          get the lock (This behaviour depends on the implementation
          of the pthread library).
          
          A read/write lock has to be initialized with sge_fifo_lock_init()
          before it can be used with this function.

INPUTS
          sge_fifo_rw_lock_t *lock - lock object
          bool is_reader           - try to get the read lock (true)
                                     or write lock (false)

RESULT
          bool - error state
             true  - success
             false - error occured

NOTES
          MT-NOTE: sge_fifo_lock() is MT safe

SEE ALSO


2.1.2 sge_fifo_lock_init

NAME
          sge_fifo_lock_init() -- initialize a fifo read/write lock

SYNOPSIS
          bool sge_fifo_lock_init(sge_fifo_rw_lock_t *lock)

FUNCTION
          This function is used to initialize a fifo read/write lock.
          
          On success the function returns true. If the lock object can't be
          initialized then the function will return with false.

INPUTS
          sge_fifo_rw_lock_t *lock - fifo lock object

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_fifo_lock_init() is MT safe

SEE ALSO


2.1.3 sge_fifo_ulock

NAME
          sge_fifo_ulock() -- release a read or write lock

SYNOPSIS
          bool sge_fifo_ulock(sge_fifo_rw_lock_t *lock, bool is_reader)

FUNCTION
          Releases a read or write lock previously obtained with
          sge_fifo_lock() or sge_fifo_unlock()

INPUTS
          sge_fifo_rw_lock_t *lock - lock object
          bool is_reader           - type of lock to be released

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_fifo_ulock() is MT safe

SEE ALSO


3 libs


3.1 lck


3.1.1 id_callback_impl

NAME
          id_callback_impl() -- locker ID callback

SYNOPSIS
          static sge_locker_t id_callback_impl(void)

FUNCTION
          Return ID of current locker.

INPUTS
          void - none

RESULT
          sge_locker_t - locker id

NOTES
          MT-NOTE: id_callback() is MT safe.


3.1.2 lock_once_init

NAME
          lock_once_init() -- setup lock service

SYNOPSIS
          static void lock_once_init(void)

FUNCTION
          Determine number of locks needed. Create and initialize the respective
          mutexes. Register the callbacks required by the locking API

INPUTS
          void - none

RESULT
          void - none

NOTES
          MT-NOTE: lock_once_init() is NOT MT safe.
          
          Currently we do not use so called recursive mutexes. This may change
          *without* warning, if necessary!

SEE ALSO


4 rmon


4.1 Introduction

NAME
          RMON - Grid Engine Monitoring Interface

FUNCTION
          The RMON library is a set of functions, which do allow monitoring of
          of application execution. The functions provided, however, should not
          be used directly. Rather the RMON functions are utilized by a set of
          monitoring macros, like 'DENTER' or 'DEXIT'.
          
          If monitoring is active, the RMON functions do get called very frequently.
          Hence, the overhead caused by monitoring needs to be minimal. For this
          reason, access to external global and static global variables is NOT
          synchronized through a mutex! Not using a lock of type 'pthread_mutex_t'
          also means that the RMON functions are async-signal safe.
          
          To use RMON library in a multi threaded environment, some restrictions
          must be followed strictly! It is of utmost importance, that the function
          'rmon_mopen()' is ONLY invoked from exactly one thread. The thread which
          is calling 'rmon_mopen()' must be the ONLY thread at this point in time.
          'DENTER_MAIN' is the only macro from which 'rmon_mopen()' is called. The
          macro 'DENTER_MAIN' is used at the beginning of a main function. At this
          point in time, the so called main-thread is the only thread.
          
          It is safe to call the remaining RMON functions, like 'rmon_menter()' or
          'rmon_mexit()', from within multiple threads. 'rmon_mopen()' is the only
          RMON function which does change the critical global variables ('mtype',
          'rmon_fp' and 'RMON_DEBUG_ON'). 'rmon_menter()' and 'rmon_mexit()' are used by
          the macro 'DENTER' and 'DEXIT', respectively.


5 rmon_macros


5.1 mwrite

NAME
          mwrite() -- Write monitoring message

SYNOPSIS
          static void mwrite(char *message)

FUNCTION
          Write monitoring message. The message is written to the output stream
          associated with 'rmon_fp'. The output stream is flushed immediately.
          
          A prefix is added to 'message'. It does consist of a trace sequence number,
          the PID and the thread ID of the calling thread.

INPUTS
          char *message - monitoring message

RESULT
          void - none

NOTES
          MT-NOTE: 'mwrite()' is MT safe with exceptions. See introduction!
          MT-NOTE:
          MT-NOTE: It is guaranteed that the output of different threads is not
          MT-NOTE: mingled.


5.2 rmon_condition

NAME
          rmon_condition() -- Check monitoring condition.

SYNOPSIS
          int rmon_condition(int layer, int class)

FUNCTION
          Check whether monitoring should be enabled for the given combination of
          'layer' and 'class'.

INPUTS
          int layer - monitor layer
          int class - monitor class

RESULT
          1 - do monitor
          0 - do not monitor

NOTES
          MT-NOTE: 'rmon_condition()' is MT safe with exceptions. See introduction!


5.3 rmon_debug_client_callback

NAME
          rmon_debug_client_callback() -- callback for debug clients

SYNOPSIS
          static void rmon_debug_client_callback(int dc_connected, int debug_level)

FUNCTION
          Is called when a debug client is connected/disconnected or on
          debug level changes. Use cl_com_application_debug() to send debug
          messages to the connected qping -dump client.

INPUTS
          int dc_connected - 1 debug client is connected
                             0 no debug client is connected
          int debug_level  - debug level from 0 (off) to 5(DPRINTF)

NOTES
          MT-NOTE: rmon_debug_client_callback() is MT safe
                   (but is called from commlib thread, which means that no
                    qmaster thread specific setup is done), just use global
                    thread locking methods which are initialized when called, or
                    initialized at compile time)


5.4 rmon_is_enabled

NAME
          rmon_is_enabled() -- Check if monitoring is enabled.

SYNOPSIS
          int rmon_is_enabled(void)

FUNCTION
          Check if monitoring is enabled. Note that even if monitoring is enabled
          no actual monitoring output may be generated. Generation of monitoring
          output is controlled by 'rmon_condition()'.

INPUTS
          void - none

RESULT
          1 - monitoring enabled
          0 - monitoring disabled

NOTES
          MT-NOTE: 'rmon_is_enabled()' is MT safe with exceptions. See introduction!


5.5 rmon_menter

NAME
          rmon_menter() -- Monitor function entry

SYNOPSIS
          void rmon_menter(const char *func)

FUNCTION
          Monitor function entry. Generate function entry message.

INPUTS
          const char *func - function name

RESULT
          void - none

NOTES
          MT-NOTE: 'rmon_menter()' is MT safe with exceptions. See introduction!


5.6 rmon_mexit

NAME
          rmon_mexit() -- Monitor function exit

SYNOPSIS
          void rmon_mexit(const char *func, const char *file, int line)

FUNCTION
          Monitor function exit. Generate function exit message.

INPUTS
          const char *func - function name
          const char *file - source file in which function is defined
          int line         - number of invocation source line

RESULT
          void - none

NOTES
          MT-NOTE: 'rmon_mexit()' is MT safe with exceptions. See introduction!


5.7 rmon_mopen

NAME
          rmon_mopen() -- Open, i.e. initialize monitoring.

SYNOPSIS
          void rmon_mopen(int *argc, char *argv[], char *programname)

FUNCTION
          Initialize monitoring. Clear all monitoring levels. Set monitoring levels
          according to 'SGE_DEBUG_LEVEL' environment variable. Set monitoring
          target (i.e. output stream) according to 'SGE_DEBUG_TARGET' environment
          variable. Enable monitoring.
          
          NOTE: Even though 'argc' and 'argv' are not used, they do make sure that
          'rmon_mopen()' is only used within a main function to a certain degree.

INPUTS
          int *argc         - not used
          char *argv[]      - not used
          char *programname - not used

RESULT
          void - none

NOTES
          MT-NOTE: 'rmon_mopen()' is NOT MT safe. See introduction!


5.8 rmon_mprintf

NAME
          rmon_mprintf() -- Print formatted monitoring message.

SYNOPSIS
          void rmon_mprintf(const char *fmt, ...)

FUNCTION
          Print formatted monitoring message.

INPUTS
          const char *fmt - format string
          ...             - variable argument list

RESULT
          void - none

NOTES
          MT-NOTE: 'rmon_mprintf()' is MT safe with exceptions. See introduction!


5.9 rmon_mtrace

NAME
          rmon_mtrace() -- Monitor function progress

SYNOPSIS
          void rmon_mtrace(const char *func, const char *file, int line)

FUNCTION
          Monitor function progress. Generate function trace message.

INPUTS
          const char *func - function name
          const char *file - source file in which function is defined
          int line         - number of invocation source line

RESULT
          void - none

NOTES
          MT-NOTE: 'rmon_mtrace()' is MT safe with exceptions. See introduction!


5.10 set_debug_level_from_env

NAME
          set_debug_level_from_env() -- Set debug level from environment variable.

SYNOPSIS
          static int set_debug_level_from_env(void)

FUNCTION
          Set debug level. Read environment variable "SGE_DEBUG_LEVEL" and use it
          to initialize debug levels.

INPUTS
          void - none

RESULT
          0 - successful
          ENOENT - environment variable not set
          EINVAL - unexpected format

NOTES
          MT-NOTE: 'set_debug_level_from_env()' is MT safe with exceptions.
          MT-NOTE:  See introduction!


5.11 set_debug_target_from_env

NAME
          set_debug_target_from_env() -- Set debug target from environment variable.

SYNOPSIS
          static int set_debug_target_from_env(void)

FUNCTION
          Set debug target. Read environment variable "SGE_DEBUG_TARGET" and use it
          to initialize debug output target.
          
          'SGE_DEBUG_TARGET' may either be 'stdout', 'stderr' or a fully qualified
          file name (that is file name and path). If a file name is given an
          already existing file with the same name will be overwritten.

INPUTS
          void - none

RESULT
          0 - successful
          EACCES - file name is invalid or unable to open file

NOTES
          MT-NOTE: 'set_debug_target_from_env()' is MT safe with exceptions.
          MT-NOTE: See introduction!


6 sge_binding_hlp


6.1 bindingLinearParseCoreOffset

NAME
          bindingLinearParseCoreOffset() -- Get core number of linear request.

SYNOPSIS
          int bindingLinearParseCoreOffset(const char* parameter)

FUNCTION
          In a request like "-binding linear:<amount>:<socketnr>,<corenr>" it
          parses the core number.

INPUTS
          const char* parameter - pointer to the binding request

RESULT
          int - if a value >= 0 then this reflects the core number
                if a value < 0 then there was a parsing error or no core number was given

NOTES
          MT-NOTE: bindingLinearParseCoreOffset() is not MT safe


6.2 bindingLinearParseSocketOffset

NAME
          bindingLinearParseSocketOffset() -- Get socket number of linear request.

SYNOPSIS
          int bindingLinearParseSocketOffset(const char* parameter)

FUNCTION
          In a request like "-binding linear:<amount>:<socketnr>,<corenr>" it
          parses the socket number.

INPUTS
          const char* parameter - pointer to the binding request

RESULT
          int - if a value >= 0 then this reflects the socket number
                if a value < 0 then there was a parsing error or no socket number was given

NOTES
          MT-NOTE: bindingLinearParseSocketOffset() is not MT safe


6.3 binding_explicit_has_correct_syntax

NAME
          binding_explicit_has_correct_syntax() -- Check if parameter has correct syntax.

SYNOPSIS
          bool binding_explicit_has_correct_syntax(const char* parameter)

FUNCTION
          This function checks if the given string is a valid argument for the
          -binding parameter which provides a list of socket, cores which have
          to be selected explicitly.
          
          The accepted syntax is: "explicit:[1-9][0-9]*,[1-9][0-9]*(:[1-9][0-9]*,[1-9][0-9]*)*"
          
          This is used from parse_qsub.c.

INPUTS
          const char* parameter - A string with the parameter.

RESULT
          bool - True if the parameter has the expected syntax.

NOTES
          MT-NOTE: binding_explicit_has_correct_syntax() is not MT safe


6.4 binding_linear_parse_number

NAME
          binding_linear_parse_number() -- Parse the number of cores to occupy.

SYNOPSIS
          int binding_linear_parse_number(const char* parameter)

FUNCTION
          Parses a string in order to get the number of cores requested.
          
          The string has following format: "linear:<amount>[:<socket>,<core>]"

INPUTS
          const char* parameter - The first character of the string

RESULT
          int - if a value >= 0 then this reflects the number of cores
                if a value < 0 then there was a parsing error

NOTES
          MT-NOTE: binding_linear_parse_number() is MT safe


6.5 binding_parse_type

NAME
          binding_parse_type() -- Parses binding type out of binding string.

SYNOPSIS
          binding_type_t binding_parse_type(const char* parameter)

FUNCTION
          The execution daemon communicates with the shepherd with the config
          file. This function parses the type of binding out of the specific
          binding string from the config file. In case of binding type "set"
          there is no special prefix in this string. In case of "environment"
          the "env_" prefix in within the string. In case of setting the
          rankfile the "pe_" prefix can be found in this string.

INPUTS
          const char* parameter - The binding string from the config file.

RESULT
          binding_type_t - The type of binding.

NOTES
          MT-NOTE: binding_parse_type() is MT safe


6.6 binding_striding_parse_first_core

NAME
          binding_striding_parse_first_core() -- Parses core number from command line.

SYNOPSIS
          int binding_striding_parse_first_core(const char* parameter)

FUNCTION
          Parses the core number from command line in which to start binding
          in "striding" case.
          
          -binding striding:<amount>:<stepsize>:<socket>,<core>

INPUTS
          const char* parameter - Pointer to first character of CL string.

RESULT
          int - -1 in case the string is corrupt or core number is not set
                >= 0 in case the core number could parsed successfully.

NOTES
          MT-NOTE: binding_striding_parse_first_core() is not MT safe


6.7 binding_striding_parse_first_socket

NAME
          binding_striding_parse_first_socket() -- Parses the socket to begin binding on.

SYNOPSIS
          int binding_striding_parse_first_socket(const char* parameter)

FUNCTION
          Parses the "striding:" parameter string for the socket number.
          
          The string is expected to have following syntax:
          
                "striding:<amount>:<stepsize>[:<socket>,<core>]"

INPUTS
          const char* parameter - Points to the string with the query.

RESULT
          int - Returns the socket number in case it could be parsed otherwise -1

NOTES
          MT-NOTE: binding_striding_parse_first_socket() is not MT safe


6.8 binding_striding_parse_number

NAME
          binding_striding_parse_number() -- Parses the number of cores to bind to.

SYNOPSIS
          int binding_striding_parse_number(const char* parameter)

FUNCTION
          Parses the number of cores to bind to out of "striding:" parameter string.
          
          The string is expected to have following syntax:
          
                "striding:<amount>:<stepsize>[:<socket>,<core>]"

INPUTS
          const char* parameter - Points to the string with the query.

RESULT
          int - Returns the number of cores to bind to otherwise -1.

NOTES
          MT-NOTE: binding_striding_parse_number() is not MT safe


6.9 binding_striding_parse_step_size

NAME
          binding_striding_parse_step_size() -- Parses the step size out of the "striding" query.

SYNOPSIS
          int binding_striding_parse_step_size(const char* parameter)

FUNCTION
          Parses the step size for the core binding strategy "striding" out of the
          query.
          
          The query string is expected to have following syntax:
          
                "striding:<amount>:<stepsize>[:<socket>,<core>]"

INPUTS
          const char* parameter - Points to the string with the query.

RESULT
          int - Returns the step size or -1 when it could not been parsed.

NOTES
          MT-NOTE: binding_striding_parse_step_size() is not MT safe


6.10 check_explicit_binding_string

NAME
          check_explicit_binding_string() -- Checks binding string for duplicate pairs.

SYNOPSIS
          bool check_explicit_binding_string(const char* expl, const int amount)

FUNCTION
          Checks binding string for duplicate <socket,core> pairs. Works
          also when the first pair is the "explicit" string.

INPUTS
          const char* expl - pointer to the explicit binding request
          const int amount - expected number of pairs
          const bool with_explicit_prefix - expl start with "excplicit:"

RESULT
          bool - true if the explicit binding request is duplicate free

NOTES
          MT-NOTE: check_explicit_binding_string() is MT safe

SEE ALSO


6.11 get_explicit_number

NAME
          get_explicit_number() -- Counts the number of <socket,core> pairs.

SYNOPSIS
          int get_explicit_number(const char* expl)

FUNCTION
          Counts the number of <socket,core> pairs in the binding explicit request.

INPUTS
          const char* expl - pointer to explicit binding request string
          const bool with_explicit_prefix - does string start with "explicit:"?

RESULT
          int - number of <socket,core> pairs in explicit binding request string

NOTES
          MT-NOTE: get_explicit_number() is MT safe

SEE ALSO


6.12 is_digit

NAME
          is_digit() -- Checks if char array consists of digits.

SYNOPSIS
          static bool is_digit(const char* position, const char stopchar)

FUNCTION
          Checks if the character array contains only digits till the end of the
          array or to a given stop character. If there is no digit found or
          the input pointer is a null pointer 'false' is returned.
          The input pointer have to point to the first digit of a number.

INPUTS
          const char* position - pointer to the character array
          const char stopchar  - stop scanning at this parameter

RESULT
          static bool - true if a number is found false if not

NOTES
          MT-NOTE: is_digit() is MT safe


6.13 parse_binding_parameter_string

NAME
          parse_binding_parameter_string() -- Parses binding parameter string.

SYNOPSIS
          bool parse_binding_parameter_string(const char* parameter, u_long32*
          type, dstring* strategy, int* amount, int* stepsize, int* firstsocket,
          int* firstcore, dstring* socketcorelist, dstring* error)

FUNCTION
          Parses binding parameter string and returns the values of the parameter.
          Please check output values in dependency of the strategy string.

INPUTS
          const char* parameter   - binding parameter string

OUTPUT
          u_long32* type          - type of binding (pe = 0| env = 1|set = 2)
          dstring* strategy       - binding strategy string
          int* amount             - number of cores to bind to
          int* stepsize           - step size between cores (or -1)
          int* firstsocket        - first socket to use (or -1)
          int* firstcore          - first core to use (on "first socket") (or -1)
          dstring* socketcorelist - list of socket,core pairs with prefix explicit or NULL
          dstring* error          - error as string in case of return false

RESULT
          bool - true in case parsing was successful false in case of errors

NOTES
          MT-NOTE: parse_binding_parameter_string() is MT safe


6.14 topology_string_to_socket_core_lists

NAME
          topology_string_to_socket_core_lists() -- Converts a topology into socket,core lists.

SYNOPSIS
          bool topology_string_to_socket_core_lists(const char* topology, int**
          sockets, int** cores, int* amount)

FUNCTION
          Converts a topology string into lists of cores and sockets which are marked
          as beeing used and returns them.

INPUTS
          const char* topology - Pointer to a topology string.

OUTPUTS
          int** sockets        - Pointer to the location of the socket array.
          int** cores          - Pointer to the location of the core array.
          int* amount          - Length of the arrays.

RESULT
          bool - false when problems occured true otherwise

NOTES
          MT-NOTE: topology_string_to_socket_core_lists() is MT safe


7 sge_hostname


7.1 sge_get_qmaster_port

NAME
          sge_get_qmaster_port() -- get qmaster port

SYNOPSIS
          int sge_get_qmaster_port(bool *from_services)

FUNCTION
          This function returns the TCP/IP port of the qmaster daemon. It returns
          a cached value from a previous run. The cached value will be refreshed
          every 10 Minutes. The port may come from environment variable
          SGE_QMASTER_PORT or the services files entry "sge_qmaster".

INPUTS
          bool *from_services - Pointer to a boolean which is set to true
                                when the port value comes from the services file.

RESULT
          int - port of qmaster


8 sge_lock


8.1 Introduction

NAME
          Grid Engine Locking API

FUNCTION
          The Grid Engine Locking API is a mediator between a lock service provider
          and a lock client. A lock service provider offers a particular lock
          implementation by registering a set of callbacks. A lock client does acquire
          and release a lock using the respective API functions.
          
          A lock service provider (usually a daemon) needs to register three
          different callbacks:
          
            + a lock callback, which is used by the API lock function
          
            + an unlock callback, which is used by the API unlock function
          
            + an ID callback, which is used by the API locker ID function
          
          Lock service provider has to register these callbacks *before* lock client
          uses the lock/unlock API functions. Otherwise the lock/unlock operations do
          have no effect at all.
          
          Locktype denotes the entity which will be locked/unlocked (e.g. Global
          Lock. Lockmode denotes in which mode the locktype will be locked/unlocked.
          Locker ID unambiguously identifies a lock client.
          
          Adding a new locktype does recquire two steps:
          
          1. Add an enumerator to 'sge_locktype_t'. Do not forget to update
             'NUM_OF_TYPES'.
          
          2. Add a description to 'locktype_names'.

SEE ALSO


8.2 sge_lock

NAME
          sge_lock() -- Acquire lock

SYNOPSIS
          void sge_lock(sge_locktype_t aType, sge_lockmode_t aMode)

FUNCTION
          Acquire lock. If the lock is already held, block the caller until lock
          becomes available again.
          
          Instead of using this function directly the convenience macro
          'SGE_LOCK(type, mode)' could (and should) be used.
          

INPUTS
          sge_locktype_t aType - lock to acquire
          sge_lockmode_t aMode - lock mode

RESULT
          void - none

NOTES
          MT-NOTE: sge_lock() is MT safe


8.3 sge_locker_id

NAME
          sge_locker_id() -- Locker identifier

SYNOPSIS
          sge_locker_t sge_locker_id(void)

FUNCTION
          Return an unambiguous identifier for the locker.

INPUTS
          void - none

RESULT
          sge_locker_t - locker identifier

NOTES
          There is a 1 to 1 mapping between a locker id an a thread. However the
          locker id and the thread id may be different.
          
          MT-NOTE: sge_locker_id() is MT safe


8.4 sge_unlock

NAME
          sge_unlock() -- Release lock

SYNOPSIS
          void sge_unlock(sge_locktype_t aType, sge_lockmode_t aMode)

FUNCTION
          Release lock.
          
          Instead of using this function directly the convenience macro
          'SGE_UNLOCK(type, mode)' could (and should) be used.

INPUTS
          sge_locktype_t aType - lock to release
          sge_lockmode_t aMode - lock mode in which the lock has been acquired

RESULT
          void - none

NOTES
          MT-NOTE: sge_unlock() is MT safe


9 sge_mtutil


9.1 sge_mutex_lock

NAME
          sge_mutex_lock() -- Mutex locking wrapper with rmon monitoring

SYNOPSIS
          void sge_mutex_lock(const char *mutex_name, const char *func,
          int line, pthread_mutex_t *mutex)

FUNCTION
          Locks the passed mutex. Before and after locking rmon DLOCKPRINTF()
          is used to facilitate tracking of deadlocks that are caused by
          mutexes.

INPUTS
          const char *mutex_name - The name of the mutex.
          const char *func       - The function where sge_mutex_lock()
                                   was called from
          int line               - The line number where sge_mutex_lock()
                                   was called from
          pthread_mutex_t *mutex - The mutex.

NOTES
          MT-NOTE: sge_mutex_lock() is MT-safe
          MT-NOTE:
          MT-NOTE: This function is considered being MT-safe, even though is does
          MT-NOTE: use 'strerror()'. The error message returned from 'strerror()'
          MT-NOTE: is not stored and used imediately.

SEE ALSO


9.2 sge_mutex_unlock

NAME
          sge_mutex_unlock() -- Mutex unlocking wrapper with rmon monitoring

SYNOPSIS
          void sge_mutex_unlock(const char *mutex_name, const char *func,
          int line, pthread_mutex_t *mutex)

FUNCTION
          Unlocks the passed mutex. Before and after unlocking rmon DLOCKPRINTF()
          is used to facilitate tracking of deadlocks that are caused by
          mutexes.

INPUTS
          const char *mutex_name - The name of the mutex.
          const char *func       - The function where sge_unmutex_unlock()
                                   was called from
          int line               - The line number where sge_unmutex_lock()
                                   was called from
          pthread_mutex_t *mutex - The mutex.

NOTES
          MT-NOTE: sge_mutex_unlock() is MT-safe
          MT-NOTE:
          MT-NOTE: This function is considered being MT-safe, even though is does
          MT-NOTE: use 'strerror()'. The error message returned from 'strerror()'
          MT-NOTE: is not stored and used imediately.

SEE ALSO


9.3 sge_relative_timespec

NAME
          sge_relative_timespec() -- set timespec to now plus timeout

SYNOPSIS
          static void sge_relative_timespec(signed long timeout, struct
          timespec *ts)

FUNCTION
          Based on the relative timeout passed an absolute timespec is
          returned. The timespec can e.g. be used for pthread_cond_timedwait().
          Also a timout of 0 can be used. However if the timespec returned is then
          used with pthread_cond_timedwait() this requires the predicate is checked
          once at least.

INPUTS
          signed long timeout - A relative timeout interval or 0

OUTPUTS
          struct timespec *ts - An abstime timespec value

NOTES
          MT-NOTE: sge_relative_timespec() is MT safe


10 sge_parse_args


10.1 convert_arg_list_to_vector

NAME
          convert_arg_list_to_vector() -- creates an argument vector from a list

SYNOPSIS
          void convert_arg_list_to_vector(sge_sl_list_t *sl_args, char ***pargs)

FUNCTION
          Takes the list of arguments (i.e. a list of strings) and creates an
          argument vector out of it, like you get it in the main() function.
          The strings in the argument vector are still the ones from the argument
          list, i.e. the string buffers are not copied, the elements of the
          argument vector just point to them.

INPUTS
          sge_sl_list_t *sl_args - a list with single C strings as elements
          char ***pargs          - an argument vector like main() provides, filled
                                   with all arguments from the list.
                                   This argument vector is terminated by an element
                                   that points to NULL.

RESULT
          int - The length of the argument vector including the terminal NULL
                element.

EXAMPLE
          sge_sl_list_t *sl_args;
          char          **args;
          char          command_line[] = "foo bla \"trala\"";
          
          sge_sl_create(&sl_args);
          
          parse_quoted_command_line(command_line, sl_args);
          convert_arg_list_to_vector(sl_args, &args);
          
          ... use args ...
          ... done using args ...
          sge_sl_destroy(&sl_args, NULL);

NOTES
          MT-NOTE: convert_arg_list_to_vector() is not MT safe

SEE ALSO


10.2 parse_quoted_command_line

NAME
          parse_quoted_command_line() -- parses a command line with quoted arguments

SYNOPSIS
          int parse_quoted_command_line(char *command, sge_sl_list_t *sl_args)

FUNCTION
          Parses a command line with quoted arguments and stores the single
          arguments into a SGE simple list (sge_sl). The command line is modified
          during the parse process. This function recognizes the quotes " and '.
          This function can't handle escaped quotes, see last example.

INPUTS
          char *command          - the command line to be parsed. "command" gets
                                   modified during the parse process, so provide
                                   a copy of the real command line if you need it
                                   afterwards.
          sge_sl_list_t *sl_args - pointer to the list where the single arguments
                                   get stored to. This must be a properly created
                                   list (using sge_sl_create()).
                                   In case of error, the list contains all arguments
                                   not including the last quoted one (with the
                                   missing closing quote)

RESULT
          int - 0: OK
                1: unmatched quote "
                2: unmatched quote '

EXAMPLE
          command line: foo "bar trala 'hey hu'"
          list:
          + foo
          + bar trala 'hey hu'
          
          command line: 'foo bar' trala "hey" hu
          list:
          + foo bar
          + trala
          + hey
          + hu
          
          command line: foo "bar trala '"hey hu'
          list:
          + foo
          + bar trala '
          + hey hu'
          
          command line: foo "bar trala hey hu
          return value 1
          list:
          + foo
          
          command line: "foo \"bar huhu\" trala" hey
          list:
          + foo \
          + bar
          + huhu\
          +  trala
          + hey

NOTES
          MT-NOTE: parse_quoted_command_line() is not MT safe

SEE ALSO


11 sge_var


11.1 unescape_env_value

NAME
          unescape_env_value() --

SYNOPSIS
          char * unescape_env_value(char *value)

FUNCTION
          Undo any backslash escapes (\\ or \n) in value string, returning
          a new string.

INPUTS
          char *value                 - environment variable value

RESULT
          new string

NOTES
          MT-NOTE: unescape_env_value() is MT safe


12 test_sge_deadlock


12.1 thread_function_2

NAME
          thread_function_2() -- Thread function to execute

SYNOPSIS
          static void* thread_function_2(void *anArg)

FUNCTION
          Acquire multiple locks and sleep. Release the locks. After each 'sge_lock()'
          and 'sge_unlock()' sleep to increase the probability of interlocked execution.
          
          Note: This function for itself is perfectly reasonable. However, a race
          condition, and thus a potential deadlock, does emerge if this function is
          run in parallel with 'thread_function_1()'.
          
          The reason for this is, that 'thread_function_2()' and 'thread_function_1()'
          each follow their own local acquire/release protocol. As a consequence,
          'thread_function_2()' and 'thread_function_1()' acquire and release their
          respective locks in different orders.
          
          This example does reveal how important it is to obey a GLOBAL acquire/release
          protocol.

INPUTS
          void *anArg - thread function arguments

RESULT
          static void* - none

SEE ALSO


13 test_sge_lock_main


13.1 main

NAME
          main() -- Generic skeleton for lock API test programs.

SYNOPSIS
          int main(int argc, char *argv[])

FUNCTION
          Generic driver for lock API test programs utilizing pthreads and pthread
          mutexes. Setup locking API by registering the needed callbacks. Determine
          the number of threads needed. Create threads and execute the provided thread
          function. Wait until all the threads have finished. Teardown the locking API.
          
          If a program wants to utilize this skeleton it has to implement the functions
          of a small API defined in 'sge_lock_main.h'.

INPUTS
          int argc     - number of arguments
          char *argv[] - argument array

RESULT
          int - always 0

SEE ALSO


14 test_sge_lock_multiple


14.1 thread_function

NAME
          thread_function() -- Thread function to execute

SYNOPSIS
          static void* thread_function(void *anArg)

FUNCTION
          Acquire multiple locks and sleep. Release the locks. After each 'sge_lock()'
          and 'sge_unlock()' sleep to increase the probability of interlocked execution.
          Note that we deliberately test the boundaries of 'sge_locktype_t'.

INPUTS
          void *anArg - thread function arguments

RESULT
          static void* - none

SEE ALSO


15 test_sge_lock_simple


15.1 thread_function

NAME
          thread_function() -- Thread function to execute

SYNOPSIS
          static void* thread_function(void *anArg)

FUNCTION
          Lock the global lock in read mode and sleep. Unlock the global lock.

INPUTS
          void *anArg - thread function arguments

RESULT
          static void* - none

SEE ALSO


15.2 thread_function_1

NAME
          thread_function_1() -- Thread function to execute

SYNOPSIS
          static void* thread_function_1(void *anArg)

FUNCTION
          Acquire multiple locks and sleep. Release the locks. After each 'sge_lock()'
          and 'sge_unlock()' sleep to increase the probability of interlocked execution.
          
          Note: This function for itself is perfectly reasonable. However, a race
          condition, and thus a potential deadlock, does emerge if this function is
          run in parallel with 'thread_function_2()'.
          
          The reason for this is, that 'thread_function_1()' and 'thread_function_2()'
          each follow their own local acquire/release protocol. As a consequence,
          'thread_function_1()' and 'thread_function_2()' acquire and release their
          respective locks in different orders.
          
          This example does reveal how important it is to obey a GLOBAL acquire/release
          protocol.

INPUTS
          void *anArg - thread function arguments

RESULT
          static void* - none

SEE ALSO


16 uti


16.1 afsutil


16.1.1 sge_afs_extend_token

NAME
          sge_afs_extend_token() -- Extend an AFS token

SYNOPSIS
          int sge_afs_extend_token(const char *command, char *tokenbuf,
                                   const char *user, int token_extend_time,
                                   char *err_str, size_t lstr)

FUNCTION
          Call 'command', pipe content of 'tokenbuf' to 'command', using
          'user' as arg1 and 'token_extend_time' as arg2

INPUTS
          const char *command   - command
          char *tokenbuf        - input for command
          const char *user      - 1st argument for command
          int token_extend_time - 2nd argument for command
          char *err_str         - error message
          size_t lstr           - length of err_str

NOTES
          MT-NOTE: sge_afs_extend_token() is not MT safe because it uses MT unsafe
          MT-NOTE: sge_peopen()

RESULT
          int - error state
              0 - OK
             -1 - Error


16.1.2 sge_get_token_cmd

NAME
          sge_get_token_cmd() -- Check if 'tokencmdname' is executable

SYNOPSIS
          int sge_get_token_cmd(const char *tokencmdname, char *buf, size_t lbuf)

FUNCTION
          Check if 'tokencmdname' exists and is executable. If an error
          occures write a error message into 'buf' if not NULL.
          Otherwise write error messages to stderr.

INPUTS
          const char *tokencmdname - command
          char *buf                - NULL or buffer for error message
          size_t lbuf              - size of buf

NOTES
          MT-NOTE: sge_get_token_cmd() is MT safe

RESULT
          int - error state
              0 - OK
              1 - Error


16.1.3 sge_read_token

NAME
          sge_read_token() -- read token from file

SYNOPSIS
          char* sge_read_token(const char *file)

FUNCTION
          Read token from file, malloc buffer, add '\0' byte and
          return pointer to buffer.

INPUTS
          const char *file - filename

NOTES
          MT-NOTE: sge_read_token() is MT safe

RESULT
          char* - pointer to a malloced buffer or
                  NULL if error occured


16.2 binding_hlp


16.2.1 binding_get_topology_for_job

NAME
          binding_get_topology_for_job() -- Returns topology string.

SYNOPSIS
          const char *
          binding_get_topology_for_job(const char *binding_result)

FUNCTION
          Returns the topology string of a host where the cores are
          marked with lowercase letters for those cores that were
          "bound" to a certain job.
          
          It is assumed the 'binding_result' parameter that is
          passed to this function was previously returned by
          create_binding_strategy_string()

INPUTS
          const char *binding_result - string returned by
                              create_binding_strategy_string()

RESULT
          const char * - topology string like "SCc"


16.3 bitfield


16.3.1 –Bitfield

NAME
          Bitfield -- A variable size bitfield implementation

SYNOPSIS
          bitfield sge_bitfield_new(unsigned int size)

FUNCTION
          This module provides variable size bitfields.
          The size of a bitfield can be defined when the bitfield is created.
          Individual bits can be set, read and cleared.
          The contents of a bitfield can be printed to stdout or any
          file handle.

EXAMPLE
          See main program (module test) in libs/uti/sge_bitfield.c

NOTES
          MT-NOTE: this module is MT safe

SEE ALSO


16.3.2 -Bitfield_Typedefs

NAME
          Bitfield_Typedefs -- type definitions for the Bitfield module

SYNOPSIS
          typedef struct {
             unsigned int size;
             union {
                char fix[sizeof(char *)];
                char *dyn;
             } bf;
          } bitfield;
          
          typedef _bitfield *bitfield;

FUNCTION
          The _bitfield structure is the internal representation of a bitfield.
          All operations on bitfields use the bitfield type.
          
          For small bitfields, no memory is allocated, but the space available in
          bf.fix is used (depending on the architecture, this suffices for 32 or 64
          bit bitfields).
          This saves a considerable amount of memory and above all processing time.


16.3.3 BIT_MANIPULATION_MAKROS

NAME
          ISSET(),VALID(),SETBIT(),CLEARBIT() - Bit manipulation makros

SYNOPSIS
          #define ISSET(a,b)      ((a&b)==b)
          #define VALID(a,b)      ((a|b)==b)
          #define SETBIT(a,b)     (b=(a)|b);
          #define CLEARBIT(a,b)   (b &= (~(a)));

FUNCTION
          Makros to get/set/clear bits in native variables.

INPUTS
          int,long,u_long32... a - Bitmask
          int,long,u_long32... b - Variable

RESULT
          b will be modified

NOTE
          These Makros can't be used in combination with the bitfield type.


16.3.4 sge_bitfield_bitwise_copy

NAME
          sge_bitfield_copy() -- copies a bitfield into another one.

SYNOPSIS
          bool
          sge_bitfield_bitwise_copy(const bitfield *source, bitfield *target)

FUNCTION
          The memory has to be allocated before, but the bitfields can have
          different sizes.  If the source is longer than the target, only the bits
          up to target's length are copied.

INPUTS
          const bitfield *source  - source bitfield
          bitfield *target        - target bitfield

RESULT
          bool - false, if one of the bitfields is NULL

NOTES
          MT-NOTE: sge_bitfield_bitwise_copy() is MT safe


16.3.5 sge_bitfield_changed

NAME
          sge_bitfield_changed() -- figures out if something was changed.

SYNOPSIS
          bool
          sge_bitfield_changed(const bitfield *source)

INPUTS
          bitfield *source - bitfield to analyze

RESULT
          bool - true, if the bitfield has a changed bit set.

NOTES
          MT-NOTE: sge_bitfield_copy() is MT safe


16.3.6 sge_bitfield_clear

NAME
          sge_bitfield_clear() -- clear a bit

SYNOPSIS
          bool
          sge_bitfield_clear(bitfield *bf, unsigned int bit)

FUNCTION
          Clears a certain bit in a bitfield (sets its content to 0).

INPUTS
          bitfield *bf - the bitfield to manipulate
          unsigned int bit     - the bit to clear

NOTES
          MT-NOTE: sge_bitfield_clear() is MT safe

RESULT
          bool - true on success,
                 false on error


16.3.7 sge_bitfield_copy

NAME
          sge_bitfield_copy() -- copies a bitfield into another one.

SYNOPSIS
          bool
          sge_bitfield_copy(const bitfield *source, bitfield *target)

FUNCTION
          The memory has to be allocated before, and source and target has to have
          the same size. Otherwise it will return false and does not copy anything.

INPUTS
          const bitfield *source  - source bitfield
          bitfield *target        - target bitfield

RESULT
          bool - false, if one of the bitfields is NULL or
                        the bitfield sizes are different

NOTES
          MT-NOTE: sge_bitfield_copy() is MT safe


16.3.8 sge_bitfield_free

NAME
          sge_bitfield_free() -- destroy a bitfield

SYNOPSIS
          bitfield sge_bitfield_free(bitfield *bf)

FUNCTION
          Destroys a bitfield. Frees all memory allocated by the bitfield.

INPUTS
          bitfield *bf - the bitfield to destroy

NOTES
          MT-NOTE: sge_bitfield_free() is MT safe

RESULT
          bitfield * - NULL


16.3.9 sge_bitfield_free_data

NAME
          sge_bitfield_free_data() -- free the bitfield data

SYNOPSIS
          bool
          sge_bitfield_free_data(bitfield *bf)

FUNCTION
          Frees the data part of a bitfield.
          The bitfield itself is not freed.

INPUTS
          bitfield *bf - the bitfield to work on

RESULT
          bool - true on success, else false

NOTES
          MT-NOTE: sge_bitfield_free_data() is MT safe


16.3.10 sge_bitfield_get

NAME
          sge_bitfield_get() -- read a bit

SYNOPSIS
          bool
          sge_bitfield_get(const bitfield *bf, unsigned int bit)

FUNCTION
          Reads a certain bit of a bitfield and returns it's contents.

INPUTS
          bitfield *bf - the bitfield to read from
          unsigned int bit     - the bit to read

NOTES
          MT-NOTE: sge_bitfield_get() is MT safe

RESULT
          bool - false, if bit is not set (or input params invalid),
                 true, if bit is set


16.3.11 sge_bitfield_init

NAME
          sge_bitfield_init() -- initialize a bitfield object

SYNOPSIS
          bool
          sge_bitfield_init(bitfield *bf, unsigned int size)

FUNCTION
          Initializes a bitfield object.
          Storage for the bits is allocated if necessary (size of the bitfield is
          bigger than the preallocated storage) and the size is stored.

INPUTS
          bitfield *bf      - the bitfield to initialize
          unsigned int size - the targeted size of the bitfield

RESULT
          bool - true on success, else false

NOTES
          MT-NOTE: sge_bitfield_init() is MT safe


16.3.12 sge_bitfield_new

NAME
          sge_bitfield_new() -- create a new bitfield

SYNOPSIS
          bitfield *
          sge_bitfield_new(unsigned int size)

FUNCTION
          Allocates and initializes the necessary memory.
          It is in the responsibility of the caller to free the bitfield
          once it is no longer needed.

INPUTS
          unsigned int size - size in bits

RESULT
          bitfield - a new bitfield or NULL, if the creation of the bitfield
                     failed

NOTES
          MT-NOTE: sge_bitfield_new() is MT safe

SEE ALSO


16.3.13 sge_bitfield_print

NAME
          sge_bitfield_print() -- print contents of a bitfield

SYNOPSIS
          void sge_bitfield_print(bitfield *bf, FILE *fd)

FUNCTION
          Prints the contents of a bitfield.
          For each bit one digit (0/1) is printed.
          If NULL is passed as file descriptor, output is sent to stdout.

NOTES
          MT-NOTE: sge_bitfield_print() is MT safe

INPUTS
          bitfield  bf - the bitfield to output
          FILE *fd     - filehandle or NULL


16.3.14 sge_bitfield_reset

NAME
          sge_bitfield_reset() -- clears a bitfield

SYNOPSIS
          bool
          sge_bitfield_reset(bitfield *bf)

INPUTS
          bitfield *bf - bitfield to reset

RESULT
          bool - false, if bf is NULL

NOTES
          MT-NOTE: sge_bitfield_copy() is MT safe


16.3.15 sge_bitfield_set

NAME
          sge_bitfield_set() -- set a bit

SYNOPSIS
          bool
          sge_bitfield_set(bitfield *bf, unsigned int bit)

FUNCTION
          Sets a certain bit in a bitfield to 1.

INPUTS
          bitfield *bf - the bitfield to manipulate
          unsigned int bit     - the bit to set

NOTES
          MT-NOTE: sge_bitfield_set() is MT safe

RESULT
          bool - true on success,
                false on error


16.4 bootstrap


16.4.1 bootstrap_mt_init

NAME
          bootstrap_mt_init() -- Initialize bootstrap code for multi threading use.

SYNOPSIS
          void bootstrap_mt_init(void)

FUNCTION
          Set up bootstrap code. This function must be called at least once before
          any of the bootstrap oriented functions can be used. This function is
          idempotent, i.e. it is safe to call it multiple times.
          
          Thread local storage for the bootstrap state information is reserved.

INPUTS
          void - NONE

RESULT
          void - NONE

NOTES
          MT-NOTE: bootstrap_mt_init() is MT safe


16.4.2 bootstrap_state_destroy

NAME
          bootstrap_state_destroy() -- Free thread local storage

SYNOPSIS
          static void bootstrap_state_destroy(void* theState)

FUNCTION
          Free thread local storage.

INPUTS
          void* theState - Pointer to memory which should be freed.

RESULT
          static void - none

NOTES
          MT-NOTE: bootstrap_state_destroy() is MT safe.


16.4.3 bootstrap_thread_local_destroy

NAME
          bootstrap_thread_local_destroy() -- Free thread local storage

SYNOPSIS
          static void bootstrap_thread_local_destroy(void* theState)

FUNCTION
          Free thread local storage.

INPUTS
          void* theState - Pointer to memory which should be freed.

RESULT
          static void - none

NOTES
          MT-NOTE: bootstrap_thread_local_destroy() is MT safe.


16.4.4 bootstrap_thread_local_init

NAME
          bootstrap_thread_local_init() -- Initialize bootstrap state.

SYNOPSIS
          static void bootstrap_thread_local_init(sge_bootstrap_state_class_t* theState)

FUNCTION
          Initialize bootstrap state.

INPUTS
          bootstrap_state_t* theState - Pointer to bootstrap state structure.

RESULT
          static void - none

NOTES
          MT-NOTE: bootstrap_thread_local_init() is MT safe.


16.4.5 bootstrap_thread_local_once_init

NAME
          bootstrap_thread_local_once_init() -- One-time bootstrap code initialization.

SYNOPSIS
          static bootstrap_thread_local_once_init(void)

FUNCTION
          Create access key for thread local storage. Register cleanup function.
          
          This function must be called exactly once.

INPUTS
          void - none

RESULT
          void - none

NOTES
          MT-NOTE: bootstrap_thread_local_once_init() is MT safe.


16.4.6 sge_bootstrap

NAME
          sge_bootstrap() -- read and process bootstrap file

SYNOPSIS
          bool sge_bootstrap(void)

FUNCTION
          Reads the bootstrap file ($SGE_ROOT/$SGE_CELL/common/bootstrap).
          
          Initializes the policy for hostcpy and hostcmp (ignore_fqdn and
          default_domain).

INPUTS
          dstring *error_dstring - dynamic string buffer to return error messages.
                                   if error_string is NULL, error messages will be
                                   written using the sge_log functions, else they
                                   will be returned in error_dstring.

RESULT
          bool - true on success, else false

NOTES
          MT-NOTE: sge_bootstrap() is MT safe


16.5 dstring


16.5.1 DSTRING_INIT

NAME
          DSTRING_INIT -- Define to initialize dstring variables

SYNOPSIS
          #define DSTRING_INIT {NULL, 0, 0}

FUNCTION
          Define to preinitialize dstring variables

EXAMPLE
          {
             dstring error_msg = DSTRING_INIT;
          }

NOTE
          The DSTRING_INIT counterpart for static buffers is sge_dstring_init()


16.5.2 sge_dstring_append

NAME
          sge_dstring_append() -- strcat() for dstrings

SYNOPSIS
          const char* sge_dstring_append(dstring *sb, const char *a)

FUNCTION
          Append 'a' after 'sb'

INPUTS
          dstring *sb   - dynamic string
          const char *a - string

NOTES
          MT-NOTE: sge_dstring_append() is MT safe

RESULT
          const char* - result string


16.5.3 sge_dstring_append_dstring

NAME
          sge_dstring_append() -- strcat() for dstrings

SYNOPSIS
          const char* sge_dstring_append(dstring *sb, const dstring *a)

FUNCTION
          Append 'a' after 'sb'

INPUTS
          dstring *sb      - dynamic string
          const dstring *a - string

NOTES
          MT-NOTE: sge_dstring_append_dstring() is MT safe

RESULT
          const char* - result string


16.5.4 sge_dstring_clear

NAME
          sge_dstring_clear() -- empty a dstring

SYNOPSIS
          void sge_dstring_clear(dstring *sb)

FUNCTION
          Set a dstring to an empty string.

NOTES
          MT-NOTE: sge_dstring_clear() is MT safe

INPUTS
          dstring *sb - dynamic string


16.5.5 sge_dstring_copy_dstring

NAME
          sge_dstring_copy_dstring() -- strcpy() for dstrings

SYNOPSIS
          const char* sge_dstring_copy_dstring(dstring *sb1,
                                               const dstring *sb2)

FUNCTION
          strcpy() for dstrings

INPUTS
          dstring *sb1 - destination dstring
          const dstring *sb2 - source dstring

NOTES
          MT-NOTE: sge_dstring_copy_dstring() is MT safe

RESULT
          const char* - result string buffer


16.5.6 sge_dstring_copy_string

NAME
          sge_dstring_copy_string() -- copy string into dstring

SYNOPSIS
          const char* sge_dstring_copy_string(dstring *sb, char* str)

FUNCTION
          Copy string into dstring

INPUTS
          dstring *sb - destination dstring
          char* str   - source string

NOTES
          MT-NOTE: sge_dstring_copy_string() is MT safe

RESULT
          const char* - result string


16.5.7 sge_dstring_free

NAME
          sge_dstring_free() -- sge_free() for dstrings

SYNOPSIS
          void sge_dstring_free(dstring *sb)

FUNCTION
          Frees a dynamically allocated string

NOTES
          MT-NOTE: sge_dstring_free() is MT safe

INPUTS
          dstring *sb - dynamic string


16.5.8 sge_dstring_get_string

NAME
          sge_dstring_get_string() -- Returns string buffer

SYNOPSIS
          const char* sge_dstring_get_string(const dstring *string)

FUNCTION
          Returns a pointer to the buffer where the string is stored.
          The pointer is not valid until doomsday. The next
          sge_dstring_* call may make it invalid.

INPUTS
          const dstring *string - pointer to dynamic string

NOTES
          MT-NOTE: sge_dstring_get_string() is MT safe

RESULT
          const char* - pointer to string buffer


16.5.9 sge_dstring_init

NAME
          sge_dstring_init() -- init static dstrings

SYNOPSIS
          size_t sge_dstring_init(dstring *string, char *s, size_t size)

FUNCTION
          Initialize dstring with a static buffer.

INPUTS
          const dstring *string - pointer to dynamic string

NOTES
          MT-NOTE: sge_dstring_init() is MT safe

RESULT
          size_t - remaining chars


16.5.10 sge_dstring_remaining

NAME
          sge_dstring_remaining() -- remaining chars in dstring

SYNOPSIS
          size_t sge_dstring_remaining(const dstring *string)

FUNCTION
          Returns number of chars remaining in dstrings.

INPUTS
          const dstring *string - pointer to dynamic string

NOTES
          MT-NOTE: sge_dstring_remaining() is MT safe

RESULT
          size_t - remaining chars


16.5.11 sge_dstring_split

NAME
          sge_dstring_split() -- splits a string into two parts

SYNOPSIS
          bool
          sge_dstring_split(dstring *string, char character,
                            dstring *before, dstring *after)

FUNCTION
          This functions tries to find the first occurrence of "character"
          in "string". The characters before will be copied into "before"
          and the characters behind into "after" dstring.

INPUTS
          dstring *sb     - dstring
          char character  - character
          dstring *before - characters before
          dstring *after  - characters after

RESULT
          error state
             true  - success
             false - error


16.5.12 sge_dstring_sprintf

NAME
          sge_dstring_sprintf() -- sprintf() for dstrings

SYNOPSIS
          const char* sge_dstring_sprintf(dstring *sb,
                                          const char *format, ...)

FUNCTION
          see sprintf()

INPUTS
          dstring *sb        - dynamic string
          const char *format - format string
          ...                - additional parameters

RESULT
          const char* - result string

NOTES
          MT-NOTE: sge_dstring_sprintf() is MT safe


16.5.13 sge_dstring_sprintf_append

NAME
          sge_dstring_sprintf_append() -- sprintf() and append for dstrings

SYNOPSIS
          const char* sge_dstring_sprintf_append(dstring *sb,
                                                 const char *format, ...)

FUNCTION
          See sprintf()
          The string created by sprintf is appended to the existing
          contents of the dstring.

INPUTS
          dstring *sb        - dynamic string
          const char *format - format string
          ...                - additional parameters

RESULT
          const char* - result string

NOTES
          MT-NOTE: sge_dstring_sprintf_append() is MT safe


16.5.14 sge_dstring_strip_white_space_at_eol

NAME
          sge_dstring_strip_white_space_at_eol() -- as it says

SYNOPSIS
          void sge_dstring_strip_white_space_at_eol(dstring *string)

FUNCTION
          removes whitespace at the end of the given "string".

INPUTS
          dstring *string - dstring


16.5.15 sge_dstring_strlen

NAME
          sge_dstring_strlen() -- strlen() for dstrings

SYNOPSIS
          size_t sge_dstring_strlen(const dstring *string)

FUNCTION
          strlen() for dstrings

INPUTS
          const dstring *string - pointer to dynamic string

NOTES
          MT-NOTE: sge_dstring_strlen() is MT safe

RESULT
          size_t - string length


16.5.16 sge_dstring_ulong_to_binstring

NAME
          sge_dstring_ulong_to_binstring() -- convert ulong into bin-string

SYNOPSIS
          const char*
          sge_dstring_ulong_to_binstring(dstring *sb, u_long32 number)

FUNCTION
          Convert ulong into bin-string

INPUTS
          dstring *sb     - dstring
          u_long32 number - 32 bit ulong value

RESULT
          const char* - pointer to dstrings internal buffer


16.5.17 sge_dstring_vsprintf

NAME
          sge_dstring_vsprintf() -- vsprintf() for dstrings

SYNOPSIS
          const char* sge_dstring_vsprintf(dstring *sb, const char *format,va_list ap)

FUNCTION
          see vsprintf()

INPUTS
          dstring *sb        - dynamic string
          const char *format - format string
          va_list ap         - argument list

RESULT
          const char* - result string

NOTES
          MT-NOTE: sge_dstring_vsprintf() is MT safe


16.6 file_exists

NAME
          file_exists -- whether file exists

SYNOPSIS
          bool file_exists(const char *file)

FUNCTION
          Test whether a file exists (actually can be stat'ed).

INPUTS
          file  - file name

RESULT
          true iff file can be stat'ed

NAME
          copy_linewise -- copy a file line-by-line

SYNOPSIS
          bool copy_linewise(const char *src, const char *dst)

FUNCTION
          Copy line-by-line (unbuffered writes) from file SRC to file DST,
          assuming line length < MAX_STRING_SIZE.

INPUTS
          src  - source file name
          dst  - destination file name

RESULT
          true on success, false if an i/o error occurs


16.7 host


16.7.1 sge_copy_hostent

NAME
          sge_copy_hostent() -- make a deep copy of a struct hostent

SYNOPSIS
          struct hostent *sge_copy_hostent (struct hostent *orig)

FUNCTION
          Makes a deep copy of a struct hostent so that sge_gethostbyname() can
          free it's buffer for the gethostbyname_r() calls on Linux and Solaris.

NOTES
          MT-NOTE: sge_copy_hostent() is MT safe


16.7.2 sge_gethostbyaddr

NAME
          sge_gethostbyaddr() -- gethostbyaddr() wrapper

SYNOPSIS
          struct hostent *sge_gethostbyaddr(const struct in_addr *addr, int* system_error_retval)

FUNCTION
          Wraps gethostbyaddr() function calls, measures time spent
          in gethostbyaddr() and logs when very much time has passed.
          On error, return error code in *system_error_retval if that is non-null.
          
          return value must be released by function caller (don't forget the
          char** array lists inside of struct hostent)
          
          If possible (libcomm linked) use  cl_com_cached_gethostbyaddr()
          from libcomm. This will return an sge aliased hostname.
          

NOTES
          MT-NOTE: sge_gethostbyaddr() is MT safe
          MT-NOTE: sge_gethostbyaddr() uses a mutex to guard access to the
          MT-NOTE: gethostbyaddr() system call on all platforms other than Solaris,
          MT-NOTE: Linux, and HP-UX.  Therefore, except on the aforementioned
          MT-NOTE: platforms, MT calls to gethostbyaddr() must go through
          MT-NOTE: sge_gethostbyaddr() to be MT safe.


16.7.3 sge_gethostbyname

NAME
          sge_gethostbyname() -- gethostbyname() wrapper

SYNOPSIS
          struct hostent *sge_gethostbyname(const char *name, int *system_error_retval)

FUNCTION
          Wraps gethostbyname() function calls, measures time spent
          in gethostbyname() and logs when very much time has passed.
          On error, return error code in *system_error_retval if that is non-null.
          
          return value must be released by function caller (don't forget the
          char* array lists inside of struct hostent)
          
          If possible (libcomm linked) use getuniquehostname() or
          cl_com_cached_gethostbyname() or cl_com_gethostname() from libcomm.
          
          This will return an sge aliased hostname.
          

NOTES
          MT-NOTE: sge_gethostbyname() is MT safe
          MT-NOTE: sge_gethostbyname() uses a mutex to guard access to the
          MT-NOTE: gethostbyname() system call on all platforms other than Solaris,
          MT-NOTE: Linux, AIX, Tru64, HP-UX, and MacOS 10.2 and greater.  Therefore,
          MT-NOTE: except on the aforementioned platforms, MT calls to
          MT-NOTE: gethostbyname() must go through sge_gethostbyname() to be MT safe.


16.8 hostname


16.8.1 is_hgroup_name

NAME
          is_hgroup_name() -- Is the given name a hostgroup name

SYNOPSIS
          bool is_hgroup_name(const char *name)

FUNCTION
          Is the given name a hostgroup name

NOTE
          This function is also used for usergroup in resource quota sets

INPUTS
          const char *name - hostname or hostgroup name

RESULT
          bool - true for hostgroupnames otherwise false


16.8.2 sge_gethostbyname_retry

NAME
          sge_gethostbyname_retry() -- gethostbyname() wrapper

SYNOPSIS
          struct hostent *sge_gethostbyname_retry(const char *name)

FUNCTION
          Wraps sge_gethostbyname() function calls, and retries if the host is not
          found.
          
          return value must be released by function caller (don't forget the
          char** array lists inside of struct hostent)
          
          If possible (libcomm linked) use getuniquehostname() or
          cl_com_cached_gethostbyname() or cl_com_gethostname() from commlib.
          
          This will return an sge aliased hostname.

NOTES
          MT-NOTE: see sge_gethostbyname()


16.8.3 sge_host_delete

NAME
          sge_host_delete() -- delete host in host list with all aliases

SYNOPSIS
          static void sge_host_delete(host *h)

INPUTS
          host *h - host to be deleted

NOTES
          MT-NOTE: sge_host_delete() is not MT safe due to access to global variable


16.8.4 sge_host_get_mainname

NAME
          sge_host_get_mainname() -- Return mainname considering aliases

SYNOPSIS
          char* sge_host_get_mainname(host *h)

FUNCTION
          Return the mainname of a host considering aliases.

INPUTS
          host *h - host

RESULT
             char* - mainname
          
          NOTES:
             MT-NOTE: sge_host_get_mainname() is not MT safe


16.8.5 sge_host_list_print

NAME
          sge_host_list_print() -- Print hostlist into file

SYNOPSIS
          void sge_host_list_print(FILE *fp)

FUNCTION
          Print hostlist into file

INPUTS
          FILE *fp - filename

NOTES
          MT-NOTE: sge_host_list_print() is not MT safe due to access to hostlist
          MT-NOTE: global variable


16.8.6 sge_host_print

NAME
          sge_host_print() -- Print host entry info file

SYNOPSIS
          void sge_host_print(host *h, FILE *fp)

FUNCTION
          Print host entry info file

INPUTS
          host *h  - host entry
          FILE *fp - file

NOTES
          MT-NOTE: sge_host_print() is NOT MT safe ( because of inet_ntoa() call)


16.8.7 sge_host_search

NAME
          sge_host_search() -- Search for host

SYNOPSIS
          host* sge_host_search(const char *name, char *addr)

FUNCTION
          Search for host. If 'name' is not NULL the returned host has
          the given or the alias that matches this name. 'name' is
          not case sensitive. 'addr' is in hostorder.
          If 'addr' is not NULL the returned host has 'addr' in his
          addrlist. If 'addr' is aliased this function returns the
          hostname of the first alias (mainname)

INPUTS
          const char *name - hostname
          char *addr       - address

NOTES
          MT-NOTE: sge_host_search() is not MT safe due to access to hostlist
          MT-NOTE: global variable

RESULT
          host* - host entry


16.8.8 sge_host_search_pred_alias

NAME
          sge_host_search_pred_alias() -- search host who's aliasptr points to host

SYNOPSIS
          static host* sge_host_search_pred_alias(host *h)

INPUTS
          host *h - host we search for

RESULT
          static host* - found host if contained in host list

NOTES
          MT-NOTE: sge_host_search_pred_alias() is not MT safe due to access to
          MT-NOTE: global variable

BUGS
          ???

SEE ALSO


16.8.9 sge_hostcmp

NAME
          sge_hostcmp() -- strcmp() for hostnames

SYNOPSIS
          int sge_hostcmp(const char *h1, const char*h2)

FUNCTION
          strcmp() for hostnames. Honours some configuration values:
             - Domain name may be ignored
             - Domain name may be replaced by a 'default domain'
             - Hostnames may be used as they are.

INPUTS
          const char *h1 - 1st hostname
          const char *h2 - 2nd hostname

RESULT
          int - 0, 1 or -1

SEE ALSO


16.8.10 sge_hostcpy

NAME
          sge_hostcpy() -- strcpy() for hostnames.

SYNOPSIS
          void sge_hostcpy(char *dst, const char *raw)

FUNCTION
          strcpy() for hostnames. Honours some configuration values:
             - Domain name may be ignored
             - Domain name may be replaced by a 'default domain'
             - Hostnames may be used as they are.
             - straight strcpy() for hostgroup names

INPUTS
          char *dst       - possibly modified hostname
          const char *raw - hostname

SEE ALSO


16.8.11 sge_hostmatch

NAME
          sge_hostmatch() -- fnmatch() for hostnames

SYNOPSIS
          int sge_hostmatch(const char *h1, const char*h2)

FUNCTION
          fnmatch() for hostnames. Honours some configuration values:
             - Domain name may be ignored
             - Domain name may be replaced by a 'default domain'
             - Hostnames may be used as they are.

INPUTS
          const char *h1 - 1st hostname
          const char *h2 - 2nd hostname

RESULT
          int - 0, 1 or -1

SEE ALSO


16.8.12 sge_strtolower

NAME
          sge_strtolower() -- convert all upper character in the string to lower case

SYNOPSIS
          int sge_strtolower(char *buffer)

FUNCTION
          sge_strtolower() for hostnames. Honours some configuration values:

INPUTS
          char *buffer - string to be lowered

RESULT
          no result, this function modify the argument string

SEE ALSO


16.9 htable


16.9.1 –Hashtable

NAME
          htable -- A Hashtable Implementation for Grid Engine

SYNOPSIS
          htable sge_htable_create(int size,
                        int (*hash_func)(const void *),
                        int (*compare_func)(const void *, const void *));
          
          void sge_htable_destroy(htable ht);
          
          void sge_htable_store(htable ht, const void* key,
                                const void* data);
          
          int sge_htable_lookup(htable ht, const void* key,
                                const void** data);
          
          void sge_htable_delete(htable ht, const void* key);
          
          void sge_htable_for_each(htable ht,
                                   sge_htable_for_each_proc proc);

FUNCTION
          This module provides a hash table implementation for Grid Engine.
          
          Hash tables are used to have very fast access to objects stored in
          data structures like linked lists without having to traverse the
          whole list when searching a specific element.
          
          An element in a hash table is characterized by a unique key.
          
          This hash table implementation dynamically adjusts the size of the
          hash table when necessary.

NOTES
          MT-NOTE: This module is MT safe.

SEE ALSO


16.9.2 -Compare-Functions

NAME
          compare_func_<type>() -- Compare functions for selected data types

SYNOPSIS
          int HashCompare_<type>(const void *a, const void *b)

FUNCTION
          Depending on the data type of the hash key, different functions
          have to be used to compare two elements.
          Which compare function to use has to be specified when creating
          a new hash table. Syntax and return value are similar to strcmp.

INPUTS
          const void *a - pointer to first element
          const void *b - pointer to second element

RESULT
          int - 0, if the elements are equal
                > 0, if the first element is bigger than the second
                < 0, if the first element is smaller than the second

NOTES
          The following data types are provided with this module:
             - strings (char *)
             - u_long32

SEE ALSO


16.9.3 -Dup-Functions

NAME
          dup_func_<type>() -- function duplicate the key

SYNOPSIS
          const void *dup_func_<type>(const void *key)

FUNCTION
          The hash table cannot rely on the key data to remain valid over
          the programs execution time. Therefore copies of keys are stored
          in the bucket object. To allow duplication of keys with types
          unknown to the hash table implementation, a duplication function
          must be specified when a hash table is created.

INPUTS
          const void *key - pointer to the key to duplicate

RESULT
          const void * - the duplicated key

NOTES
          The following data types are provided with this module:
             - strings (char *)
             - u_long32

SEE ALSO


16.9.4 -Hash-Functions

NAME
          hash_func_<type>() -- Hash functions for selected data types

SYNOPSIS
          int hash_func_<type>(const void *key)

FUNCTION
          Depending on the data type of the hash key, different hash
          functions have to be used.
          Which hash function to use has to be specified when creating a new
          hash table.

INPUTS
          const void *key - pointer to key for which to compute a hash value

RESULT
          int - the hash value

NOTES
          The following data types are provided with this module:
             - strings (char *)
             - u_long32

SEE ALSO


16.9.5 sge_htable_create

NAME
          sge_htable_create() -- Create a new hash table

SYNOPSIS
          htable sge_htable_create(int size,
                         int (*hash_func)(const void *),
                         int (*compare_func)(const void *, const void *)

FUNCTION
          Creates an empty hash table and initializes its data structures.

INPUTS
          int size            - Initial table size will be 2^n
          int (*hash_func)    - pointer to hash function
          int (*compare_func) - pointer to compare function

RESULT
          htable - the created hash table

EXAMPLE
          htable MyHashTable = sge_htable_create(5, hash_func_u_long32,
                                                  hash_compare_u_long32);


16.9.6 sge_htable_delete

NAME
          sge_htable_delete() -- Delete an element in a hash table

SYNOPSIS
          void sge_htable_delete(htable table, const void* key)

FUNCTION
          Deletes an element in a hash table.
          If the number of elements falls below a certain threshold
          (half the size of the hash table), the hash table is resized
          (shrunk).

INPUTS
          htable table    - hash table that contains the element
          const void* key - key of the element to delete

NOTES
          Only deletes the entry in the hash table. The object itself
          is not deleted.

SEE ALSO


16.9.7 sge_htable_destroy

NAME
          sge_htable_destroy() -- Destroy a hash table

SYNOPSIS
          void sge_htable_destroy(htable ht)

FUNCTION
          Destroys a hash table and frees all used memory.

INPUTS
          htable ht - the hash table to destroy

NOTES
          The objecs managed by the hash table are not destroyed and have
          to be handled separately.


16.9.8 sge_htable_for_each

NAME
          sge_htable_for_each() -- Apply an action on all elements

SYNOPSIS
          void sge_htable_for_each(htable table,
                                   sge_htable_for_each_proc proc)

FUNCTION
          Calls a certain function for all elements in a hash table.

INPUTS
          htable table                  - the hash table
          sge_htable_for_each_proc proc - func to call for each element


16.9.9 sge_htable_lookup

NAME
          sge_htable_lookup() -- search for an element

SYNOPSIS
          int sge_htable_lookup(htable table, const void* key,
                              const void** data)

FUNCTION
          Search for a certain object characterized by a unique key in the
          hash table.
          If an element can be found, it is returned in data.

INPUTS
          htable table      - the table to search
          const void* key   - unique key to search
          const void** data - object if found, else NULL

RESULT
          int - true, when an object was found, else false


16.9.10 sge_htable_resize

NAME
          sge_htable_resize() -- Resize the hash table

SYNOPSIS
          static void sge_htable_resize(htable ht, int grow)

FUNCTION
          Hash tables are dynamically resized if necessary.
          If the number of elements in a has table becomes too big, the hash
          algorithm can no longer provide efficient access to the stored
          objects. On the other hand, storing only a few elements in a much
          too big hash table wastes memory. Therefore the whole table can
          be resized. If the hash table has to grow, it is doubled in size.
          If it has to be shrunk, it is halfed in size.
          
          Resizing implies rehashing all stored objects.

INPUTS
          htable ht             - the hashtable  to resize
          int grow              - true or false
                true  = double size of the table,
                false = shrink table to half the size

NOTE
          If the system is running in log_level log_debug, statistics is
          output before and after resizing the hash table, along with timing
          information.

SEE ALSO


16.9.11 sge_htable_statistics

NAME
          sge_htable_statistics() -- Get some statistics for a hash table

SYNOPSIS
          const char* sge_htable_statistics(htable ht)

FUNCTION
          Returns a constant string containing statistics for a hash table
          in the following format:
          "size: %ld, %ld entries, chains: %ld empty, %ld max, %.1f avg"
          size is the size of the hash table (number of hash chains)
          entries is the number of objects stored in the hash table
          Information about hash chains:
             empty is the number of empty hash chains
             max is the maximum number of objects in a hash chain
             avg is the average number of objects for all occupied
             hash chains
          
          The string returned is a static buffer, subsequent calls to the
          function will overwrite this buffer.

INPUTS
          htable ht - Hash table for which statistics shall be generated
          dstring *buffer - buffer to be provided by caller

RESULT
          const char* - the string described above


16.9.12 sge_htable_store

NAME
          sge_htable_store() -- Store a new element in a hash table

SYNOPSIS
          void sge_htable_store(htable table, const void* key,
                                const void* data)

FUNCTION
          Stores a new element in a hash table.
          If there already exists an element with the same key in the table,
          it will be replaced by the new element.
          
          If the number of elements in the table exceeds the table size, the
          hash table will be resized.

INPUTS
          htable table     - table to hold the new element
          const void* key  - unique key
          const void* data - data to store, usually a pointer to an object

SEE ALSO


16.10 io


16.10.1 sge_bin2string

NAME
          sge_bin2string() -- Put binary stream into a string

SYNOPSIS
          char* sge_bin2string(FILE *fp, int size)

FUNCTION
          Read a binary steam from given file descriptor 'fp' and
          write it into (dynamically) malloced buffer as "ASCII" format.
          
          "ASCII" format means:
                '\0' is written as '\\' '\0'
                '\\' is written as '\\' '\\'
                End of buffer is written as '\0'

INPUTS
          FILE *fp - file descriptor
          int size - size of the buffer used within this function

RESULT
          char* - malloced buffer

SEE ALSO

NOTES
          MT-NOTE: sge_bin2string() is MT safe


16.10.2 sge_copy_append

NAME
          sge_copy_append() -- Copy/append one file to another

SYNOPSIS
          int sge_copy_append(char *src, const char *dst,
                              sge_mode_t mode)

FUNCTION
          Copy/append content from 'src' to 'dst'

INPUTS
          char *src       - source filename
          const char *dst - destination filename
          sge_mode_t mode - mode

RESULT
          int - error state
              0 - OK
             -1 - Error

SEE ALSO

NOTES
          MT-NOTE: sge_copy_append() is MT safe


16.10.3 sge_file2string

NAME
          sge_file2string() -- Load file into string

SYNOPSIS
          char* sge_file2string(const char *fname, int *len)

FUNCTION
          Load file into string. Returns a pointer to a string buffer containing
          the file contents and the size of the buffer (= number of bytes read)
          in the variable len.
          If the file cannot be read (doesn't exist, permissions etc.), NULL is
          returned as buffer and len is set to 0.

INPUTS
          const char *fname - filename
          int *len          - number of bytes read

RESULT
          char* - malloced string buffer

SEE ALSO

NOTES
          MT-NOTE: sge_file2string() is MT safe


16.10.4 sge_filecmp

NAME
          sge_filecmp() -- Compare two files

SYNOPSIS
          int sge_filecmp(const char *name0, const char *name1)

FUNCTION
          Compare two files. They are equal if:
             - both of them have the same name
             - if a stat() succeeds for both files and
               i-node/device-id are equal
          
          we are not sure
          - if stat() failes for at least one of the files
            (It could be that both pathes direct to the same
            file not existing)

INPUTS
          const char *name0 - 1st filename
          const char *name1 - 2nd filename

RESULT
          int - Identical?
              0 - Yes.
              1 - No they are not equivalent.

NOTES
          MT-NOTE: sge_filecmp() is MT safe


16.10.5 sge_mode_t

NAME
          sge_mode_t -- Type of operation for sge_copy_append()

SYNOPSIS
          typedef enum {
             SGE_MODE_APPEND = 1,
             SGE_MODE_COPY = 2
          } sge_mode_t;

FUNCTION
          Defines the operation which should be performed by
          sge_copy_append():
          
             SGE_MODE_APPEND - append the file
             SGE_MODE_COPY   - copy the file

SEE ALSO


16.10.6 sge_readnbytes

NAME
          sge_readnbytes() -- Read n bytes from file descriptor

SYNOPSIS
          int sge_readnbytes(int sfd, char *ptr,
                             int n)

FUNCTION
          Read n bytes from file descriptor.

INPUTS
          int sfd   - file descriptor
          char *ptr - pointer to buffer
          int n     - number of bytes

RESULT
          int - number of bytes read

SEE ALSO

NOTES
          MT-NOTE: sge_readnbytes() is MT safe


16.10.7 sge_stream2string

NAME
          sge_stream2string() -- Read string from stream

SYNOPSIS
          char* sge_stream2string(FILE *fp, int *len)

FUNCTION
          Read string from stream

INPUTS
          FILE *fp - file descriptor
          int *len - number of bytes read

RESULT
          char* - pointer to malloced string buffer

SEE ALSO

NOTES
          MT-NOTE: sge_stream2string() is MT safe


16.10.8 sge_string2bin

NAME
          sge_string2bin() -- Write 'binary' string into file

SYNOPSIS
          int sge_string2bin(FILE *fp, const char *buf)

FUNCTION
          Write 'binary' string into file

INPUTS
          FILE *fp        - file descriptor
          const char *buf - "ASCII" string (see sge_bin2string())

RESULT
          int - error state
              0 - OK
             -1 - Error

SEE ALSO

NOTES
          MT-NOTE: sge_string2bin() is MT safe


16.10.9 sge_string2file

NAME
          sge_string2file() -- Write string into file

SYNOPSIS
          int sge_string2file(const char *str, int len, const char *fname)

FUNCTION
          Write string into file

INPUTS
          const char *str   - pointer to buffer
          int len           - number of bytes which should be written
          const char *fname - filename

RESULT
          int - error state
              0 - OK
             -1 - Error

SEE ALSO

NOTES
          MT-NOTE: sge_string2file() is MT safe


16.10.10 sge_writenbytes

NAME
          sge_writenbytes() -- Write n bytes to file descriptor

SYNOPSIS
          int sge_writenbytes(int sfd, const char *ptr,
                              int n)

FUNCTION
          Write n bytes to file descriptor

INPUTS
          int sfd         - file descriptor
          const char *ptr - pointer to buffer
          int n           - number of bytes

RESULT
          int - number of bytes written

SEE ALSO

NOTES
          MT-NOTE: sge_writenbytes() is MT safe


16.11 language


16.11.1 sge_get_message_id_output

NAME
          sge_get_message_id_output() -- check if message id should be added

SYNOPSIS
          int sge_get_message_id_output(void)

FUNCTION
          This function returns the value stored in the static global
          variable sge_message_id_view_flag.

RESULT
          int - value of sge_message_id_view_flag

NOTES
          MT-NOTE: sge_get_message_id_output() is guarded by language_mutex

SEE ALSO


16.11.2 sge_get_message_id_output_implementation

NAME
          sge_get_message_id_output_implementation() -- pure implementation of
             sge_get_message_id_output_implementation() that does not lock
             language_mutex

SYNOPSIS
          int sge_get_message_id_output_implementation(void)

FUNCTION
          When the sge_get_message_id_output() functionality is needed from within
          the language modules the language_mutex may not be obtained because this
          mutex is already owned by the same thread.

RESULT
          int - value of sge_message_id_view_flag

NOTES
          MT-NOTE: The caller of sge_get_message_id_output_implementation() must
          MT-NOTE: have obtained the language_mutex mutex due to access to
          MT-NOTE: 'sge_enable_msg_id' and 'sge_enable_msg_id_to_every_message'.

SEE ALSO


16.11.3 sge_gettext

NAME
          sge_gettext() -- dummy gettext() function

SYNOPSIS
          const char* sge_gettext(char *x)

FUNCTION
          This function returns the given argument

INPUTS
          char *x - string

RESULT
          const char* - input string

SEE ALSO


16.11.4 sge_gettext_

NAME
          sge_gettext_() -- add error id to message

SYNOPSIS
          const char* sge_gettext_(int msg_id, const char *msg_str)

FUNCTION
          This function is used for adding the message id to the translated
          gettext message string. The message id is only added when the
          function sge_get_message_id_output() returns not "0" and the
          message string contains at least one SPACE character.

INPUTS
          int msg_id          - message id
          const char *msg_str - message to translate

RESULT
          const char* - translated (L10N) message with message id

SEE ALSO


16.11.5 sge_gettext__

NAME
          sge_gettext__() -- get translated message from message file

SYNOPSIS
          char *sge_gettext__(char *x)

FUNCTION
          makes a call to sge_language_functions.gettext_func(x) if
          gettext_func is not NULL, otherwise it returns the input
          string.

INPUTS
          char *x - pointer to message which should be internationalizied

RESULT
          char*   - pointer internationalized message

NOTE
          MT-NOTE: not guarded b/c sge_gettext__() is used only in infotext utility

SEE ALSO


16.11.6 sge_init_language

NAME
          sge_init_language() -- initialize language package for gettext()

SYNOPSIS
          int sge_init_language(char* package, char* localeDir)
          

FUNCTION
          starts up the language initialization for gettext(). This
          function should be called nearly after the main() function.
          
          sge_init_language_func() must be called first to install the
          correct function pointers for gettext() setlocale() etc. etc.

INPUTS
          char* package     -  package name like "gridengine" of binary
                               package *.mo file.
                               (if package is NULL sge_init_language tries
                               to get the package name from the invironment
                               variable "GRIDPACKAGE").
          char* localeDir  -   path to the localisazion directory
                               (if localeDir is NULL sge_init_language
                               tries to get the localization directory path
                               from the invironment variable
                               "GRIDLOCALEDIR").

RESULT
          int state         -  true for seccess, false on error.

NOTES
          MT-NOTE: sge_init_languagefunc() is guarded by language_mutex

SEE ALSO


16.11.7 sge_init_language_func

NAME
          sge_init_language() -- install language functions

SYNOPSIS
          void sge_init_language_func(gettext_func_type new_gettext,
                              setlocale_func_type new_setlocale,
                              bindtextdomain_func_type new_bindtextdomain,
                              textdomain_func_type new_textdomain);

FUNCTION
          set the function pointer for the gettext(), setlocale(),
          bindtextdomain() and textdomain() function calls. This function
          must called before any call to sge_init_language() and
          sge_gettext().

INPUTS
          gettext_func_type        - pointer for gettext()
          setlocale_func_type      - pointer for setlocale()
          bindtextdomain_func_type - pointer for bindtextdomain()
          textdomain_func_type     - pointer for textdomain()

NOTES
          MT-NOTE: sge_init_language_func() is guarded by language_mutex

SEE ALSO


16.11.8 sge_set_message_id_output

NAME
          sge_set_message_id_output() -- enable message id number adding

SYNOPSIS
          void sge_set_message_id_output(int flag)

FUNCTION
          This procedure is used to enable the adding of message id's when
          showing error messages. This function is used in the macro
          SGE_ADD_MSG_ID(x) to enable the message id for errors.

INPUTS
          int flag - 0 = off ; 1 = on

NOTES
          MT-NOTE: sge_set_message_id_output() is guarded by language_mutex

SEE ALSO


16.12 log


16.12.1 CRITICAL

NAME
          CRITICAL() -- Log a critical message

SYNOPSIS
          #define CRITICAL(params)
          void CRITICAL(char *buffer, const char* formatstring, ...)

FUNCTION
          Log a critical message

INPUTS
          buffer       - e.g SGE_EVENT
          formatstring - printf formatstring
          ...


16.12.2 DEBUG

NAME
          DEBUG() -- Log a debug message

SYNOPSIS
          #define DEBUG(params)
          void DEBUG(char *buffer, const char* formatstring, ...)

FUNCTION
          Log a debug message

INPUTS
          buffer       - e.g SGE_EVENT
          formatstring - printf formatstring
          ...


16.12.3 ERROR

NAME
          ERROR() -- Log an error message

SYNOPSIS
          #define ERROR(params)
          void ERROR(char *buffer, const char* formatstring, ...)

FUNCTION
          Log a error message

INPUTS
          buffer       - e.g SGE_EVENT
          formatstring - printf formatstring
          ...


16.12.4 INFO

NAME
          INFO() -- Log an info message

SYNOPSIS
          #define INFO(params)
          void INFO(char *buffer, const char* formatstring, ...)

FUNCTION
          Log an info message

INPUTS
          buffer       - e.g SGE_EVENT
          formatstring - printf formatstring
          ...


16.12.5 NOTICE

NAME
          NOTICE() -- Log a notice message

SYNOPSIS
          #define NOTICE(params)
          void NOTICE(char *buffer, const char* formatstring, ...)

FUNCTION
          Log a notice message

INPUTS
          buffer       - e.g SGE_EVENT
          formatstring - printf formatstring
          ...


16.12.6 PROFILING

NAME
          PROFILING() -- Log a profiling message

SYNOPSIS
          #define PROFILING(params)
          void PROFILING(char *buffer, const char* formatstring, ...)

FUNCTION
          Log a profiling message

INPUTS
          buffer       - e.g SGE_EVENT
          formatstring - printf formatstring
          ...


16.12.7 SGE_ASSERT

NAME
          SGE_ASSERT() -- Log a message and exit if assertion is false

SYNOPSIS
          #define SGE_ASSERT(expression)
          void SGE_ASSERT(int expression)

FUNCTION
          Log a critical message and exit if assertion is false.

INPUTS
          expression   - a logical expression


16.12.8 WARNING

NAME
          WARNING() -- Log an warning message

SYNOPSIS
          #define WARNING(params)
          void WARNING(char *buffer, const char* formatstring, ...)

FUNCTION
          Log a warning message

INPUTS
          buffer       - e.g SGE_EVENT
          formatstring - printf formatstring
          ...


16.12.9 log_buffer_destroy

NAME
          log_buffer_destroy() -- Free thread local storage

SYNOPSIS
          static void log_buffer_destroy(void* theState)

FUNCTION
          Free thread local storage.

INPUTS
          void* theState - Pointer to memroy which should be freed.

RESULT
          static void - none

NOTES
          MT-NOTE: log_buffer_destroy() is MT safe.


16.12.10 log_buffer_getspecific

NAME
          log_buffer_getspecific() -- Get thread local log state

SYNOPSIS
          static log_buffer_t* log_buffer_getspecific()

FUNCTION
          Return thread local log state.
          
          If a given thread does call this function for the first time, no thread
          local log state is available for this particular thread. In this case the
          thread local log state is allocated and set.

RESULT
          static log_buffer_t* - Pointer to thread local log state.

NOTES
          MT-NOTE: log_buffer_getspecific() is MT safe


16.12.11 log_buffer_once_init

NAME
          log_buffer_once_init() -- One-time logging initialization.

SYNOPSIS
          static log_buffer_once_init(void)

FUNCTION
          Create access key for thread local storage. Register cleanup function.
          This function must be called exactly once.

INPUTS
          void - none

RESULT
          void - none

NOTES
          MT-NOTE: log_buffer_once_init() is MT safe.


16.12.12 log_context_destroy

NAME
          log_context_destroy() -- Free thread local storage

SYNOPSIS
          static void log_context_destroy(void* theState)

FUNCTION
          Free thread local storage.

INPUTS
          void* theState - Pointer to memroy which should be freed.

RESULT
          static void - none

NOTES
          MT-NOTE: log_context_destroy() is MT safe.


16.12.13 log_context_getspecific

NAME
          log_context_getspecific() -- Get thread local log context

SYNOPSIS
          static log_context_t* log_context_getspecific()

FUNCTION
          Return thread local log context.
          
          If a given thread does call this function for the first time, no thread
          local log state is available for this particular thread. In this case the
          thread local log state is allocated and set.

RESULT
          static log_context_t* - Pointer to thread local log context.

NOTES
          MT-NOTE: log_context_getspecific() is MT safe


16.12.14 log_context_once_init

NAME
          log_context_once_init() -- One-time logging initialization.

SYNOPSIS
          static log_context_once_init(void)

FUNCTION
          Create access key for thread local storage. Register cleanup function.
          This function must be called exactly once.

INPUTS
          void - none

RESULT
          void - none

NOTES
          MT-NOTE: log_context_once_init() is MT safe.


16.12.15 log_get_log_buffer

NAME
          log_get_log_buffer() -- Return a buffer that can be used to build logging
                                        strings

SYNOPSIS
          char *log_get_log_buffer(void)

FUNCTION
          Return a buffer that can be used to build logging strings

RESULT
          char *


16.12.16 log_get_log_context

NAME
          log_get_log_context() -- Return a context for the specific thread

SYNOPSIS
          sge_gdi_ctx_class_t* log_get_log_context(void)

FUNCTION
          Return a context for the specific thread

RESULT
          sge_gdi_ctx_class_t*


16.12.17 log_set_log_context

NAME
          log_set_log_context() -- set a context for the specific thread

SYNOPSIS
          void log_set_log_context(void *newctx)

FUNCTION
          Return a context for the specific thread

INPUTS
          void newctx - the new ctx

NOTES
          MT-NOTE: log_state_set_log_file() is not MT safe.
          MT-NOTE:
          MT-NOTE: It is safe, however, to call this function from within multiple
          MT-NOTE: threads as long as no other thread calls log_state_set_log_file()


16.12.18 log_state_get_log_as_admin_user

NAME
          log_state_get_log_as_admin_user() -- Needs sge_log() to change into admin user?

SYNOPSIS
          trace_func_type log_state_get_log_as_admin_user(void)

FUNCTION
          Returns whether logging shall be done as admin user.

RESULT
          int

SEE ALSO


16.12.19 log_state_get_log_gui

NAME
          log_state_get_log_gui() -- Is GUI logging enabled?

SYNOPSIS
          int log_state_get_log_gui(void)

FUNCTION
          Is GUI logging enabled?
          With GUI logging enabled messages are printed to stderr/stdout.

RESULT
          int - 0 or 1

SEE ALSO


16.12.20 log_state_get_log_level

NAME
          log_state_get_log_level() -- Return log level.

SYNOPSIS
          u_long32 log_state_get_log_level(void)

FUNCTION
          Return log level

RESULT
          u_long32


16.12.21 log_state_get_log_verbose

NAME
          log_state_get_log_verbose() -- Is verbose logging enabled?

SYNOPSIS
          int log_state_get_log_verbose(void)

FUNCTION
          Is verbose logging enabled?
          With verbose logging enabled not only ERROR/CRITICAL messages are
          printed to stderr but also WARNING/INFO.

RESULT
          int - 0 or 1

SEE ALSO


16.12.22 log_state_set_log_as_admin_user

NAME
          log_state_set_log_as_admin_user() -- Enable/Disable logging as admin user

SYNOPSIS
          void log_state_set_log_as_admin_user(int i)

FUNCTION
          This function enables/disables logging as admin user. This
          means that the function/macros switches from start user to
          admin user before any messages will be written. After that
          they will switch back to 'start' user.

INPUTS
          int i - 0 or 1

SEE ALSO


16.12.23 log_state_set_log_gui

NAME
          log_state_set_log_gui() -- Enable/disable logging for GUIs

SYNOPSIS
          void log_state_set_log_gui(int i)

FUNCTION
          Enable/disable logging for GUIs
          With GUI logging enabled messages are printed to stderr/stdout.

INPUTS
          int i - 0 or 1


16.12.24 log_state_set_log_level

NAME
          log_state_set_log_level() -- Set log level to be used.

SYNOPSIS
          void log_state_set_log_level(int i)

FUNCTION
          Set log level to be used.

INPUTS
          u_long32

SEE ALSO


16.12.25 log_state_set_log_verbose

NAME
          log_state_set_log_verbose() -- Enable/disable verbose logging

SYNOPSIS
          void log_state_set_log_verbose(int i)

FUNCTION
          Enable/disable verbose logging

INPUTS
          int i - 0 or 1

SEE ALSO


16.12.26 sge_log

NAME
          sge_log() -- Low level logging function

SYNOPSIS
          int sge_log(int log_level, char *mesg, char *file__,
                      char *func__, int line__)

FUNCTION
          Low level logging function. Used by various macros.
          Do not use this function directly.

INPUTS
          int log_level - Logging Level
          char *mesg    - Message
          char *file__  - Filename
          char *func__  - Function Name
          int line__    - Line within 'file__'

RESULT
          int - 0

SEE ALSO

NOTES
          MT-NOTE: sge_log() is not MT safe due to sge_switch2admin_user()
          MT-NOTE: sge_log() can be used in clients where no admin user switching
          MT-NOTE: takes place
          MT-NOTE: sge_log() is not MT safe due rmon_condition()
          MT-NOTE: sge_log() can be used if DENTER_MAIN() is called only by one
          MT-NOTE: thread


16.13 monitor


16.13.1 ext_edt_output

NAME
          ext_edt_output() -- generates a string from the GDI extension

SYNOPSIS
          static void ext_edt_output(char *message, int size, void
          *monitoring_extension, double time)

FUNCTION
          generates a string from the extension and returns it.

INPUTS
          char *message              - initilized string buffer
          int size                   - buffer size
          void *monitoring_extension - the extension structure
          double time                - length of the mesurement interval

NOTES
          MT-NOTE: ext_edt_output() is MT safe


16.13.2 ext_gdi_output

NAME
          ext_gdi_output() -- generates a string from the GDI extension

SYNOPSIS
          static void ext_gdi_output(char *message, int size, void
          *monitoring_extension, double time)

FUNCTION
          generates a string from the extension and returns it.

INPUTS
          char *message              - initilized string buffer
          int size                   - buffer size
          void *monitoring_extension - the extension structure
          double time                - length of the mesurement interval

NOTES
          MT-NOTE: ext_gdi_output() is MT safe


16.13.3 ext_lis_output

NAME
          ext_lis_output() -- generates a string from the listener extension

SYNOPSIS
          static void
          ext_lis_output(char *message, int size, void
                         *monitoring_extension, double time)

FUNCTION
          generates a string from the extension and returns it.

INPUTS
          char *message              - initilized string buffer
          int size                   - buffer size
          void *monitoring_extension - the extension structure
          double time                - length of the mesurement interval

NOTES
          MT-NOTE: ext_lis_output() is MT safe


16.13.4 ext_sch_output

NAME
          ext_sch_output() -- generates a string from the scheduler extension

SYNOPSIS
          static void
          ext_sch_output(char *message, int size, void
                         *monitoring_extension, double time)

FUNCTION
          generates a string from the extension and returns it.

INPUTS
          char *message              - initilized string buffer
          int size                   - buffer size
          void *monitoring_extension - the extension structure
          double time                - length of the mesurement interval

NOTES
          MT-NOTE: ext_gdi_output() is MT safe


16.13.5 ext_tet_output

NAME
          ext_tet_output() -- generates a string from the GDI extension

SYNOPSIS
          static void ext_edt_output(char *message, int size, void
          *monitoring_extension, double time)

FUNCTION
          generates a string from the extension and returns it.

INPUTS
          dstring *message           - initilized string buffer
          void *monitoring_extension - the extension structure
          double time                - length of the mesurement interval

NOTES
          MT-NOTE: ext_tet_output() is MT safe


16.13.6 sge_monitor_free

NAME
          sge_monitor_free() -- frees the monitoring data structure

SYNOPSIS
          void sge_monitor_free(monitoring_t *monitor)

FUNCTION
          removes the line for the commlib output, and frees memory in the
          monitoring structure

INPUTS
          monitoring_t *monitor - monitoring strucutre

NOTES
          MT-NOTE: sge_monitor_free() is MT safe


16.13.7 sge_monitor_init

NAME
          sge_monitor_init() -- init the monitoring structure

SYNOPSIS
          void sge_monitor_init(monitoring_t *monitor, const char *thread_name,
          extension_t ext, thread_warning_t warning_timeout, thread_error_t
          error_timeout)

FUNCTION
          Sets the default values and inits the structure, finds the line pos
          for the comlib output

INPUTS
          monitoring_t *monitor            - monitoring strucutre
          const char *thread_name          - the thread name
          extension_t ext                  - the extension time (-> enum)
          thread_warning_t warning_timeout - the warning timeout (-> enum)
          thread_error_t error_timeout     - the error timeout (-> enum)

NOTES
          MT-NOTE: sge_monitor_init() is MT safe


16.13.8 sge_monitor_output

NAME
          sge_monitor_output() -- outputs the result into the message file

SYNOPSIS
          void sge_monitor_output(monitoring_t *monitor)

FUNCTION
          This function computes the output line from the gathered statistics.
          The output is only generated, when the the output flag in the
          monitoring structure is set.
          
          The monitoring line is printed to the message file in the profiling
          class and it made available for the qping -f output. For the qping
          output, it stores the the generation time, though that qping can
          show, when the message was generated.
          
          If an extension is set, it calls the apropriate output function for
          it.

INPUTS
          monitoring_t *monitor - the monitoring info

NOTES
          MT-NOTE: sge_monitor_output() is MT safe


16.13.9 sge_monitor_reset

NAME
          sge_monitor_reset() --  resets the monitoring data

SYNOPSIS
          void sge_monitor_reset(monitoring_t *monitor)

FUNCTION
          Resets the data structure including the extesion. No data in the
          extension is presevered.

INPUTS
          monitoring_t *monitor - monitoring structure

NOTES
          MT-NOTE: sge_monitor_reset() is MT safe


16.13.10 sge_monitor_status

NAME
          sge_monitor_status() -- generates the status for qping / commlib

SYNOPSIS
          u_long32 sge_monitor_status(char **info_message, u_long32 monitor_time)

FUNCTION
          This method creates the health monitoring output and returns the monitoring
          info to the commlib.

INPUTS
          char **info_message   - info_message pointer, has to point to a NULL string
          u_long32 monitor_time - the configured monitoring interval

RESULT
          u_long32 - 0 : everything is okay
                     1 : warning
                     2 : error
                     3 : init problems

NOTES
          MT-NOTE: sge_monitor_status() is MT safe


16.13.11 sge_set_last_wait_time

NAME
          sge_set_last_wait_time() -- updates the last wait time (health monitoring)

SYNOPSIS
          void sge_set_last_wait_time(monitoring_t *monitor, struct timeval after)

FUNCTION
          Updates the last wait time, which is used for the health monitoring to
          determine if a thread has a problem or not.

INPUTS
          monitoring_t *monitor    - monitoring structure
          struct timeval wait_time - current time

NOTES
          MT-NOTE: sge_set_last_wait_time() is MT safe


16.14 os


16.14.1 fd_compare

NAME
          fd_compare() -- file descriptor compare function for qsort()

SYNOPSIS
          static int fd_compare(const void* fd1, const void* fd2)

FUNCTION
          qsort() needs a callback function to compare two filedescriptors for
          sorting them. This is the implementation to value the difference of two
          file descriptors. If one paramter is NULL, only the pointers are
          used for the comparsion.
          Used by sge_close_all_fds().

INPUTS
          const void* fd1 - pointer to an int (file descriptor 1)
          const void* fd2 - pointer to an int (file descriptor 2)

RESULT
          static int - compare result (1, 0 or -1)
                       1  : fd1 > fd2
                       0  : fd1 == fd2
                       -1 : fd1 < fd2

NOTES
          MT-NOTE: fd_compare() is MT safe

SEE ALSO


16.14.2 redirect_to_dev_null

NAME
          redirect_to_dev_null() -- redirect a channel to /dev/null

SYNOPSIS
          int redirect_to_dev_null(int target, int mode)

FUNCTION
          Attaches a certain filedescriptor to /dev/null.

INPUTS
          int target - file descriptor
          int mode   - mode for open

RESULT
          int - target fd number if everything was ok,
                else -1

NOTES
          MT-NOTE: redirect_to_dev_null() is MT safe


16.14.3 sge_checkprog

NAME
          sge_checkprog() -- Has "pid" of a running process the given "name"

SYNOPSIS
          int sge_checkprog(pid_t pid, const char *name,
                            const char *pscommand)

FUNCTION
          Check if "pid" of a running process has given "name".
          Only first 8 characters of "name" are significant.
          Check only basename of command after "/".

INPUTS
          pid_t pid             - process id
          const char *name      - process name
          const char *pscommand - ps commandline

RESULT
          int - result state
              0 - Process with "pid" has "name"
              1 - No such pid or pid has other name
             -1 - error occurred (mostly sge_peopen() failed)

NOTES
          MT-NOTES: sge_checkprog() is not MT safe


16.14.4 sge_close_all_fds

NAME
          sge_close_all_fds() -- close all open file descriptors

SYNOPSIS
          void sge_close_all_fds(int* keep_open, unsigned long nr_of_fds)

FUNCTION
          This function is used to close all possible open file descriptors for
          the current process. This is done by getting the max. possible file
          descriptor count and looping over all file descriptors and calling
          sge_close_fd().
          
          It is possible to specify a file descriptor set which should not be
          closed.

INPUTS
          int* keep_open          - integer array which contains file descriptor
                                    ids which should not be closed
                                  - if this value is set to NULL nr_of_fds is
                                    ignored
          unsigned long nr_of_fds - nr of filedescriptors in the keep_open array

RESULT
          void - no result

SEE ALSO


16.14.5 sge_close_fd

NAME
          sge_close_fd() -- close a file descriptor

SYNOPSIS
          static void sge_close_fd(int fd)

FUNCTION
          This function closes the specified file descriptor on an architecture
          specific way. If __INSURE__ is defined during compile time and it is an
          fd used by insure the file descriptor is not closed.

INPUTS
          int fd - file descriptor number to close

RESULT
          static void - no return value

SEE ALSO


16.14.6 sge_contains_pid

NAME
          sge_contains_pid() -- Checks whether pid array contains pid

SYNOPSIS
          int sge_contains_pid(pid_t pid, pid_t *pids, int npids)

FUNCTION
          whether pid array contains pid

INPUTS
          pid_t pid   - process id
          pid_t *pids - pid array
          int npids   - number of pids in array

RESULT
          int - result state
              0 - pid was not found
              1 - pid was found

NOTES
          MT-NOTES: sge_contains_pid() is MT safe


16.14.7 sge_dup_fd_above_stderr

NAME
          sge_dup_fd_above_stderr() -- Make sure a fd is >=3

SYNOPSIS
          int sge_dup_fd_above_stderr(int *fd)

FUNCTION
          This function checks if the given fd is <3, if yes it dups it to be >=3.
          The fd obtained by open(), socket(), pipe(), etc. can be <3 if stdin,
          stdout and/or stderr are closed. As it is difficult for an application
          to determine if the first three fds are connected to the std-handles or
          something else and because many programmers just rely on these three fds
          to be connected to the std-handles, this function makes sure that it
          doesn't use these three fds.

INPUTS
          int *fd - pointer to the fd which is to be checked and dupped.

RESULT
          int - 0: Ok
               >0: errno


16.14.8 sge_get_max_fd

NAME
          sge_get_max_fd() -- get max filedescriptor count

SYNOPSIS
          int sge_get_max_fd(void)

FUNCTION
          This function returns the nr of file descriptors which are available
          (Where fd 0 is the first one).
          So the highest file descriptor value is: max_fd - 1.

INPUTS
          void - no input paramteres

RESULT
          int - max. possible open file descriptor count on this system

SEE ALSO


16.14.9 sge_get_pids

NAME
          sge_get_pids() -- Return all "pids" of a running processes

SYNOPSIS
          int sge_get_pids(pid_t *pids, int max_pids, const char *name,
                           const char *pscommand)

FUNCTION
          Return all "pids" of a running processes with given "name".
          Only first 8 characters of "name" are significant.
          Checks only basename of command after "/".

INPUTS
          pid_t *pids           - pid array
          int max_pids          - size of pid array
          const char *name      - name
          const char *pscommand - ps commandline

RESULT
          int - Result
              0 - No program with given name found
             >0 - Number of processes with "name"
             -1 - Error

NOTES
          MT-NOTES: sge_get_pids() is not MT safe


16.14.10 sge_getcpuload

NAME
          sge_getcpuload() -- Retrieve cpu utilization percentage

SYNOPSIS
          int sge_getcpuload(double *cpu_load)

FUNCTION
          Retrieve cpu utilization percentage (load value "cpu")

INPUTS
          double *cpu_load - caller passes adr of double variable
                             for cpu load

RESULT
          int - error state
              0 - OK
             !0 - Error


16.14.11 sge_mem_info_t

NAME
          sge_mem_info_t -- Structure to store memory information

SYNOPSIS
          typedef struct {
             double mem_total;
             double mem_free;
             double swap_total;
             double swap_free;
          #ifdef IRIX
             double swap_rsvd;
          #endif
          } sge_mem_info_t;

FUNCTION
          mem_total  - total amount of memory in MB
          mem_free   - amount of free memory in MB
          swap_total - total amount of swap space in MB
          swap_free  - amount of free swap space in MB
          swap_rsvd  - amount of reserved swap space in MB

SEE ALSO


16.14.12 sge_nprocs

NAME
          sge_nprocs() -- Number of processors in this machine

SYNOPSIS
          int sge_nprocs()

FUNCTION
          Use this function to get the number of processors in
          this machine

RESULT
          int - number of procs

NOTES
          MT-NOTE: sge_nprocs() is MT safe (SOLARIS, NEC, IRIX, ALPHA, HPUX, LINUX)


16.14.13 sge_occupy_first_three

NAME
          sge_occupy_first_three() -- Open descriptor 0, 1, 2 to /dev/null

SYNOPSIS
          int sge_occupy_first_three(void)

FUNCTION
          Occupy the first three filedescriptors, if not available. This is done
          to be sure that a communication by a socket will not get any "forgotten"
          print output from code.

RESULT
          int - error state
             -1 - OK
              0 - there are problems with stdin
              1 - there are problems with stdout
              2 - there are problems with stderr

NOTES
          MT-NOTE: sge_occupy_first_three() is MT safe

SEE ALSO


16.15 parse_script_params

NAME
          parse_script_params() -- Parse prolog/epilog/pe_start/pe_stop line from
                                   config

SYNOPSIS
          char *parse_script_params(char **script_file)

FUNCTION
          Parses the config value for prolog/epilog/pe_start or pe_stop.
          Retrieves the target user (as whom the script should be run) and
          eats the target user from the config value string, so that the path of
          the script file remains.

INPUTS
          char **script_file - Pointer to the string containing the conf value.
                               syntax: [<user>@]<path>, e.g. joe@/home/joe/script

OUTPUT
          char **script_file - Pointer to the string containing the script path.

RESULT
          char* - If one is given, the name of the user.
                  Else NULL.


16.16 path


16.16.1 path_mt_init

NAME
          path_mt_init() -- Initialize global SGE path state for multi threading use.

SYNOPSIS
          void path_mt_init(void)

FUNCTION
          Set up global SGE path state. This function must be called at least once
          before any of the path oriented functions can be used. This function is
          idempotent, i.e. it is safe to call it multiple times.
          
          Thread local storage for the path state information is reserved.

INPUTS
          void - NONE

RESULT
          void - NONE

NOTES
          MT-NOTE: path_mt_init() is MT safe


16.16.2 path_once_init

NAME
          path_once_init() -- One-time SGE path state initialization.

SYNOPSIS
          static path_once_init(void)

FUNCTION
          Create access key for thread local storage. Register cleanup function.
          
          This function must be called exactly once.

INPUTS
          void - none

RESULT
          void - none

NOTES
          MT-NOTE: path_once_init() is MT safe.


16.16.3 path_state_destroy

NAME
          path_state_destroy() -- Free thread local storage

SYNOPSIS
          static void path_state_destroy(void* theState)

FUNCTION
          Free thread local storage.

INPUTS
          void* theState - Pointer to memory which should be freed.

RESULT
          static void - none

NOTES
          MT-NOTE: path_state_destroy() is MT safe.


16.16.4 path_state_get_

NAME
          path_state_get_????() - read access to SGE path state.

FUNCTION
          Provide access to thread local storage.


16.16.5 path_state_init

NAME
          path_state_init() -- Initialize SGE path state.

SYNOPSIS
          static void path_state_init( path_state_t* theState)

FUNCTION
          Initialize SGE path state.

INPUTS
          path_state_t* theState - Pointer to SGE path state structure.

RESULT
          static void - none

NOTES
          MT-NOTE: path_state_init() is MT safe.


16.16.6 path_state_set_

NAME
          path_state_get_????() - write access to SGE path state.

FUNCTION
          Provide access to thread local storage.


16.16.7 sge_setup_paths

NAME
          sge_setup_paths() -- setup global paths

SYNOPSIS
          bool sge_setup_paths(const char *sge_cell, dstring *error_dstring)

FUNCTION
          Set SGE_ROOT and SGE_CELL dependent path components. The spool
          directory may later be overridden by global configuration.
          
          This function calls 'path_mt_init()' to initialize thread local
          storage. This function is idempotent, i.e. it is safe to inovke
          it multiple times.

INPUTS
          const char *sge_cell - the SGE cell to be used

OUTPUT
          dstring *error_dstring - A string buffer to return error messages.
                                   Also used by caller to indicate
                                   if setup function should exit on errror or not.

RESULT
          bool - true on success, else false

NOTES
          MT-NOTE: sge_setup_paths() is MT safe


16.17 profiling


16.17.1 –Profiling

NAME
          Profiling -- A simple profiling utility

FUNCTION
          The profiling module provides a number of utility functions
          to output some performance metrics about a program, like wallclock,
          busy time, user and system cpu time etc.
          
          Profiling can be started and stopped, the measured data can be
          reset to 0.
          
          Profiling for individual code blocks can be done by starting
          and stopping a measurement.
          
          Measured data can be queried individually for each metric variable,
          or an informational message string can be requested containing the
          most interesting variables.
          
          To distinguish profiling data for different modules of a program,
          (e.g. time/cpu consumed for communication, spooling, etc.),
          multiple levels have been introduced.
          
          Besides the predefined levels, there exist 10 custom levels
          (SGE_PROF_CUSTOM0 up to SGE_PROF_CUSTOM9) that can
          be used to profile individual parts of a program.
          
          The predefined levels shall only be used by the developers of the
          corresponding components.
          
          The level SGE_PROF_OTHER is maintained by the profiling module itself
          and collects the remaining usage not covered by other levels. It shall
          NOT be used outside the profiling module itself.
          
          A measurement is always done for a certain level.
          If a measurement for a certain level is started, while another
          measurement for another level is still active, the data of the
          subordinated measurement is remembered in the superordinated level.
          
          When retrieving profiling information, a parameter defines whether
          information for subordinated measurements shall be included or excluded.
          
          Cyclic starting of measurements is not allowed and will result in
          profiling being switched off.

EXAMPLE
          There is a test program (libs/uti/test_sge_profiling) and the
          module is used in sge_schedd (daemons/schedd/scheduler.c),
          in the event mirror module (libs/gdi/sge_mirror.c), the qmaster
          and his threads, execd and the spooling
          test program (libs/spool/test_sge_spooling.c).

SEE ALSO

NOTES
          MT-NOTE: this module is MT safe, if prof_mt_init() and/or
                   sge_prof_set_enabled() are called before
                   profiling is started and sge_prof_cleanup() is called after
                   all threads which make profiling calls have been stopped!
                   sge_prof_cleanup() is used to free  the profiling array

BUGS
          In a multithreaded program, the values delivered by the times system call
          for cpu system and user time are per process times.
          This module assumes that the values delivered by times are per thread
          values.
          In the profiling output, the sum of user and system time can be higher
          than the wallclock time, the utilization greater 100%.

TODO
          - Replace all pthread_mutex_(un)lock() calls with sge_mutex_(un)lock()
          - Separate public and private interfaces so that thread index can be
            passed around instead of always being rediscovered
          - Replace static array with thread specific storage?
          - Document static functions
          - Print levels without names


16.17.2 -Profiling-Defines

NAME
          Defines -- Defines and macros for profiling

SYNOPSIS
          #define PROF_START_MEASUREMENT ...
          #define PROF_STOP_MEASUREMENT ...

FUNCTION
          Macros to start and stop a profiling measurement.
          They test if profiling is enabled at all and then call the
          functions to start or stop a measurement.

SEE ALSO


16.17.3 PROF_START_MEASUREMENT

NAME
          PROF_START_MEASUREMENT() -- starts the measurement for the specified level

SYNOPSIS
          PROF_START_MEASUREMENT(prof_level level)

FUNCTION
          starts the measurement for the specified level
          to use profiling the sge_prof_setup() function
          must be called in the main program first.
          At the end of the main program, sge_prof_cleanup()
          should be called to make sure, that all that
          stuff becomes clean.

INPUTS
          prof_level level

EXAMPLE
          PROF_START_MEASUREMENT(SGE_PROF_GDI)

NOTES
          MT-NOTE: PROF_START_MEASUREMENT() is MT safe


16.17.4 PROF_STOP_MEASUREMENT

NAME
          PROF_STOP_MEASUREMENT() -- stops the measurement for the specified level

SYNOPSIS
          PROF_STOP_MEASUREMENT(prof_level level)

FUNCTION
          stops the measurement for the specified level
          to use profiling the sge_prof_setup() function
          must be called in the main program first.
          At the end of the main program, sge_prof_cleanup()
          should be called to make sure, that all that
          stuff becomes clean.

INPUTS
          prof_level level

EXAMPLE
          PROF_STOP_MEASUREMENT(SGE_PROF_GDI)

NOTES
          MT-NOTE: PROF_STOP_MEASUREMENT() is MT safe


16.17.5 get_thread_info

NAME
          get_thread_info() -- get the thread name/id mapping array

SYNOPSIS
          thread_info_t* get_thread_info(void)

FUNCTION
          if the thread name/id mapping array is not initialized
          it will be done

RESULT
          returns a pointer to the thread name/id mapping array

NOTES
          MT-NOTE: get_thread_info() is MT safe


16.17.6 init_array

NAME
          init_array() -- mallocs memory for the sge_prof_info_t array

SYNOPSIS
          void init_array(pthread_t num)

FUNCTION
          mallocs memory for sge_prof_info_t array for the number
          of MAX_THREAD_NUM threads
          mallocs memory for each thread if nedded

INPUTS
          the thread id, which needs malloced memory

NOTES
          MT-NOTE: init_array() is MT safe


16.17.7 init_thread_info

NAME
          init_thread_info() -- mallocs memory for the thread_info_t array

SYNOPSIS
          void init_thread_info(void)

FUNCTION
          mallocs memory for thread_info_t array (thread name/id mapping)
          for the number of MAX_THREAD_NUM threads. Must be called once
          per process.

NOTES
          MT-NOTE: init_thread_info() is MT safe


16.17.8 prof_get_info_string

NAME
          prof_get_info_string() -- get informational message

SYNOPSIS
          const char* prof_get_info_string(prof_level level, bool with_sub, dstring *error)

FUNCTION
          Returns a string containing the most interesting data, both for the
          last measurement and for the total runtime:
             - wallclock of measurement
             - user cpu time of measurement
             - system cpu time of measurement
             - total wallclock time (runtime)
             - total busys time
             - utilization (busy time / wallclock time) * 100 %

INPUTS
          prof_level level - level to process
          bool with_sub    - include usage of subordinated measurements?
          dstring *error   - if != NULL, error messages will be put here

RESULT
          const char* - pointer to result string. It is valid until the next
                        call of prof_get_info_string()
                        on error, 0 is returned and an error message is written
                        to the buffer given in parameter error, if error != NULL

EXAMPLE
          The result can look like the following:
          "wc = 0.190s, utime = 0.120s, stime = 0.000s, runtime 9515s, busy 105s,
          utilization 1%"

NOTES
          MT-NOTE: prof_get_info_string() is MT safe


16.17.9 prof_get_measurement_stime

NAME
          prof_get_measurement_stime() -- return system cpu time of measurement

SYNOPSIS
          double prof_get_measurement_stime(prof_level level, bool with_sub, dstring *error)

FUNCTION
          Returns the system cpu time of the last measurement in seconds.
          Resolution is clock ticks (_SC_CLK_TCK).

INPUTS
          prof_level level - level to process
          bool with_sub    - include usage of subordinated measurements?
          dstring *error   - if != NULL, error messages will be put here

RESULT
          double - the system cpu time of the last measurement
                   on error, 0 is returned and an error message is written
                   to the buffer given in parameter error, if error != NULL

NOTES
          MT-NOTE: prof_get_measurement_stime() is MT safe


16.17.10 prof_get_measurement_utime

NAME
          prof_get_measurement_utime() -- return user cpu time of measurement

SYNOPSIS
          double prof_get_measurement_utime(prof_level level, bool with_sub, dstring *error)

FUNCTION
          Returns the user cpu time of the last measurement in seconds.
          Resolution is clock ticks (_SC_CLK_TCK).

INPUTS
          prof_level level - level to process
          bool with_sub    - include usage of subordinated measurements?
          dstring *error   - if != NULL, error messages will be put here

RESULT
          double - the user cpu time of the last measurement
                   on error, 0 is returned and an error message is written
                   to the buffer given in parameter error, if error != NULL

NOTES
          MT-NOTE: prof_get_measurement_utime() is not MT safe


16.17.11 prof_get_measurement_wallclock

NAME
          prof_get_measurement_wallclock() -- return wallclock of a measurement

SYNOPSIS
          double prof_get_measurement_wallclock(prof_level level, bool with_sub, dstring *error)

FUNCTION
          Returns the wallclock of the last measurement in seconds.
          Resolution is clock ticks (_SC_CLK_TCK).

INPUTS
          prof_level level - level to process
          bool with_sub    - include usage of subordinated measurements?
          dstring *error   - if != NULL, error messages will be put here

RESULT
          double - the wallclock time of the last measurement
                   on error, 0 is returned and an error message is written
                   to the buffer given in parameter error, if error != NULL

RESULT
          double - the wallclock time of the last measurement
                   on error, 0 is returned and an error message is written
                   to the buffer given in parameter error, if error != NULL

NOTES
          MT-NOTE: prof_get_measurement_wallclock() is MT safe


16.17.12 prof_get_total_busy

NAME
          prof_get_total_busy() -- return total busy time

SYNOPSIS
          double prof_get_total_busy(prof_level level, bool with_sub, dstring *error)

FUNCTION
          Returns the total busy time since profiling was enabled in seconds.
          Busy time is the time between starting and stopping a measurement.
          Resolution is clock ticks (_SC_CLK_TCK).

INPUTS
          prof_level level - level to process
          bool with_sub    - include usage of subordinated measurements?
          dstring *error   - if != NULL, error messages will be put here

RESULT
          double - the total busy time of the profiling run
                   on error, 0 is returned and an error message is written
                   to the buffer given in parameter error, if error != NULL

NOTES
          MT-NOTE: prof_get_total_busy() is MT safe


16.17.13 prof_get_total_stime

NAME
          prof_get_total_stime() -- get total system cpu time

SYNOPSIS
          double prof_get_total_stime(prof_level level, bool with_sub)

FUNCTION
          Returns the total system cpu time since profiling was enabled in seconds.
          Resolution is clock ticks (_SC_CLK_TCK).

INPUTS
          prof_level level - level to process
          bool with_sub    - include usage of subordinated measurements?
          dstring *error   - if != NULL, error messages will be put here

RESULT
          double - the total system cpu time of the profiling run
                   on error, 0 is returned and an error message is written
                   to the buffer given in parameter error, if error != NULL

NOTES
          MT-NOTE: prof_get_total_stime() is MT safe


16.17.14 prof_get_total_utime

NAME
          prof_get_total_utime() -- get total user cpu time

SYNOPSIS
          double prof_get_total_utime(prof_level level, bool with_sub, dstring *error)

FUNCTION
          Returns the user cpu time since profiling was enabled in seconds.
          Resolution is clock ticks (_SC_CLK_TCK).

INPUTS
          prof_level level - level to process
          bool with_sub    - include usage of subordinated measurements?
          dstring *error   - if != NULL, error messages will be put here

RESULT
          double - the total user cpu time of the profiling run
                   on error, 0 is returned and an error message is written
                   to the buffer given in parameter error, if error != NULL

NOTES
          MT-NOTE: prof_get_total_utime() is MT safe


16.17.15 prof_get_total_wallclock

NAME
          prof_get_total_wallclock() -- get total wallclock time

SYNOPSIS
          double prof_get_total_wallclock(dstring *error)

FUNCTION
          Returns the wallclock time since profiling was enabled in seconds.
          Resolution is clock ticks (_SC_CLK_TCK).

INPUTS
          dstring *error   - if != NULL, error messages will be put here

RESULT
          double - the total wallclock time of the profiling run
                   on error, 0 is returned and an error message is written
                   to the buffer given in parameter error, if error != NULL

NOTES
          MT-NOTE: prof_get_total_wallclock() is MT safe


16.17.16 prof_info_init

NAME
          prof_info_init() -- initialize the sge_prof_info_t struc array with default values

SYNOPSIS
          static void prof_info_init(prof_level level)

FUNCTION
          initialize the sge_prof_info_t struct array with default values

INPUTS
          prof_level level

RESULT
          initialized sge_prof_info_t array for the given profiling level

NOTES
          MT-NOTE: prof_info_init() is MT safe


16.17.17 prof_info_level_init

NAME
          prof_info_level_init() -- initialize the sge_prof_info_t struc array with default values

SYNOPSIS
          static void prof_info_level_init(prof_level level)

FUNCTION
          initialize the sge_prof_info_t struct array with default values

INPUTS
          prof_level i
          int thread_num

RESULT
          initialized sge_prof_info_t array for the given profiling level

NOTES
          MT-NOTE: prof_info_level_init() is MT safe


16.17.18 prof_is_active

NAME
          prof_is_active() -- is profiling active?

SYNOPSIS
          bool prof_is_active(void)

FUNCTION
          Returns true, if profiling is active, else false.

RESULT
          bool - true on success, else false is returned and an error message
                 is returned in parameter error, if error != NULL

SEE ALSO

NOTES
          MT-NOTE: prof_is_active() is MT safe


16.17.19 prof_reset

NAME
          prof_reset() -- reset usage information

SYNOPSIS
          bool prof_reset(dstring *error)

FUNCTION
          Reset usage and timing information to 0.

INPUTS
          dstring *error   - if != NULL, error messages will be put here

RESULT
          bool - true on success, else false is returned and an error message
                 is returned in parameter error, if error != NULL

NOTES
          MT-NOTE: prof_reset() is MT safe


16.17.20 prof_reset_thread

NAME
          prof_reset_thread() -- reset usage information

SYNOPSIS
          bool prof_reset_thread(int thread_num, prof_level level)

FUNCTION
          Reset usage and timing information for a single thread and level to 0.

INPUTS
          int thread_num    the thread to reset
          prof_level level  the profiling level to reset

NOTES
          MT-NOTE: prof_reset() is MT safe


16.17.21 prof_set_level_name

NAME
          prof_set_level_name() -- set name of a custom level

SYNOPSIS
          bool prof_set_level_name(prof_level level, const char *name)

FUNCTION
          Set the name of a custom profiling level.

INPUTS
          prof_level level - level to edit
          const char *name - new name for level
          dstring *error   - if != NULL, error messages will be put here

RESULT
          bool - true on success, else false is returned and an error message
                 is returned in parameter error, if error != NULL

NOTES
          MT-NOTE: prof_set_level_name() is MT safe

SEE ALSO


16.17.22 prof_start

NAME
          prof_start() -- start profiling

SYNOPSIS
          bool prof_start(dstring *error)

FUNCTION
          Enables profiling. All internal variables are reset to 0.
          Performance measurement has to be started and stopped by
          calling profiling_start_measurement or profiling_stop_measurement.

INPUTS
          dstring *error   - if != NULL, error messages will be put here

RESULT
          bool - true on success, else false is returned and an error message
                 is returned in parameter error, if error != NULL

SEE ALSO

NOTES
          MT-NOTE: prof_start() is MT safe


16.17.23 prof_start_measurement

NAME
          prof_start_measurement() -- start measurement

SYNOPSIS
          bool prof_start_measurement(prof_level level, dstring *error)

FUNCTION
          Starts measurement of performance data.
          Retrieves and stores current time and usage information.

INPUTS
          prof_level level - level to process
          dstring *error   - if != NULL, error messages will be put here

RESULT
          bool - true on success, else false is returned and an error message
                 is returned in parameter error, if error != NULL

SEE ALSO

NOTES
          MT-NOTE: prof_start_measurement() is MT safe


16.17.24 prof_stop

NAME
          prof_stop() -- stop profiling

SYNOPSIS
          bool prof_stop(dstring *error)

FUNCTION
          Profiling is disabled.
          
          Subsequent calls to profiling_start_measurement or
          profiling_stop_measurement will have no effect.
          
          Profiling can be re-enabled by calling profiling_start.

INPUTS
          dstring *error   - if != NULL, error messages will be put here

RESULT
          bool - true on success, else false is returned and an error message
                 is returned in parameter error, if error != NULL

SEE ALSO

NOTES
          MT-NOTE: prof_start() is MT safe


16.17.25 prof_stop_measurement

NAME
          prof_stop_measurement() -- stop measurement

SYNOPSIS
          bool prof_stop_measurement(prof_level level, dstring *error)

FUNCTION
          Stops measurement for a certain code block.
          Retrieves and stores current time and usage information.
          Sums up global usage information.

INPUTS
          prof_level level - level to process
          dstring *error   - if != NULL, error messages will be put here

RESULT
          bool - true on success, else false is returned and an error message
                 is returned in parameter error, if error != NULL

SEE ALSO

NOTES
          MT-NOTE: prof_stop_measurement() is MT safe


16.17.26 prof_thread_local_once_init

NAME
          prof_thread_local_once_init() -- inititalizes the profiling array

SYNOPSIS
          void prof_thread_local_once_init(void)

FUNCTION
          Initializes the profiling array.

NOTES
          MT-NOTE: prof_thread_local_once_init() is MT safe only if called before any other
                   profiling calls other than sge_prof_set_enabled()


16.17.27 set_thread_name

NAME
          set_thread_name() -- set the thread name mapped to its id

SYNOPSIS
          void set_thread_name(pthread_t thread_id, const char* thread_name)

FUNCTION
          maps the name and the id of a thread
          set the thread profiling status to false

INPUTS
          pthread_t thread_id
          const char* thread_name

NOTES
          MT-NOTE: set_thread_info() is MT safe


16.17.28 set_thread_prof_status_by_id

NAME
          set_thread_prof_status_by_id() -- sets the profiling status for the thread
                                            with the given thread id

SYNOPSIS
          void set_thread_prof_status_by_id(pthread_t thread_id, bool prof_status)

FUNCTION
          set the thread profiling status of the thread with the given id

INPUTS
          pthread_t thread_id
          bool prof_status

NOTES
          MT-NOTE: set_thread_prof_status_by_id() is MT safe


16.17.29 set_thread_prof_status_by_name

NAME
          set_thread_prof_status_by_name() -- sets the profiling status for the thread
                                              with the given thread id and thread name

SYNOPSIS
          void set_thread_prof_status_by_name(pthread_t thread_id, const char* thread_name,  bool prof_status)

FUNCTION
          set the thread profiling status of the thread with the given id and name

INPUTS
          pthread_t thread_id
          const char* thread_name
          bool prof_status

RESULTS
          return 0 - ok
          return 1 - thread_name = NULL

NOTES
          MT-NOTE: set_thread_prof_status_by_name() is MT safe


16.17.30 sge_prof_cleanup

NAME
          sge_prof_cleanup() -- frees the profiling array

SYNOPSIS
          void sge_prof_cleanup(void)

FUNCTION
          frees the profiling array

NOTES
          MT-NOTE: sge_prof_cleanup() is MT safe


16.17.31 sge_prof_set_enabled

NAME
          sge_prof_set_enabled() -- enables/disables profiling

SYNOPSIS
          void sge_prof_set_enabled(bool enabled)

FUNCTION
          Enables/disables profiling completely.  Profiling is enabled by
          default.  This method is the fix to Issue 1471.

INPUTS
          bool enabled   Whether profiling should be enabled

NOTES
          MT-NOTE: sge_prof_set_enabled() is MT safe only if called before any other
                   profiling calls


16.17.32 thread_output_profiling

NAME
          thread_output_profiling() -- output profiling info for thread

SYNOPSIS
          void
          thread_output_profiling(const char *title, time_t *next_prof_output)

FUNCTION
          Outputs profiling information for the current thread.
          Information for all active profiling levels is dumped.
          The first line dumped is a sort of title, that can/should be used
          to identify the thread.
          
          The variable next_prof_output will be set by this function.
          This variable should be initialized to 0 (zero) by the caller before the
          first call of this function.

INPUTS
          const char *title        - title to print as first line
          time_t *next_prof_output - time of next profiling output

NOTES
          MT-NOTE: thread_output_profiling() is MT safe

SEE ALSO


16.17.33 thread_prof_active_by_id

NAME
          thread_prof_active_by_id() -- returns the status of a thread

SYNOPSIS
          bool thread_prof_active_by_id(pthread_t thread_id)

FUNCTION
          returns the profiling status of a thread

INPUTS
          pthread_t thread_id

NOTES
          MT-NOTE: thread_prof_active_by_id() is MT safe


16.17.34 thread_prof_active_by_name

NAME
          thread_prof_active_by_name() -- returns the status of a thread

SYNOPSIS
          bool thread_prof_active_by_name(pthread_t thread_id)

FUNCTION
          returns the profiling status of a thread

INPUTS
          pthread_t thread_id

NOTES
          MT-NOTE: thread_prof_active_by_name() is MT safe


16.17.35 thread_start_stop_profiling

NAME
          thread_start_stop_profiling() -- start profiling for thread

SYNOPSIS
          void
          thread_start_stop_profiling(void)

FUNCTION
          Checks if profiling has been enabled for the current thread.
          If yes, starts profiling for all levels.
          If profiling has been disabled for the current thread, profiling
          is disabled for all levels.

NOTES
          MT-NOTE: thread_start_stop_profiling() is MT safe


16.18 prog


16.18.1 prog_once_init

NAME
          prog_once_init() -- One-time executable state initialization.

SYNOPSIS
          static prog_once_init(void)

FUNCTION
          Create access key for thread local storage. Register cleanup function.
          
          This function must be called exactly once.

INPUTS
          void - none

RESULT
          void - none

NOTES
          MT-NOTE: prog_once_init() is MT safe.


16.18.2 prog_state_destroy

NAME
          prog_state_destroy() -- Free thread local storage

SYNOPSIS
          static void prog_state_destroy(void* theState)

FUNCTION
          Free thread local storage.

INPUTS
          void* theState - Pointer to memroy which should be freed.

RESULT
          static void - none

NOTES
          MT-NOTE: prog_state_destroy() is MT safe.


16.18.3 prog_state_getspecific

NAME
          prog_state_getspecific() -- Get thread local prog state

SYNOPSIS
          static prog_state_t* prog_state_getspecific(pthread_key_t aKey)

FUNCTION
          Return thread local prog state.
          
          If a given thread does call this function for the first time, no thread
          local prog state is available for this particular thread. In this case the
          thread local prog state is allocated and set.

INPUTS
          pthread_key_t aKey - Key for thread local prog state.

RESULT
          static prog_state_t* - Pointer to thread local prog state

NOTES
          MT-NOTE: prog_state_getspecific() is MT safe


16.18.4 prog_state_init

NAME
          prog_state_init() -- Initialize executable state.

SYNOPSIS
          static void prog_state_init(prog_state_t *theState)

FUNCTION
          Initialize executable state.

INPUTS
          struct prog_state_t* theState - Pointer to executable state structure.

RESULT
          static void - none

NOTES
          MT-NOTE: prog_state_init() in MT safe.


16.18.5 sge_get_alias_path

NAME
          sge_get_alias_path() -- Return the path of the 'alias_file'

SYNOPSIS
          const char* sge_get_alias_path(void)

FUNCTION
          Return the path of the 'alias_file'

NOTES
          MT-NOTE: sge_get_alias_path() is MT safe


16.18.6 sge_get_arch

NAME
          sge_get_arch() -- SGE/EE architecture string

SYNOPSIS
          const char* sge_get_arch(void)

FUNCTION
             This function returns the SGE/EE architecture string of that
             host where the application is running which called this
             functionon.
          
          NOTES:
             MT-NOTE: sge_get_arch() is MT safe

RESULT
          const char* - architecture string


16.18.7 sge_get_default_cell

NAME
          sge_get_default_cell() -- get cell name and remove trailing slash

SYNOPSIS
          const char* sge_get_default_cell(void)

FUNCTION
          This function returns the defined cell name of SGE.
          This directory is defined by the SGE_CELL environment variable
          of the calling process.
          If the environment variable does not exist or is not set then
          this function will return the 'DEFAULT_CELL'.

RESULT
          const char* - Cell name of this SGE installation

NOTES
          MT-NOTE: sge_get_default_cell() is MT safe


16.18.8 sge_get_lib_dir

NAME
          sge_get_lib_dir() -- Path to SGE libraries

SYNOPSIS
          int sge_get_lib_dir(char *buffer, size_t size)

FUNCTION
          This function stores the path to the SGE libraries in the buffer

INPUTS
             char     *buffer - Buffer where to store the SGE library dir
             size_t   size    - Size of the given buffer
          NOTES:
             MT-NOTE: sge_get_lib_dir() is MT safe

RESULT
          int - Return code
            1 - Success
           -1 - Given buffer is NULL
           -2 - SGE_ROOT cannot be obtained
           -3 - given buffer is to small


16.18.9 sge_get_root_dir

NAME
          sge_get_root_dir() -- SGE installation directory

SYNOPSIS
          const char* sge_get_root_dir(int do_exit,
                                       char *buffer,
                                       size_t size,
                                       int do_error_log )

FUNCTION
          This function returns the installation directory of SGE.
          This directory is defined by the SGE_ROOT environment variable
          of the calling process.
          If the environment variable does not exist or is not set then
          this function will handle this as error and return NULL
          (do_exit = 0). If 'do_exit' is 1 and an error occures, the
          function will terminate the  calling application.

INPUTS
          int do_exit - Terminate the application in case of an error
          char *buffer - buffer to be used for error message
          size_t size - size of buffer
          int do_error_log - enable/disable error logging

RESULT
          const char* - Root directory of the SGE installation

NOTES
          MT-NOTE: sge_get_arch() is MT safe


16.18.10 sge_getme

NAME
          sge_getme() -- Initialize me-struct

SYNOPSIS
          void sge_getme(u_long32 program_number)

FUNCTION
          Initialize me-struct according to 'program_number'

INPUTS
          u_long32 program_number - uniq internal program number

NOTES
          MT-NOTE: sge_getme() is MT safe


16.18.11 sge_show_me

NAME
          sge_show_me() -- Show content of me structure

SYNOPSIS
          static void sge_show_me()

FUNCTION
          Show content of me structure in debug output

NOTES
          MT-NOTE: sge_show_me() is MT safe


16.18.12 uti_state_get_

NAME
          uti_state_get_????() - read access to utilib global variables

FUNCTION
          Provides access to either global variable or per thread global variable.


16.18.13 uti_state_get_exit_func

NAME
          uti_state_get_exit_func() -- Return installed exit funciton

SYNOPSIS
          sge_exit_func_t uti_state_get_exit_func(void)

FUNCTION
          Returns installed exit funciton. Exit function
          will be called be sge_exit()

RESULT
          sge_exit_func_t - function pointer

SEE ALSO


16.18.14 uti_state_set_

NAME
          uti_state_set_????() - write access to utilib global variables

FUNCTION
          Provides access to either global variable or per thread global variable.


16.18.15 uti_state_set_exit_func

NAME
          uti_state_set_exit_func() -- Installs a new exit handler

SYNOPSIS
          void uti_state_set_exit_func(sge_exit_func_t f)

FUNCTION
          Installs a new exit handler. Exit function will be called be sge_exit()

INPUTS
          sge_exit_func_t f - new function pointer

SEE ALSO


16.19 pty


16.19.1 fork_no_pty

NAME
          fork_no_pty() -- Opens pipes, forks and redirects the std handles

SYNOPSIS
          pid_t fork_no_pty(int *fd_pipe_in, int *fd_pipe_out, int *fd_pipe_err,
          dstring *err_msg)

FUNCTION
          Opens three pipes, forks and redirects stdin, stdout and stderr of the
          child to the pty.

INPUTS
          int *fd_pipe_in  - int[2] array for the two stdin pipe file descriptors
          int *fd_pipe_out - int[2] array for the two stdout pipe file descriptors
          int *fd_pipe_err - int[2] array for the two stderr pipe file descriptors
          dstring *err_msg - Receives an error string in case of error.

RESULT
          pid_t - -1 in case of error,
                   0 in the child process,
                   or the pid of the child process in the parent process.

NOTES
          MT-NOTE: fork_no_pty() is not MT safe

SEE ALSO


16.19.2 fork_pty

NAME
          fork_pty() -- Opens a pty, forks and redirects the std handles

SYNOPSIS
          pid_t fork_pty(int *ptrfdm, int *fd_pipe_err, dstring *err_msg)

FUNCTION
          Opens a pty, forks and redirects stdin, stdout and stderr of the child
          to the pty.

INPUTS
          int *ptrfdm      - Receives the file descriptor of the master side of
                             the pty.
          int *fd_pipe_err - A int[2] array that receives the file descriptors
                             of a pipe to separately redirect stderr.
                             To achieve the same behaviour like rlogin/rsh, this
                             is normally disabled, compile with
                             -DUSE_PTY_AND_PIPE_ERR to enable this feature.
          dstring *err_msg - Receives an error string in case of error.
          uid_t uid        - uid for pty owner

RESULT
          pid_t - -1 in case of error,
                   0 in the child process,
                   or the pid of the child process in the parent process.

NOTES
          MT-NOTE: fork_pty() is not MT safe

SEE ALSO


16.19.3 ptym_open

NAME
          ptym_open() -- Opens a pty master device

SYNOPSIS
          int ptym_open(char *pts_name)

FUNCTION
          Searches for a free pty master device and opens it.

INPUTS
          char *pts_name - A buffer that is to receive the name of the
                           pty master device. Must be at least 12 bytes large.

RESULT
          int - The file descriptor of the pty master device.
                -1 in case of error.

NOTES
          MT-NOTE: ptym_open() is not MT safe

SEE ALSO


16.19.4 ptys_open

NAME
          ptys_open() -- Opens a pty slave device.

SYNOPSIS
          int ptys_open(int fdm, char *pts_name)

FUNCTION
          Opens a pty slave device that matches to a given pty master device.

INPUTS
          int fdm        - File descriptor of the pty master device.
          char *pts_name - The name of the master slave device.

RESULT
          int - File descriptor of the pty slave device.
                -1 in case of error.

NOTES
          MT-NOTE: ptys_open() is not MT safe

SEE ALSO


16.19.5 terminal_enter_raw_mode

NAME
          terminal_enter_raw_mode() -- Sets terminal to raw mode

SYNOPSIS
          int terminal_enter_raw_mode(void)

FUNCTION
          Sets terminal to raw mode, i.e. no control characters are interpreted any
          more, but are simply printed.

RESULT
          int - 0 if Ok, else errno

NOTES
          MT-NOTE: terminal_enter_raw_mode() is not MT safe

SEE ALSO


16.19.6 terminal_leave_raw_mode

NAME
          terminal_leave_raw_mode() -- restore previous terminal mode

SYNOPSIS
          int terminal_leave_raw_mode(void)

FUNCTION
          Restores the previous terminal mode.

RESULT
          int - 0 if Ok, else errno

NOTES
          MT-NOTE: terminal_leave_raw_mode() is not MT safe

SEE ALSO


16.20 sanitize_environment

NAME
          sanitize_environment() -- remove sensitive variables from the environment before calling programs

SYNOPSIS
          #include "uti/execvlp.h"
          void sanitize_environment(char *env[])

FUNCTION
          Remove variables from the environment which represent a security
          risk when a program is called under a privileged id with an
          environment supplied by the user, such as remote
          communication daemons.  (For instance, if the user can get a
          dynamically-linked privileged program run in an ELF environment
          with arbitrary LD_LIBRARY_PATH or LD_PRELOAD, all bets are off.)

SEE ALSO


16.21 sge_copy_sanitize_env

NAME
          sge_copy_sanitize_environment() -- make a copy of environment with sensitive variables removed

SYNOPSIS
          #include "uti/execvlp.h"
          char **sge_copy_sanitize_env(char *env[])

FUNCTION
          Remove variables from the environment which represent a security
          risk if when a program is called under a privileged id with an
          environment supplied by the user, for example, remote
          communication daemons.  (If the user can get a
          dynamically-linked privileged program run in an ELF environment,
          say, with arbitrary LD_LIBRARY_PATH or LD_PRELOAD, all bets are
          off.)  Also try to protect shell scripts from IFS, at least.


16.22 sge_dlopen

NAME
          sge_dlopen -- interface to dlopen

SYNOPSIS
          #include <uti/sge_dlopen.h>
          void *sge_dlopen(const char *libbase, const char *libversion)

FUNCTION
          Call dlopen on a shared library name in a system-dependent way.
          Flags RTLD_NOW and RTLD_GLOBAL are used, along with RTLD_NODELETE,
          if it is defined.

INPUTS
          libbase  - Name of shared library.  A system-dependent extension
                     is appended if it doesn't have one.
          libversion  - Version string appended to the shared library name
                        if non-NULL.  Currently only used for ELF libraries.

RESULT
          As for dlopen.


16.23 sge_execvlp

NAME
          sge_execvlp -- like execve, but search the path

SYNOPSIS
          #include "uti/execvlp.h"
          int sge_execvlp (const char *file, char *const argv[], char *const envp[])

FUNCTION
          A version of execve that does a path search for the executable
          like execlp/execvp.

INPUTS
          file - name of executable
          argv - null-terminated list of arguments
          envp - null-terminated list of environment elements

RESULT
          on success, the function will not return (it execs)
          -1 if the exec fails


16.24 sge_log


16.24.1 log_state_get_log_file

NAME
          log_state_get_log_file() -- get log file name

SYNOPSIS
          const char* log_state_get_log_file(void)

FUNCTION
          Return name of current log file. The string returned may or may not
          contain a path.

INPUTS
          void - none

RESULT
          const char* - log file name (with relative or absolute path)

NOTES
          MT-NOTE: log_state_get_log_file() is not MT safe.
          MT-NOTE:
          MT-NOTE: It is safe, however, to call this function from within multiple
          MT-NOTE: threads as long as no other thread does change 'Log_File'.

BUGS
          BUGBUG-AD: This function should use something like a barrier for
          BUGBUG-AD: synchronization.


16.24.2 sge_do_log

NAME
          sge_do_log() -- Write message to log file (or syslog)

SYNOPSIS
          static void sge_do_log(u_long32 me, const char* progname, const char* unqualified_hostname, int aLevel, const char *aMessage, int log_level)

FUNCTION
          ???

INPUTS
          u_long32 me          - process type (QMASTER etc.)
          const char* progname - program name
          const char* unqualified_hostname - name of host issuing message
          int aLevel           - log level
          const char *aMessage - log message
          int log_level        - numeric level from which aLevel is derived

RESULT
          void - none

NOTES
          MT-NOTE: sge_do_log() is MT safe.


16.25 sge_shlib_ext

NAME
          sge_shlib_ext -- return system-dependent shared librray extension

SYNOPSIS
          #include <uti/sge_dlopen.h>
          const char *sge_shlib_ext()

FUNCTION
          Return shared library extension for the system, e.g. ".so".

RESULT
          Library extension.


16.26 sge_tmpnam


16.26.1 sge_mkstemp

NAME
          sge_mkstemp() -- SGE version of mkstemp()

SYNOPSIS
          int sge_mkstemp(char *aBuffer, size_t size, dstring *error_message)

FUNCTION
          SGE-specific version of mkstemp(3) that tries TMPDIR as well as
          P_tmpdir before /tmp, returns an error message, and guarantees
          read and write access for the user only.
          
          The 'aBuffer' argument points to an array of at least
          'size' in length.  'aBuffer' will contain the generated
          filename upon successful completion, and the file descriptor for
          the opened file is returned.  If the function fails, -1 will be
          returned, with an error message in error_message.

INPUTS
          char *aBuffer - Array to hold filename
          size_t size - size of aBuffer
          dstring error_message - Error message

RESULT
          char* - Points to 'aBuffer' if successful, NULL otherwise

NOTE
          MT-NOTE: sge_mkstemp() is MT safe.


16.27 signal


16.27.1 sge_map_signal

NAME
          sge_map_signal() -- Map system signal to 32bit SGE/EE signal

SYNOPSIS
          u_long32 sge_map_signal(int sys_sig)

FUNCTION
          Map the system specific signal to the 32bit sge signal

INPUTS
          int sys_sig - system signal

RESULT
          u_long32 - SGE/EE Signal

NOTES
          MT-NOTE: sge_map_signal() is MT safe


16.27.2 sge_set_def_sig_mask

NAME
          sge_set_def_sig_mask() -- Set signal mask to default

SYNOPSIS
          void sge_set_def_sig_mask(int sig_num, err_func_t err_func)

FUNCTION
          Set signal mask to default for all signals except given signal

INPUTS
          sigset_t sig_num    - signals which should be ignored
                                (use sigemptyset and sigaddset to set signals,
                                if NULL, no signals are ignored)
          err_func_t err_func - callback function to report errors

NOTES
          MT-NOTE: sge_set_def_sig_mask() is MT safe


16.27.3 sge_sig2str

NAME
          sge_sig2str() -- Make a string out of a SGE/EE signal

SYNOPSIS
          const char* sge_sig2str(u_long32 sge_sig)

FUNCTION
          Make a string out of a SGE/EE signal

INPUTS
          u_long32 sge_sig - SGE/EE signal

RESULT
          const char* - signal string

NOTES
          MT-NOTE: sge_sig2str() is MT safe


16.27.4 sge_str2signal

NAME
          str2signal() -- Make an SGE signal out of a string

SYNOPSIS
          u_long32 sge_str2signal(const char *str)

FUNCTION
          Make a sge signal out of a string. 'str' can be the signal name
          (caseinsensitive) without sig or the signal number (Take care
          numbers are system dependent).

INPUTS
          const char *str - signal string

RESULT
          u_long32 - SGE/EE signal

NOTES
          MT-NOTE: sge_str2signal() is MT safe


16.27.5 sge_sys_sig2str

NAME
          sge_sys_sig2str() -- Make a string out of a system signal

SYNOPSIS
          const char* sge_sys_sig2str(u_long32 sys_sig)

FUNCTION
          Make a string out of a system signal

INPUTS
          u_long32 sys_sig - system signal

RESULT
          const char* - signal string

NOTES
          MT-NOTE: sge_sys_sig2str() is MT safe


16.27.6 sge_sys_str2signal

NAME
          sge_sys_str2signal() -- Make an SGE signal out of a string

SYNOPSIS
          u_long32 sge_sys_str2signal(const char *str)

FUNCTION
          Make an SGE signal out of a string

INPUTS
          const char *str - signal name

RESULT
          u_long32 - SGE/EE signal

NOTES
          MT-NOTE: sge_sys_str2signal() is MT safe


16.27.7 sge_thread_block_all_signals

NAME
          sge_thread_block_all_signals()

SYNOPSIS
          int sge_thread_block_all_signals(void)

FUNCTION
          Blocks all signals the OS knows for the calling thread.

OUTPUTS
          sigset_t *oldsigmask - the sigmask of this thread that was set before
                                 this function was called.

RETURN VALUES
          int - 0 if ok,
                errno if pthread_sigmask failed,
                1000 if oldsigmask == NULL.

NOTES
          MT-NOTE: sge_thread_block_signals() is MT safe


16.27.8 sge_unblock_all_signals

NAME
          sge_unblock_all_signals()

SYNOPSIS
          void sge_unblock_all_signals(void)

FUNCTION
          Allow for all signals.

NOTES
          MT-NOTE: sge_unblock_all_signals() is MT safe


16.27.9 sge_unmap_signal

NAME
          sge_unmap_signal() -- Unmap 32bit SGE/EE signal to system signal

SYNOPSIS
          int sge_unmap_signal(u_long32 sge_sig)

FUNCTION
          Unmap the 32bit SGE/EEsignal to the system specific signal

INPUTS
          u_long32 sge_sig - SGE/EE signal

RESULT
          int - system signal

NOTES
          MT-NOTE: sge_unmap_signal() is MT safe


16.28 sl


16.28.1 –SimpleList

NAME
          sl - A Simple List Implementation for Grid Engine

FUNCTION
          This module provides a simple and thread safe list
          implementation for Grid Engine. Lists can be created, destroyed
          and the number of the contained nodes can be retrieved.
          
             sge_sl_create()
             sge_sl_destroy()
             sge_sl_get_elements()
          
          The list is implemented as double links list so that data
          can be accessed forward and backward easily. Function arguments
          decide if the first or last element should be addressed.
          
             sge_sl_insert()
             sge_sl_delete()
             sge_sl_data()
          
          Elements can also be inserted into a sorted list or they can
          be searched using a user defined compare function.
          
             sge_sl_insert_search()
             sge_sl_delete_search()
             sge_sl_data_search()
             sge_sl_sort()
          
          The underlaying list data structure is thread safe so that one list
          can be accessed without additional synchronisation between the
          threads.
          
          Node data structures are NOT thread safe for that reason
          following functions need additional synchronisation because they
          provide access to node data structures.
          
             sge_sl_elem_create()
             sge_sl_elem_destroy()
             sge_sl_elem_data()
             sge_sl_elem_next()
             sge_sl_elem_search()
             sge_sl_dechain()
             sge_sl_insert_before()
             sge_sl_append_after()
          
          The list implementation provides locking functions that provide a way
          to synchronize access with a list object. Therefore it is easily
          possible to secure the above node based functions and execute them in
          an atomic block.
          
             sge_sl_lock()
             sge_sl_unlock()
          
          Please be cautious when you need other locks in a code block between
          the lock and unlock function. If the sequence in demanding the locks
          is not correct this might cause a deadlock.

SEE ALSO


16.28.2 sge_sl_append_after

NAME
          sge_sl_append_after() -- Appends a new element after another one

SYNOPSIS
          bool
          sge_sl_append_after(sge_sl_list_t *list,
                              sge_sl_elem_t *new_elem, sge_sl_elem_t *elem)

FUNCTION
          This elements appends 'new_elem' into 'list' after 'elem'.

INPUTS
          sge_sl_list_t *list     - sl list
          sge_sl_elem_t *new_elem - new sl elem
          sge_sl_elem_t *elem     - sl elem already part of list

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_sl_append_after() is MT safe

SEE ALSO


16.28.3 sge_sl_create

NAME
          sge_sl_create() -- Create a new simple list

SYNOPSIS
          bool sge_sl_create(sge_sl_list_t **list)

FUNCTION
          This function creates a new simple list and returns the list in the
          'list' parameter. In case of an error NULL will be returned.

INPUTS
          sge_sl_list_t **list - new simple list

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_sl_create() is MT safe

SEE ALSO


16.28.4 sge_sl_data

NAME
          sge_sl_data() -- returns the first or last data element

SYNOPSIS
          bool
          sge_sl_data(sge_sl_list_t *list,
                      void **data, sge_sl_direction_t direction)

FUNCTION
          Depending on 'direction' this function returns the pointer
          to the first/last data object of 'list' in 'data'.

INPUTS
          sge_sl_list_t *list          - list
          void **data                  - data pointer
          sge_sl_direction_t direction - direction

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_sl_data() is MT safe


16.28.5 sge_sl_data_search

NAME
          sge_sl_data_search() --  search a elements in list

SYNOPSIS
          bool
          sge_sl_data_search(sge_sl_list_t *list, void *key, void **data,
                             sge_sl_compare_f compare, sge_sl_direction_t direction)

FUNCTION
          This function tries to find a element in 'list'. As result of the
          search the 'data' pointer will be returned. To find the data pointer
          the 'compare' function and the 'key' will be used. 'key' is past as
          first argument to the 'compare' function. 'direction' decides if
          this function starts the search from beginning or end of the list.

INPUTS
          sge_sl_list_t *list          - list
          void *key                    - search key
          void **data                  - returned data pointer
          sge_sl_compare_f compare     - compare function
          sge_sl_direction_t direction - direction

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_sl_data_search() is MT safe


16.28.6 sge_sl_dechain

NAME
          sge_sl_dechain() -- unchains a element from a list

SYNOPSIS
          bool sge_sl_dechain(sge_sl_list_t *list, sge_sl_elem_t *elem)

FUNCTION
          This functions unchains 'elem' from 'list'. 'elem' can afterwards
          be inserted into a list again or can be destroyed.

INPUTS
          sge_sl_list_t *list - sl list
          sge_sl_elem_t *elem - sl elem

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_sl_dechain() is MT safe

SEE ALSO


16.28.7 sge_sl_delete

NAME
          sge_sl_delete() -- delete first/last element

SYNOPSIS
          bool
          sge_sl_delete(sge_sl_list_t *list, sge_sl_destroy_f destroy,
                        sge_sl_direction_t direction)

FUNCTION
          This function deletes the first/last element of 'list' depending
          on the provided 'direction'. If 'destroy' is not NULL then
          this function will be used to destroy the element data.

INPUTS
          sge_sl_list_t *list          - list
          sge_sl_destroy_f destroy     - destroy
          sge_sl_direction_t direction - direction

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_sl_delete() is MT safe


16.28.8 sge_sl_delete_search

NAME
          sge_sl_delete_search() -- search a element and delete it

SYNOPSIS
          bool
          sge_sl_delete_search(sge_sl_list_t *list, void *key,
                               sge_sl_destroy_f destroy,
                               sge_sl_compare_f compare,
                               sge_sl_direction_t direction)

FUNCTION
          This function searches a element in 'list' using the 'key' and
          'compare' function and then deletes it. If 'direction' is
          SGE_SL_FORWARD then the search will start from beginning, otherwise
          from the end of the list. The first matched element will be
          destroyed. If there is a 'destroy' function provided then this
          function will be used to destroy the element data.

INPUTS
          sge_sl_list_t *list          - list
          void *key                    - search key
          sge_sl_destroy_f destroy     - destroy function
          sge_sl_compare_f compare     - compare function
          sge_sl_direction_t direction - search direction

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_sl_delete_search() is MT safe


16.28.9 sge_sl_destroy

NAME
          sge_sl_destroy() -- Destroys a simple list

SYNOPSIS
          bool sge_sl_destroy(sge_sl_list_t **list, sge_sl_destroy_f destroy)

FUNCTION
          This function destroys 'list' and sets the pointer to NULL.
          If a 'destroy' function is provided then it will be used
          to destroy all data elements that are referenced by the list
          elements.

INPUTS
          sge_sl_list_t **list     - sl list
          sge_sl_destroy_f destroy - destroy function

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_sl_destroy() is not MT safe

EXAMPLE
          Here is an example for a destroy function for a C string.
          
             bool
             destroy(void **data_ptr) {
                char *string = *(char **) data_ptr;
          
                sge_free(&string);
                return true;
             }

SEE ALSO


16.28.10 sge_sl_elem_count

NAME
          sge_sl_elem_count() -- returns the number of elements

SYNOPSIS
          u_long32 sge_sl_elem_count(sge_sl_list_t *list)

FUNCTION
          This function returns the number of elements contained in 'list'.

INPUTS
          sge_sl_list_t *list - list pointer

RESULT
          u_long32 - number of elements

NOTES
          MT-NOTE: sge_sl_elem_count() is MT safe


16.28.11 sge_sl_elem_create

NAME
          sge_sl_elem_create() -- create a list element

SYNOPSIS
          bool sge_sl_elem_create(sge_sl_elem_t **elem, void *data)

FUNCTION
          This function creates a new sl element that can later on be inserted
          into a sl list.
          
          On success the function creates the element stores the 'data' pointer
          in it and returns the element pointer in 'elem'.
          
          On error false is returned by this function and 'elem' contains a
          NULL pointer.
          
          sge_sl_elem_destroy() can be used to destroy elements that were
          created with this function.

INPUTS
          sge_sl_elem_t **elem - location were the pointer to the new
                                 element will be stored
          void *data           - data pointer that will be stored in elem

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_sl_elem_create() is MT safe

SEE ALSO


16.28.12 sge_sl_elem_data

NAME
          sge_sl_elem_data() -- return first/last data pointer

SYNOPSIS
          void *sge_sl_elem_data(sge_sl_elem_t *elem)

FUNCTION
          returns the stored data pointer of an element

INPUTS
          sge_sl_elem_t *elem - sl element

RESULT
          void * - data pointer

NOTES
          MT-NOTE: sge_sl_elem_data() is MT safe

SEE ALSO


16.28.13 sge_sl_elem_destroy

NAME
          sge_sl_elem_destroy() -- destroys a sl element

SYNOPSIS
          bool sge_sl_elem_destroy(sge_sl_elem_t **elem, sge_sl_destroy_f destroy)
          
          typedef bool (*sge_sl_destroy_f)(void **data);

FUNCTION
          This function destroys the provided sl 'elem' and optionally destroys
          also the data that is referenced in the element if a 'destroy'
          function is passed.
          
          If 'elem' is part of a list it has to be unchained before this
          function can be called. Otherwise the list would be corrupted.
          
          On success elem will be set to NULL and the function returns true.

INPUTS
          sge_sl_elem_t **elem     - pointer to a sl element pointer
          sge_sl_destroy_f destroy - destroy function

RESULT
          bool - error state
             true  - success
             false - error

EXAMPLE
          Here is an example for a destroy function for a C string.
          
             bool
             destroy(void **data_ptr) {
                char *string = *(char **) data_ptr;
          
                sge_free(&string);
                return true;
             }

NOTES
          MT-NOTE: sge_sl_elem_destroy() is MT safe.

SEE ALSO


16.28.14 sge_sl_elem_next

NAME
          sge_sl_elem_next() -- provides the next element in sequence

SYNOPSIS
          bool
          sge_sl_elem_next(sge_sl_list_t *list,
                           sge_sl_elem_t **elem, sge_sl_direction_t direction)

FUNCTION
          This function provides the possibility to iterate over all elements
          in 'list'. 'elem' will contain a pointer to an element when the
          function returns or the value NULL.  'elem' is also an input
          parameter and it defines what element of 'list' is returned.
          
          If *elem is NULL and direction is SGE_SL_FORWARD them *elem will
          contain the first element in 'list'. If direction is SGE_SL_BACKWARD
          then it will contain the last.
          
          If *elem is not NULL then the next element in the list sequence is
          returned if direction is SGE_SL_FORWARD or the previous one if
          direction is SGE_SL_BACKWARD.
          
          If the list is empty or if there is no previous/next element then
          NULL will be retuned in 'elem'.

INPUTS
          sge_sl_list_t *list          - sl list
          sge_sl_elem_t **elem         - input/output sl elem
          sge_sl_direction_t direction - direction

RESULT
          bool - error state
             true  - success
             false - error

EXAMPLE
          Following code shows how it is possible to iterate over
          the whole list:
          
          {
             sge_sl_list_t *list;
             sge_sl_elem_t *next;
             sge_sl_elem_t *current;
          
             // assume that elements are added to the list here
          
             next = NULL;
             sge_sl_elem_next(list, &next, SGE_SL_FORWARD);
             while ((current = next) != NULL) {
                sge_sl_elem_next(list, &next, SGE_SL_FORWARD);
          
                // so something with 'current' here
             }
          }

NOTES
          MT-NOTE: sge_sl_elem_next() is MT safe

SEE ALSO


16.28.15 sge_sl_elem_search

NAME
          sge_sl_elem_search() -- searches the next element in sequence

SYNOPSIS
          bool
          sge_sl_elem_search(sge_sl_list_t *list, sge_sl_elem_t **elem,
                             void *key, sge_sl_compare_f compare,
                             sge_sl_direction_t direction)

FUNCTION
          This function provides the possibility to iterate over certain
          elements in 'list'. 'elem' will contain a pointer to an element when
          the function returns or the value NULL.  'elem' is also an input
          parameter and it defines what element of 'list' is returned.
          
          If *elem is NULL and direction is SGE_SL_FORWARD then *elem will
          contain the first element in 'list' that is equivalent with the
          provided 'key'.  If direction is SGE_SL_BACKWARD then it will contain
          the last element that matches.
          
          If *elem is not NULL then the next element in the list sequence is
          returned if direction is SGE_SL_FORWARD or the previous one if
          direction is SGE_SL_BACKWARD.
          
          If the list is empty or if there is no previous/next element then
          NULL will be retuned in 'elem'.
          
          The provided 'compare' function is used to compare the provided 'key'
          with the data that is contained in the element. 'key' is passed as
          first parameter to the 'compare' function.

INPUTS
          sge_sl_list_t *list          - sl list
          sge_sl_elem_t **elem         - input/output sl elem
          void *key                    - key that must match
          sge_sl_compare_f compare     - compare function
          sge_sl_direction_t direction - search direction

RESULT
          bool - error state
             true  - success
             false - error

EXAMPLE
          This compare function could match static C strings stored in
          a sl list as data pointers.
          
          int
          fnmatch_compare(const void *key_pattern, const void *data) {
             int ret = 0;
          
             if (key_pattern != NULL && data != NULL) {
                ret = fnmatch(*(char**)key_pattern, *(char**)data, 0);
             }
             return ret;
          }

NOTES
          MT-NOTE: sge_sl_elem_search() is MT safe

SEE ALSO


16.28.16 sge_sl_get_mutex

NAME
          sge_sl_get_mutex() -- returns the list mutex

SYNOPSIS
          pthread_mutex_t * sge_sl_get_mutex(sge_sl_list_t *list)

FUNCTION
          retrns the list mutex

INPUTS
          sge_sl_list_t *list - list

RESULT
          pthread_mutex_t * - mutex used in the list to secure actions

NOTES
          MT-NOTE: sge_sl_get_mutex() is MT safe


16.28.17 sge_sl_insert

NAME
          sge_sl_insert() -- insert a new element

SYNOPSIS
          bool
          sge_sl_insert(sge_sl_list_t *list,
                        void *data, sge_sl_direction_t direction)

FUNCTION
          Insert a new node in 'list' that references 'data'. If 'direction'
          is SGE_SL_FORWARD then the element will be inserted at the beginning
          of 'list' otherwise at the end.

INPUTS
          sge_sl_list_t *list - simple list
          void *data          - data
          sge_sl_direction_t  - direction

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_sl_insert() is MT safe

SEE ALSO


16.28.18 sge_sl_insert_before

NAME
          sge_sl_insert_before() -- inserts a new element before another one

SYNOPSIS
          bool
          sge_sl_insert_before(sge_sl_list_t *list,
                               sge_sl_elem_t *new_elem, sge_sl_elem_t *elem)

FUNCTION
          Inserts 'new_elem' before 'elem' in 'list'. 'elem' must be
          an element already part of 'list'.

INPUTS
          sge_sl_list_t *list     - sl list
          sge_sl_elem_t *new_elem - new sl element
          sge_sl_elem_t *elem     - sl elem already part of 'list"

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_sl_insert_before() is MT safe

SEE ALSO


16.28.19 sge_sl_insert_search

NAME
          sge_sl_insert_search() -- inserts a new element in a sorted list

SYNOPSIS
          bool sge_sl_insert_search(sge_sl_list_t *list, void *data,
                             sge_sl_compare_f *compare)

FUNCTION
          Inserts a new element in 'list' that references 'data'. The function
          assumes that 'list' is sorted in ascending order. To find the correct
          position for the new element the 'compare' function will be used.

INPUTS
          sge_sl_list_t *list      - list
          void *data               - data reference
          sge_sl_compare_f compare - compare function

RESULT
          bool - error state
             true  - success
             false - error

EXAMPLE
          Example for a compare function when data is a C string
          
          int
          compare(const void *data1, const void *data2) {
             int ret = 0;
          
             if (data1 != NULL && data2 != NULL) {
                ret = strcmp(*(char**)data1, *(char**)data2);
             }
             return ret;
          }

NOTES
          MT-NOTE: sge_sl_insert_search() is MT safe

SEE ALSO


16.28.20 sge_sl_lock

NAME
          sge_sl_lock() -- locks a list

SYNOPSIS
          bool sge_sl_lock(sge_sl_list_t *list)

FUNCTION
          A call of this functions locks the provided 'list' so that all
          list operations executed between the lock and unlock are
          executed as atomic operation.

INPUTS
          sge_sl_list_t *list - list

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_sl_lock() is MT safe

SEE ALSO


16.28.21 sge_sl_sort

NAME
          sge_sl_sort() -- Sorts the list

SYNOPSIS
          bool sge_sl_sort(sge_sl_list_t *list, sge_sl_compare_f compare)

FUNCTION
          This function sorts the 'list' with the quick sort algorithm.
          'compare' function will be used to compare the list elements.

INPUTS
          sge_sl_list_t *list      - list
          sge_sl_compare_f compare - compare function

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_sl_sort() is MT safe

SEE ALSO


16.28.22 sge_sl_unlock

NAME
          sge_sl_unlock() -- unlocks a list

SYNOPSIS
          bool sge_sl_unlock(sge_sl_list_t *list)

FUNCTION
          A call of this functions unlocks the provided 'list' that was
          previously locked with sge_sl_lock.

INPUTS
          sge_sl_list_t *list - list

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_sl_unlock() is MT safe

SEE ALSO


16.29 spool


16.29.1 sge_file_path_format_t

NAME
          sge_file_path_format_t -- Format of filename and pathname

SYNOPSIS
          typedef enum {
             FORMAT_DEFAULT      = 0x0000,
             FORMAT_DOT_FILENAME = 0x0001,
             FORMAT_FIRST_PART   = 0x0002,
             FORMAT_SECOND_PART  = 0x0004,
             FORMAT_THIRD_PART   = 0x0008
          } sge_file_path_format_t;

FUNCTION
          These constants are used with sge_get_file_path() to retrieve
          file and pathnames for objects which should be spooled onto
          a filesystem.
          
          FORMAT_DEFAULT - as it says the default format
          
          FORMAT_DOT_FILENAME - insert a '.' in front of the filename
                                (e.g. '/path/path/.filename)
          
          FORMAT_FIRST_PART   - first part of pathname (e.g /path)
          
          FORMAT_SECOND_PART  - (e.g /path/part2)
          
          FORMAT_THIRD_PART   - (e.g /path/part2/part3)


16.29.2 sge_file_path_id_t

NAME
          sge_file_path_id_t -- Type of filename or pathname

SYNOPSIS
          typedef enum {
             JOBS_SPOOL_DIR,
             JOB_SPOOL_DIR,
             JOB_SPOOL_DIR_AS_FILE,
             JOB_SPOOL_FILE,
             TASKS_SPOOL_DIR,
             TASK_SPOOL_DIR,
             TASK_SPOOL_DIR_AS_FILE,
             TASK_SPOOL_FILE,
             PE_TASK_SPOOL_FILE,
             JOB_SCRIPT_DIR,
             JOB_SCRIPT_FILE,
             JOB_ACTIVE_DIR
          } sge_file_path_id_t;

FUNCTION
          Type of filename or pathname if no other sge_spool_flags_t
          and/or sge_file_path_format_t are specified
          with sge_get_file_path():
          
          JOBS_SPOOL_DIR - "./jobs"
          
          JOB_SPOOL_DIR - "./jobs/xx/yyyy/zzzz"
                          zzzz is a directory
                          'xxyyyyzzzz' is a job id
          
          JOB_SPOOL_DIR_AS_FILE - "./jobs/xx/yyyy/zzzz"
                                  zzzz is a file
                                  'xxyyyyzzzz' is a job id
          
          JOB_SPOOL_FILE - "./jobs/xx/yyyy/zzzz/common"
          
          TASKS_SPOOL_DIR - "./jobs/xx/yyyy/zzzz/1-4096"
                           (example for task ids between 1 and 4096)
          
          TASK_SPOOL_DIR - "./jobs/xx/yyyy/zzzz/1-4096/1"
                            (example for task with id 1 (directory))
          
          TASK_SPOOL_DIR_AS_FILE - "./jobs/xx/yyyy/zzzz/1-4096/1"
                                   (example for task with id 1 (file))
          
          TASK_SPOOL_FILE - "./jobs/xx/yyyy/zzzz/1-4096/1/common"
                            (example for task with id 1)
          
          PE_TASK_SPOOL_FILE - "./jobs/xx/yyyy/zzzz/1-4096/1/1"
                            (example for ja_task 1 pe_task 1)
          
          JOB_SCRIPT_DIR - "./job_scripts"
          
          JOB_SCRIPT_FILE - "./job_scripts/1234"
                            (if job id is 1234)
          
          JOB_ACTIVE_DIR - "./active_jobs"


16.29.3 sge_get_active_job_file_path

NAME
          sge_get_active_job_file_path() -- Create paths in active_jobs dir

SYNOPSIS
          const char* sge_get_active_job_file_path(dstring *buffer,
             u_long32 job_id, u_long32 ja_task_id, const char *pe_task_id,
             const char *filename)

FUNCTION
          Creates paths in the execd's active_jobs directory.
          Both directory and file paths can be created.
          The result is placed in a buffer provided by the caller.
          
          WARNING: Do only use in shepherd and execution daemon!

INPUTS
          dstring *buffer        - buffer to hold the generated path
          u_long32 job_id        - job id
          u_long32 ja_task_id    - array task id
          const char *pe_task_id - optional pe task id
          const char *filename   - optional file name

RESULT
          const char* - pointer to the string buffer on success, else NULL

EXAMPLE
          To create the relative path to a jobs/tasks environment file, the
          following call would be used:
          
          char buffer[SGE_PATH_MAX]
          sge_get_active_job_file_path(buffer, SGE_PATH_MAX,
                                       job_id, ja_task_id, pe_task_id,
                                       "environment");
          

NOTES
          JG: TODO: The function might be converted to or might use a more
          general path creating function (utilib).

SEE ALSO


16.29.4 sge_get_confval

NAME
          sge_get_confval() -- Get config value for

SYNOPSIS
          char* sge_get_confval(const char *conf_val, const char *fname)

FUNCTION
          Get config value for entry 'conf_val' from file 'fname'.

INPUTS
          const char *conf_val - is case insensitive name
          const char *fname    - filename

RESULT
          char* - pointer to internal static buffer

NOTES
          Lines may be up to 1024 characters long. Up to 1024 characters of the
          config value are copied to the static buffer.

NOTES
          Lines may be up to 1024 characters long. Up to 1024 characters of the
          config value are copied to the static buffer.


16.29.5 sge_get_confval_array

NAME
          sge_get_confval_array() - Read configuration file entries

SYNOPSIS
          int sge_get_confval_array(const char *fname, int n,
                                    const char *name[],
                                    char value[][1025],
                                    dstring *error_dstring)

FUNCTION
          Reads in an array of configuration file entries

RESULT
          int - 0 on success

BUGS
          Function can not differ multiple similar named entries.

NOTES
          MT-NOTE: sge_get_confval_array() is MT safe


16.29.6 sge_get_file_path

NAME
          sge_get_file_path() -- Return SGE/EE specific file/pathname

SYNOPSIS
          char* sge_get_file_path(char *buffer, sge_file_path_id_t id,
                                  sge_file_path_format_t format_flags,
                                  sge_spool_flags_t spool_flags,
                                  u_long32 ulong_val1, u_long32 ulong_val2,
                                  const char *string_val1)

FUNCTION
          ???

INPUTS
          char *buffer                        - buffer for file/pathname
          sge_file_path_id_t id               - type of file/pathname
          sge_file_path_format_t format_flags - format of returned string
          sge_spool_flags_t spool_flags       - context where the name is
                                                needed
          u_long32 ulong_val1                 - 1st ulong
          u_long32 ulong_val2                 - 2nd ulong
          const char *string_val1             - 1st string

RESULT
          char* - equivalent with 'buffer'

NOTES
          MT-NOTE: sge_get_file_path() is not MT safe due to get_spool_dir_range()

SEE ALSO


16.29.7 sge_get_ja_tasks_per_directory

NAME
          sge_get_ja_tasks_per_directory() -- Configured number of tasks per dir

SYNOPSIS
          u_long32 sge_get_ja_tasks_per_directory(void)

FUNCTION
          Returns the configured number of tasks per directory

RESULT
          u_long32 - the number

NOTES
          MT-NOTE: sge_get_ja_tasks_per_directory() is not MT safe


16.29.8 sge_get_ja_tasks_per_file

NAME
          sge_get_ja_tasks_per_file() -- Configured number of tasks per file

SYNOPSIS
          u_long32 sge_get_ja_tasks_per_file(void)

FUNCTION
          Returns the configured number of tasks per file

RESULT
          u_long32 - the number

NOTES
          MT-NOTE: sge_get_ja_tasks_per_file() is not MT safe


16.29.9 sge_get_management_entry

NAME
          sge_get_management_entry() - Read management.properties file entries

SYNOPSIS
          int sge_get_management_entry(const char *fname, int n,
                                    const char *name[],
                                    char value[][1025],
                                    dstring *error_dstring)

FUNCTION
          Reads in an array of configuration file entries

RESULT
          int - 0 on success

BUGS
          Function can not differ multiple similar named entries.

NOTES
          MT-NOTE: sge_get_management_entry() is MT safe


16.29.10 sge_readpid

NAME
          sge_readpid() -- Read pid from file

SYNOPSIS
          pid_t sge_readpid(const char *fname)

FUNCTION
          Read pid from file 'fname'. The pidfile may be terminated with
          a '\n'. Empty lines at the beginning of the file are ignored.
          Whitespaces at the beginning of the line are ignored.
          Any characters or lines after a valid pid are ignored.

INPUTS
          const char *fname - filename

RESULT
          pid_t - process id

NOTES
          MT-NOTE: sge_readpid() is MT safe.


16.29.11 sge_silent_get

NAME
          sge_silent_get() -- Show whether silence is enable/disabled

SYNOPSIS
          int sge_silent_get()

FUNCTION
          Show whether silence is enable/disabled

RESULT
          int - 0 or 1

SEE ALSO

NOTES
          MT-NOTE: sge_silent_get() is not MT safe


16.29.12 sge_silent_set

NAME
          sge_silent_set() -- Enable/disable silence during spool ops

SYNOPSIS
          void sge_silent_set(int i)

FUNCTION
          Enable/disable silence during spool operations. Silence means
          that no messages are printed to stdout.

INPUTS
          int i - 0 or 1

SEE ALSO

NOTES
          MT-NOTE: sge_silent_set() is not MT safe


16.29.13 sge_spool_flags_t

NAME
          sge_spool_flags_t -- Context information for spooling functions

SYNOPSIS
          typedef enum {
             SPOOL_DEFAULT               = 0x0000,
             SPOOL_HANDLE_AS_ZOMBIE      = 0x0001,
             SPOOL_WITHIN_EXECD          = 0x0002,
             SPOOL_IGNORE_TASK_INSTANCES = 0x0004,
             SPOOL_HANDLE_PARALLEL_TASKS = 0x0008,
          } sge_spool_flags_t;

FUNCTION
          These constants are necessary to provide spooling functions
          with context information where they are called and what they
          should do. It depends on these spooling functions, how these
          constants are interpreted. The documentation of these
          routines may give you a more detailed description than you
          may find here.
          
          SPOOL_DEFAULT - as it says the standard case
          
          SPOOL_HANDLE_AS_ZOMBIE - used mostly for jobs/array tasks
                                   which are already finished and
                                   stored in the list of zombie jobs.
          
          SPOOL_WITHIN_EXECD - Used for objects which are spooled
                               within the execd.
          
          SPOOL_IGNORE_TASK_INSTANCES - Dont't handle array tasks.
          
          SPOOL_HANDLE_PARALLEL_TASKS - Spool pe tasks individually.
          
          SPOOL_ONLY_JATASK - spool only the ja_task, neither job nor pe_tasks
          
          SPOOL_ONLY_PETASK - spool only the pe_task, neither job nor ja_task


16.29.14 sge_spoolmsg_write

NAME
          sge_spoolmsg_write() -- add a comment in a file

SYNOPSIS
          int sge_spoolmsg_write(FILE *file, char comment_char)

FUNCTION
          This function writes an additional comment into a file. First
          character in a comment line is 'comment_char'.

INPUTS
          FILE *file        - file descriptor
          char comment_char - first character in a comment line

RESULT
          -1 on error else 0

NOTES
          MT-NOTE: sge_spoolmsg_write() is not MT safe due to FPRINTF() macro


16.29.15 sge_status_end_turn

NAME
          sge_status_end_turn() -- remove washing machine from display

SYNOPSIS
          void sge_status_end_turn(void)

FUNCTION
          Last turn of washing machine.

NOTES
          MT-NOTE: sge_status_end_turn() is not MT safe


16.29.16 sge_status_next_turn

NAME
          sge_status_next_turn() -- show next turn

SYNOPSIS
          void sge_status_next_turn(void)

FUNCTION
          Show next turn of rotating washing machine.

NOTES
          MT-NOTE: sge_status_next_turn() is not MT safe


16.29.17 sge_status_set_type

NAME
          sge_status_set_type() -- set display mode

SYNOPSIS
          void sge_status_set_type(washing_machine_t type)

FUNCTION
          With 'STATUS_ROTATING_BAR' each call of
          sge_status_next_turn() will show a rotating bar.
          In 'STATUS_DOTS'-mode each call will show more
          dots in a line.

INPUTS
          washing_machine_t type - display type
             STATUS_ROTATING_BAR
             STATUS_DOTS

NOTES
          MT-NOTE: sge_status_set_type() is not MT safe


16.29.18 sge_write_pid

NAME
          sge_write_pid() -- Write pid into file

SYNOPSIS
          void sge_write_pid(const char *pid_log_file)

FUNCTION
          Write pid into file

INPUTS
          const char *pid_log_file - filename

NOTES
          MT-NOTE: sge_write_pid() is MT safe


16.30 stdio


16.30.1 CLOSE

NAME
          CLOSE() -- close() macro

SYNOPSIS
          #define CLOSE(argument)
          int close(int fd)

FUNCTION
          This CLOSE macro has to be used similar to the close
          function. It is not necessary to check the return value.
          In case of an error the macro will jump to a defined label.
          The label name is 'CLOSE_ERROR'.

INPUTS
          int fd       - file descriptor

NOTES
          Don't forget to define the 'CLOSE_ERROR'-label


16.30.2 FCLOSE

NAME
          FCLOSE() -- fclose() macro

SYNOPSIS
          #define FCLOSE(argument)
          int fclose(FILE *stream)

FUNCTION
          This FCLOSE macro has to be used similar to the fclose
          function. It is not necessary to check the return value.
          In case of an error the macro will jump to a defined label.
          The label name is 'FCLOSE_ERROR'.

INPUTS
          FILE *stream       - output stream

NOTES
          Don't forget to define the 'FCLOSE_ERROR'-label


16.30.3 FPRINTF

NAME
          FPRINTF() -- fprintf() macro

SYNOPSIS
          #define FPRINTF(arguments)
          void fprintf(FILE *stream, const char *format, ...)

FUNCTION
          This FPRINTF macro has to be used similar to the fprintf
          function. It is not necessary to check the return value.
          In case of an error the macro will jump to a defined label.
          The label name is 'FPRINTF_ERROR'.

INPUTS
          FILE *stream       - output stream
          const char *format - format string
          ...

NOTES
          Don't forget to define the 'FPRINTF_ERROR'-label


16.30.4 FPRINTF_ASSIGN

NAME
          FPRINTF_ASSIGN() -- fprintf() macro with return value assignment

SYNOPSIS
          #define FPRINTF_ASSIGN(var, arguments)
          void fprintf(FILE *stream, const char *format, ...)

FUNCTION
          This FPRINTF macro has to be used similar to the fprintf
          function. It is not necessary to check the return value.
          In case of an error the macro will jump to a defined label.
          The label name is 'FPRINTF_ERROR'. This is a variarion of
          FPRINTF() that allows assigning the fprintf() return value to
          the variable passed as first makro argument.

INPUTS
          FILE *stream       - output stream
          const char *format - format string
          ...

NOTES
          Don't forget to define the 'FPRINTF_ERROR'-label


16.30.5 FSCANF

NAME
          FSCANF() -- fscanf() macro

SYNOPSIS
          #define FSCANF(n, arguments)
          void fscanf(FILE *stream, const char *format, ...)

FUNCTION
          This FSCANF macro is used similarly to the fscanf function,
          except that the first argument is the number of items which
          must be read.  It is not necessary to check the return value;
          In case too few items are read, the macro will jump to a
          defined label.  The label name is 'FSCANF_ERROR'.

INPUTS
          FILE *stream       - output stream
          const char *format - format string
          ...

NOTES
          Don't forget to define the 'FSCANF_ERROR'-label


16.30.6 sge_peclose

NAME
          sge_peclose() -- pclose() call which is suitable for sge_peopen()

SYNOPSIS
          int sge_peclose(pid_t pid, FILE *fp_in, FILE *fp_out,
                          FILE *fp_err, struct timeval *timeout)

FUNCTION
          ???

INPUTS
          pid_t pid               - pid returned by peopen()
          FILE *fp_in
          FILE *fp_out
          FILE *fp_err
          struct timeval *timeout

RESULT
          int - exit code of command or -1 in case of errors

SEE ALSO

NOTES
          MT-NOTE: sge_peclose() is MT safe


16.30.7 sge_peopen_r

NAME
          sge_peopen_r() -- Advanced popen()

SYNOPSIS
          pid_t sge_peopen_r(const char *shell, int login_shell,
                             const char *command, const char *user,
                             char **env, FILE **fp_in, FILE **fp_out,
                             FILE **fp_err)

FUNCTION
          Advanced popen() with additional parameters:
             - free shell usage
             - login shell if wanted
             - user under which to start (for root only)
             - stdin and stderr file pointers
             - wait for exactly the process we started
          File descriptors have to be closed with sge_peclose().
          
          This function is reentrant as long as env is not provided to
          this function. This means that the function can be used in
          multi thread processed as long as env is not used.

INPUTS
          const char *shell   - which shell to use
          int login_shell     - make it a login shell?
          const char *command - name of the program
          const char *user    - user under which to start (for root only)
          char **env          - env variables to add to child
          FILE **fp_in        - file input stream
          FILE **fp_out       - file output stream
          FILE **fp_err       - file error stream

RESULT
          pid_t - process id

NOTES
          MT-NOTE: sge_peopen_r() is MT safe

DUE TO THE FACT THAT THIS FUNCTION WILL BE USED IN QMASTER
          (MULTITHREADED ENVIRONMENT) THIS MIGHT CAUSE A DEADLOCK
          IN A MASTER THREAD.

SEE ALSO


16.31 stdlib


16.31.1 sge_free

NAME
          sge_free() -- replacement for free

SYNOPSIS
          void sge_free(void *cp)

FUNCTION
          Replacement for free function. Accepts NULL pointers.

INPUTS
          void *cp - pointer to a pointer of a memory block

NOTES
          MT-NOTE: sge_free() is MT safe


16.31.2 sge_getenv

NAME
          sge_getenv() -- get an environment variable

SYNOPSIS
          const char* sge_getenv(const char *env_str)

FUNCTION
          The function searches the environment list for a
          string that matches the string pointed to by 'env_str'.

INPUTS
          const char *env_str - name of env. varibale

RESULT
          const char* - value

SEE ALSO

NOTES
          MT-NOTE: sge_getenv() is MT safe


16.31.3 sge_malloc

NAME
          sge_malloc() -- replacement for malloc()

SYNOPSIS
          void* sge_malloc(size_t size)

FUNCTION
          Allocates a memory block. Initilizes the block (0). Aborts in case
          of error.

INPUTS
          size_t size - size in bytes

RESULT
          void* - pointer to memory block

NOTES
          MT-NOTE: sge_malloc() is MT safe


16.31.4 sge_maybe_set_dumpable

NAME
          sge_maybe_set_dumpable() -- maybe allow core dumps after sge_setuid & al

SYNOPSIS
          void sge_maybe_set_dumpable(void gid)

FUNCTION
          Conditionally allows dumping core after calls to sge_setuid & al.
          The condition is that SGE_ENABLE_COREDUMP is set in the environment.

NOTES
          MT-NOTE: sge_maybe_set_dumpable() is not MT safe


16.31.5 sge_putenv

NAME
          sge_putenv() -- put an environment variable to environment

SYNOPSIS
          static int sge_putenv(const char *var)

FUNCTION
          Duplicates the given environment variable and calls the system call
          putenv.

INPUTS
          const char *var - variable to put in the form <name>=<value>

RESULT
          static int - 1 on success, else 0

SEE ALSO

NOTES
          MT-NOTE: sge_putenv() is MT safe


16.31.6 sge_realloc

NAME
          sge_realloc() -- replacement for realloc

SYNOPSIS
          char* sge_realloc(char *ptr, int size, int abort)

FUNCTION
          Reallocates a memory block. Aborts in case of an error.

INPUTS
          char *ptr - pointer to a memory block
          int size  - new size
          int abort - do abort when realloc fails?

RESULT
          char* - pointer to the (new) memory block

NOTES
          MT-NOTE: sge_realloc() is MT safe


16.31.7 sge_setegid

NAME
          sge_setegid() -- set effective group id

SYNOPSIS
          int sge_setegid(gid_t gid)

FUNCTION
          Call setegid and maybe call prctl, or similar, afterwards.
          prctl is called under Linux to allow core dumps subsequently.
          That is only done if global sge_dumpable is non-zero.

INPUTS
          gid_t gid - gid to set

RESULT
          Per setegid

NOTES
          MT-NOTE: MT safe as long as sge_dumpable is only set before
          threads are started.


16.31.8 sge_setenv

NAME
          sge_setenv() -- Change or add an environment variable

SYNOPSIS
          int sge_setenv(const char *name, const char *value)

FUNCTION
          Change or add an environment variable

INPUTS
          const char *name  - variable name
          const char *value - new value

RESULT
          int - error state
              1 - success
              0 - error

SEE ALSO

NOTES
          MT-NOTE: sge_setenv() is MT safe


16.31.9 sge_seteuid

NAME
          sge_seteuid() -- set effective user id

SYNOPSIS
          int sge_seteuid(uid_t uid)

FUNCTION
          Call seteuid and maybe call prctl, or similar, afterwards.
          prctl is called under Linux to allow core dumps subsequently.
          That is only done if global sge_dumpable is non-zero.

INPUTS
          uid_t uid - uid to set

RESULT
          Per seteuid

NOTES
          MT-NOTE: MT safe as long as sge_dumpable is only set before
          threads are started.


16.31.10 sge_setgid

NAME
          sge_setgid() -- set group id

SYNOPSIS
          int sge_setgid(gid_t gid)

FUNCTION
          Call setgid and maybe call prctl, or similar, afterwards.
          prctl is called under Linux to allow core dumps subsequently.
          That is only done if global sge_dumpable is non-zero.

INPUTS
          gid_t gid - gid to set

RESULT
          Per setuid

NOTES
          MT-NOTE: MT safe as long as sge_dumpable is only set before
          threads are started.


16.31.11 sge_setuid

NAME
          sge_setuid() -- set user id

SYNOPSIS
          int sge_setuid(uid_t uid)

FUNCTION
          Call setuid and maybe call prctl, or similar, afterwards.
          prctl is called under Linux to allow core dumps subsequently.
          That is only done if global sge_dumpable is non-zero.

INPUTS
          uid_t uid - uid to set

RESULT
          Per setuid

NOTES
          MT-NOTE: MT safe as long as sge_dumpable is only set before
          threads are started.


16.31.12 sge_unsetenv

NAME
          sge_unsetenv() -- unset environment variable

SYNOPSIS
          void sge_unsetenv(const char* varName)

FUNCTION
          Some architectures doesn't support unsetenv(), sge_unsetenv() is used
          to unset an environment variable.

INPUTS
          const char* varName - name of envirionment variable

RESULT
          void - no return value

NOTES
          MT-NOTE: sge_unsetenv() is not MT safe


16.32 string


16.32.1 sge_basename

NAME
          sge_basename() -- get basename for path

SYNOPSIS
          char* sge_basename(const char *name, int delim)

FUNCTION
          Determines the basename for a path like string - the last field
          of a string where fields are separated by a fixed one character
          delimiter.

INPUTS
          const char *name - contains the input string (path)
          int delim        - delimiter

RESULT
          char* - pointer to base of name after the last delimter
                  NULL if "name" is NULL or zero length string or
                  delimiter is the last character in "name"

EXAMPLE
          sge_basename("/usr/local/bin/flex", '/'); returns "flex"

NOTES
          MT-NOTE: sge_basename() is MT safe


16.32.2 sge_compress_slashes

NAME
          sge_compress_slashes() -- compresses sequences of slashes

SYNOPSIS
          void sge_compress_slashes(char *str)

FUNCTION
          Compresses sequences of slashes in str to one slash

INPUTS
          char *str - string (e.g. path)

NOTES
          MT-NOTE: sge_compress_slashes() is MT safe


16.32.3 sge_delim_str

NAME
          sge_delim_str() -- Trunc. a str according to a delimiter set

SYNOPSIS
          char* sge_delim_str(char *str, char **delim_pos,
                              const char *delim)

FUNCTION
          Truncates a string according to a delimiter set. A copy of
          the string truncated according to the delimiter set will be
          returned.
          
          ATTENTION: The user is responsible for freeing the allocated
          memory outside this routine. If not enough space could be
          allocated, NULL is returned.

INPUTS
          char *str         - string to be truncated
          char **delim_pos  - A placeholder for the delimiting position
                              in str on exit.
                              If set on entry the position of the
                              delimiter in the input string 'str' is
                              returned. If no delimiting character in
                              string was found, the address of the
                              closing '\0' in 'str' is returned.
          const char *delim - string containing delimiter characters

RESULT
          char* - Truncated copy of 'str' (Has to be freed by the caller!)

NOTES
          MT-NOTE: sge_delim_str() is MT safe


16.32.4 sge_dirname

NAME
          sge_dirname() -- Return first part of string up to deliminator

SYNOPSIS
          char* sge_dirname(const char *name, int delim)

FUNCTION
          The function will return a malloced string containing the first
          part of 'name' up to, but not including deliminator. NULL will
          be returned if 'name' is NULL or a zero length string or if
          'delim' is the first character in 'name'

INPUTS
          const char *name - string
          int delim        - deliminator

RESULT
          char* - malloced string

NOTES
          This routine is called "dirname" in opposite to "basename"
          but is mostly used to strip off the domainname of a FQDN
          MT-NOTE: sge_dirname() is MT safe


16.32.5 sge_free_saved_vars

NAME
          sge_free_saved_vars() -- Free 'context' of sge_strtok_r()

SYNOPSIS
          void sge_free_saved_vars(struct saved_vars_s *context)

FUNCTION
          Free 'context' of sge_strtok_r()

INPUTS
          struct saved_vars_s *context

SEE ALSO

NOTES
          MT-NOTE: sge_free_saved_vars() is MT safe


16.32.6 sge_is_expression

NAME
          sge_is_expression() -- Test if string contains expressions & wildcard pattern

SYNOPSIS
          int sge_is_expression(const char *s)

FUNCTION
          Check whether string 's' contains a expressions & a wildcard pattern.

INPUTS
          const char *s - string

RESULT
          int - result
              0 - no wildcard pattern
              1 - it is a wildcard pattern

NOTES
          MT-NOTE: sge_is_expression() is MT safe


16.32.7 sge_is_pattern

NAME
          sge_is_pattern() -- Test if string contains  wildcard pattern

SYNOPSIS
          int sge_is_pattern(const char *s)

FUNCTION
          Check whether string 's' contains a wildcard pattern.

INPUTS
          const char *s - string

RESULT
          int - result
              0 - no wildcard pattern
              1 - it is a wildcard pattern

NOTES
          MT-NOTE: sge_is_pattern() is MT safe


16.32.8 sge_jobname

NAME
          sge_jobname() -- get jobname of command line string

SYNOPSIS
          const char* sge_jobname(const char *name)

FUNCTION
          Determine the jobname of a command line. The following definition is used
          for the jobname:
          - take everything up to the first semicolon
          - take everything up to the first whitespace
          - take the basename

INPUTS
          const char *name - contains the input string (command line)

RESULT
          const char* - pointer to the jobname
                        NULL if name is NULL or only '\0'

EXAMPLE
          Command line                       jobname
          ----------------------------------------------
          "cd /home/me/5five; hostname" --> cd
          "/home/me/4Ujob"              --> 4Ujob (invalid, will be denied)
          "cat /tmp/5five"              --> cat
          "bla;blub"                    --> bla
          "a b"                         --> a
          

NOTES
          MT-NOTE: sge_jobname() is not MT safe

SEE ALSO


16.32.9 sge_patternnullcmp

NAME
          sge_patternnullcmp() -- like fnmatch

SYNOPSIS
          int sge_patternnullcmp(const char *str, const char *pattern)

FUNCTION
          Like fnmatch() apart from the handling of NULL strings.
          These are treated as being less than any not-NULL strings.
          Important for sorting lists where NULL strings can occur.

INPUTS
          const char *str     - string
          const char *pattern - pattern to match

RESULT
          int - result
              0 - strings are the same or both NULL
             -1 - a < b or a is NULL
              1 - a > b or b is NULL

NOTES
          MT-NOTE: fnmatch uses static variables, not MT safe


16.32.10 sge_replace_substring

NAME
          sge_replace_substring - replace sub strings in a string

SYNOPSIS
          const char *sge_replace_substring(const char *input, char *old, char *new)

FUNCTION
          Replaces all occurences of old with new.
          If old is part of the given string input, a new string is returned
          where the replacement is done.

INPUTS
          const char *input - the input string
          const char *old   - the string to replace
          const char *new   - the replacement string

RESULT
          NULL, if the input string didn't contain the pattern,
          else a newly allocated string containing the input string with replacements.

NOTES
          MT-NOTE: sge_str_is_number() is MT safe
          It is the responsibility of the caller to free the returned string!


16.32.11 sge_str_is_number

NAME
          sge_str_is_number() -- check if a string represents a number

SYNOPSIS
          bool sge_str_is_number(const char *string)

FUNCTION
          This function returns true if the given string represents a
          floating point number.

INPUTS
          const char *string - string to parse

RESULT
          bool - result
             true  - string represents a number
             false - string is not a number

NOTES
          MT-NOTE: sge_str_is_number() is MT safe

SEE ALSO


16.32.12 sge_stracasecmp

NAME
          sge_stracasecmp() -- Find string in string array

SYNOPSIS
          char** sge_stracasecmp(const char *cp, char **cpp)

FUNCTION
          Compare string with string field and return the pointer to
          the matched character pointer. Compare case sensitive.

INPUTS
          const char *cp - string
          char **cpp     - pointer to array of strings

RESULT
          char** - NULL or pointer a string

NOTES
          MT-NOTE: sge_stracasecmp() is MT safe


16.32.13 sge_stradup

NAME
          sge_stradup() -- Duplicate array of strings

SYNOPSIS
          char** sge_stradup(char **cpp, int n)

FUNCTION
          Copy list of character pointers including the strings these
          pointers refer to. If 'n' is 0 strings are '\0'-delimited, if
          'n' is not 0 we use n as length of the strings.

INPUTS
          char **cpp - pointer to array of strings
          int n      - '\0' terminated?

RESULT
          char** - copy of 'cpp'

NOTES
          MT-NOTE: sge_stradup() is MT safe


16.32.14 sge_strafree

NAME
          sge_strafree() -- Free list of character pointers

SYNOPSIS
          void sge_strafree(char **cpp)

FUNCTION
          Free list of character pointers

INPUTS
          char ***cpp - Pointer to array of string pointers

NOTES
          MT-NOTE: sge_strafree() is MT safe


16.32.15 sge_stramemncpy

NAME
          sge_stramemncpy() -- Find string in string array

SYNOPSIS
          char** sge_stramemncpy(const char *cp, char **cpp, int n)

FUNCTION
          Compare string with string field and return the pointer to
          the matched character pointer. Compare exactly n chars
          case insensitive.

INPUTS
             const char *cp - string to be found
             char **cpp     - pointer to array of strings
             int n          - number of chars
          
          NOTES:
             MT-NOTE: sge_stramemncpy() is MT safe

RESULT
          char** - NULL or pointer a string

NOTES
          MT-NOTE: sge_stramemncpy() is MT safe


16.32.16 sge_strdup

NAME
          sge_strdup() -- Replacement for strdup()

SYNOPSIS
          char* sge_strdup(char *old, const char *s)

FUNCTION
          Duplicate string 's'. "Use" 'old' buffer.

INPUTS
          char *old     - buffer (will be freed)
          const char *s - string

RESULT
          char* - malloced string

NOTES
          MT-NOTE: sge_strdup() is MT safe


16.32.17 sge_strerror

NAME
          sge_strerror() -- replacement for strerror

SYNOPSIS
          const char*
          sge_strerror(int errnum)

FUNCTION
          Returns a string describing an error condition set by system
          calls (errno).
          
          Wrapper arround strerror. Access to strerrror is serialized by the
          use of a mutex variable to make strerror thread safe.

INPUTS
          int errnum        - the errno to explain
          dstring *buffer   - buffer into which the error message is written

RESULT
          const char* - pointer to a string explaining errnum

NOTES
          MT-NOTE: sge_strerror() is MT safe


16.32.18 sge_strip_blanks

NAME
          sge_strip_blanks() -- Strip blanks from string

SYNOPSIS
          void sge_strip_blanks(char *str)

FUNCTION
          Strip all blanks contained in a string. The string is used
          both as source and drain for the necessary copy operations.
          The string is '\0' terminated afterwards.

INPUTS
          char *str - pointer to string to be condensed

NOTES
          MT-NOTE: sge_strip_blanks() is MT safe


16.32.19 sge_strip_quotes

NAME
          sge_strip_quotes() -- Strip quotes from string

SYNOPSIS
          void sge_strip_quotes(char **pstr)

FUNCTION
          Strip quotes from "pstr".

INPUTS
          char **pstr - string to be modified

NOTES
          MT-NOTE: sge_strip_quotes() is MT safe


16.32.20 sge_strip_slash_at_eol

NAME
          sge_strip_slash_at_eol() -- truncate slash at EOL

SYNOPSIS
          void sge_strip_slash_at_eol(char *str)

FUNCTION
          Truncate slash from the end of the string

INPUTS
          char *str - string to be modified

RESULT
          void - NONE

NOTES
          MT-NOTE: sge_strip_slash_at_eol() is MT safe


16.32.21 sge_strip_white_space_at_eol

NAME
          sge_strip_white_space_at_eol() -- truncate white space at EOL

SYNOPSIS
          void sge_strip_white_space_at_eol(char *str)

FUNCTION
          Truncate white space from the end of the string

INPUTS
          char *str - string to be modified

RESULT
          void - NONE

NOTES
          MT-NOTE: sge_strip_white_space_at_eol() is MT safe


16.32.22 sge_strisint

NAME
          sge_strisint() -- Is string a integer value in characters?

SYNOPSIS
          int sge_strisint(const char *str)

FUNCTION
          May we convert 'str' to int?

INPUTS
          const char *str - string

RESULT
          int - result
              0 - It is no integer
              1 - It is a integer

NOTES
          MT-NOTE: sge_strisint() is MT safe


16.32.23 sge_strlcat

NAME
          sge_strlcat() -- sge strlcat implementation

SYNOPSIS
          size_t sge_strlcat(char *dst, const char *src, size_t dstsize)

FUNCTION
          appends characters from from "src" to "dst" and terminates
          the dst string with '\0'
          Returns the size required for successfully completing the operation.

INPUTS
          char *dst       - destination
          const char *src - source string (must be '\0' terminated)
          size_t dstsize  - size of destination string

RESULT
          size_t - min{dstsize,strlen(dst)}+strlen(src)
                   this is the size required for successfully completing the strcat.

NOTES
          MT-NOTE: sge_strlcat() is MT safe


16.32.24 sge_strlcpy

NAME
          sge_strlcpy() -- sge strlcpy implementation

SYNOPSIS
          size_t sge_strlcpy(char *dst, const char *src, size_t dstsize)

FUNCTION
          copies "dstsize"-1 characters from from "src" to "dst" and terminates
          the src string with '\0'- Returns the size of the "src" string.

INPUTS
          char *dst       - destination
          const char *src - source string (must be '\0' terminated)
          size_t dstsize  - size of destination string

RESULT
          size_t - strlen of src, not dst !!!

NOTES
          MT-NOTE: sge_strlcpy() is MT safe


16.32.25 sge_strlen

NAME
          sge_strlen() -- replacement for strlen()

SYNOPSIS
          int sge_strlen(const char *str)

FUNCTION
          replacement for strlen

INPUTS
          const char *str - NULL or pointer to string

RESULT
          int - length of string or 0 if NULL pointer

NOTES
          MT-NOTE: sge_strlen() is MT safe


16.32.26 sge_strnullcasecmp

NAME
          sge_strnullcasecmp() -- Like strcasecmp() but honours NULL ptrs.

SYNOPSIS
          int sge_strnullcasecmp(const char *a, const char *b)

FUNCTION
          Like strcasecmp() apart from the handling of NULL strings.
          These are treated as being less than any not-NULL strings.
          Important for sorting lists where NULL strings can occur.

INPUTS
          const char *a - 1st string
          const char *b - 2nd string

RESULT
          int - result
              0 - strings are the same minus case or both NULL
             -1 - a < b or a is NULL
              1 - a > b or b is NULL

NOTES
          MT-NOTE: sge_strnullcasecmp() is MT safe


16.32.27 sge_strnullcmp

NAME
          sge_strnullcmp() -- Like strcmp() but honours NULL ptrs.

SYNOPSIS
          int sge_strnullcmp(const char *a, const char *b)

FUNCTION
          Like strcmp() apart from the handling of NULL strings.
          These are treated as being less than any not-NULL strings.
          Important for sorting lists where NULL strings can occur.

INPUTS
          const char *a - 1st string
          const char *b - 2nd string

RESULT
          int - result
              0 - strings are the same or both NULL
             -1 - a < b or a is NULL
              1 - a > b or b is NULL

NOTES
          MT-NOTE: sge_strnullcmp() is MT safe


16.32.28 sge_strtok

NAME
          sge_strtok() -- Replacement for strtok()

SYNOPSIS
          char* sge_strtok(const char *str, const char *delimiter)

FUNCTION
          Replacement for strtok(). If no delimiter is given
          isspace() is used.

INPUTS
          const char *str       - string which should be tokenized
          const char *delimiter - delimiter string

RESULT
          char* - first/next token of str.

NOTES
          MT-NOTE: sge_strtok() is not MT safe, use sge_strtok_r() instead

SEE ALSO


16.32.29 sge_strtok_r

NAME
          sge_strtok_r() -- Reentrant version of strtok()

SYNOPSIS
          char* sge_strtok_r(const char *str, const char *delimiter,
                             struct saved_vars_s **context)

FUNCTION
          Reentrant version of sge_strtok. When 'str' is not NULL,
          '*context' has to be NULL. If 'str' is NULL, '*context'
          must not be NULL. The caller is responsible for freeing
          '*context' with sge_free_saved_vars().
          If no delimiter is given, isspace() is used.

INPUTS
          const char *str               - str which should be tokenized
          const char *delimiter         - delimiter string
          struct saved_vars_s **context - context

RESULT
          char* - first/next token

SEE ALSO

NOTES
          MT-NOTE: sge_strtok_r() is MT safe


16.32.30 sge_strtoupper

NAME
          sge_strtoupper() -- Convert the first n to upper case

SYNOPSIS
          void sge_strtoupper(char *buffer, int max_len)

FUNCTION
          Convert the first 'max_len' characters to upper case.

INPUTS
          char *buffer - string
          int max_len  - number of chars

NOTES
          MT-NOTE: sge_strtoupper() is MT safe


16.32.31 stra_from_str

NAME
          str_from_str() -- Extract valid qstat options/paramers from qstat profile.

SYNOPSIS
          char **str_from_str(const char *source_str, const char *delim);

FUNCTION
          Parse string 'source_str' based on delimeter(s) 'delim' and store
          resulting tokens in string array 'ret'. Supports comment lines.

INPUTS
          const char *source_str - File content of qstat profile as plain string.
          const char *delim      - Sequence of characters used to identify tokens
                                   and parameters.

RESULT
          char** - String array containing tokens found based on 'delim'.

NOTES
          It is the caller's responsibilty to free dynamic memory allocated in this
          routine.
          MT-NOTE: stra_from_str() is MT safe.


16.33 thread_ctrl


16.33.1 sge_thread_has_shutdown_started

NAME
          sge_thread_has_shutdown_started() -- shutdown in progress?

SYNOPSIS
          bool sge_thread_has_shutdown_started(void)

FUNCTION
          Service function which can be used to check if the executing
          component is already shutting down.

INPUTS
          void - NONE

RESULT
          bool - is in progress?
             true  - yes
             false - no

NOTES
          MT-NOTE: sge_thread_has_shutdown_started() is MT safe


16.33.2 sge_thread_notify_all_waiting

NAME
          sge_thread_notify_all_waiting() -- notify waiting thread

SYNOPSIS
          void sge_thread_notify_all_waiting(void)

FUNCTION
          After the main thread has initialized all needed components and
          threads it waits for a certain condition to be signaled
          (sge_thread_wait_for_signal).
          This signal will start the shutdown process of the master.
          This function triggers this signal.

INPUTS
          void - NONE

RESULT
          void - NONE

NOTES
          MT-NOTE: sge_thread_notify_all_waiting() is MT safe

SEE ALSO


16.33.3 sge_thread_wait_for_signal

NAME
          sge_thread_wait_for_signal() -- block current thread till shutdown

SYNOPSIS
          void sge_thread_wait_for_signal(void)

FUNCTION
          A call of this function will block the executing thread until the
          shutdown of the process is triggered via sge_thread_notify_all_waiting()

INPUTS
          void - NONE

RESULT
          void - NONE

NOTES
          MT-NOTE: sge_thread_wait_for_signal() is not MT safe

SEE ALSO


16.34 time


16.34.1 append_time

NAME
          append_time() -- Convert time value into string

SYNOPSIS
          const char* append_time(time_t i, dstring *buffer)

FUNCTION
          Convert time value into string

INPUTS
          time_t i - time value
          dstring *buffer - dstring
          bool is_xml - write in XML dateTime format?

RESULT
          const char* - time string (current time if 'i' was 0)
          dstring *buffer - buffer provided by caller

NOTES
          MT-NOTE: append_time() is MT safe if localtime_r() can be used
          
          SHOULD BE REPLACED BY: sge_dstring_append_time()


16.34.2 duration_add_offset

NAME
          duration_add_offset() -- add function for time add

SYNOPSIS
          u_long32 duration_add_offset(u_long32 duration, u_long32 offset)

FUNCTION
          add function to catch ulong overflow. Returns max ulong value if necessary

INPUTS
          u_long32 duration - duration in seconds
          u_long32 offset   - offset in seconds

RESULT
          u_long32 - value < U_LONG32_MAX

NOTES
          MT-NOTE: duration_add_offset() is not MT safe


16.34.3 sge_at_time

NAME
          sge_at_time() -- ???

SYNOPSIS
          const char* sge_at_time(time_t i, dstring *buffer)

FUNCTION
          ???

INPUTS
          time_t i - 0 or time value
          dstring *buffer - buffer provided by caller

RESULT
          const char* - time string (current time if 'i' was 0)

NOTES
          MT-NOTE: sge_at_time() is MT safe if localtime_r() can be used

SEE ALSO


16.34.4 sge_ctime

NAME
          sge_ctime() -- Convert time value into string

SYNOPSIS
          const char* sge_ctime(time_t i, dstring *buffer)

FUNCTION
          Convert time value into string

INPUTS
          time_t i - 0 or time value

RESULT
          const char* - time string (current time if 'i' was 0)
          dstring *buffer - buffer provided by caller

NOTES
          MT-NOTE: sge_at_time() is MT safe if localtime_r() can be used

SEE ALSO


16.34.5 sge_ctime32

NAME
          sge_ctime32() -- Convert time value into string (64 bit time_t)

SYNOPSIS
          const char* sge_ctime32(u_long32 *i, dstring *buffer)

FUNCTION
          Convert time value into string. This function is needed for
          systems with a 64 bit time_t because the ctime function would
          otherwise try to interpret the u_long32 value as
          a 64 bit value => $&&%$?$%!

INPUTS
          u_long32 *i - 0 or time value
          dstring *buffer - buffer provided by caller

RESULT
          const char* - time string (current time if 'i' was 0)

NOTE
          MT-NOTE: if ctime_r() is not available sge_ctime32() is not MT safe

SEE ALSO


16.34.6 sge_get_gmt

NAME
          sge_get_gmt() -- Return current time

SYNOPSIS
          u_long32 sge_get_gmt()

FUNCTION
          Return current time

NOTES
          MT-NOTE: sge_get_gmt() is MT safe (except for WIN32NATIVE)

RESULT
          u_long32 - 32 bit time value


16.34.7 sge_stopwatch_log

NAME
          sge_stopwatch_log() -- ???

SYNOPSIS
          void sge_stopwatch_log(int i, const char *str)

FUNCTION
          ???

INPUTS
          int i           - ???
          const char *str - ???

NOTES
          MT-NOTE: sge_stopwatch_log() is not MT safe due to access to global variables

SEE ALSO


16.34.8 sge_stopwatch_start

NAME
          sge_stopwatch_start() -- ???

SYNOPSIS
          void sge_stopwatch_start(int i)

FUNCTION
          ???

INPUTS
          int i - ???

NOTES
          MT-NOTE: sge_stopwatch_start() is not MT safe due to access to global variables

SEE ALSO


16.34.9 sge_usleep

NAME
          sge_usleep() -- Mimics a non-iterruptable usleep()

SYNOPSIS
          void sge_usleep(int sleep_time)

FUNCTION
          Mimics a non-iterruptable usleep() to the caller.

INPUTS
          int sleep_time - requested sleep time in microseconds

RESULT
          n/a

NOTES
          None.


16.35 tq


16.35.1 sge_tq_create

NAME
          sge_tq_create() -- Creates a task queue

SYNOPSIS
          bool sge_tq_create(sge_tq_queue_t **queue)

FUNCTION
          This function creates a task queue.

INPUTS
          sge_tq_queue_t **queue - task queue

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_tq_create() is MT safe

SEE ALSO


16.35.2 sge_tq_destroy

NAME
          sge_tq_destroy() -- destroys a queue.

SYNOPSIS
          bool sge_tq_destroy(sge_tq_queue_t **queue)

FUNCTION
          This function destroys a queue. The queue must be empty otherwise
          this would produce a memory leak.

INPUTS
          sge_tq_queue_t **queue - task queue

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_tq_destroy() is MT safe

SEE ALSO


16.35.3 sge_tq_get_task_count

NAME
          sge_tq_get_task_count() -- Returns the number of tasks in queue

SYNOPSIS
          u_long32 sge_tq_get_task_count(sge_tq_queue_t *queue)

FUNCTION
          This function returns the number of tasks in 'queue'

INPUTS
          sge_tq_queue_t *queue - task queue

RESULT
          u_long32 - number of tasks

NOTES
          MT-NOTE: sge_tq_get_task_count() is MT safe


16.35.4 sge_tq_get_waiting_count

NAME
          sge_tq_get_waiting_count() -- Returns number of waiting threads

SYNOPSIS
          u_long32 sge_tq_get_waiting_count(sge_tq_queue_t *queue)

FUNCTION
          This function returns the number of waiting threads. If this number
          is bigger than 0 than this indicates that threads are waiting
          in the function sge_tq_wait_for_task().

INPUTS
          sge_tq_queue_t *queue - task queue

RESULT
          u_long32 - number of threads waiting

NOTES
          MT-NOTE: sge_tq_get_waiting_count() is MT safe

SEE ALSO


16.35.5 sge_tq_store_notify

NAME
          sge_tq_store_notify() -- Appends a new task at the end of queue

SYNOPSIS
          bool
          sge_tq_store_notify(sge_tq_queue_t *queue,
                              sge_tq_type_t type, void *data)

FUNCTION
          This function creates a new task using 'type' and 'data'. The new
          task will then be appended to 'queue'. If there are threads waiting
          in sge_tq_wait_for_task() then one of those waiting threads will be
          triggered so that it will wake up.
          
          If there are multiple threads waiting then it might happen that
          always the same thread wakes up to catch the task (starvation).

INPUTS
          sge_tq_queue_t *queue - task queue
          sge_tq_type_t type    - task type
          void *data            - task data

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_tq_store_notify() is MT safe

SEE ALSO


16.35.6 sge_tq_task_compare_type

NAME
          sge_tq_task_compare_type() -- compare two tasks

SYNOPSIS
          static int sge_tq_task_compare_type(const void *data1, const void *data2)

FUNCTION
          This function compares two tasks and returns if the first ('data1')
          is smaller or bigger that the second ('data2'). It is equal if the
          type field of the elements are equal.
          
          If the type field in 'data1' is SGE_TQ_UNKNOWN then the function will
          will always return 0 to indicate that independent of the type field
          inf 'data2' all tasks are identified as equal. This makes it possible
          to use this function as a search function where SGE_TQ_UNKNOWN
          matches any object in a list like a wild card '*'.

INPUTS
          const void *data1 - key or task object
          const void *data2 - task

RESULT
          static int - compare result -1, 1 or 0

NOTES
          MT-NOTE: sge_tq_task_compare_type() is MT safe


16.35.7 sge_tq_task_create

NAME
          sge_tq_task_create() -- creates a task element

SYNOPSIS
          static bool
          sge_tq_task_create(sge_tq_task_t **task, sge_tq_type_t type, void *data)

FUNCTION
          Creates a task element that can be added to a queue. Each task
          has a type and a data pointer. The type makes it possible to identify
          the type of the data pointer.

INPUTS
          sge_tq_task_t **task - new task element
          sge_tq_type_t type   - type id
          void *data           - data pointer

RESULT
          static bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_tq_task_create() is MT safe


16.35.8 sge_tq_task_destroy

NAME
          sge_tq_task_destroy() -- Destroy a task

SYNOPSIS
          static bool sge_tq_task_destroy(sge_tq_task_t **task)

FUNCTION
          Destroy a task.

INPUTS
          sge_tq_task_t **task - task to be destroyed

RESULT
          static bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_tq_task_destroy() is MT safe


16.35.9 sge_tq_wait_for_task

NAME
          sge_tq_wait_for_task() -- Waits for a task

SYNOPSIS
          bool
          sge_tq_wait_for_task(sge_tq_queue_t *queue, int seconds,
                               sge_tq_type_t type, void **data);

FUNCTION
          This function tries to get a task of 'type'. If there is one
          available then the data pointer will be returned in 'data'.  If there
          is none available the this function will sleep a number of 'seconds'
          before it checks again if there is a task available.
          
          The sleep time might be interrupted by another thread that adds a
          task to the queue via sge_tq_store_notify() or by a thread that
          called sge_tq_wakeup_waiting().
          
          The function returns either if a task of the correct type is
          available of if sge_thread_has_shutdown_started() returns true to
          indicate that the shutdown of the thread/process has been triggered.
          In that case the function might return with NULL in *data.

INPUTS
          sge_tq_queue_t *queue - task queue
          int seconds           - max number of seconds to sleep
          sge_tq_type_t type    - type of the task that should be returned
          void **data           - NULL in case of thread/process shutdown
                                  or the data pointer of the task

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_tq_wait_for_task() is MT safe

SEE ALSO


16.35.10 sge_tq_wakeup_waiting

NAME
          sge_tq_wakeup_waiting() -- wake up all waitng threads

SYNOPSIS
          bool sge_tq_wakeup_waiting(sge_tq_queue_t *queue)

FUNCTION
          This function wakes up all waiting threads that are blocking in
          sge_tq_wait_for_task().

INPUTS
          sge_tq_queue_t *queue - task queue

RESULT
          bool - error state
             true  - success
             false - error

NOTES
          MT-NOTE: sge_tq_wakeup_waiting() is MT safe

SEE ALSO


16.36 uidgid


16.36.1 get_admin_user

NAME
          get_admin_user() -- Get user and group id of admin user.

SYNOPSIS
          static int get_admin_user(uid_t* theUID, gid_t* theGID)

FUNCTION
          Get user and group id of admin user. 'theUID' and 'theGID' will contain
          the user and group id respectively, upon successful completion.
          
          If the admin user has not been set by a call to 'set_admin_user()'
          previously, an error is returned. In case of an error, the locations
          pointed to by 'theUID' and 'theGID' remain unchanged.

OUTPUTS
          uid_t* theUID - pointer to user id storage.
          gid_t* theGID - pointer to group id storage.

RESULT
          int - Returns ESRCH, if no admin user has been initialized.

EXAMPLE
          uid_t uid;
          gid_t gid;
          
          if (get_admin_user(&uid, &gid) == ESRCH) {
             printf("error: no admin user\n");
          } else {
             printf("uid = %d, gid =%d\n", (int)uid, (int)gid);
          }

NOTES
          MT-NOTE: get_admin_user() is MT safe.


16.36.2 get_admin_user_name

NAME
          get_admin_user_name() -- Returns the admin user name

SYNOPSIS
          const char* get_admin_user_name(void)

FUNCTION
          Returns the admin user name.

INPUTS
          void - None

RESULT
          const char* - Admin user name

NOTES
          MT-NOTE: get_admin_user_name() is MT safe


16.36.3 get_file_line_size

NAME
          get_file_line_size() - helper function that counts the characters in
                                 current line of file

SYNOPSIS
          int get_file_line_size(FILE* fp)

FUNCTION
          This helper function counts the characters in current line of file,
          it restores file position pointer to the position that was before
          entering function. Function  can be called on any opened file with read
          permissions.

INPUTS
          FILE* fp - handler of the file in which the characters in current line
                     are counted

RESULT
          int - returns number of characters in current line of file,
                if number of characters is bigger than MAX_LENGTH_LINE,
                it returns MAX_LINE_LENGTH+1 value

NOTES
          MT-NOTE: get_file_line_size() is not MT safe


16.36.4 get_group_buffer_size

NAME
          get_group_buffer_size() -- get the buffer size required for getgr*_r

SYNOPSIS
          int get_group_buffer_size(void)

FUNCTION
          Returns the buffer size required for functions like getgrnam_r.
          It can either be retrieved via sysconf, or a big (20k) buffer
          size is taken.

RESULT
          int - buffer size in bytes

NOTES
          MT-NOTE: get_group_buffer_size() is MT safe

SEE ALSO


16.36.5 get_pw_buffer_size

NAME
          get_pw_buffer_size() -- get the buffer size required for getpw*_r

SYNOPSIS
          int get_pw_buffer_size(void)

FUNCTION
          Returns the buffer size required for functions like getpwnam_r.
          It can either be retrieved via sysconf, or a big (20k) buffer
          size is taken.

RESULT
          int - buffer size in bytes

NOTES
          MT-NOTE: get_pw_buffer_size() is MT safe

SEE ALSO


16.36.6 password_get_size

NAME
          password_get_size() - count number of lines in sgepasswd file

SYNOPSIS
          static int password_get_size(const char *filename)

FUNCTION
          This function counts the lines in the sgepasswd file, it also checks
          that each line is not too long.  If any line has
          more than MAX_LINE_LENGTH characters the function returns error state -1

INPUTS
          const char *filename - name of the file on which the function is run

RESULT
          int - returns number of lines in sgepasswd file if function has run
                successfully
              -1 - if there is a line in a file that is longer than MAX_LINE_LENGTH

NOTES
          MT-NOTE: password_get_size() is not MT safe


16.36.7 password_read_file

NAME
          password_read_file() - read in sgepasswd file

SYNOPSIS
          int password_read_file(char **users[], char**encryped_pwds[],
                                 const char *filename)

FUNCTION
          This function reads usernames and encrypted passwords from sgepasswd file
          and saves them in arrays that are part if function output, if the file
          could not be opened for reading or the file contains corrupted line,
          (too long line, line that doesn't contain username and password),
          the proper error state is returned

INPUTS
          const char* filename - name with path of the sgepasswd file that is
                                 going to be read

OUTPUTS
          char** users[] - array of strings to which are written the usernames
                           that are read from sgepasswd, if sgepasswd could not be
                           opened there are reserved 2 entries with NULL values,
                           if the sgepasswd file is corrupted, no entries are
                           reserved
          
          char** encrypted_pwds[] - array of strings to which are written encrypted
                                    passwords that are read from sgepasswd
                                    if sgepasswd could not be opened there are
                                    reserved 2 entries with NULL values,
                                    if the sgepasswd file is corrupted,
                                    no entries are reserved

RESULT
          int - error state
              0 - OK, no errors
              1 - sgepasswd could not be opened for reading
              2 - sgepasswd file is corrupted

NOTES
          MT-NOTE: password_read_file() is not MT safe


16.36.8 set_admin_user

NAME
          set_admin_user() -- Set user and group id of admin user.

SYNOPSIS
          static void set_admin_user(uid_t theUID, gid_t theGID)

FUNCTION
          Set user and group id of admin user.

INPUTS
          uid_t theUID - user id of admin user
          gid_t theGID - group id of admin user

RESULT
          static void - none

NOTES
          MT-NOTE: set_admin_user() is MT safe.


16.36.9 sge_add_group

NAME
          sge_add_group() -- Add a gid to the list of additional group ids

SYNOPSIS
          int sge_add_group(gid_t add_grp_id, char *err_str)

FUNCTION
          Add a gid to the list of additional group ids. If 'add_grp_id'
          is 0 don't add value to group id list (but return successfully).
          If an error occurs, a descriptive string will be written to
          err_str.

INPUTS
          gid_t add_grp_id   - new gid
          char *err_str      - if points to a valid string buffer
                               error descriptions
                               will be written here
          size_t lstr        - size of err_str
          bool skip_silently - skip silently if setting the group is skipped
                               because this would exceed the NGROUPS_MAX limit.

NOTE
          MT-NOTE: sge_add_group() is MT safe

RESULT
          int - error state
              0 - Success
             -1 - Error


16.36.10 sge_getgrgid_r

NAME
          sge_getgrgid_r() -- Return group information for a given group ID.

SYNOPSIS
          struct group* sge_getgrgid_r(gid_t gid, struct group *pg,
                                       char *buffer, size_t bufsize, int retries)

FUNCTION
          Search account database for a group. This function is just a wrapper for
          'getgrgid_r()', taking into account some additional possible errors.
          For a detailed description see 'getgrgid_r()' man page.

INPUTS
          gid_t gid         - group ID
          struct group *pg  - points to structure which will be updated upon success
          char *buffer      - points to memory referenced by 'pg'
          size_t buflen     - size of 'buffer' in bytes
          int retries       - number of retries to connect to NIS

RESULT
          struct group*  - Pointer to entry matching group information upon success,
                           NULL otherwise.

NOTES
          MT-NOTE: sge_getpwnam_r() is MT safe.


16.36.11 sge_getpwnam_r

NAME
          sge_getpwnam_r() -- Return password file entry for a given user name.

SYNOPSIS
          struct passwd* sge_getpwnam_r(const char*, struct passwd*, char*, int)

FUNCTION
          Search user database for a name. This function is just a wrapper for
          'getpwnam_r()', taking into account some additional possible errors.
          For a detailed description see 'getpwnam_r()' man page.

INPUTS
          const char *name  - points to user name
          struct passwd *pw - points to structure which will be updated upon success
          char *buffer      - points to memory referenced by 'pw'
          size_t buflen     - size of 'buffer' in bytes

RESULT
          struct passwd* - Pointer to entry matching user name upon success,
                           NULL otherwise.

NOTES
          MT-NOTE: sge_getpwnam_r() is MT safe.


16.36.12 sge_gid2group

NAME
          sge_gid2group() -- Resolves gid to group name.

SYNOPSIS
          int sge_gid2group(gid_t gid, char *dst, size_t sz, int retries)

FUNCTION
          Resolves gid to group name. if 'dst' is NULL the function checks
          only if the gid is resolvable.

INPUTS
          uid_t gid   - group id
          char *dst   - buffer for the group name
          size_t sz   - buffer size
          int retries - number of retries

NOTES
          MT-NOTE: sge_gid2group() is MT safe.

RESULT
          int - error state
              0 - OK
              1 - Error


16.36.13 sge_group2gid

NAME
          sge_group2gid() -- Resolve a group name to its gid

SYNOPSIS
          int sge_group2gid(const char *gname, gid_t *gidp, int retries)

FUNCTION
          Resolves a groupname ('gname') to its gid (stored in 'gidp').
          'retries' defines the number of (e.g. NIS/DNS) retries.
          If 'gidp' is NULL the group name is resolved without saving it.

INPUTS
          const char *gname - group name
          gid_t *gidp       - gid pointer
          int retries       - number of retries

NOTES
          MT-NOTE: sge_group2gid() is MT safe.

RESULT
          int - exit state
              0 - OK
              1 - Error


16.36.14 sge_has_admin_user

NAME
          sge_has_admin_user() -- is there a admin user configured and set

SYNOPSIS
          bool sge_has_admin_user(void)

FUNCTION
          Returns if there is a admin user setting configured and set.

INPUTS
          void - None

RESULT
          bool - result
             true  - there is a setting

NOTES
          MT-NOTE: sge_has_admin_user() is MT safe


16.36.15 sge_is_admin_user

NAME
          sge_is_admin_user() -- Check if user is SGE admin user

SYNOPSIS
          bool sge_is_admin_user(const char *username)

FUNCTION
          Checks if the given user is the SGE admin user.

INPUTS
          const char *username - given user name

RESULT
          bool - true if the given user is the SGE admin user
                 false if not.

NOTES
          MT-NOTE: sge_is_admin_user() is MT safe.


16.36.16 sge_is_start_user_superuser

NAME
          sge_is_start_user_superuser() -- return true/false is current real user
                                          is superuser (root/Administrator)

SYNOPSIS
          bool sge_is_start_user_superuser(void)

FUNCTION
          Check the real user id to determine if it is the superuser. If so, return
          true, else return false. This function relies on getuid == 0 for UNIX.
          On INTERIX, this function determines if the user is the built-in local
          admin user or the domain administrator.
          Other members of the Administrators group do not have the permission
          to "su" without password!

RESULT
          true - root was start user
          false - otherwise

NOTES
          MT-NOTE: sge_is_start_user_superuser() is MT safe.

SEE ALSO


16.36.17 sge_is_user_superuser

NAME
          sge_is_user_superuser() -- check if provided user is the superuser

SYNOPSIS
          bool sge_is_user_superuser(const char *name);

FUNCTION
          Checks platform independently if the provided user is the superuser.

INPUTS
          const char *name - name of the user to check

RESULT
          bool - true if it is the superuser,
                 false if not.

NOTES
          MT-NOTE: sge_is_user_superuser() is MT safe.


16.36.18 sge_run_as_user

NAME
          sge_run_as_user() -- Set euid to uid

SYNOPSIS
          int sge_run_as_user(void)

FUNCTION
          Set euid to uid

RESULT
          int - error state
              0 - OK
             -1 - setegid()/seteuid() failed

NOTES
          MT-NOTE: sge_run_as_user() is MT safe

SEE ALSO


16.36.19 sge_set_admin_username

NAME
          sge_set_admin_username() -- Set SGE/EE admin user

SYNOPSIS
          int sge_set_admin_username(const char *user, char *err_str, size_t lstr)

FUNCTION
          Set SGE/EE admin user. If 'user' is "none" then use the current
          uid/gid. Ignore if current user is not root.

INPUTS
          const char *user - admin user name
          char *err_str    - error message
          size_t lstr      - size of err_str

RESULT
          int - error state
              0 - OK
             -1 - Username does not exist
             -2 - Admin user was already set

NOTES
          MT-NOTE: sge_set_admin_username() is MT safe.

SEE ALSO


16.36.20 sge_set_uid_gid_addgrp

NAME
          sge_set_uid_gid_addgrp() -- Set uid and gid of calling process

SYNOPSIS
          int sge_set_uid_gid_addgrp(const char *user,
                                     const char *intermediate_user,
                                     int min_gid, int min_uid, int add_grp,
                                     char *err_str, int use_qsub_gid,
                                     gid_t qsub_gid)

FUNCTION
          Set uid and gid of calling process. This can be done only by root.

INPUTS
          const char *user              - ???
          const char *intermediate_user - ???
          int min_gid                   - ???
          int min_uid                   - ???
          int add_grp                   - ???
          char *err_str                 - ???
          int use_qsub_gid              - ???
          gid_t qsub_gid                - ???
          bool skip_silently            - skip silently when add_grp could not
                                          be added due to NGROUP_MAX limit

NOTES
          MT-NOTE: sge_set_uid_gid_addgrp() is MT safe
          
          TODO: This function needs to be rewritten from scratch! It calls
          'initgroups()' which is not part of POSIX. The call to 'initgroups()'
          shall be replaced by a combination of 'getgroups()/getegid()/setgid()'.
          
          This function is used by 'shepherd' only anyway. Hence it shall be
          considered to move it from 'libuti' to 'shepherd'.

RESULT
          int - error state
              0 - OK
             -1 - we can't switch to user since we are not root
              1 - we can't switch to user or we can't set add_grp
              2 - can't read sgepasswd file
              3 - no password entry in sgepasswd file
              4 - switch to user failed, likely wrong password for this user


16.36.21 sge_switch2admin_user

NAME
          sge_switch2admin_user() -- Set euid/egid to admin uid/gid

SYNOPSIS
          int sge_switch2admin_user(void)

FUNCTION
          Set euid/egid to admin uid/gid. Silently ignore if our uid
          is not root. Do nothing if out euid/egid is already the admin
          uid/gid. If the admin user was not set with
          sge_set_admin_username() the function will not return.

RESULT
          int - error state
              0 - OK
             -1 - setegid()/seteuid() fails

NOTES
          MT-NOTE: sge_switch2admin_user() is MT safe.

SEE ALSO


16.36.22 sge_switch2start_user

NAME
          sge_switch2start_user() -- set euid/egid to start uid/gid

SYNOPSIS
          int sge_switch2start_user(void)

FUNCTION
          Set euid/egid to the uid/gid of that user which started the
          application which calls this function. If our euid/egid is
          already the start uid/gid don't do anything. If the admin user
          was not set with sge_set_admin_username() the function will
          not return.

RESULT
          int - error state
              0 - OK
             -1 - setegid()/seteuid() fails

NOTES
          MT-NOTE: sge_switch2start_user() is MT safe.

SEE ALSO


16.36.23 sge_uid2user

NAME
          sge_uid2user() -- Resolves uid to user name.

SYNOPSIS
          int sge_uid2user(uid_t uid, char *dst, size_t sz, int retries)

FUNCTION
          Resolves uid to user name. if 'dst' is NULL the function checks
          only if the uid is resolvable.

INPUTS
          uid_t uid   - user id
          char *dst   - buffer for the username
          size_t sz   - buffer size
          int retries - number of retries

NOTES
          MT-NOTE: sge_uid2user() is MT safe.

RESULT
          int - error state
              0 - OK
              1 - Error


16.36.24 sge_user2uid

NAME
          sge_user2uid() -- resolves user name to uid and gid

SYNOPSIS
          int sge_user2uid(const char *user, uid_t *puid, gid_t *pgid, int retries)

FUNCTION
          Resolves a username ('user') to it's uid (stored in 'puid') and
          it's primary gid (stored in 'pgid').
          'retries' defines the number of (e.g. NIS/DNS) retries.
          If 'puid' is NULL the user name is resolved without saving it.

INPUTS
          const char *user - username
          uid_t *puid      - uid pointer
          gid_t *pgid      - gid pointer
          int retries      - number of retries

NOTES
          MT-NOTE: sge_user2uid() is MT safe.

RESULT
          int - exit state
              0 - OK
              1 - Error


16.36.25 uidgid_mt_init

NAME
          uidgid_mt_init() -- Initialize user and group oriented functions for multi
                              threading use.

SYNOPSIS
          void uidgid_mt_init(void)

FUNCTION
          Set up user and group oriented functions. This function must be called at
          least once before any of the user and group functions can be used. This
          function is idempotent, i.e. it is safe to call it multiple times.
          
          Thread local storage for the user and group state information is reserved.

INPUTS
          void - NONE

RESULT
          void - NONE

NOTES
          MT-NOTE: uidgid_mt_init() is MT safe


16.36.26 uidgid_once_init

NAME
          uidgid_once_init() -- One-time user and group function initialization.

SYNOPSIS
          static uidgid_once_init(void)

FUNCTION
          Create access key for thread local storage. Register cleanup function.
          
          This function must be called exactly once.

INPUTS
          void - none

RESULT
          void - none

NOTES
          MT-NOTE: uidgid_once_init() is MT safe.


16.36.27 uidgid_state_destroy

NAME
          uidgid_state_destroy() -- Free thread local storage

SYNOPSIS
          static void uidgid_state_destroy(void* theState)

FUNCTION
          Free thread local storage.

INPUTS
          void* theState - Pointer to memory which should be freed.

RESULT
          static void - none

NOTES
          MT-NOTE: uidgid_state_destroy() is MT safe.


16.36.28 uidgid_state_get_

NAME
          uidgid_state_set_*() - read access to lib/uti/sge_uidgid.c global variables

FUNCTION
          Provides access to per thread global variable.


16.36.29 uidgid_state_init

NAME
          uidgid_state_init() -- Initialize user and group function state.

SYNOPSIS
          static void cull_state_init(struct cull_state_t* theState)

FUNCTION
          Initialize user and group function state.

INPUTS
          struct cull_state_t* theState - Pointer to user and group state structure.

RESULT
          static void - none

NOTES
          MT-NOTE: cull_state_init() is MT safe.


16.36.30 uidgid_state_set_

NAME
          uidgid_state_set_*() - write access to lib/uti/sge_uidgid.c global variables

FUNCTION
          Provides access to per thread global variable.


16.37 unistd


16.37.1 sge_chdir

NAME
          sge_chdir() --  Replacement for chdir()

SYNOPSIS
          int sge_chdir(const char *dir)

FUNCTION
          Change working directory

INPUTS
          const char *dir - pathname

RESULT
          int - error state
             0 - success
             != 0 - error

NOTE
          Might be used in shepherd because it does not use CRITICAL/ERROR.
          TODO: pass a dstring for the return of error messages.

SEE ALSO


16.37.2 sge_chdir_exit

NAME
          sge_chdir_exit() -- Replacement for chdir()

SYNOPSIS
          int sge_chdir_exit(const char *path, int exit_on_error)

FUNCTION
          Change working directory

INPUTS
          const char *path  - pathname
          int exit_on_error - exit in case of errors

RESULT
          int - error state
              0 - OK
             -1 - ERROR ('exit_on_error'==1 the function may not return)

SEE ALSO


16.37.3 sge_exit

NAME
          sge_exit() -- Wrapped exit Function

SYNOPSIS
          void sge_exit(int i)

FUNCTION
          Calls 'exit_func' if installed. Stops monitoring with DCLOSE

INPUTS
          sge_gdi_ctx_class_t **ref_ctx - address of the context, the context is freed in exit_func
          int i          - exit state

SEE ALSO


16.37.4 sge_is_directory

NAME
          sge_is_directory() -- Does 'name' exist and is it a directory?

SYNOPSIS
          int sge_is_directory(const char *name)

FUNCTION
          Does 'name' exist and is it a directory?

INPUTS
          const char *name  - directory name

RESULT
          int - error state
              0 - No
              1 - Yes


16.37.5 sge_is_file

NAME
          sge_is_file() -- Does 'name' exist and is it a file?

SYNOPSIS
          int sge_is_file(const char *name)

FUNCTION
          Does 'name' exist and is it a file?

INPUTS
          const char *name  - filename

RESULT
          int - error state
              0 - No
              1 - Yes


16.37.6 sge_mkdir

NAME
          sge_mkdir() -- Create a directory (and necessary parents)

SYNOPSIS
          int sge_mkdir(const char *path, int fmode, bool exit_on_error, bool may_not_exist)

FUNCTION
          Create a directory

INPUTS
          const char *path  - path
          int fmode         - file mode
          bool exit_on_error - as it says
          bool may_not_exist - if true an error is returned if the last component
                              of the path exists

RESULT
          int - error state
              0 - OK
             -1 - Error (The function may never return)


16.37.7 sge_rmdir

NAME
          sge_rmdir() -- Recursive rmdir

SYNOPSIS
          int sge_rmdir(const char *cp, dstring *error)

FUNCTION
          Remove a directory tree. In case of errors a message may be found
          in 'error' afterwards.

INPUTS
          const char *cp  - path
          dstring *error  - destination for error message if non-NULL

RESULT
          int - error state
              0 - OK
             -1 - Error


16.37.8 sge_sleep

NAME
          sge_sleep() -- sleep for x microseconds

SYNOPSIS
          void sge_sleep(int sec, int usec)

FUNCTION
          Delays the calling application for 'sec' seconds and 'usec'
          microseconds

INPUTS
          int sec  - seconds
          int usec - microseconds


16.37.9 sge_unlink

NAME
          sge_unlink() -- delete a name and possibly the file it refers to

SYNOPSIS
          bool sge_unlink(const char *prefix, const char *suffix)

FUNCTION
          Replacement for unlink(). 'prefix' and 'suffix' will be combined
          to a filename. This file will be deleted. 'prefix' may be NULL.

INPUTS
          const char *prefix - pathname or NULL
          const char *suffix - filename

RESULT
          int - error state
              true  - OK
              false - Error


Function Index

Table of Contents