MXS-1405: Move externcmd documentation to header

The function documentation is more useful in the public header.
This commit is contained in:
Markus Mäkelä
2017-09-13 22:54:26 +03:00
parent 4f7606ebc0
commit 097f1b4613
2 changed files with 67 additions and 43 deletions

View File

@ -30,11 +30,68 @@ typedef struct extern_cmd_t
} EXTERNCMD;
char* externcmd_extract_command(const char* argstr);
EXTERNCMD* externcmd_allocate(char* argstr);
/**
* Allocate a new external command.
*
* The name and parameters are copied into the external command structure so
* the original memory can be freed if needed.
*
* @param command Command to execute with the parameters
* @param timeout Command timeout in seconds
*
* @return Pointer to new external command struct or NULL if an error occurred
*/
EXTERNCMD* externcmd_allocate(char* argstr, uint32_t timeout);
/**
* Free a previously allocated external command
*
* @param cmd Command to free
*/
void externcmd_free(EXTERNCMD* cmd);
/**
* Execute a command
*
* @param cmd Command to execute
*
* @return The return value of the executed command or -1 on error
*/
int externcmd_execute(EXTERNCMD* cmd);
/**
* Substitute all occurrences of @c match with @c replace in the arguments for @c cmd
*
* @param cmd External command
* @param match Match string
* @param replace Replacement string
*
* @return True if replacement was successful, false on error
*/
bool externcmd_substitute_arg(EXTERNCMD* cmd, const char* re, const char* replace);
/**
* Check if a command can be executed
*
* Checks if the file being executed exists and if the current user has execution
* permissions on the file.
*
* @param argstr Command to check, can contain arguments for the command
*
* @return True if the file was found and the use has execution permissions to it
*/
bool externcmd_can_execute(const char* argstr);
/**
* Simple matching of string and command
*
* @param cmd Command where the match is searched from
* @param match String to search for
*
* @return True if the string matched
*/
bool externcmd_matches(const EXTERNCMD* cmd, const char* match);
MXS_END_DECLS