From 41ad0b40066d59b38b80d6d6396d208f61d31203 Mon Sep 17 00:00:00 2001 From: Ruslan Kuchumov Date: Tue, 12 Aug 2014 22:32:11 +0000 Subject: [PATCH 1/2] cc_name --- src/ccextractor.c | 3 ++- src/ccextractor.h | 1 + src/networking.c | 9 ++++++++- src/networking.h | 2 +- src/params.c | 9 +++++++++ 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/ccextractor.c b/src/ccextractor.c index 7d938eb4..17d74be7 100644 --- a/src/ccextractor.c +++ b/src/ccextractor.c @@ -180,6 +180,7 @@ void init_options (struct ccx_s_options *options) options->send_to_srv = 0; options->tcpport = NULL; options->tcp_password = NULL; + options->tcp_cc_name = NULL; options->srv_addr = NULL; options->srv_port = NULL; options->line_terminator_lf=0; // 0 = CRLF @@ -431,7 +432,7 @@ int main(int argc, char *argv[]) if (ccx_options.send_to_srv) { - connect_to_srv(ccx_options.srv_addr, ccx_options.srv_port); + connect_to_srv(ccx_options.srv_addr, ccx_options.srv_port, ccx_options.tcp_cc_name); } if (ccx_options.write_format!=CCX_OF_NULL) diff --git a/src/ccextractor.h b/src/ccextractor.h index c1f0b1c9..2b8a08b9 100644 --- a/src/ccextractor.h +++ b/src/ccextractor.h @@ -121,6 +121,7 @@ struct ccx_s_options // Options from user parameters unsigned send_to_srv; char *tcpport; char *tcp_password; + char *tcp_cc_name; char *srv_addr; char *srv_port; int line_terminator_lf; // 0 = CRLF, 1=LF diff --git a/src/networking.c b/src/networking.c index 1d8a1342..9f5e9d56 100644 --- a/src/networking.c +++ b/src/networking.c @@ -15,6 +15,7 @@ #define OK 1 #define PASSWORD 2 #define BIN_MODE 3 +#define CC_NAME 4 #define ERROR 51 #define UNKNOWN_COMMAND 52 #define WRONG_PASSWORD 53 @@ -66,7 +67,7 @@ void init_sockets (void); void pr_command(char c); #endif -void connect_to_srv(const char *addr, const char *port) +void connect_to_srv(const char *addr, const char *port, const char *cc_name) { if (NULL == addr) { @@ -86,6 +87,12 @@ void connect_to_srv(const char *addr, const char *port) if (ask_passwd(srv_sd) < 0) fatal(EXIT_FAILURE, "Unable to connect\n"); + if (cc_name != NULL && + write_block(srv_sd, CC_NAME, cc_name, strlen(cc_name)) < 0) + { + fatal(EXIT_FAILURE, "Unable to connect\n"); + } + mprint("Connected to %s:%s\n", addr, port); } diff --git a/src/networking.h b/src/networking.h index b013e411..ef1e14a9 100644 --- a/src/networking.h +++ b/src/networking.h @@ -3,7 +3,7 @@ #include -void connect_to_srv(const char *addr, const char *port); +void connect_to_srv(const char *addr, const char *port, const char *cc_name); void net_send_header(const unsigned char *data, size_t len); void net_send_cc(const unsigned char *data, size_t len); diff --git a/src/params.c b/src/params.c index ed695bda..fab72ccd 100644 --- a/src/params.c +++ b/src/params.c @@ -429,6 +429,7 @@ void usage (void) mprint (" -tcp port: Reads the input data in BIN format according to CCExtractor's\n"); mprint (" protocol, listening specified port on the local host\n"); mprint (" -tcppassword password: Sets server password for new connections to tcp server\n"); + mprint (" -tcpccname name: Sends to the server caption name, e.g. channel name or file name\n"); mprint ("Options that affect what will be processed:\n"); mprint (" -1, -2, -12: Output Field 1 data, Field 2 data, or both\n"); mprint (" (DEFAULT is -1)\n"); @@ -1667,6 +1668,14 @@ void parse_parameters (int argc, char *argv[]) continue; } + if (strcmp (argv[i],"-tcpccname")==0 && i Date: Fri, 15 Aug 2014 21:29:28 +0000 Subject: [PATCH 2/2] renaming --- src/ccextractor.c | 4 ++-- src/ccextractor.h | 2 +- src/networking.c | 8 ++++---- src/networking.h | 2 +- src/params.c | 7 ++++--- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/ccextractor.c b/src/ccextractor.c index 17d74be7..0c90648b 100644 --- a/src/ccextractor.c +++ b/src/ccextractor.c @@ -180,7 +180,7 @@ void init_options (struct ccx_s_options *options) options->send_to_srv = 0; options->tcpport = NULL; options->tcp_password = NULL; - options->tcp_cc_name = NULL; + options->tcp_desc = NULL; options->srv_addr = NULL; options->srv_port = NULL; options->line_terminator_lf=0; // 0 = CRLF @@ -432,7 +432,7 @@ int main(int argc, char *argv[]) if (ccx_options.send_to_srv) { - connect_to_srv(ccx_options.srv_addr, ccx_options.srv_port, ccx_options.tcp_cc_name); + connect_to_srv(ccx_options.srv_addr, ccx_options.srv_port, ccx_options.tcp_desc); } if (ccx_options.write_format!=CCX_OF_NULL) diff --git a/src/ccextractor.h b/src/ccextractor.h index 2b8a08b9..6c283b39 100644 --- a/src/ccextractor.h +++ b/src/ccextractor.h @@ -121,7 +121,7 @@ struct ccx_s_options // Options from user parameters unsigned send_to_srv; char *tcpport; char *tcp_password; - char *tcp_cc_name; + char *tcp_desc; char *srv_addr; char *srv_port; int line_terminator_lf; // 0 = CRLF, 1=LF diff --git a/src/networking.c b/src/networking.c index 9f5e9d56..8ac1626c 100644 --- a/src/networking.c +++ b/src/networking.c @@ -15,7 +15,7 @@ #define OK 1 #define PASSWORD 2 #define BIN_MODE 3 -#define CC_NAME 4 +#define CC_DESC 4 #define ERROR 51 #define UNKNOWN_COMMAND 52 #define WRONG_PASSWORD 53 @@ -67,7 +67,7 @@ void init_sockets (void); void pr_command(char c); #endif -void connect_to_srv(const char *addr, const char *port, const char *cc_name) +void connect_to_srv(const char *addr, const char *port, const char *cc_desc) { if (NULL == addr) { @@ -87,8 +87,8 @@ void connect_to_srv(const char *addr, const char *port, const char *cc_name) if (ask_passwd(srv_sd) < 0) fatal(EXIT_FAILURE, "Unable to connect\n"); - if (cc_name != NULL && - write_block(srv_sd, CC_NAME, cc_name, strlen(cc_name)) < 0) + if (cc_desc != NULL && + write_block(srv_sd, CC_DESC, cc_desc, strlen(cc_desc)) < 0) { fatal(EXIT_FAILURE, "Unable to connect\n"); } diff --git a/src/networking.h b/src/networking.h index ef1e14a9..840fc046 100644 --- a/src/networking.h +++ b/src/networking.h @@ -3,7 +3,7 @@ #include -void connect_to_srv(const char *addr, const char *port, const char *cc_name); +void connect_to_srv(const char *addr, const char *port, const char *cc_desc); void net_send_header(const unsigned char *data, size_t len); void net_send_cc(const unsigned char *data, size_t len); diff --git a/src/params.c b/src/params.c index fab72ccd..fd85528e 100644 --- a/src/params.c +++ b/src/params.c @@ -429,7 +429,8 @@ void usage (void) mprint (" -tcp port: Reads the input data in BIN format according to CCExtractor's\n"); mprint (" protocol, listening specified port on the local host\n"); mprint (" -tcppassword password: Sets server password for new connections to tcp server\n"); - mprint (" -tcpccname name: Sends to the server caption name, e.g. channel name or file name\n"); + mprint (" -tcpdesc description: Sends to the server short description about captions e.g.\n"); + mprint (" channel name or file name\n"); mprint ("Options that affect what will be processed:\n"); mprint (" -1, -2, -12: Output Field 1 data, Field 2 data, or both\n"); mprint (" (DEFAULT is -1)\n"); @@ -1668,9 +1669,9 @@ void parse_parameters (int argc, char *argv[]) continue; } - if (strcmp (argv[i],"-tcpccname")==0 && i