mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2024-12-24 20:01:42 +00:00
constants
This commit is contained in:
parent
9beee068ce
commit
12efb6166a
@ -17,16 +17,16 @@
|
||||
|
||||
#define DEBUG_OUT 0
|
||||
|
||||
#define INT_LEN 10
|
||||
|
||||
#define PASSW 10
|
||||
#define MAX_CONN 16
|
||||
#define NEW_PRG 12
|
||||
#define CC 11
|
||||
#define SERV_ERROR 4
|
||||
#define WRONG_COMMAND 3
|
||||
#define WRONG_PASSW 2
|
||||
#define OK 1
|
||||
/* Protocol constants: */
|
||||
#define INT_LEN 10
|
||||
#define OK 1
|
||||
#define PASSWORD 2
|
||||
#define CAPTIONS 3
|
||||
#define PROGRAM 4
|
||||
#define ERROR 51
|
||||
#define UNKNOWN_COMMAND 52
|
||||
#define WRONG_PASSWORD 53
|
||||
#define CONN_LIMIT 54
|
||||
|
||||
int srv_sd = -1; /* Server socket descriptor */
|
||||
|
||||
@ -151,7 +151,7 @@ void net_send_cc()
|
||||
if (buf_end - buf == 0)
|
||||
return;
|
||||
|
||||
if (write_block(srv_sd, CC, buf, buf_end - buf) < 0)
|
||||
if (write_block(srv_sd, CAPTIONS, buf, buf_end - buf) < 0)
|
||||
{
|
||||
mprint("Can't send subtitle block\n");
|
||||
return; // XXX: store somewhere
|
||||
@ -169,7 +169,7 @@ void net_send_cc()
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
|
||||
if (SERV_ERROR == ok)
|
||||
if (ERROR == ok)
|
||||
{
|
||||
mprint("Internal server error\n");
|
||||
return;
|
||||
@ -187,7 +187,7 @@ void net_set_new_program(const char *name)
|
||||
|
||||
size_t len = strlen(name) - 1; /* without '\0' */
|
||||
|
||||
if (write_block(srv_sd, NEW_PRG, name, len) < 0)
|
||||
if (write_block(srv_sd, PROGRAM, name, len) < 0)
|
||||
{
|
||||
mprint("Can't send new program name to the server\n");
|
||||
return; // XXX: store somewhere
|
||||
@ -345,18 +345,18 @@ int ask_passwd(int sd)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (MAX_CONN == ok)
|
||||
else if (CONN_LIMIT == ok)
|
||||
{
|
||||
mprint("Too many connections to the server, try later\n");
|
||||
return -1;
|
||||
}
|
||||
else if (SERV_ERROR == ok)
|
||||
else if (ERROR == ok)
|
||||
{
|
||||
mprint("Internal server error\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
} while(ok != PASSW);
|
||||
} while(ok != PASSWORD);
|
||||
|
||||
printf("Enter password: ");
|
||||
fflush(stdout);
|
||||
@ -384,7 +384,7 @@ int ask_passwd(int sd)
|
||||
printf("\n");
|
||||
fflush(stdout);
|
||||
|
||||
if (write_block(sd, PASSW, pw, rc) < 0)
|
||||
if (write_block(sd, PASSWORD, pw, rc) < 0)
|
||||
return -1;
|
||||
|
||||
if (read_byte(sd, &ok) != 1)
|
||||
@ -396,12 +396,12 @@ int ask_passwd(int sd)
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
|
||||
if (WRONG_PASSW == ok)
|
||||
if (UNKNOWN_COMMAND == ok)
|
||||
{
|
||||
printf("Wrong password\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
else if (SERV_ERROR == ok)
|
||||
else if (ERROR == ok)
|
||||
{
|
||||
mprint("Internal server error\n");
|
||||
return -1;
|
||||
@ -416,29 +416,29 @@ void pr_command(char c)
|
||||
{
|
||||
switch(c)
|
||||
{
|
||||
case CC:
|
||||
fprintf(stderr, "CC");
|
||||
case CAPTIONS:
|
||||
fprintf(stderr, "CAPTIONS");
|
||||
break;
|
||||
case OK:
|
||||
fprintf(stderr, "OK");
|
||||
break;
|
||||
case WRONG_PASSW:
|
||||
fprintf(stderr, "WRONG_PASSW");
|
||||
case UNKNOWN_COMMAND:
|
||||
fprintf(stderr, "UNKNOWN_COMMAND");
|
||||
break;
|
||||
case WRONG_COMMAND:
|
||||
fprintf(stderr, "WRONG_COMMAND");
|
||||
case UNKNOWN_COMMAND:
|
||||
fprintf(stderr, "UNKNOWN_COMMAND");
|
||||
break;
|
||||
case SERV_ERROR:
|
||||
fprintf(stderr, "SERV_ERROR");
|
||||
case ERROR:
|
||||
fprintf(stderr, "ERROR");
|
||||
break;
|
||||
case NEW_PRG:
|
||||
fprintf(stderr, "NEW_PRG");
|
||||
case PROGRAM:
|
||||
fprintf(stderr, "PROGRAM");
|
||||
break;
|
||||
case MAX_CONN:
|
||||
fprintf(stderr, "MAX_CONN");
|
||||
case CONN_LIMIT:
|
||||
fprintf(stderr, "CONN_LIMIT");
|
||||
break;
|
||||
case PASSW:
|
||||
fprintf(stderr, "PASSW");
|
||||
case PASSWORD:
|
||||
fprintf(stderr, "PASSWORD");
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "UNKNOWN (%d)", (int) c);
|
||||
|
Loading…
Reference in New Issue
Block a user