(PS3/Wii) Make netlogger code portable

This commit is contained in:
TwinAphex51224 2012-03-13 00:44:37 +01:00
parent 6cd4989651
commit 47dcb54c1f
8 changed files with 55 additions and 60 deletions

View File

@ -96,7 +96,7 @@ PPU_CXXFLAGS = $(PPU_OPTIMIZE_LV) $(INCDIRS) $(DEFINES)
ifeq ($(HAVE_LOGGER), 1)
PPU_CFLAGS += -DHAVE_LOGGER
PPU_SRCS += ps3/cellframework2/fileio/logger.c
PPU_SRCS += console/logger/logger.c
endif
EXIST_EBOOT_WILDCARD := $(wildcard $(EBOOT_PATH))

View File

@ -22,7 +22,7 @@ PPU_SRCS = ps3/salamander/main.c strl.c conf/config_file.c
ifeq ($(HAVE_LOGGER), 1)
PPU_CFLAGS += -DHAVE_LOGGER
PPU_SRCS += ps3/cellframework2/fileio/logger.c
PPU_SRCS += console/logger/logger.c
endif
PPU_TARGET = ssnes-salamander.elf

View File

@ -5,7 +5,11 @@
###
##
DEBUG = 0
DEBUG = 0
HAVE_LOGGER = 0
PC_DEVELOPMENT_IP_ADDRESS = "192.168.1.7"
PC_DEVELOPMENT_UDP_PORT = 3490
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc
CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++
@ -25,7 +29,12 @@ LIBS := -lfat -lsnes -lwiiuse -logc -lbte -lfreetype
OBJ = wii/main.o fifo_buffer.o ssnes.o driver.o gfx/fonts.o file.o settings.o message.o rewind.o movie.o ups.o bps.o strl.o screenshot.o audio/hermite.o dynamic.o audio/utils.o conf/config_file.o wii/audio.o wii/input.o wii/video.o console/sgui.o console/list.o console/font.bmpobj console/main_wrap.o console/console_ext.o console/szlib/szlib.o
CFLAGS += -std=gnu99 -DSSNES_CONSOLE -DHAVE_CONFIGFILE=1 -DHAVE_GETOPT_LONG -DHAVE_FREETYPE -DPACKAGE_VERSION=\"0.9.5\" -Dmain=ssnes_main -Wno-char-subscripts
ifeq ($(HAVE_LOGGER), 1)
CFLAGS += -DHAVE_LOGGER
OBJ += console/logger/logger.o
endif
CFLAGS += -std=gnu99 -DSSNES_CONSOLE -DHAVE_CONFIGFILE=1 -DHAVE_GETOPT_LONG -DHAVE_FREETYPE -DPACKAGE_VERSION=\"0.9.5\" -Dmain=ssnes_main -Wno-char-subscripts -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g

View File

@ -1,23 +1,3 @@
/* -- Cellframework Mk.II - Open framework to abstract the common tasks related to
* PS3 application development.
*
* Copyright (C) 2010-2012
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - Daniel De Matteis
@ -36,17 +16,27 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef __CELLOS_LV2__
#include <netex/net.h>
#include <cell/sysmodule.h>
#include <netex/libnetctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/timer.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#ifdef HW_RVL
#include <network.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include "../../netplay_compat.h"
#include "logger.h"
#if !defined(PC_DEVELOPMENT_IP_ADDRESS)
@ -62,13 +52,26 @@ static int sock;
static struct sockaddr_in target;
static char sendbuf[4096];
#ifdef HW_RVL
#define sendto(s, msg, len, flags, addr, tolen) net_sendto(s, msg, len, flags, addr, tolen)
#define socket(domain, type, protocol) net_socket(domain, type, protocol)
static int inet_pton(int af, const char *src, void *dst)
{
if (af != AF_INET)
return -1;
return inet_aton (src, dst);
}
#endif
static int if_up_with(int index)
{
(void)index;
#ifdef __CELLOS_LV2__
int timeout_count = 10;
int state;
int ret;
(void)index;
ret = cellNetCtlInit();
if (ret < 0)
{
@ -94,6 +97,7 @@ static int if_up_with(int index)
return (0);
}
}
#endif
sock=socket(AF_INET,SOCK_DGRAM ,0);
@ -107,7 +111,9 @@ static int if_up_with(int index)
static int if_down(int sid)
{
(void)sid;
#ifdef __CELLOS_LV2__
cellNetCtlTerm();
#endif
return (0);
}
@ -121,7 +127,7 @@ void logger_shutdown (void)
if_down(g_sid);
}
void net_send(const char *__format,...)
void logger_send(const char *__format,...)
{
va_list args;
@ -130,5 +136,5 @@ void net_send(const char *__format,...)
va_end(args);
int len=strlen(sendbuf);
sendto(sock,sendbuf,len,MSG_DONTWAIT,(const struct sockaddr*)&target,sizeof(target));
sendto(sock,sendbuf,len,MSG_DONTWAIT,(struct sockaddr*)&target,sizeof(target));
}

View File

@ -1,23 +1,3 @@
/* -- Cellframework Mk.II - Open framework to abstract the common tasks related to
* PS3 application development.
*
* Copyright (C) 2010-2012
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
* Copyright (C) 2011-2012 - Daniel De Matteis
@ -40,12 +20,11 @@
#define _LOGGER_H_
#define BUFSIZE (64 * 1024)
#define TCPDUMP_FILE (SYS_APP_HOME "/tcpdump.dump")
#define TCPDUMP_STACKSIZE (16 * 1024)
#define TCPDUMP_PRIO (2048)
void logger_init (void);
void logger_shutdown (void);
void net_send(const char *__format,...);
void logger_send (const char *__format,...);
#endif

View File

@ -19,20 +19,20 @@
#ifndef __SSNES_LOGGER_OVERRIDE_H
#define __SSNES_LOGGER_OVERRIDE_H
#ifdef __CELLOS_LV2__
#if (defined(__CELLOS_LV2__) || defined(HW_RVL)) && defined(HAVE_LOGGER)
#include "ps3/cellframework2/fileio/logger.h"
#include "console/logger/logger.h"
#define SSNES_LOG(...) do { \
if (g_extern.verbose) net_send("SSNES: " __VA_ARGS__); \
if (g_extern.verbose) logger_send("SSNES: " __VA_ARGS__); \
} while(0)
#define SSNES_ERR(...) do { \
net_send("SSNES [ERROR] :: " __VA_ARGS__); \
logger_send("SSNES [ERROR] :: " __VA_ARGS__); \
} while(0)
#define SSNES_WARN(...) do { \
net_send("SSNES [WARN] :: " __VA_ARGS__); \
logger_send("SSNES [WARN] :: " __VA_ARGS__); \
} while(0)
#endif

View File

@ -82,5 +82,6 @@ void freeaddrinfo(struct addrinfo *res);
// gai_strerror() not used, so we skip that.
#endif
#endif

View File

@ -36,10 +36,10 @@
#define MAX_PATH_LENGTH 1024
#ifdef HAVE_LOGGER
#include "../cellframework2/fileio/logger.h"
#define SSNES_LOG(...) net_send("SSNES Salamander: " __VA_ARGS__);
#define SSNES_ERR(...) net_send("SSNES Salamander [ERROR] :: " __VA_ARGS__);
#define SSNES_WARN(...) net_send("SSNES Salamander [WARN] :: " __VA_ARGS__);
#include "logger.h"
#define SSNES_LOG(...) logger_send("SSNES Salamander: " __VA_ARGS__);
#define SSNES_ERR(...) logger_send("SSNES Salamander [ERROR] :: " __VA_ARGS__);
#define SSNES_WARN(...) logger_send("SSNES Salamander [WARN] :: " __VA_ARGS__);
#else
#define SSNES_LOG(...) do { \
fprintf(stderr, "SSNES Salamander: " __VA_ARGS__); \