2007-07-01 01:05:44 +08:00
|
|
|
/****************************************************************************
|
2014-08-09 03:53:29 +08:00
|
|
|
* sched/environ/environ.h
|
2007-07-01 01:05:44 +08:00
|
|
|
*
|
2021-02-08 23:33:58 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2007-07-01 01:05:44 +08:00
|
|
|
*
|
2021-02-08 23:33:58 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-07-01 01:05:44 +08:00
|
|
|
*
|
2021-02-08 23:33:58 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2007-07-01 01:05:44 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-08-09 03:53:29 +08:00
|
|
|
#ifndef __SCHED_ENVIRON_ENVIRON_H
|
|
|
|
#define __SCHED_ENVIRON_ENVIRON_H
|
2007-07-01 01:05:44 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <nuttx/sched.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
2014-10-07 21:42:36 +08:00
|
|
|
* Pre-processor Definitions
|
2007-07-01 01:05:44 +08:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_DISABLE_ENVIRON
|
2022-04-04 18:11:06 +08:00
|
|
|
# define env_dup(group, envp) (0)
|
|
|
|
# define env_release(group) (0)
|
2013-01-26 07:21:27 +08:00
|
|
|
#else
|
2007-07-01 01:05:44 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
2015-10-03 06:30:35 +08:00
|
|
|
* Public Data
|
2007-07-01 01:05:44 +08:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define EXTERN extern "C"
|
2013-01-26 07:21:27 +08:00
|
|
|
extern "C"
|
|
|
|
{
|
2007-07-01 01:05:44 +08:00
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
2013-01-26 07:21:27 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
2007-07-01 03:39:17 +08:00
|
|
|
|
2018-08-11 00:16:39 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: env_dup
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Copy the internal environment structure of a task. This is the action
|
2021-02-09 01:46:31 +08:00
|
|
|
* that is performed when a new task is created:
|
|
|
|
* The new task has a private, exact duplicate of the parent task's
|
|
|
|
* environment.
|
2018-08-11 00:16:39 +08:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* group - The child task group to receive the newly allocated copy of the
|
|
|
|
* parent task groups environment structure.
|
2022-04-04 18:11:06 +08:00
|
|
|
* envp - Pointer to the environment strings.
|
2018-08-11 00:16:39 +08:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* zero on success
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Not called from an interrupt handler.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2007-07-01 03:39:17 +08:00
|
|
|
|
2022-04-04 18:11:06 +08:00
|
|
|
int env_dup(FAR struct task_group_s *group, FAR char * const *envp);
|
2018-08-11 00:16:39 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: env_release
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* env_release() is called only from group_leave() when the last member of
|
|
|
|
* a task group exits. The env_release() function clears the environment
|
|
|
|
* of all name-value pairs and sets the value of the external variable
|
|
|
|
* environ to NULL.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* group - Identifies the task group containing the environment structure
|
|
|
|
* to be released.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* Not called from an interrupt handler
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-01-27 07:49:02 +08:00
|
|
|
void env_release(FAR struct task_group_s *group);
|
2007-07-01 03:39:17 +08:00
|
|
|
|
2018-08-11 00:16:39 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: env_findvar
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Search the provided environment structure for the variable of the
|
|
|
|
* specified name.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* group - The task group containing environment array to be searched.
|
|
|
|
* pname - The variable name to find
|
|
|
|
*
|
|
|
|
* Returned Value:
|
2022-04-16 19:38:17 +08:00
|
|
|
* A index to the name=value string in the environment
|
2018-08-11 00:16:39 +08:00
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* - Not called from an interrupt handler
|
|
|
|
* - Pre-emption is disabled by caller
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2013-01-26 07:21:27 +08:00
|
|
|
|
2023-02-09 14:59:03 +08:00
|
|
|
ssize_t env_findvar(FAR struct task_group_s *group, FAR const char *pname);
|
2018-08-11 00:16:39 +08:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: env_removevar
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Remove the referenced name=value pair from the environment
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* group - The task group with the environment containing the name=value
|
|
|
|
* pair
|
2022-04-16 19:38:17 +08:00
|
|
|
* index - A index to the name=value pair in the restroom
|
2018-08-11 00:16:39 +08:00
|
|
|
*
|
|
|
|
* Returned Value:
|
2022-04-16 19:38:17 +08:00
|
|
|
* None
|
2018-08-11 00:16:39 +08:00
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* - Not called from an interrupt handler
|
|
|
|
* - Caller has pre-emption disabled
|
|
|
|
* - Caller will reallocate the environment structure to the correct size
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2023-02-09 14:59:03 +08:00
|
|
|
void env_removevar(FAR struct task_group_s *group, ssize_t index);
|
2007-07-01 01:05:44 +08:00
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-01-26 07:21:27 +08:00
|
|
|
#endif /* !CONFIG_DISABLE_ENVIRON */
|
2014-08-09 03:53:29 +08:00
|
|
|
#endif /* __SCHED_ENVIRON_ENVIRON_H */
|