Пример #1
0
int main() {
    if(daemon(0, 0) < 0) {
        exit(1);
    }

    signal(SIGHUP, handler);
    signal(SIGTERM, handler);
    signal(SIGINT, handler);
    signal(SIGQUIT, handler);

    char *home = getenv("HOME");

    int size = snprintf(NULL, 0, "%s/.mpdnp.pipe", home) + 1;
    path = malloc(size);
    snprintf(path, size, "%s/.mpdnp.pipe", home);

    mkfifo(path, 0666);
    fd = open(path, O_WRONLY | O_NONBLOCK);

    if(path != NULL) {
        free(path);
    }

    write(fd, " ", 2);

    char *host = getenv("MPD_HOST");
    char *port = getenv("MPD_PORT");

    if(host == NULL) {
        host = "localhost";
    }

    if(port == NULL) {
        port = "6600";
    }

    // New object
    obj = mpd_new(host, atoi(port), NULL);

    // Connect the signal
    mpd_signal_connect_status_changed(obj, (StatusChangedCallback) status_changed, NULL);

    // Timeout
    mpd_set_connection_timeout(obj, 10);

    if(!mpd_connect(obj)) {
        while(!usleep(100000)) {
            if(obj == NULL) {
                break;
            } else {
                mpd_status_update(obj);
            }
        }
    }

    tidyUp();

    return 0;
}
Пример #2
0
// assumes indices are sorted in descending order
void eEditMesh::removeFaces(const eArray<eU32> &indices)
{
    for (eU32 i=0; i<indices.size(); i++)
    {
        eASSERT(indices[i] < m_faces.size());
        m_faces.removeSwap(indices[i]);
    }

    tidyUp();
}
Пример #3
0
TidyNetworkReply::TidyNetworkReply(const QNetworkRequest &req, QObject *parent) :
    QNetworkReply(parent)
{
    output = {0};
    errbuf = {0};
    tdoc = tidyCreate();

    offset = 0;

    nam = new QNetworkAccessManager();
    reply = nam->get(req);
    connect(reply, SIGNAL(finished()), this, SLOT(tidyUp()));
    this->setRequest(req);
}
Пример #4
0
    inline sU8 *allocate(sU32 id, sU32 size)
    {
      sInt pos;
      
      while ((pos = findAllocationSpace(size)) == -1)
      {
        handleList::reverse_iterator it;
        for (it = m_accesses.rbegin(); it != m_accesses.rend(); it++)
        {
          bufferInfo& inf = m_buffers[*it];
          
          if (inf.ptr && inf.locks == 0)
          {
            freeMemoryOf(inf);
            tidyUp();
            break;
          }
        }

        if (it == m_accesses.rend()) // nothing found? this is fatal, but print some info first
        {
          fr::debugOut("poolBufferMemoryManager::<internal>::allocate failed. stats dump:\n");

          fr::debugOut("buffers:\n");
          sInt bufCount=0;

          for (sUInt bind = 0; bind < m_buffers.size(); ++bind)
          {
            if (m_buffers[bind].size != sU32(-1))
              fr::debugOut("  %4d. id=%d, size=%d, ptr=%08x, %d locks\n", ++bufCount, bind, m_buffers[bind].size, m_buffers[bind].ptr, m_buffers[bind].locks);
            else
              fr::debugOut("  xxxx. free id %d\n", bind);
          }

          fr::debugOut("\nallocs:\n");
          for (allocVectorCIt it = m_allocations.begin(); it != m_allocations.end(); ++it)
            fr::debugOut("  start=%d size=%d buffer=%d\n", it->start, it->len, it->id);

          fr::errorExit("poolBufferMemoryManager::<internal>::allocate failed! (buf %d, size %d)", id, size);
        }
      }

      addAllocation(pos, size, id);
      return m_pool + pos;
    }
Пример #5
0
void handler(int sig) {
    tidyUp();
}
Пример #6
0
/// Destructor
UndoBuffer::~UndoBuffer()
{
  tidyUp();
  undolist.clear();
//  while (undolist.removeLast());
}