Skip to content

Commit

Permalink
A few quick hacks to get the Squirrel debugger sqdbg to compile on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Grumbel committed Aug 13, 2014
1 parent 46a9c67 commit 0034881
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
12 changes: 10 additions & 2 deletions external/squirrel/sqdbg/sqdbgserver.cpp
@@ -1,9 +1,17 @@
#include <squirrel.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sqstdblob.h>
#include "sqrdbg.h"
#include "sqdbgserver.h"

#ifndef _WIN32
# define Sleep sleep
# include <sys/types.h>
# include <sys/socket.h>
#endif

#ifndef _UNICODE
#define scstrcpy strcpy
Expand Down Expand Up @@ -633,7 +641,7 @@ void SQDbgServer::EndDocument()
//this can be done much better/faster(do we need that?)
const SQChar *SQDbgServer::escape_xml(const SQChar *s)
{
SQChar *temp=sq_getscratchpad(_v,((SQInteger)scstrlen(s)*6) + sizeof SQChar);
SQChar *temp=sq_getscratchpad(_v,((SQInteger)scstrlen(s)*6) + sizeof(SQChar));
SQChar *dest=temp;
while(*s!=_SC('\0')){

Expand All @@ -659,4 +667,4 @@ const SQChar *SQDbgServer::escape_xml(const SQChar *s)
*dest=_SC('\0');
return temp;

}
}
10 changes: 8 additions & 2 deletions external/squirrel/sqdbg/sqdbgserver.h
Expand Up @@ -8,7 +8,13 @@
#include <map>
#include <string>
#include <vector>
#include <winsock.h>
#ifdef _WIN32
# include <winsock.h>
#else
# include <unistd.h>
# define SOCKET int
# define INVALID_SOCKET (-1)
#endif

typedef std::basic_string<SQChar> SQDBGString;

Expand Down Expand Up @@ -148,4 +154,4 @@ struct SQDbgServer{
#define sqdbg_closesocket(x) close((x))
#endif

#endif //_SQ_DBGSERVER_H_
#endif //_SQ_DBGSERVER_H_
19 changes: 15 additions & 4 deletions external/squirrel/sqdbg/sqrdbg.cpp
@@ -1,5 +1,16 @@
#include <squirrel.h>
#include <winsock.h>
#ifdef _WIN32
# include <winsock.h>
#else
# include <sys/types.h>
# include <sys/socket.h>
# include <arpa/inet.h>
# include <sys/time.h>
# define SOCKET_ERROR (-1)
# define TIMEVAL struct timeval
#endif
#include <stdio.h>
#include <string.h>
#include <squirrel.h>
#include <squirrel.h>
#include "sqrdbg.h"
Expand All @@ -11,9 +22,9 @@ SQInteger error_handler(HSQUIRRELVM v);

HSQREMOTEDBG sq_rdbg_init(HSQUIRRELVM v,unsigned short port,SQBool autoupdate)
{
WSADATA wsadata;
sockaddr_in bindaddr;
struct sockaddr_in bindaddr;
#ifdef _WIN32
WSADATA wsadata;
if (WSAStartup (MAKEWORD(2,2), &wsadata) != 0){
return NULL;
}
Expand Down Expand Up @@ -48,7 +59,7 @@ SQRESULT sq_rdbg_waitforconnections(HSQREMOTEDBG rdbg)
sq_pop(rdbg->_v,1);

sockaddr_in cliaddr;
int addrlen=sizeof(cliaddr);
socklen_t addrlen=sizeof(cliaddr);
if(listen(rdbg->_accept,0)==SOCKET_ERROR)
return sq_throwerror(rdbg->_v,_SC("error on listen(socket)"));
rdbg->_endpoint = accept(rdbg->_accept,(sockaddr*)&cliaddr,&addrlen);
Expand Down
4 changes: 3 additions & 1 deletion external/squirrel/sqdbg/sqrdbg.h
Expand Up @@ -4,7 +4,9 @@
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
#pragma comment(lib, "WSOCK32.LIB")
#endif

struct SQDbgServer;
typedef SQDbgServer* HSQREMOTEDBG;
Expand All @@ -18,4 +20,4 @@ SQRESULT sq_rdbg_update(HSQREMOTEDBG rdbg);
} /*extern "C"*/
#endif

#endif //_SQ_RDBG_H_
#endif //_SQ_RDBG_H_

0 comments on commit 0034881

Please sign in to comment.