|
Paraslash Audio Streaming |
About News Download Documentation Development |
Data Structures | |
struct | i9e_completion_info |
struct | i9e_completion_result |
struct | i9e_completer |
struct | i9e_client_info |
Macros | |
#define | I9E_DUMMY_COMPLETER(name) |
Functions | |
int | i9e_open (struct i9e_client_info *ici, struct sched *s) |
void | i9e_attach_to_stdout (struct btr_node *producer) |
void | i9e_print_status_bar (char *buf, unsigned len) |
void | i9e_close (void) |
void | i9e_signal_dispatch (int sig_num) |
__printf_2_3 void | i9e_log (int ll, const char *fmt,...) |
int | i9e_poll (struct pollfd *fds, nfds_t nfds, int timeout) |
int | i9e_extract_completions (const char *word, char *const *string_list, char ***result) |
char ** | i9e_complete_commands (const char *word, const struct i9e_completer *completers) |
void | i9e_complete_option (char *const *opts, struct i9e_completion_info *ci, struct i9e_completion_result *cr) |
unsigned | i9e_get_nonopt_argnum (char *const *opts, struct i9e_completion_info *ci) |
int | i9e_cword_is_option_arg (char *const *opts, struct i9e_completion_info *ci) |
int | i9e_print_completions (const struct i9e_completer *completers) |
int | i9e_get_error (void) |
void | i9e_ll_completer (struct i9e_completion_info *ci, struct i9e_completion_result *cr) |
Public API for interactive sessions.
#define I9E_DUMMY_COMPLETER | ( | name | ) |
Define a completer which does nothing.
name | Determines the name of the function to be defined. |
int i9e_open | ( | struct i9e_client_info * | ici, |
struct sched * | s | ||
) |
Register the i9e task and initialize readline.
ici | The i9e configuration parameters set by the caller. |
s | The scheduler instance to add the i9e task to. |
The caller must allocate and initialize the structure ici points to.
void i9e_attach_to_stdout | ( | struct btr_node * | producer | ) |
Prepare writing to stdout.
producer | The buffer tree node which produces output. |
The i9e subsystem maintains a buffer tree node which may be attached to another node which generates output (a "producer"). When attached, the i9e buffer tree node copies the buffers generated by the producer to stdout.
This function attaches the i9e input queue to an output queue of producer.
References btr_remove_node().
void i9e_print_status_bar | ( | char * | buf, |
unsigned | len | ||
) |
Print the current status to stderr.
buf | The text to print. |
len | The number of bytes in buf. |
This clears the bottom line, moves to the beginning of the line and prints the given text. If the length of this text exceeds the width of the terminal, the text is shortened by leaving out a part in the middle.
void i9e_close | ( | void | ) |
Reset the terminal and save the in-memory command line history.
This should be called before the caller exits.
void i9e_signal_dispatch | ( | int | sig_num | ) |
Tell i9e that the caller received a signal.
sig_num | The number of the signal received. |
__printf_2_3 void i9e_log | ( | int | ll, |
const char * | fmt, | ||
... | |||
) |
The log function of the i9e subsystem.
ll | Severity log level. |
fmt | Printf-like format string. |
This clears the bottom line of the terminal if necessary and writes the string given by fmt to fd[2], where fd[] is the array provided earlier in i9e_open().
int i9e_poll | ( | struct pollfd * | fds, |
nfds_t | nfds, | ||
int | timeout | ||
) |
Wrapper for poll(2) which handles EINTR and returns paraslash error codes.
fds | See poll(2). |
nfds | See poll(2). |
timeout | See poll(2). |
The only difference between this function and xpoll() is that i9e_poll() returns zero if the system call was interrupted while xpoll() restarts the system call in this case.
References ERRNO_TO_PARA_ERROR, and i9e_client_info::fds.
int i9e_extract_completions | ( | const char * | word, |
char *const * | string_list, | ||
char *** | result | ||
) |
Return the possible completions for a given word.
word | The word to complete. |
string_list | All possible words in this context. |
result | String list is returned here. |
This function never fails. If no completion was found, a string list of length zero is returned. In any case, the result must be freed by the caller using free_argv().
This function is independent of readline and may be called before i9e_open().
References alloc().
Referenced by i9e_complete_option(), and i9e_ll_completer().
char** i9e_complete_commands | ( | const char * | word, |
const struct i9e_completer * | completers | ||
) |
Return the list of partially matching words.
word | The command to complete. |
completers | The array containing all command names. |
This is similar to i9e_extract_completions(), but completes on the command names in completers.
void i9e_complete_option | ( | char *const * | opts, |
struct i9e_completion_info * | ci, | ||
struct i9e_completion_result * | cr | ||
) |
Complete according to the given options.
opts | All available options. |
ci | Information which was passed to the completer. |
cr | Result pointer. |
This convenience helper can be used to complete an option. The array of all possible options is passed as the first argument. Flags, i.e. options without an argument, are expected to be listed as strings of type "-X" in opts while options which require an argument should be passed with a trailing "=" character like "-X=".
If the word can be uniquely completed to a flag option, an additional space character is appended to the output. For non-flag options no space character is appended.
References i9e_completion_result::dont_append_space, i9e_extract_completions(), i9e_completion_result::matches, and i9e_completion_info::word.
unsigned i9e_get_nonopt_argnum | ( | char *const * | opts, |
struct i9e_completion_info * | ci | ||
) |
Return the number of non-option arguments encountered so far.
This counts the number of arguments up to the current word which are neither options nor arguments to options.
opts | NULL terminated array of short and long options, may be NULL. |
ci | Provided by i9e in completion context. |
For convenience, NULL can be passed as the option array pointer to indicate that the subcommand has no options. In this case the function returns the word number stored in the completion info structure.
References i9e_completion_info::argv, and i9e_completion_info::word_num.
int i9e_cword_is_option_arg | ( | char *const * | opts, |
struct i9e_completion_info * | ci | ||
) |
Find out whether the current word is an argument to an option.
This handles both the –opt=arg and –opt arg syntax to specify option arguments.
opts | NULL-terminated array of short and long options. |
ci | Provided by i9e in completion context. |
References i9e_completion_info::argv, i9e_completion_info::word, and i9e_completion_info::word_num.
int i9e_print_completions | ( | const struct i9e_completer * | completers | ) |
Print possible completions to stdout.
completers | The array of completion functions. |
At the end of the output a line starting with "-o=", followed by the (possibly empty) list of completion options is printed. Currently, the only two completion options are "nospace" and "filenames". The former indicates that no space should be appended even for a unique match while the latter indicates that usual filename completion should be performed in addition to the previously printed options.
int i9e_get_error | ( | void | ) |
Return the error state of the i9e task.
This is mainly useful for other tasks to tell whether the i9e task is still running.
void i9e_ll_completer | ( | struct i9e_completion_info * | ci, |
struct i9e_completion_result * | cr | ||
) |
Complete on severity strings.
ci | See struct i9e_completer. |
cr | See struct i9e_completer. |
This is used by para_client and para_audioc which need the same completion primitive for the ll server/audiod command. Both define their own completer which is implemented as a trivial wrapper that calls this function.
References i9e_extract_completions(), i9e_completion_result::matches, i9e_completion_info::word, and i9e_completion_info::word_num.