mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-28 04:23:37 +01:00
file socket : invert in and out, and little adjustments
This commit is contained in:
parent
6419f17b64
commit
75644f9cf2
3 changed files with 21 additions and 35 deletions
|
@ -23,8 +23,8 @@ struct fxlink_options {
|
||||||
extern struct fxlink_options options;
|
extern struct fxlink_options options;
|
||||||
|
|
||||||
/* Input/output socket filename in case of -s option */
|
/* Input/output socket filename in case of -s option */
|
||||||
extern char* file_in;
|
extern char *file_in;
|
||||||
extern char* file_out;
|
extern char *file_out;
|
||||||
|
|
||||||
/* Main function for -l */
|
/* Main function for -l */
|
||||||
int main_list(struct fxlink_filter *filter, delay_t *delay,
|
int main_list(struct fxlink_filter *filter, delay_t *delay,
|
||||||
|
|
|
@ -41,8 +41,8 @@ static const char *help_string =
|
||||||
" -w <SECONDS> Wait this many seconds for a calculator to connect\n"
|
" -w <SECONDS> Wait this many seconds for a calculator to connect\n"
|
||||||
" -w Wait indefinitely for a calculator to connect\n"
|
" -w Wait indefinitely for a calculator to connect\n"
|
||||||
" -f <FILTER> Filter which calculators we connect to (see below)\n"
|
" -f <FILTER> Filter which calculators we connect to (see below)\n"
|
||||||
" --filein <FILE> Send received data to <FILE>"
|
" --filein <FILE> Send data in <FILE> to calculator\n"
|
||||||
" --fileout <FILE> Send data in <FILE> to calculator\n"
|
" --fileout <FILE> Send received data to <FILE>\n"
|
||||||
" --libusb-log=LEVEL libusb log level (NONE, ERROR, WARNING, INFO, DEBUG)\n"
|
" --libusb-log=LEVEL libusb log level (NONE, ERROR, WARNING, INFO, DEBUG)\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Mode-specific options:\n"
|
"Mode-specific options:\n"
|
||||||
|
@ -65,12 +65,8 @@ static const char *help_string =
|
||||||
struct fxlink_options options;
|
struct fxlink_options options;
|
||||||
|
|
||||||
/* In and out files */
|
/* In and out files */
|
||||||
char* file_in;
|
char *file_in;
|
||||||
char* file_out;
|
char *file_out;
|
||||||
|
|
||||||
/* Input/output socket filenames for -s option */
|
|
||||||
char *socket_in;
|
|
||||||
char *socket_out;
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -104,8 +100,8 @@ int main(int argc, char **argv)
|
||||||
{ "repeat", no_argument, NULL, 'r' },
|
{ "repeat", no_argument, NULL, 'r' },
|
||||||
{ "verbose", no_argument, NULL, 'v' },
|
{ "verbose", no_argument, NULL, 'v' },
|
||||||
{ "folder", required_argument, NULL, OUT_FOLDER },
|
{ "folder", required_argument, NULL, OUT_FOLDER },
|
||||||
{ "filein", required_argument, NULL, FILE_IN },
|
{ "filein", required_argument, NULL, FILE_IN },
|
||||||
{ "fileout", required_argument, NULL, FILE_OUT },
|
{ "fileout", required_argument, NULL, FILE_OUT },
|
||||||
/* Deprecated options ignored for compatibility: */
|
/* Deprecated options ignored for compatibility: */
|
||||||
{ "quiet", no_argument, NULL, 'q' },
|
{ "quiet", no_argument, NULL, 'q' },
|
||||||
{ "unmount", no_argument, NULL, 'u' },
|
{ "unmount", no_argument, NULL, 'u' },
|
||||||
|
@ -121,19 +117,14 @@ int main(int argc, char **argv)
|
||||||
case 'l':
|
case 'l':
|
||||||
case 'b':
|
case 'b':
|
||||||
case FILE_IN:
|
case FILE_IN:
|
||||||
if(optarg)
|
options.file_in = true;
|
||||||
{
|
file_in = optarg;
|
||||||
options.file_in = true;
|
|
||||||
file_in = optarg;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case FILE_OUT:
|
case FILE_OUT:
|
||||||
if(optarg)
|
options.file_out = true;
|
||||||
{
|
file_out = optarg,"w";
|
||||||
options.file_out = true;
|
|
||||||
file_out = optarg;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
case 'i':
|
case 'i':
|
||||||
case 't':
|
case 't':
|
||||||
case 'p':
|
case 'p':
|
||||||
|
|
|
@ -39,17 +39,14 @@ static void handle_new_message(struct fxlink_device *fdev,
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fxlink_message_is_fxlink_text(msg)) {
|
if(fxlink_message_is_fxlink_text(msg)) {
|
||||||
char *str = msg->data;
|
char const *str = msg->data;
|
||||||
str[msg->size] = '\0';
|
|
||||||
if(options.verbose)
|
if(options.verbose)
|
||||||
printf("------------------\n");
|
printf("------------------\n");
|
||||||
if(options.file_in)
|
if(options.file_out)
|
||||||
{
|
{
|
||||||
FILE *fPtr;
|
FILE *out = fopen(file_out,"w");
|
||||||
fPtr = fopen(file_in, "a");
|
fwrite(str,1,msg->size, out);
|
||||||
fputs(str, fPtr);
|
fclose(out);
|
||||||
fputs("\n\0",fPtr);
|
|
||||||
fclose(fPtr);
|
|
||||||
}
|
}
|
||||||
fwrite(str, 1, msg->size, stdout);
|
fwrite(str, 1, msg->size, stdout);
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -132,13 +129,13 @@ int main_interactive(struct fxlink_filter *filter, delay_t *delay,
|
||||||
char c[100];
|
char c[100];
|
||||||
while(1) {
|
while(1) {
|
||||||
|
|
||||||
if(options.file_out)
|
if(options.file_in)
|
||||||
{
|
{
|
||||||
if ((fptr = fopen(file_out, "r"))) {
|
if ((fptr = fopen(file_in, "r"))) {
|
||||||
fscanf(fptr, "%[^\n]", c);
|
fscanf(fptr, "%[^\n]", c);
|
||||||
printf("%i",strlen(c));
|
printf("%i",strlen(c));
|
||||||
fxlink_device_start_bulk_OUT(fdev,"fxlink", "text", &c, strlen(c), false);
|
fxlink_device_start_bulk_OUT(fdev,"fxlink", "text", &c, strlen(c), false);
|
||||||
remove(file_out);
|
remove(file_in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,8 +158,6 @@ int main_interactive(struct fxlink_filter *filter, delay_t *delay,
|
||||||
if(transferred <= 0)
|
if(transferred <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Either start a new message or continue an unfinished one */
|
/* Either start a new message or continue an unfinished one */
|
||||||
if(tr == NULL)
|
if(tr == NULL)
|
||||||
tr = fxlink_transfer_make_IN(buffer, transferred);
|
tr = fxlink_transfer_make_IN(buffer, transferred);
|
||||||
|
|
Loading…
Reference in a new issue