diff --git a/mythzoneminder/mythzmserver/main.cpp b/mythzoneminder/mythzmserver/main.cpp
index 0681b1c..6ca85b0 100644
|
a
|
b
|
|
| 21 | 21 | #include <cstdio> |
| 22 | 22 | #include <map> |
| 23 | 23 | #include <sys/types.h> |
| | 24 | #ifdef WIN32 |
| | 25 | #include <winsock2.h> |
| | 26 | typedef int socklen_t; |
| | 27 | #else |
| 24 | 28 | #include <sys/socket.h> |
| 25 | 29 | #include <sys/time.h> |
| 26 | 30 | #include <netinet/in.h> |
| 27 | 31 | #include <arpa/inet.h> |
| | 32 | #endif |
| 28 | 33 | #include <fcntl.h> |
| 29 | 34 | #include <signal.h> |
| 30 | 35 | |
| … |
… |
int main(int argc, char **argv)
|
| 186 | 191 | close(logfd); |
| 187 | 192 | } |
| 188 | 193 | |
| | 194 | #ifndef WIN32 |
| 189 | 195 | if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) |
| 190 | 196 | cout << "Unable to ignore SIGPIPE\n"; |
| | 197 | #endif |
| 191 | 198 | |
| 192 | 199 | // Switch to daemon mode? |
| 193 | 200 | if (daemon_mode) |
| 194 | 201 | { |
| | 202 | #ifndef WIN32 |
| 195 | 203 | if (daemon(0, 0) < 0) |
| | 204 | #endif |
| 196 | 205 | { |
| 197 | 206 | cout << "Failed to run as a daemon. Bailing out.\n"; |
| 198 | 207 | return EXIT_DAEMONIZING_ERROR; |
| … |
… |
int main(int argc, char **argv)
|
| 222 | 231 | } |
| 223 | 232 | |
| 224 | 233 | // lose the pesky "address already in use" error message |
| 225 | | if (setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, &yes, |
| | 234 | if (setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, (const char*)&yes, |
| 226 | 235 | sizeof(int)) == -1) |
| 227 | 236 | { |
| 228 | 237 | perror("setsockopt"); |
diff --git a/mythzoneminder/mythzmserver/mythzmserver.pro b/mythzoneminder/mythzmserver/mythzmserver.pro
index 923f345..af2f3a6 100644
|
a
|
b
|
macx {
|
| 14 | 14 | CONFIG += qt |
| 15 | 15 | QT += sql |
| 16 | 16 | } |
| 17 | | !macx:LIBS = $$system(mysql_config --libs) |
| | 17 | mingw:LIBS += -lwsock32 -lmysql |
| | 18 | linux:LIBS = $$system(mysql_config --libs) |
| 18 | 19 | |
| 19 | 20 | linux: DEFINES += linux |
| 20 | 21 | |
diff --git a/mythzoneminder/mythzmserver/zmserver.cpp b/mythzoneminder/mythzmserver/zmserver.cpp
index a6c94ac..e73caf8 100644
|
a
|
b
|
|
| 19 | 19 | #include <cstring> |
| 20 | 20 | #include <cstdio> |
| 21 | 21 | #include <errno.h> |
| | 22 | #ifdef WIN32 |
| | 23 | #include <winsock2.h> |
| | 24 | #define MSG_NOSIGNAL 0 |
| | 25 | #else |
| 22 | 26 | #include <sys/socket.h> |
| 23 | | #include <fcntl.h> |
| 24 | 27 | #include <netinet/in.h> |
| 25 | 28 | #include <sys/stat.h> |
| 26 | 29 | #include <sys/shm.h> |
| | 30 | #endif |
| | 31 | #include <fcntl.h> |
| 27 | 32 | |
| 28 | 33 | #ifdef linux |
| 29 | 34 | # include <sys/vfs.h> |
| 30 | 35 | # include <sys/statvfs.h> |
| 31 | 36 | # include <sys/sysinfo.h> |
| | 37 | #elif defined USING_MINGW |
| | 38 | # include <sys/param.h> |
| 32 | 39 | #else |
| 33 | 40 | # include <sys/param.h> |
| 34 | 41 | # include <sys/mount.h> |
| … |
… |
ZMServer::ZMServer(int sock, bool debug)
|
| 207 | 214 | |
| 208 | 215 | // get the shared memory key |
| 209 | 216 | char buf[100]; |
| | 217 | #ifndef USING_MINGW |
| 210 | 218 | m_shmKey = 0x7a6d2000; |
| 211 | 219 | string setting = getZMSetting("ZM_SHM_KEY"); |
| 212 | 220 | |
| … |
… |
ZMServer::ZMServer(int sock, bool debug)
|
| 217 | 225 | snprintf(buf, sizeof(buf), "0x%x", m_shmKey); |
| 218 | 226 | cout << "Shared memory key is: " << buf << endl; |
| 219 | 227 | } |
| | 228 | #else |
| | 229 | string setting; |
| | 230 | #endif |
| 220 | 231 | |
| 221 | 232 | // get the event filename format |
| 222 | 233 | setting = getZMSetting("ZM_EVENT_IMAGE_DIGITS"); |
| … |
… |
bool ZMServer::send(const string s, const unsigned char *buffer, int dataLen) co
|
| 352 | 363 | return false; |
| 353 | 364 | |
| 354 | 365 | // send data |
| 355 | | status = ::send(m_sock, buffer, dataLen, MSG_NOSIGNAL); |
| | 366 | status = ::send(m_sock, (const char*)buffer, dataLen, MSG_NOSIGNAL); |
| 356 | 367 | if ( status == -1 ) |
| 357 | 368 | return false; |
| 358 | 369 | |
| … |
… |
void ZMServer::handleHello()
|
| 378 | 389 | |
| 379 | 390 | long long ZMServer::getDiskSpace(const string &filename, long long &total, long long &used) |
| 380 | 391 | { |
| | 392 | #ifndef USING_MINGW |
| 381 | 393 | struct statfs statbuf; |
| 382 | 394 | bzero(&statbuf, sizeof(statbuf)); |
| 383 | 395 | long long freespace = -1; |
| … |
… |
long long ZMServer::getDiskSpace(const string &filename, long long &total, long
|
| 404 | 416 | } |
| 405 | 417 | |
| 406 | 418 | return freespace; |
| | 419 | #else |
| | 420 | return -1; |
| | 421 | #endif |
| 407 | 422 | } |
| 408 | 423 | |
| 409 | 424 | void ZMServer::handleGetServerStatus(void) |
| … |
… |
void ZMServer::handleGetServerStatus(void)
|
| 415 | 430 | string status = runCommand(g_binPath + "/zmdc.pl check"); |
| 416 | 431 | ADD_STR(outStr, status) |
| 417 | 432 | |
| | 433 | #ifndef USING_MINGW |
| 418 | 434 | // get load averages |
| 419 | 435 | double loads[3]; |
| 420 | 436 | if (getloadavg(loads, 3) == -1) |
| … |
… |
void ZMServer::handleGetServerStatus(void)
|
| 427 | 443 | sprintf(buf, "%0.2lf", loads[0]); |
| 428 | 444 | ADD_STR(outStr, buf) |
| 429 | 445 | } |
| | 446 | #else |
| | 447 | ADD_STR(outStr, "Unknown") |
| | 448 | #endif |
| 430 | 449 | |
| 431 | 450 | // get free space on the disk where the events are stored |
| 432 | 451 | char buf[15]; |
| … |
… |
void ZMServer::initMonitor(MONITOR *monitor)
|
| 1309 | 1328 | ((monitor->image_buffer_count) * (sizeof(struct timeval))) + |
| 1310 | 1329 | ((monitor->image_buffer_count) * monitor->frame_size); |
| 1311 | 1330 | |
| | 1331 | #ifndef USING_MINGW |
| 1312 | 1332 | int shmid; |
| 1313 | 1333 | |
| 1314 | 1334 | if ((shmid = shmget((m_shmKey & 0xffffff00) | monitor->mon_id, |
| … |
… |
void ZMServer::initMonitor(MONITOR *monitor)
|
| 1352 | 1372 | sizeof(SharedData) + |
| 1353 | 1373 | sizeof(TriggerData) + |
| 1354 | 1374 | ((monitor->image_buffer_count) * sizeof(struct timeval)); |
| | 1375 | #endif |
| 1355 | 1376 | } |
| 1356 | 1377 | |
| 1357 | 1378 | int ZMServer::getFrame(unsigned char *buffer, int bufferSize, MONITOR *monitor) |
diff --git a/mythzoneminder/mythzmserver/zmserver.h b/mythzoneminder/mythzmserver/zmserver.h
index 849f4ec..451e1c5 100644
|
a
|
b
|
class ZMServer
|
| 190 | 190 | map<int, MONITOR *> m_monitors; |
| 191 | 191 | string m_eventFileFormat; |
| 192 | 192 | string m_analyseFileFormat; |
| | 193 | #ifndef USING_MINGW /* Need <sys/shm.h> */ |
| 193 | 194 | key_t m_shmKey; |
| | 195 | #endif |
| 194 | 196 | }; |
| 195 | 197 | |
| 196 | 198 | |
diff --git a/mythzoneminder/mythzoneminder/zmliveplayer.cpp b/mythzoneminder/mythzoneminder/zmliveplayer.cpp
index 9b8fc8a..2cd05e8 100644
|
a
|
b
|
|
| 13 | 13 | * ============================================================ */ |
| 14 | 14 | |
| 15 | 15 | #include <iostream> |
| | 16 | #ifndef USING_MINGW |
| 16 | 17 | #include <sys/shm.h> |
| | 18 | #endif |
| 17 | 19 | #include <cstdlib> |
| 18 | 20 | |
| 19 | 21 | // qt |