aboutsummaryrefslogtreecommitdiff
path: root/plugins/dfnet
diff options
context:
space:
mode:
authornotaz2010-11-18 14:47:57 +0200
committernotaz2010-11-18 14:47:57 +0200
commitf2bd6ff85d23f3e421b2f30f86080d71d4e95046 (patch)
tree48de2d061424762f17d752b68e774d981b799634 /plugins/dfnet
parent80c2304e511b5463b5046f7ff1c49103c786755f (diff)
downloadpcsx_rearmed-f2bd6ff85d23f3e421b2f30f86080d71d4e95046.tar.gz
pcsx_rearmed-f2bd6ff85d23f3e421b2f30f86080d71d4e95046.tar.bz2
pcsx_rearmed-f2bd6ff85d23f3e421b2f30f86080d71d4e95046.zip
rm plugins that we won't use
Diffstat (limited to 'plugins/dfnet')
-rw-r--r--plugins/dfnet/cfg.c37
-rw-r--r--plugins/dfnet/dfnet.c274
-rw-r--r--plugins/dfnet/dfnet.h80
-rw-r--r--plugins/dfnet/gui.c233
-rw-r--r--plugins/dfnet/unix.c125
5 files changed, 0 insertions, 749 deletions
diff --git a/plugins/dfnet/cfg.c b/plugins/dfnet/cfg.c
deleted file mode 100644
index a63b074..0000000
--- a/plugins/dfnet/cfg.c
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// DF Netplay Plugin
-//
-// Based on netSock 0.2 by linuzappz.
-// The Plugin is free source code.
-//
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "dfnet.h"
-
-#define CFG_FILENAME "dfnet.cfg"
-
-void SaveConf() {
- FILE *f;
-
- f = fopen(CFG_FILENAME, "w");
- if (f == NULL) return;
- fwrite(&conf, 1, sizeof(conf), f);
- fclose(f);
-}
-
-void LoadConf() {
- FILE *f;
-
- f = fopen(CFG_FILENAME, "r");
- if (f == NULL) {
- conf.PlayerNum = 1;
- conf.PortNum = 33306;
- strcpy(conf.ipAddress, "127.0.0.1");
- return;
- }
-
- fread(&conf, 1, sizeof(conf), f);
- fclose(f);
-}
diff --git a/plugins/dfnet/dfnet.c b/plugins/dfnet/dfnet.c
deleted file mode 100644
index d76a757..0000000
--- a/plugins/dfnet/dfnet.c
+++ /dev/null
@@ -1,274 +0,0 @@
-//
-// DF Netplay Plugin
-//
-// Based on netSock 0.2 by linuzappz.
-// The Plugin is free source code.
-//
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <errno.h>
-extern int errno;
-
-#include "dfnet.h"
-
-const unsigned char version = 2; // NET library v2
-const unsigned char revision = 0;
-const unsigned char build = 3; // increase that with each version
-
-static char *libraryName = N_("Socket Driver");
-
-unsigned long CALLBACK PSEgetLibType() {
- return PSE_LT_NET;
-}
-
-char* CALLBACK PSEgetLibName() {
- return _(libraryName);
-}
-
-unsigned long CALLBACK PSEgetLibVersion() {
- return version << 16 | revision << 8 | build;
-}
-
-long CALLBACK NETinit() {
- return sockInit();
-}
-
-int SEND(const void *buf, int Size, int Mode) {
- int bytes;
- int count = 0;
- const char *pData = (const char *)buf;
-
- if (Mode & PSE_NET_NONBLOCKING) { // NONBLOCKING
- int ret;
-
- FD_ZERO(&wset);
- FD_SET(sock, &wset);
-
- ret = select(sock + 1, NULL, &wset, NULL, &tm);
- if (ret == -1) return -1;
-
- if (FD_ISSET(sock, &wset)) {
- return send(sock, pData, Size, 0);
- } else {
- return 0;
- }
- } else { // BLOCKING
- while (Size > 0) {
- bytes = send(sock, pData, Size, 0);
- if (bytes < 0) return -1;
- pData += bytes; Size -= bytes;
- count += bytes;
- }
- }
-
- return count;
-}
-
-int RECV(void *buf, int Size, int Mode) {
- int bytes;
- int count = 0;
- char *pData = (char *)buf;
-
- if (Mode & PSE_NET_NONBLOCKING) { // NONBLOCKING
- int ret;
-
- FD_ZERO(&rset);
- FD_SET(sock, &rset);
-
- ret = select(sock, &rset, NULL, NULL, &tm);
-
- if (FD_ISSET(sock, &rset)) {
- return recv(sock, pData, Size, 0);
- } else {
- return 0;
- }
- } else { // BLOCKING
- while (Size > 0) {
- bytes = recv(sock, pData, Size, 0);
- if (bytes == -1) return -1;
- pData+= bytes; Size-= bytes;
- count+= bytes;
- }
- }
-
- return count;
-}
-
-long CALLBACK NETopen(unsigned long *gpuDisp) {
- int ret = sockOpen();
-
- struct sockaddr_in address;
-
- if (ret == -1) return -1;
-
- if (conf.PlayerNum == 1) {
- int listen_sock, reuse_addr = 1;
- int ret;
-
- memset((char *)&address, 0, sizeof (address));
-
- address.sin_family = AF_INET;
- address.sin_port = htons(conf.PortNum);
- address.sin_addr.s_addr = INADDR_ANY;
-
- listen_sock = socket(AF_INET, SOCK_STREAM, 0);
- if (listen_sock == -1)
- return -1;
-
- setsockopt(listen_sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&reuse_addr, sizeof(reuse_addr));
-
- if (bind(listen_sock,(struct sockaddr *) &address, sizeof(address)) == -1)
- return -1;
-
- if (listen(listen_sock, 1) != 0)
- return -1;
-
- sock = -1;
-
- WaitCancel = 0;
- sockCreateWaitDlg();
-
- while (sock < 0) {
- FD_ZERO(&rset);
- FD_SET(listen_sock, &rset);
-
- ret = select(listen_sock + 1, &rset, NULL, NULL, &tm);
- if (FD_ISSET(listen_sock, &rset)) {
- sock = accept(listen_sock, NULL, NULL);
- }
-
- if (WaitCancel) break;
- sockDlgUpdate();
- }
- close(listen_sock);
-
- sockDestroyWaitDlg();
- if (WaitCancel == 1) return -1;
- } else {
- memset((char *)&address, 0, sizeof(address));
- address.sin_family = AF_INET;
- address.sin_port = htons(conf.PortNum);
- address.sin_addr.s_addr = inet_addr(conf.ipAddress);
-
- sock = socket(AF_INET, SOCK_STREAM, 0);
-
- if (connect(sock, (struct sockaddr *)&address, sizeof(address))!=0) {
- SysMessage(_("error connecting to %s: %s\n"), conf.ipAddress, strerror(errno));
- return -1;
- }
- }
-
- PadInit = 0;
- PadCount = 0;
- PadSize[0] = -1;
- PadSize[1] = -1;
- PadRecvSize = -1;
- PadSendSize = -1;
- Ping = sockPing();
- Ping = (sockPing() + Ping) / 2;
- Ping = (sockPing() + Ping) / 2;
-
- if (conf.PlayerNum == 1) {
- PadCountMax = (int)(((double)Ping / 1000.0) * 60.0);
- if (PadCountMax <= 0) PadCountMax = 1;
- SEND(&PadCountMax, 4, PSE_NET_BLOCKING);
- } else {
- RECV(&PadCountMax, 4, PSE_NET_BLOCKING);
- }
-
- PadSendData = (char *)malloc(PadCountMax * 128);
- if (PadSendData == NULL) {
- SysMessage(_("Error allocating memory!\n")); return -1;
- }
- memset(PadSendData, 0xff, PadCountMax);
-
- return ret;
-}
-
-long CALLBACK NETclose() {
- close(sock);
-
- return 0;
-}
-
-long CALLBACK NETshutdown() {
- return sockShutdown();
-}
-
-void CALLBACK NETpause() {
-/* unsigned char Code = 0x80;
-
- SEND(&Code, 1, PSE_NET_BLOCKING);*/
-}
-
-void CALLBACK NETresume() {
-/* unsigned char Code = 0x80;
-
- SEND(&Code, 1, PSE_NET_BLOCKING);*/
-}
-
-long CALLBACK NETsendData(void *pData, int Size, int Mode) {
- return SEND(pData, Size, Mode);
-}
-
-long CALLBACK NETrecvData(void *pData, int Size, int Mode) {
- return RECV(pData, Size, Mode);
-}
-
-long CALLBACK NETsendPadData(void *pData, int Size) {
- if (PadSendSize == -1) {
- PadSendSize = Size;
-
- if (SEND(&PadSendSize, 1, PSE_NET_BLOCKING) == -1)
- return -1;
-
- if (RECV(&PadRecvSize, 1, PSE_NET_BLOCKING) == -1)
- return -1;
- }
-
- memcpy(&PadSendData[PadCount], pData, Size);
- if (SEND(pData, PadSendSize, PSE_NET_BLOCKING) == -1)
- return -1;
-
- return 0;
-}
-
-long CALLBACK NETrecvPadData(void *pData, int Pad) {
- if (PadInit == 0) {
- if (conf.PlayerNum == Pad) {
- memset(pData, 0xff, PadSendSize);
- } else {
- memset(pData, 0xff, PadRecvSize);
- }
- } else {
- if (conf.PlayerNum == Pad) {
- memcpy(pData, &PadSendData[PadCount == 0 ? PadCountMax-1 : PadCount-1], PadSendSize);
- } else {
- if (RECV(pData, PadRecvSize, PSE_NET_BLOCKING) == -1)
- return -1;
- }
- }
-
- if (Pad == 2) {
- PadCount++;
- if (PadCount == PadCountMax) {
- PadCount = 0;
- PadInit = 1;
- }
- }
-
- return 0;
-}
-
-long CALLBACK NETqueryPlayer() {
- return conf.PlayerNum;
-}
-
-long CALLBACK NETtest() {
- return 0;
-}
diff --git a/plugins/dfnet/dfnet.h b/plugins/dfnet/dfnet.h
deleted file mode 100644
index 62f3842..0000000
--- a/plugins/dfnet/dfnet.h
+++ /dev/null
@@ -1,80 +0,0 @@
-//
-// DF Netplay Plugin
-//
-// Based on netSock 0.2 by linuzappz.
-// The Plugin is free source code.
-//
-
-#ifndef __DFNET_H__
-#define __DFNET_H__
-
-#include "config.h"
-
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#include <locale.h>
-#define _(x) gettext(x)
-#define N_(x) (x)
-#else
-#define _(x) (x)
-#define N_(x) (x)
-#endif
-
-typedef void* HWND;
-
-struct timeval tm;
-
-#define CALLBACK
-
-long timeGetTime();
-
-#include "psemu_plugin_defs.h"
-
-typedef struct {
- int PlayerNum;
- unsigned short PortNum;
- char ipAddress[32];
-} Config;
-
-Config conf;
-
-void LoadConf();
-void SaveConf();
-
-long sock;
-char *PadSendData;
-char *PadRecvData;
-char PadSendSize;
-char PadRecvSize;
-char PadSize[2];
-int PadCount;
-int PadCountMax;
-int PadInit;
-int Ping;
-volatile int WaitCancel;
-fd_set rset;
-fd_set wset;
-
-long sockInit();
-long sockShutdown();
-long sockOpen();
-void sockCreateWaitDlg();
-void sockDlgUpdate();
-void sockDestroyWaitDlg();
-int sockPing();
-
-int ShowPauseDlg();
-void SysMessage(const char *fmt, ...);
-
-int SEND(const void *pData, int Size, int Mode);
-int RECV(void *pData, int Size, int Mode);
-
-#endif
diff --git a/plugins/dfnet/gui.c b/plugins/dfnet/gui.c
deleted file mode 100644
index 60e165a..0000000
--- a/plugins/dfnet/gui.c
+++ /dev/null
@@ -1,233 +0,0 @@
-//
-// DF Netplay Plugin
-//
-// Based on netSock 0.2 by linuzappz.
-// The Plugin is free source code.
-//
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-#include <glade/glade.h>
-#include <signal.h>
-
-#include "cfg.c"
-
-void cfgSysMessage(const char *fmt, ...) {
- GtkWidget *MsgDlg;
- va_list list;
- char msg[512];
-
- va_start(list, fmt);
- vsprintf(msg, fmt, list);
- va_end(list);
-
- if (msg[strlen(msg) - 1] == '\n') msg[strlen(msg) - 1] = 0;
-
- MsgDlg = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("NetPlay"));
- gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(MsgDlg), "%s", msg);
-
- gtk_dialog_run(GTK_DIALOG(MsgDlg));
- gtk_widget_destroy(MsgDlg);
-}
-
-void CFGconfigure() {
- cfgSysMessage(_("Nothing to configure"));
-}
-
-#ifdef __linux__
-
-#include <sys/ioctl.h>
-#include <linux/if.h>
-
-#define MAXINTERFACES 16
-
-void sockGetIP(char *IPAddress) {
- int fd, intrface;
- struct ifreq buf[MAXINTERFACES];
- struct ifconf ifc;
- struct sockaddr_in addr;
-
- strcpy(IPAddress, "127.0.0.1");
-
- if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) {
- ifc.ifc_len = sizeof(buf);
- ifc.ifc_buf = (caddr_t)buf;
- if (!ioctl(fd, SIOCGIFCONF, (char *)&ifc)) {
- intrface = ifc.ifc_len / sizeof(struct ifreq);
- while (intrface-- > 0) {
- if (!(ioctl(fd, SIOCGIFADDR, (char *)&buf[intrface]))) {
- memcpy(&addr, &(buf[intrface].ifr_addr), sizeof(addr));
- strcpy(IPAddress, inet_ntoa(addr.sin_addr));
- break;
- }
- }
- }
- close(fd);
- }
-}
-
-#else
-
-void sockGetIP(char *IPAddress) {
- struct hostent *host;
- char str[256];
-
- gethostname(str, 256);
- host = gethostbyname(str);
-
- if (host != NULL)
- strcpy(IPAddress, inet_ntoa(*((struct in_addr *)host->h_addr_list[0])));
- else strcpy(IPAddress, "127.0.0.1");
-}
-
-#endif
-
-void OnCopyIP(GtkWidget *widget, gpointer user_data) {
- char str[256];
-
- sockGetIP(str);
- gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), str, strlen(str));
- cfgSysMessage(_("IP %s"), str);
-}
-
-long CFGopen() {
- GladeXML *xml;
- GtkWidget *widget, *MainWindow;
- char buf[256];
-
- LoadConf();
-
- xml = glade_xml_new(DATADIR "dfnet.glade2", "dlgStart", NULL);
- if (xml == NULL) {
- g_warning("We could not load the interface!");
- return 0;
- }
-
- MainWindow = glade_xml_get_widget(xml, "dlgStart");
- gtk_window_set_title(GTK_WINDOW(MainWindow), _("NetPlay"));
-
- widget = glade_xml_get_widget(xml, "btnCopyIP");
- g_signal_connect_data(GTK_OBJECT(widget), "clicked",
- GTK_SIGNAL_FUNC(OnCopyIP), NULL, NULL, G_CONNECT_AFTER);
-
- widget = glade_xml_get_widget(xml, "tbServerIP");
- gtk_entry_set_text(GTK_ENTRY(widget), conf.ipAddress);
-
- widget = glade_xml_get_widget(xml, "tbPort");
- sprintf(buf, "%d", conf.PortNum);
- gtk_entry_set_text(GTK_ENTRY(widget), buf);
-
- if (conf.PlayerNum == 1) {
- widget = glade_xml_get_widget(xml, "rbServer");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
- } else {
- widget = glade_xml_get_widget(xml, "rbClient");
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
- }
-
- if (gtk_dialog_run(GTK_DIALOG(MainWindow)) == GTK_RESPONSE_OK) {
- widget = glade_xml_get_widget(xml, "tbServerIP");
- strcpy(conf.ipAddress, gtk_entry_get_text(GTK_ENTRY(widget)));
-
- widget = glade_xml_get_widget(xml, "tbPort");
- conf.PortNum = atoi(gtk_entry_get_text(GTK_ENTRY(widget)));
-
- widget = glade_xml_get_widget(xml, "rbServer");
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
- conf.PlayerNum = 1;
- } else {
- conf.PlayerNum = 2;
- }
-
- SaveConf();
- gtk_widget_destroy(MainWindow);
- return 1;
- }
-
- gtk_widget_destroy(MainWindow);
-
- return 0;
-}
-
-void OnWaitDialog_Abort() {
- kill(getppid(), SIGUSR2);
-}
-
-void CFGwait() {
- GtkWidget *WaitDlg;
-
- WaitDlg = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO,
- GTK_BUTTONS_CANCEL, _("Waiting for connection..."));
-
- gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(WaitDlg),
- _("The Client should now Start a Connection, waiting..."));
-
- gtk_dialog_run(GTK_DIALOG(WaitDlg));
- gtk_widget_destroy(WaitDlg);
-
- OnWaitDialog_Abort();
-}
-
-long CFGpause() {
- return 0;
-}
-
-void CFGabout() {
- const char *authors[]= {"linuzappz <linuzappz@hotmail.com>", "Wei Mingzhi <whistler_wmz@users.sf.net>", NULL};
- GtkWidget *widget;
-
- widget = gtk_about_dialog_new();
- gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(widget), "Socket NetPlay Driver");
- gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(widget), "0.21");
- gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(widget), authors);
- gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(widget), "http://www.codeplex.com/pcsxr/");
-
- gtk_dialog_run(GTK_DIALOG(widget));
- gtk_widget_destroy(widget);
-}
-
-long CFGmessage(char *args[], int num) {
- char msg[512];
-
- memset(msg, 0, sizeof(msg));
- while (num) {
- strcat(msg, *args); strcat(msg, " ");
- num--; args++;
- }
- cfgSysMessage(msg);
-
- return 0;
-}
-
-int main(int argc, char *argv[]) {
-#ifdef ENABLE_NLS
- setlocale(LC_ALL, "");
- bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
- textdomain(GETTEXT_PACKAGE);
-#endif
-
- gtk_set_locale();
- gtk_init(&argc, &argv);
-
- if (!strcmp(argv[1], "configure")) {
- CFGconfigure();
- } else if (!strcmp(argv[1], "open")) {
- return CFGopen();
- } else if (!strcmp(argv[1], "wait")) {
- CFGwait();
- } else if (!strcmp(argv[1], "pause")) {
- return CFGpause();
- } else if (!strcmp(argv[1], "about")) {
- CFGabout();
- } else if (!strcmp(argv[1], "message")) {
- CFGmessage(&argv[2], argc - 2);
- }
-
- return 0;
-}
diff --git a/plugins/dfnet/unix.c b/plugins/dfnet/unix.c
deleted file mode 100644
index 390a5fc..0000000
--- a/plugins/dfnet/unix.c
+++ /dev/null
@@ -1,125 +0,0 @@
-//
-// DF Netplay Plugin
-//
-// Based on netSock 0.2 by linuzappz.
-// The Plugin is free source code.
-//
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <signal.h>
-#include <sys/wait.h>
-extern int errno;
-
-#include "dfnet.h"
-
-int ExecCfg(const char *arg, int f) {
- char cfg[512];
-
- strcpy(cfg, "cfg/cfgDFNet");
- strcat(cfg, " ");
- strcat(cfg, arg);
-
- if (f) {
- if (fork() == 0) { system(cfg); exit(0); }
- return 0;
- }
-
- return system(cfg);
-}
-
-void SysMessage(const char *fmt, ...) {
- va_list list;
- char msg[512];
- char cmd[512];
-
- va_start(list, fmt);
- vsprintf(msg, fmt, list);
- va_end(list);
-
- sprintf(cmd, "message %s\n", msg);
- ExecCfg(cmd, 1);
-}
-
-long sockInit() {
- conf.PlayerNum = 0;
- tm.tv_sec = 0;
- tm.tv_usec = 0;
-
- return 0;
-}
-
-long sockShutdown() {
- return 0;
-}
-
-long sockOpen() {
- if (ExecCfg("open", 0) == 0) return -1;
-
- LoadConf();
-
- return 0;
-}
-
-int sockPing() {
- char data[32];
- struct timeval tv, tvn;
-
- memset(data, 0, sizeof(data));
-
- gettimeofday(&tv, NULL);
- SEND(data, 32, PSE_NET_BLOCKING);
- RECV(data, 32, PSE_NET_BLOCKING);
- gettimeofday(&tvn, NULL);
-
- return (tvn.tv_sec - tv.tv_sec) * 1000 +
- (tvn.tv_usec - tv.tv_usec) / 1000;
-}
-
-void CALLBACK NETconfigure() {
- ExecCfg("configure", 1);
-}
-
-void CALLBACK NETabout() {
- ExecCfg("about", 1);
-}
-
-pid_t cfgpid = 0;
-
-void OnWaitDlg_Abort(int num) {
- WaitCancel = 1;
- cfgpid = 0;
-}
-
-void sockCreateWaitDlg() {
- signal(SIGUSR2, OnWaitDlg_Abort);
- if ((cfgpid = fork()) == 0) {
- execl("cfg/cfgDFNet", "cfgDFNet", "wait", NULL);
- exit(0);
- }
- usleep(100000);
-}
-
-void sockDlgUpdate() {
- usleep(100000);
-}
-
-void sockDestroyWaitDlg() {
- if (cfgpid > 0) {
- kill(cfgpid, SIGKILL);
- cfgpid = 0;
- }
-}
-
-long timeGetTime() {
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
- return (tv.tv_sec) * 1000 + (tv.tv_usec) / 1000;
-}