Ticket #9380: 40-zoneminder.diff

File 40-zoneminder.diff, 5.7 KB (added by Lawrence Rust <lvr@…>, 13 years ago)
  • mythzoneminder/mythzmserver/main.cpp

    diff --git a/mythzoneminder/mythzmserver/main.cpp b/mythzoneminder/mythzmserver/main.cpp
    index 0681b1c..6ca85b0 100644
    a b  
    2121#include <cstdio>
    2222#include <map>
    2323#include <sys/types.h>
     24#ifdef WIN32
     25#include <winsock2.h>
     26typedef int socklen_t;
     27#else
    2428#include <sys/socket.h>
    2529#include <sys/time.h>
    2630#include <netinet/in.h>
    2731#include <arpa/inet.h>
     32#endif
    2833#include <fcntl.h>
    2934#include <signal.h>
    3035
    int main(int argc, char **argv) 
    186191            close(logfd);
    187192    }
    188193
     194#ifndef WIN32
    189195    if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
    190196        cout << "Unable to ignore SIGPIPE\n";
     197#endif
    191198
    192199    //  Switch to daemon mode?
    193200    if (daemon_mode)
    194201    {
     202#ifndef WIN32
    195203        if (daemon(0, 0) < 0)
     204#endif
    196205        {
    197206            cout << "Failed to run as a daemon. Bailing out.\n";
    198207            return EXIT_DAEMONIZING_ERROR;
    int main(int argc, char **argv) 
    222231    }
    223232
    224233    // 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,
    226235                                                        sizeof(int)) == -1)
    227236    {
    228237        perror("setsockopt");
  • mythzoneminder/mythzmserver/mythzmserver.pro

    diff --git a/mythzoneminder/mythzmserver/mythzmserver.pro b/mythzoneminder/mythzmserver/mythzmserver.pro
    index 923f345..af2f3a6 100644
    a b macx { 
    1414    CONFIG += qt
    1515    QT += sql
    1616}
    17 !macx:LIBS = $$system(mysql_config --libs)
     17mingw:LIBS += -lwsock32 -lmysql
     18linux:LIBS = $$system(mysql_config --libs)
    1819
    1920linux: DEFINES += linux
    2021
  • mythzoneminder/mythzmserver/zmserver.cpp

    diff --git a/mythzoneminder/mythzmserver/zmserver.cpp b/mythzoneminder/mythzmserver/zmserver.cpp
    index a6c94ac..e73caf8 100644
    a b  
    1919#include <cstring>
    2020#include <cstdio>
    2121#include <errno.h>
     22#ifdef WIN32
     23#include <winsock2.h>
     24#define MSG_NOSIGNAL 0
     25#else
    2226#include <sys/socket.h>
    23 #include <fcntl.h>
    2427#include <netinet/in.h>
    2528#include <sys/stat.h>
    2629#include <sys/shm.h>
     30#endif
     31#include <fcntl.h>
    2732
    2833#ifdef linux
    2934#  include <sys/vfs.h>
    3035#  include <sys/statvfs.h>
    3136#  include <sys/sysinfo.h>
     37#elif defined USING_MINGW
     38#  include <sys/param.h>
    3239#else
    3340#  include <sys/param.h>
    3441#  include <sys/mount.h>
    ZMServer::ZMServer(int sock, bool debug) 
    207214
    208215    // get the shared memory key
    209216    char buf[100];
     217#ifndef USING_MINGW
    210218    m_shmKey = 0x7a6d2000;
    211219    string setting = getZMSetting("ZM_SHM_KEY");
    212220
    ZMServer::ZMServer(int sock, bool debug) 
    217225        snprintf(buf, sizeof(buf), "0x%x", m_shmKey);
    218226        cout << "Shared memory key is: " << buf << endl;
    219227    }
     228#else
     229    string setting;
     230#endif
    220231
    221232    // get the event filename format
    222233    setting = getZMSetting("ZM_EVENT_IMAGE_DIGITS");
    bool ZMServer::send(const string s, const unsigned char *buffer, int dataLen) co 
    352363        return false;
    353364
    354365    // send data
    355     status = ::send(m_sock, buffer, dataLen, MSG_NOSIGNAL);
     366    status = ::send(m_sock, (const char*)buffer, dataLen, MSG_NOSIGNAL);
    356367    if ( status == -1 )
    357368        return false;
    358369
    void ZMServer::handleHello() 
    378389
    379390long long ZMServer::getDiskSpace(const string &filename, long long &total, long long &used)
    380391{
     392#ifndef USING_MINGW
    381393    struct statfs statbuf;
    382394    bzero(&statbuf, sizeof(statbuf));
    383395    long long freespace = -1;
    long long ZMServer::getDiskSpace(const string &filename, long long &total, long 
    404416    }
    405417
    406418    return freespace;
     419#else
     420    return -1;
     421#endif
    407422}
    408423
    409424void ZMServer::handleGetServerStatus(void)
    void ZMServer::handleGetServerStatus(void) 
    415430    string status = runCommand(g_binPath + "/zmdc.pl check");
    416431    ADD_STR(outStr, status)
    417432
     433#ifndef USING_MINGW
    418434    // get load averages
    419435    double loads[3];
    420436    if (getloadavg(loads, 3) == -1)
    void ZMServer::handleGetServerStatus(void) 
    427443        sprintf(buf, "%0.2lf", loads[0]);
    428444        ADD_STR(outStr, buf)
    429445    }
     446#else
     447    ADD_STR(outStr, "Unknown")
     448#endif
    430449
    431450    // get free space on the disk where the events are stored
    432451    char buf[15];
    void ZMServer::initMonitor(MONITOR *monitor) 
    13091328            ((monitor->image_buffer_count) * (sizeof(struct timeval))) +
    13101329            ((monitor->image_buffer_count) * monitor->frame_size);
    13111330
     1331#ifndef USING_MINGW
    13121332    int shmid;
    13131333
    13141334    if ((shmid = shmget((m_shmKey & 0xffffff00) | monitor->mon_id,
    void ZMServer::initMonitor(MONITOR *monitor) 
    13521372            sizeof(SharedData) +
    13531373            sizeof(TriggerData) +
    13541374            ((monitor->image_buffer_count) * sizeof(struct timeval));
     1375#endif
    13551376}
    13561377
    13571378int ZMServer::getFrame(unsigned char *buffer, int bufferSize, MONITOR *monitor)
  • mythzoneminder/mythzmserver/zmserver.h

    diff --git a/mythzoneminder/mythzmserver/zmserver.h b/mythzoneminder/mythzmserver/zmserver.h
    index 849f4ec..451e1c5 100644
    a b class ZMServer 
    190190    map<int, MONITOR *>  m_monitors;
    191191    string               m_eventFileFormat;
    192192    string               m_analyseFileFormat;
     193#ifndef USING_MINGW /* Need <sys/shm.h> */
    193194    key_t                m_shmKey;
     195#endif
    194196};
    195197
    196198
  • mythzoneminder/mythzoneminder/zmliveplayer.cpp

    diff --git a/mythzoneminder/mythzoneminder/zmliveplayer.cpp b/mythzoneminder/mythzoneminder/zmliveplayer.cpp
    index 9b8fc8a..2cd05e8 100644
    a b  
    1313 * ============================================================ */
    1414
    1515#include <iostream>
     16#ifndef USING_MINGW
    1617#include <sys/shm.h>
     18#endif
    1719#include <cstdlib>
    1820
    1921// qt