PRBool NTStatsServer::createStatsChannel(void) { HANDLE hPipe = createPipe(); if (hPipe == INVALID_HANDLE_VALUE) { return PR_FALSE; } HANDLE hEvent = CreateEvent(NULL, // Security descriptor TRUE, // Manual Rest TRUE, // Initially Signaled state NULL); // Unnamed if (hEvent == INVALID_HANDLE_VALUE) { CloseHandle(hPipe); return PR_FALSE; } if (addPollItem(hPipe, hEvent) != PR_TRUE) { CloseHandle(hPipe); CloseHandle(hEvent); return PR_FALSE; } int nIndex = nPollItems_ - 1; if (connectPipe(nIndex) == PR_FALSE) { return PR_FALSE; } return PR_TRUE; }
int agregar(char *prefixo[], unsigned nivel, char *path) { char buffer[BUFF_SIZE]; int i = 0, nNomes = 0, lixo = 0; int pipeServ = 0; if( (pipeServ = connectPipe()) <= 0 ) return 1; while(prefixo[nNomes] != NULL) { nNomes++; } nNomes++; sprintf(buffer, "%d number", nNomes); lixo = write(pipeServ, buffer, BUFF_SIZE); while(prefixo[i] != NULL) { lixo = write(pipeServ, prefixo[i], BUFF_SIZE); i++; } sprintf(buffer, "0 %d %s", nivel, path); lixo = write(pipeServ, buffer, BUFF_SIZE); close(pipeServ); return 0; lixo++; }
// Ensure that we're connected to the PIME input method server // If we are already connected, the method simply returns true; // otherwise, it tries to establish the connection. bool Client::connectServerPipe() { if (pipe_ == INVALID_HANDLE_VALUE) { // the pipe is not connected connectingServerPipe_ = true; wstring serverPipeName = getPipeName(L"Launcher"); // try to connect to the server pipe_ = connectPipe(serverPipeName.c_str()); if (pipe_ != INVALID_HANDLE_VALUE) { // successfully connected to the server init(); // send initialization info to the server if (isActivated_) { // we lost connection while being activated previously // re-initialize the whole text service. // cleanup for the previous instance. // remove all buttons for (auto& item: buttons_) { textService_->removeButton(item.second); } buttons_.clear(); // FIXME: other cleanup might also be needed // activate the text service again. onActivate(); } } connectingServerPipe_ = false; return (pipe_ != INVALID_HANDLE_VALUE); } return true; }
int incrementar(char *nome[], unsigned valor) { char buffer[BUFF_SIZE]; int i = 0, nNomes = 0, lixo = 0; int pipeServ = 0; if( (pipeServ = connectPipe()) <= 0 ) return 1; while(nome[nNomes] != NULL) { nNomes++; } nNomes++; sprintf(buffer, "%d number", nNomes); lixo = write(pipeServ, buffer, BUFF_SIZE); while(nome[i] != NULL) { lixo = write(pipeServ, nome[i], BUFF_SIZE); i++; } sprintf(buffer, "1 %d useless", valor); lixo = write(pipeServ, buffer, BUFF_SIZE); close(pipeServ); return 0; lixo++; }