コード例 #1
0
ファイル: mpdnp.c プロジェクト: Zariel/mpdnp
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.cpp プロジェクト: jackuess/titta
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
ファイル: memmgr.cpp プロジェクト: Ambrevar/fr_public
    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
ファイル: mpdnp.c プロジェクト: Zariel/mpdnp
void handler(int sig) {
    tidyUp();
}
コード例 #6
0
ファイル: UndoBuffer.cpp プロジェクト: Kampbell/qfsm
/// Destructor
UndoBuffer::~UndoBuffer()
{
  tidyUp();
  undolist.clear();
//  while (undolist.removeLast());
}