Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
819 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{'src/*', | ||
[debug_info, | ||
{i,"include"}, | ||
{outdir,"ebin"} | ||
]}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
RUN: | ||
erl -noinput -pa $ESSH_HOME/ebin -run essh start $LD_LIBRARY_PATH $PATH_TO_SERVER_LST_FILE | ||
|
||
SERVER_LST_FILE's Format: | ||
#------------ | ||
server-1 | ||
server-2 | ||
server-3 | ||
#------------ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
denpendency: | ||
libreadline.so.5.2 | ||
libhistory.so.5.2 | ||
|
||
-------------------------- | ||
compiled under 64bit debian | ||
readline_drv.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <stdio.h> | ||
#include "erl_driver.h" | ||
#include <readline/history.h> | ||
#include <readline/readline.h> | ||
|
||
typedef struct { | ||
ErlDrvPort port; | ||
} readline_data; | ||
|
||
static char *line_read = (char*)NULL; | ||
static char *prompt = "essh>: "; | ||
|
||
static ErlDrvData readline_drv_start(ErlDrvPort port, char *buff){ | ||
|
||
readline_data* d = (readline_data*)driver_alloc(sizeof(readline_data)); | ||
d->port = port; | ||
return (ErlDrvData)d; | ||
} | ||
|
||
static void readline_drv_stop(ErlDrvData handle) | ||
{ | ||
driver_free((char*)handle); | ||
} | ||
|
||
static void readline_drv_output(ErlDrvData handle, char *buff, int bufflen) | ||
{ | ||
readline_data* d = (readline_data*)handle; | ||
|
||
if (line_read) | ||
{ | ||
free(line_read); | ||
line_read = (char *)NULL; | ||
} | ||
|
||
line_read = readline(prompt); | ||
|
||
if (line_read && *line_read) | ||
add_history(line_read); | ||
|
||
driver_output(d->port, line_read, strlen(line_read)); | ||
} | ||
|
||
ErlDrvEntry readline_driver_entry = { | ||
NULL, /* F_PTR init, N/A */ | ||
readline_drv_start, /* L_PTR start, called when port is opened */ | ||
readline_drv_stop, /* F_PTR stop, called when port is closed */ | ||
readline_drv_output, /* F_PTR output, called when erlang has sent */ | ||
NULL, /* F_PTR ready_input, called when input descriptor ready */ | ||
NULL, /* F_PTR ready_output, called when output descriptor ready */ | ||
"readline_drv", /* char *driver_name, the argument to open_port */ | ||
NULL, /* F_PTR finish, called when unloaded */ | ||
NULL, /* F_PTR control, port_command callback */ | ||
NULL, /* F_PTR timeout, reserved */ | ||
NULL /* F_PTR outputv, reserved */ | ||
}; | ||
|
||
DRIVER_INIT(readline_drv) /* must match name in driver_entry */ | ||
{ | ||
return &readline_driver_entry; | ||
} |
Oops, something went wrong.