zabbix-agent2/src/zabbix_agent/logfiles/persistent_state.c
/******************************************************************************
 *                                                                            *
 * Function: create_base_path_directories                                     *
 *                                                                            *
 * Purpose: create all subdirectories in the pathname if they do not exist    *
 *                                                                            *
 * Parameters:                                                                *
 *          pathname - [IN] full pathname of directory, must consist of only  *
 *                          ASCII characters                                  *
 *          error    - [OUT] error message                                    *
 *                                                                            *
 * Return value: SUCCEED - directories created or already exist               *
 *               FAIL    - cannot create directory or it has insufficient     *
 *                         access rights (see dynamically allocated 'error')  *
 *                                                                            *
 ******************************************************************************/
create_base_path_directories

Purpose: create all subdirectories in the pathname if they do not exist

Parameters:
pathname - [IN] full pathname of directory, must consist of only
ASCII characters
error    - [OUT] error message

Return value: SUCCEED - directories created or already exist
FAIL    - cannot create directory or it has insufficient
access rights
create_base_path_directories Purpose : create all subdirectories in the pathname if they do not exist Parameters : pathname - [ IN ] full pathname of directory must consist of only ASCII characters error - [ OUT ] error message Return value : SUCCEED - directories created or already exist FAIL - cannot create directory or it has insufficient access rights
static int	create_base_path_directories(const char *pathname, char **error)
{
	char	*path, *p;
	zabbix_log(LOG_LEVEL_DEBUG, "%s(): pathname:[%s]", __func__, pathname);
	if ('/' != pathname[0])
	{
		*error = zbx_dsprintf(*error, "persistent directory name is not an absolute path,"
				" it does not start with '/'");
		return FAIL;
	}
	path = zbx_strdup(NULL, pathname);	
	for (p = path + 1; ; ++p)
	{
		if ('/' == *p)
		{
			*p = '\0';
			zabbix_log(LOG_LEVEL_DEBUG, "%s(): checking directory:[%s]", __func__, path);
			if (SUCCEED != create_persistent_directory(path, error))
			{
				zbx_free(path);
				return FAIL;
			}
			*p = '/';
		}
		else if ('\0' == *p)
		{
			zabbix_log(LOG_LEVEL_DEBUG, "%s(): checking directory:[%s]", __func__, path);
			if (SUCCEED != create_persistent_directory(path, error))
			{
				zbx_free(path);
				return FAIL;
			}
			break;
		}
	}
	zbx_free(path);
	return SUCCEED;
}
static int create_base_path_directories ( const char * pathname , char * * error ) { char * path , * p ; zabbix_log ( LOG_LEVEL_DEBUG , " " , __func__ , pathname ) ; if ( ' ' != pathname [ 0 ] ) { * error = zbx_dsprintf ( * error , " " " " ) ; return FAIL ; } path = zbx_strdup ( NULL , pathname ) ; for ( p = path + 1 ; ; ++ p ) { if ( ' ' == * p ) { * p = ' \0 ' ; zabbix_log ( LOG_LEVEL_DEBUG , " " , __func__ , path ) ; if ( SUCCEED != create_persistent_directory ( path , error ) ) { zbx_free ( path ) ; return FAIL ; } * p = ' ' ; } else if ( ' \0 ' == * p ) { zabbix_log ( LOG_LEVEL_DEBUG , " " , __func__ , path ) ; if ( SUCCEED != create_persistent_directory ( path , error ) ) { zbx_free ( path ) ; return FAIL ; } break ; } } zbx_free ( path ) ; return SUCCEED ; }
Function: create_base_path_directories                                     
                                                                            
 Purpose: create all subdirectories in the pathname if they do not exist    
                                                                            
 Parameters:                                                                
          pathname - [IN] full pathname of directory, must consist of only  
                          ASCII characters                                  
          error    - [OUT] error message                                    
                                                                            
 Return value: SUCCEED - directories created or already exist               
               FAIL    - cannot create directory or it has insufficient     
                         access rights (see dynamically allocated 'error')
Function : create_base_path_directories Purpose : create all subdirectories in the pathname if they do not exist Parameters : pathname - [ IN ] full pathname of directory must consist of only ASCII characters error - [ OUT ] error message Return value : SUCCEED - directories created or already exist FAIL - cannot create directory or it has insufficient access rights ( see dynamically allocated ' error ' )
/* mutable copy */