#include "misc.h"#include "visualThread.h"#include "outputThread.h"#include "coreThread.h"#include "configFrontEndPlugIn.h"#include "../common/options.h"#include "../common/config.h"#include "../common/matrixThread.h"#include <dlfcn.h>#include <string>Go to the source code of this file.
Functions | |
| int | main (int argc, char** argv) |
Variables | |
| Buffer* | matrixBufIn = 0 |
| The buffer the matrixThread reads from (created in main to avoid sync-problems). More... | |
| map<int,Buffer*> | clientBufferIn |
| The buffers the matrixThread's clients (those are coreThread and outputThread) read from. More... | |
|
Definition at line 54 of file client/main.cpp.
00055 {
00056 ThreadArgs* targs = new ThreadArgs;
00057
00058 targs->argc = argc;
00059 targs->argv = argv;
00060
00061 Config* myConf = new Config ();
00062
00063 string username;
00064 string password;
00065 string server;
00066
00067 int tmpBool = false;
00068 FILE* tmpFile = fopen (CLIENT_CONFIG_FILE, "r");
00069
00070 if (tmpFile != NULL) tmpBool = true;
00071
00072 if (tmpBool) {
00073 if (myConf->openConfig (CLIENT_CONFIG_FILE)) {
00074 if (myConf->searchTag ("User")) {
00075 username = myConf->getCharVariable ("Name");
00076 password = myConf->getCharVariable ("Password");
00077 server = myConf->getCharVariable ("Server");
00078 };
00079 };
00080 } else {
00081 printf ("Configuration-file not present, starting configuration-frontend...\n");
00082
00083 struct ConfigFrontEndPlugIn* CFEPlugIn;
00084 typedef void* (*pfnPlugIn) (void);
00085 pfnPlugIn getPlugIn;
00086 void* handler;
00087 string tmpStr;
00088
00089 tmpStr = CLIENT_PLUGIN_DIR;
00090 tmpStr+= "/";
00091 tmpStr+= PLUGINNAME;
00092
00093 if ((handler = dlopen (tmpStr.c_str (), RTLD_NOW)) != NULL) {
00094 if ((getPlugIn = (pfnPlugIn)dlsym (handler, "GetConfigFrontEndPlugIn")) != NULL) {
00095 CFEPlugIn = (ConfigFrontEndPlugIn*) getPlugIn ();
00096 CFEPlugIn->init ();
00097 CFEPlugIn->run (targs->argc, targs->argv);
00098
00099 dlclose (handler);
00100 } else {
00101 printf ("Not a configuration-frontend-plugin !");
00102 exit (1);
00103 };
00104 } else {
00105 printf ("Could not open configuration-frontend-plugin !");
00106 printf ("%s\n", dlerror ());
00107 exit (1);
00108 };
00109
00110 printf ("\nConfiguration complete, starting client...\n");
00111 };
00112
00113 fprintf(stderr,"\n[3Dsia Reference Client v %d.%d.%d]",VERSION_MAJOR,
00114 VERSION_MINOR,
00115 PATCH_LEVEL );
00116 fprintf(stderr," written 2000 by Marc Haisenko & Alexander Feder\n");
00117
00118 if ( (argc > 4) || (argv[1] == "-h") || (argv[1] == "--help") )
00119 {
00120 fprintf(stderr,"\nusage:\n");
00121 fprintf(stderr,"\t %s \n",argv[0]);
00122 fprintf(stderr,"\tor %s Username Password ServerIP\n",argv[0]);
00123 exit(1);
00124 }
00125
00126 switch (argc) {
00127 case 4 : server = argv[3];
00128 case 3 : password = argv[2];
00129 case 2 : username = argv[1];
00130 default: break;
00131 };
00132
00133 if (username == "") username = "clonewar";
00134 if (password == "") password = "idpman";
00135 if (server == "") server = "127.0.0.1";
00136
00137 targs->argc = 4;
00138 targs->argv[1] = const_cast<char*>(username.c_str());
00139 targs->argv[2] = const_cast<char*>(password.c_str());
00140 targs->argv[3] = const_cast<char*>(server.c_str());
00141
00142 extern Buffer* outputBufferIn;
00143
00144 outputBufferIn = new Buffer(); //in order to prevent any segfaults if threads try to access this buffer even if outputThread didn't even yet created it..
00145
00146 //CAREFUL: Following will not work once the client is capable of connecting to more servers than one at the same time
00147 matrixBufIn = new Buffer();
00148 clientBufferIn[CLIENT_OUTPUT] = outputBufferIn;
00149
00150 pthread_t oThread; //output
00151 pthread_t mThread; //matrix
00152 pthread_t cThread; //core
00153
00154 pthread_create (&mThread, NULL, MatrixThread, NULL);
00155 pthread_create (&cThread, NULL, coreThread, targs);
00156 pthread_create (&oThread, NULL, outputThread, targs);
00157
00158 pthread_join (oThread, NULL);
00159 pthread_join (mThread, NULL);
00160 pthread_join (cThread, NULL);
00161
00162 fprintf(stderr,"\nbye!\n");
00163
00164 return 0;
00165 }
|
The buffers the matrixThread's clients (those are coreThread and outputThread) read from.
Definition at line 52 of file client/main.cpp.
|
The buffer the matrixThread reads from (created in main to avoid sync-problems).
Definition at line 51 of file client/main.cpp.
1.1.2 written by Dimitri van Heesch,
© 1997-2000