windows support

This commit is contained in:
Ruslan Kuchumov 2014-07-26 12:06:17 +00:00
parent 29515bfcd5
commit ec0873f5a2
7 changed files with 37 additions and 33 deletions

View File

@ -8,14 +8,7 @@
#include <errno.h>
#include <assert.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <termios.h>
#include <unistd.h>
#include <sys/ioctl.h>
#define DEBUG_OUT 1
#define DEBUG_OUT 0
/* Protocol constants: */
#define INT_LEN 10
@ -29,7 +22,7 @@
#define DFT_PORT "2048" /* Default port for server and client */
#define WRONG_PASSWORD_DELAY 2 /* Seconds */
#define BUFFER_SIZE 50 /* for password actually */
#define BUFFER_SIZE 50
int srv_sd = -1; /* Server socket descriptor */
@ -279,10 +272,9 @@ int ask_passwd(int sd)
{
assert(srv_sd > 0);
struct termios old, new;
int rc;
size_t len = 0;
char *pw = NULL;
size_t len;
char pw[BUFFER_SIZE] = { 0 };
char ok;
@ -319,30 +311,15 @@ int ask_passwd(int sd)
printf("Enter password: ");
fflush(stdout);
if (tcgetattr(STDIN_FILENO, &old) != 0)
{
mprint("tcgetattr() error: %s\n", strerror(errno));
}
new = old;
new.c_lflag &= ~ECHO;
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &new) != 0)
{
mprint("tcgetattr() error: %s\n", strerror(errno));
}
rc = getline(&pw, &len, stdin);
rc--; /* -1 for \n */
if (tcsetattr (STDIN_FILENO, TCSAFLUSH, &old) != 0)
{
mprint("tcgetattr() error: %s\n", strerror(errno));
}
char *p = pw;
while (p - pw < sizeof(pw) && ((*p = fgetc(stdin)) != '\n'))
p++;
len = p - pw; /* without \n */
printf("\n");
fflush(stdout);
if (write_block(sd, PASSWORD, pw, rc) < 0)
if (write_block(sd, PASSWORD, pw, len) < 0)
return -1;
if (read_byte(sd, &ok) != 1)
@ -577,6 +554,7 @@ ssize_t read_block(int fd, char *command, char *buf, size_t *buf_len)
#if DEBUG_OUT
fwrite(len_str, sizeof(char), INT_LEN, stderr);
fprintf(stderr, " ");
#endif
size_t len = atoi(len_str);
@ -607,6 +585,7 @@ ssize_t read_block(int fd, char *command, char *buf, size_t *buf_len)
#if DEBUG_OUT
fwrite(buf, sizeof(char), len, stderr);
fprintf(stderr, " ");
#endif
}

View File

@ -307,6 +307,12 @@ void set_output_format (const char *format)
void set_input_format (const char *format)
{
if (ccx_options.input_source == CCX_DS_TCP && strcmp(format, "bin")!=0)
{
mprint("Intput format is changed to bin\n");
format = "bin";
}
while (*format=='-')
format++;
if (strcmp (format,"es")==0) // Does this actually do anything?

View File

@ -6,6 +6,7 @@
#ifdef _WIN32
#include <io.h>
#include <ws2tcpip.h>
#include <windows.h>
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
@ -13,11 +14,14 @@
#include "inttypes.h"
#define UINT64_MAX _UI64_MAX
typedef int socklen_t;
typedef int ssize_t;
typedef uint32_t in_addr_t;
#define IN_CLASSD(i) (((INT32)(i) & 0xf0000000) == 0xe0000000)
#define IN_MULTICAST(i) IN_CLASSD(i)
#include <direct.h>
#define mkdir(path, mode) _mkdir(path)
#define snprintf(buf, len, fmt, ...) _snprintf(buf, len, fmt, __VA_ARGS__)
#define sleep(sec) Sleep((sec) * 1000)
#else // _WIN32

BIN
windows/ccextractor.v12.suo Normal file → Executable file

Binary file not shown.

View File

@ -55,6 +55,7 @@
<ClInclude Include="..\src\libpng\pnglibconf.h" />
<ClInclude Include="..\src\libpng\pngpriv.h" />
<ClInclude Include="..\src\libpng\pngstruct.h" />
<ClInclude Include="..\src\networking.h" />
<ClInclude Include="..\src\platform.h" />
<ClInclude Include="..\src\spupng_encoder.h" />
<ClInclude Include="..\src\stdint.h" />
@ -156,6 +157,7 @@
<ClCompile Include="..\src\libpng\pngwtran.c" />
<ClCompile Include="..\src\libpng\pngwutil.c" />
<ClCompile Include="..\src\myth.c" />
<ClCompile Include="..\src\networking.c" />
<ClCompile Include="..\src\output.c" />
<ClCompile Include="..\src\params.c" />
<ClCompile Include="..\src\params_dump.c" />

View File

@ -216,6 +216,12 @@
<ClInclude Include="..\src\configuration.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\cc_encoders_common.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\networking.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\gpacmp4\stbl_read.c">
@ -521,5 +527,11 @@
<ClCompile Include="..\src\configuration.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\cc_encoders_common.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\networking.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -32,7 +32,8 @@ objects = 608.o \
sequencing.o \
stream_functions.o \
timing.o \
ts_functions.o
ts_functions.o \
networking.o
bentoobjects = bento4/Ap48bdlAtom.o \
bento4/Ap4AdtsParser.o \