selector, mp3/ogg support, http/dccp/ortp support) is about 110K
on i386 under Linux. para_audiod is even smaller.
-command line interface, including shell:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- para_client without arguments starts interactive (shell)
- mode. Otherwise, command is sent to para_server directly
- and output is dumped to stdout. This can be used by any
- scripting language to produce user interfaces with little
- programming effort.
+command line interface:
+~~~~~~~~~~~~~~~~~~~~~~~
+ paraslash commands are sent to para_server and the response is
+ dumped to stdout. This can be used by any scripting language
+ to produce user interfaces with little programming effort.
authentication/encryption via openssl:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include "para.h"
#include "config.h"
-#include <readline/readline.h>
-#include <readline/history.h>
#include "client.cmdline.h"
#include "crypt.h"
#include "rc4.h"
#include "net.h"
#include "string.h"
-/* A static variable for holding the line. */
-static char *line_read;
-
struct gengetopt_args_info args_info;
/*
va_end(argp);
}
-/*
- * Read a string, and return a pointer to it. Returns NULL on EOF.
- */
-static char *rl_gets(void)
-{
- free(line_read);
- /* Get a line from the user. */
- line_read = readline("para_client> ");
- /* If the line has any text in it, save it on the history. */
- if (line_read && *line_read)
- add_history(line_read);
- return line_read;
-}
-
-/*
- * do several cleanups on sigint
- */
-static void sigint_handler(__a_unused int i)
-{
- rl_cleanup_after_signal();
- rl_reset_after_signal();
-}
-
void get_options(int argc, char *argv[],
char **config_file, char **key_file)
{
int main(int argc, char *argv[])
{
- int sockfd, numbytes, i, interactive, received, ret;
+ int sockfd, numbytes, i, received, ret;
struct hostent *he;
struct sockaddr_in their_addr;
char *command = NULL;
char *auth_str;
char *key_file, *config_file;
long unsigned challenge_nr;
- char *line;
get_options(argc, argv, &config_file, &key_file);
if (args_info.loglevel_arg <= NOTICE)
args_info.hostname_arg,
args_info.server_port_arg
);
- interactive = args_info.inputs_num == 0? 1 : 0;
- if (interactive) {
- PARA_NOTICE_LOG("%s", "no command, entering interactive mode\n");
- signal(SIGINT, sigint_handler);
- } else {
- /* not interactive, concat args */
- for (i = 0; i < args_info.inputs_num; i++)
- append_str(&command, args_info.inputs[i]);
+ if (!args_info.inputs_num) {
+ PARA_ERROR_LOG("%s", "syntax error\n");
+ exit(EXIT_FAILURE);
}
-interactive_loop:
+ /* concat args */
+ for (i = 0; i < args_info.inputs_num; i++)
+ append_str(&command, args_info.inputs[i]);
+
crypt_function_recv = NULL;
crypt_function_send = NULL;
- if (interactive) {
- int i = 0;
- char *p;
-
- rl_save_prompt();
- rl_message("\n");
- rl_kill_full_line(0, 0);
- rl_free_line_state();
- /* read a line via readline */
- line = rl_gets();
- if (!line)
- return 0;
- if (!line[0])
- goto interactive_loop;
- p = line;
- while (sscanf(p, "%200s%n", buf, &i) == 1) {
- append_str(&command, buf);
- p += i;
- }
- }
/* get the host info */
PARA_NOTICE_LOG("getting host info of %s\n",
args_info.hostname_arg);
if (!numbytes)
PARA_NOTICE_LOG("%s", "connection closed by peer\n");
close(sockfd);
- if (interactive)
- goto interactive_loop;
return ret >= 0? 0: 1;
}