Main Page | Class List | File List | Class Members | File Members

demo_header.h

Go to the documentation of this file.
00001 00015 #include <iostream> 00016 #include <string> 00017 #include <sstream> 00018 00019 #ifdef WIN32 00020 //disable the (stupid) warning "identifier was truncated in debug information" 00021 // which happens because of the use of a map with two strings from the STL 00022 #pragma warning(disable:4786) 00023 00024 #include <windows.h> 00025 #include <conio.h> 00026 #define ioctl ioctlsocket 00027 #else 00028 #include <sys/ioctl.h> 00029 #include <time.h> 00030 #endif 00031 00032 using namespace std; 00033 00034 00035 //define bzero as a macro in case it is not provided by the system-libs (windows) 00036 #ifndef HAVE_BZERO 00037 #define bzero(ptr,n) memset(ptr,0,n) 00038 #endif 00039 00040 #define READBUFSIZE 100 00041 00042 //=== constants for main demo_db object 00043 00044 #define def_DBFILE "pc_db.txt" 00045 #define def_PORT 4701 00046 #define def_IP "127.0.0.1" 00047 00048 #define DS175FILENAME "ds175format.txt" 00049 #define PC2FILENAME "PC2format.txt" 00050 00051 #define HELPTEXT "\ 00052 Usage: pc_demo [-fhipv]\n\ 00053 \n\ 00054 -f=FILENAME : set the filename of the database-text file to use.\n\ 00055 default: pc_db.txt\n\ 00056 -h : this helptext.\n\ 00057 -i=IPADDRESS : the IP-address of the PC_ethernet_driver to connect to.\n\ 00058 In dotted-decimal notation (e.g. 222.222.222.222)\n\ 00059 default: 127.0.0.1 (localhost)\n\ 00060 -p=PORTNUMBER : the number of the port of the PC_ethernet_driver.\n\ 00061 default: 4701\n\ 00062 -v : display version information.\n\ 00063 " 00064 00065 #define HELPCMDTEXT "\ 00066 Command help:\n\ 00067 - ?, help : This helptext.\n\ 00068 - quit : Quit the PC_Database demo.\n\ 00069 - send <file> : Send the contents of <file> to the PC_Ethernet_Driver.\n\ 00070 NO formatting is done; the contents of the file is sent\n\ 00071 as-is, including special characters like LF or CR.\n\ 00072 - loadformat : (re)Loads the PCxx format files\n\ 00073 - loaddb <name> : Load the database with filename <name>.\n\ 00074 If no name specified reload the last database.\n\ 00075 " 00076 00077 #define VERSIONTEXT "\n\ 00078 PC_Database demo.\n\ 00079 Version 0.9\n\ 00080 " 00081 00082 #ifndef DEMO_HEADER_H 00083 #define DEMO_HEADER_H 00084 00090 inline void mSleep(int msec) { 00091 #ifdef WIN32 00092 Sleep(msec); 00093 #endif 00094 #ifndef WIN32 00095 struct timespec nanotime; 00096 nanotime.tv_sec=0; 00097 nanotime.tv_nsec=msec*1000000; 00098 nanosleep(&nanotime, NULL); 00099 #endif 00100 }; 00101 00102 #define ESC "\x1b" 00103 #define ESCALIAS "<ESC>" 00104 00110 inline string ExpandEsc(string s) { 00111 unsigned int pos; 00112 string EscStr = ESCALIAS; 00113 //replace any "<ESC>" with an ESCAPE - ESC == '\x1b' 00114 pos=0; 00115 while (pos != string::npos){ 00116 pos = s.find(EscStr, pos); 00117 if (pos!= string::npos){ 00118 s.replace(pos,EscStr.size(), ESC); 00119 }; 00120 }; 00121 return s; 00122 } 00123 00124 #endif

Generated on Thu Jun 16 15:47:18 for pc_demo.kdevelop by doxygen 1.3.8