static TACommandVerdict getpriority_cmd(TAThread thread,TAInputStream stream) { int which; int who ; int res ; // Prepare which = readInt( & stream ); who = readInt( & stream ); errno = 0; // Execute START_TARGET_OPERATION(thread); res = getpriority( which, who ); END_TARGET_OPERATION(thread); // Response writeInt( thread, res ); writeInt( thread, errno ); sendResponse( thread ); return taDefaultVerdict; }
static TACommandVerdict gzdopen_cmd(TAThread thread,TAInputStream stream) { char *mode; void* res; int fd; fd = readInt(&stream); mode = readString(&stream); START_TARGET_OPERATION(thread); errno=0; res = gzdopen(fd, mode); END_TARGET_OPERATION(thread); writeInt(thread, errno); writePointer(thread, res); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict gzprintf_cmd(TAThread thread,TAInputStream stream) { void* file; char* s; int res, errnum; file = readPointer(&stream); s = readString(&stream); START_TARGET_OPERATION(thread); res = gzprintf(file, s); END_TARGET_OPERATION(thread); writeInt(thread, errnum); writeInt(thread, errno); writeInt(thread, res); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict wcscat_cmd(TAThread thread,TAInputStream stream) { wchar_t* ws1; wchar_t* ws2; wchar_t* res; // Prepare ws1 = (wchar_t*)readPointer(&stream); ws2 = (wchar_t*)readPointer(&stream); START_TARGET_OPERATION(thread); // Execute res = wcscat(ws1, ws2); END_TARGET_OPERATION(thread); // Response writePointer(thread, res); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict gztell_cmd(TAThread thread,TAInputStream stream) { void* file; z_off_t res; int errnum; file = readPointer(&stream); START_TARGET_OPERATION(thread); res = gztell(file); END_TARGET_OPERATION(thread); gzerror(file, &errnum); writeInt(thread, errnum); writeLLong(thread, (long long)res); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict wcpcpy_cmd(TAThread thread,TAInputStream stream) { wchar_t* dest; wchar_t* src; wchar_t* res; // Prepare dest = (wchar_t*)readPointer(&stream); src = (wchar_t*)readPointer(&stream); START_TARGET_OPERATION(thread); // Execute res = wcpcpy(dest, src); END_TARGET_OPERATION(thread); // Response writePointer(thread, res); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict wcsrchr_cmd(TAThread thread,TAInputStream stream) { wchar_t* ws; int wc; wchar_t* res; // Prepare ws = (wchar_t*)readPointer(&stream); wc = readWChar(&stream); START_TARGET_OPERATION(thread); // Execute res = wcsrchr(ws, wc); END_TARGET_OPERATION(thread); // Response writePointer(thread, res); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict wmemcpy_cmd(TAThread thread,TAInputStream stream) { wchar_t* ws1; wchar_t* ws2; size_t n; wchar_t* res; // Prepare ws1 = readPointer(&stream); ws2 = readPointer(&stream); n = readSize(&stream); // Execute START_TARGET_OPERATION(thread); res = wmemcpy( ws1, ws2, n); END_TARGET_OPERATION(thread); // Response writePointer(thread, res); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict wmemchr_cmd(TAThread thread,TAInputStream stream) { wchar_t* s; wchar_t c; size_t n; wchar_t* res; // Prepare s = readPointer(&stream); c = readWChar(&stream); n = readSize(&stream); // Execute START_TARGET_OPERATION(thread); res = wmemchr( s, c, n ); END_TARGET_OPERATION(thread); // Response writePointer(thread,res); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict ctime_r_cmd(TAThread thread,TAInputStream stream) { time_t clock; char * buf ; char * res ; // Prepare clock = readLong ( & stream ); buf = readString( & stream ); // Execute START_TARGET_OPERATION(thread); res = ctime_r( & clock, buf ); END_TARGET_OPERATION(thread); // Response writeInt( thread, res == NULL ); if ( res != NULL ) { writeString( thread, res ); } writeString( thread, buf ); sendResponse( thread ); return taDefaultVerdict; }
static TACommandVerdict nice_cmd(TAThread thread,TAInputStream stream) { int incr; int res ; // ta_debug_printf( "[%3d]", nice( 0 ) ); // Prepare incr = readInt( & stream ); errno = 0; // Execute START_TARGET_OPERATION(thread); res = nice( incr ); END_TARGET_OPERATION(thread); // ta_debug_printf( "[%3d|%3d|%3d|%3d|%3d|%3d]\n", res, incr, getuid(), geteuid(), getgid(), getegid() ); // Response writeInt( thread, res ); writeInt( thread, errno ); sendResponse( thread ); return taDefaultVerdict; }
static void add(Dict* args, void* vcontext, String* txid, struct Allocator* alloc) { struct Context* context = (struct Context*) vcontext; String* passwd = Dict_getString(args, String_CONST("password")); int64_t* authType = Dict_getInt(args, String_CONST("authType")); String* user = Dict_getString(args, String_CONST("user")); String* ipv6 = Dict_getString(args, String_CONST("ipv6")); int64_t one = 1; if (!authType) { authType = &one; } else if (*authType < 1 || *authType > 255) { sendResponse(String_CONST("Specified auth type is not supported."), context->admin, txid, alloc); return; } int32_t ret = CryptoAuth_addUser_ipv6(passwd, *authType, user, ipv6, context->ca); switch (ret) { case 0: sendResponse(String_CONST("none"), context->admin, txid, alloc); break; case CryptoAuth_addUser_INVALID_AUTHTYPE: sendResponse(String_CONST("Specified auth type is not supported."), context->admin, txid, alloc); break; case CryptoAuth_addUser_OUT_OF_SPACE: sendResponse(String_CONST("Out of memory to store password."), context->admin, txid, alloc); break; case CryptoAuth_addUser_DUPLICATE: sendResponse(String_CONST("Password already added."), context->admin, txid, alloc); break; case CryptoAuth_addUser_INVALID_IP: sendResponse(String_CONST("Invalid IPv6 Address"), context->admin, txid, alloc); break; default: sendResponse(String_CONST("Unknown error."), context->admin, txid, alloc); } }
static TACommandVerdict gmtime_cmd(TAThread thread,TAInputStream stream) { time_t timer; struct tm * res ; // Prepare timer = readLong( & stream ); errno = 0; // Execute START_TARGET_OPERATION(thread); res = gmtime( & timer ); END_TARGET_OPERATION(thread); ta_debug_printf("gmtime_param: %d, res: %d", timer, res->tm_sec); // Response writeTm ( thread, res ); writeInt( thread, errno ); sendResponse( thread ); return taDefaultVerdict; }
static TACommandVerdict pthread_rwlock_init_cmd(TAThread thread, TAInputStream stream) { pthread_rwlock_t* rwlock; pthread_rwlockattr_t* attr; int res; // Prepare rwlock = readPointer(&stream); attr = readPointer(&stream); START_TARGET_OPERATION(thread); // Execute res = pthread_rwlock_init(rwlock, attr); END_TARGET_OPERATION(thread); // Response writeInt(thread, res); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict strdup_cmd(TAThread thread, TAInputStream stream) { char* s1; char* res; // Prepare s1 = (char*)readPointer(&stream); START_TARGET_OPERATION(thread); // Execute errno = 0; res = strdup(s1); END_TARGET_OPERATION(thread); // Response writePointer(thread, res); writeInt(thread, errno); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict malloc_cmd(TAThread thread,TAInputStream stream) { size_t size; void* res; // Prepare size = readSize(&stream); START_TARGET_OPERATION(thread); // Execute errno = 0; res = malloc(size); END_TARGET_OPERATION(thread); // Response writePointer(thread, res); writeInt(thread, errno); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict strspn_cmd(TAThread thread, TAInputStream stream) { char* s1; char* s2; size_t res; // Prepare s1 = (char*)readPointer(&stream); s2 = (char*)readPointer(&stream); START_TARGET_OPERATION(thread); // Execute res = strspn(s1, s2); END_TARGET_OPERATION(thread); // Response writeSize(thread, res); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict asctime_r_cmd(TAThread thread,TAInputStream stream) { struct tm time; char * buf ; char * res ; // Prepare readTm( & stream, & time ); buf = readString( & stream ); // Execute START_TARGET_OPERATION(thread); res = asctime_r( & time, buf ); END_TARGET_OPERATION(thread); // Response writeInt( thread, res == NULL ); if ( res != NULL ) { writeString( thread, res ); } writeString( thread, buf ); sendResponse( thread ); return taDefaultVerdict; }
static TACommandVerdict strnlen_cmd(TAThread thread, TAInputStream stream) { char* s; size_t n; size_t res; // Prepare s = (char*)readPointer(&stream); n = readSize(&stream); START_TARGET_OPERATION(thread); // Execute res = strnlen(s,n); END_TARGET_OPERATION(thread); // Response writeSize(thread, res); sendResponse(thread); return taDefaultVerdict; }
static TACommandVerdict strrchr_cmd(TAThread thread, TAInputStream stream) { char* s; int c; char* res; // Prepare s = (char*)readPointer(&stream); c = readInt(&stream); START_TARGET_OPERATION(thread); // Execute res = strrchr(s, c); END_TARGET_OPERATION(thread); // Response writePointer(thread, res); sendResponse(thread); return taDefaultVerdict; }
/* * When client bug with pings, process them here. */ void processPing(void) { response_t ping; struct tms times_; clock_t boot_time; printf ( "Processing PING request from client with PID=%d, resource ID=%d, semid=%d...\n", request.client_pid, request.resource_id, request.sem_id ); fflush(stdout); responsePrepare(&ping); boot_time = times(×_); if(boot_time == -1) { strcpy(ping.data, "There was an error getting system time. Please come back later and check the server's log.\n"); perror("mtimesrv::sendTime():times() - failed"); fflush(stderr); } sprintf ( ping.data, "PING reply: Elapsed Time: [%.2f]\n", (float)boot_time / sysconf(_SC_CLK_TCK) ); if(sendResponse(&ipc_packet_data) < 0) ipcerror("mtimesrv::processPing():sendResponse() - failed"); }
void WiFlyDevice::handleRequest() { int timeout = 800; unsigned long start = millis(); Serial.println("Reading request"); static char firstLine[REQUEST_LENGTH]; boolean currentLineIsBlank = true; boolean isFirstLine = true; int index = 0; while (true) { while (!uart.available()) { if (millis() > start + timeout) { enterCommandMode(); uart.println("close"); uart.println("exit"); return; } } char c = uart.read(); Serial.print(c); if (isFirstLine && index < REQUEST_LENGTH) { firstLine[index++] = c; } if (c == '\n' && currentLineIsBlank) { firstLine[index] = '\0'; sendResponse(firstLine); return; } if (c == '\n') { currentLineIsBlank = true; isFirstLine = false; } else if (c != '\r') { currentLineIsBlank = false; } } }
static TACommandVerdict getgrent_cmd(TAThread thread,TAInputStream stream) { struct group* result; int i=0; errno = 0; START_TARGET_OPERATION_WHICH_MAY_CONTAIN_CANCELPOINT(thread); result = getgrent(); END_TARGET_OPERATION_WHICH_MAY_CONTAIN_CANCELPOINT(thread); writePointer(thread,(void*)result); if(result) { writeString(thread, result->gr_name); writeInt(thread, result->gr_gid); while ((result->gr_mem)[i]!=NULL) { i++; } writeInt(thread, i); i=0; while ((result->gr_mem)[i]!=NULL) { writeString(thread, (result->gr_mem)[i]); i++; } } writeInt(thread,errno); sendResponse(thread); return taDefaultVerdict; }
void DataAggregatorActor::handleCountResponse(const idgs::actor::ActorMessagePtr& msg) { DVLOG_FIRST_N(2, 20) << "receive store size of member " << msg->getSourceActorId(); idgs::store::pb::SizeResponse* response = dynamic_cast<idgs::store::pb::SizeResponse*>(msg->getPayload().get()); if (response->result_code() != idgs::store::pb::SRC_SUCCESS) { // error DVLOG_FIRST_N(2, 20) << "error at member " << msg->getSourceActorId(); resultCode = response->result_code(); } // collect response from all members and calculate size and then response to client. shared_ptr<idgs::store::pb::SizeResponse> globalResponse = make_shared<idgs::store::pb::SizeResponse>(); dataSizeMap[msg->getSourceMemberId()] = response->size(); if (dataSizeMap.size() == requestCount) { DVLOG_FIRST_N(2, 20) << "aggregate done."; if (resultCode != idgs::store::pb::SRC_SUCCESS) { globalResponse->set_result_code(resultCode); } else { // calculate size size_t size = 0; map<int32_t, size_t>::iterator it = dataSizeMap.begin(); for (; it != dataSizeMap.end(); ++ it) { size += (* it).second; } globalResponse->set_result_code(idgs::store::pb::SRC_SUCCESS); globalResponse->set_size(size); } // response result DVLOG_FIRST_N(2, 20) << "response client."; sendResponse(OP_COUNT_RESPONSE, globalResponse); terminate(); } }
/** * Looks for a connection */ uint8_t tftpPoll() { uint8_t response = ACK; // Get the size of the recieved data uint16_t packetSize = netReadWord(REG_S3_RX_RSR0); if(packetSize) { if(!tftpFlashing) resetTick(); tftpFlashing = TRUE; for(;;) { if(!(netReadReg(REG_S3_IR) & IR_RECV)) break; netWriteReg(REG_S3_IR, IR_RECV); //FIXME: is this right after all? smaller delay but //still a delayand it still breaks occasionally _delay_ms(400); } // Process Packet and get TFTP response code #ifdef _DEBUG_TFTP response = processPacket(packetSize); #else response = processPacket(); #endif // Send the response sendResponse(response); } if(response==FINAL_ACK) { netWriteReg(REG_S3_CR, CR_CLOSE); // Complete return(0); } // Tftp continues return(1); }
static TACommandVerdict mkfifo_cmd(TAThread thread,TAInputStream stream) { char* path; int mode; int res; // Prepare path = readString(&stream); mode = readFilePermissions(&stream); errno = 0; START_TARGET_OPERATION(thread); res = mkfifo(path, mode); END_TARGET_OPERATION(thread); // Response writeInt(thread,res); writeInt(thread,errno); sendResponse(thread); return taDefaultVerdict; }
bool QgsRequestHandler::startGetFeatureResponse( QByteArray* ba, const QString& infoFormat ) { if ( !ba ) { return false; } if ( ba->size() < 1 ) { return false; } QString format; if ( infoFormat == QLatin1String( "GeoJSON" ) ) format = QStringLiteral( "text/plain" ); else format = QStringLiteral( "text/xml" ); setInfoFormat( format ); appendBody( *ba ); // Streaming sendResponse(); return true; }
void RedisConnection::runCommand(const Command &command) { if (command.hasDbIndex()) { selectDb(command.getDbIndex()); } resp.clear(); commandRunning = true; runningCommand = command; executionTimer->start(config.executeTimeout); if (command.isEmpty()) { return sendResponse(); } QString formattedCommand = command.getFormattedString(); /* * Send command */ QTextStream out(socket); out << formattedCommand; out.flush(); }
static TACommandVerdict tgetstr_cmd(TAThread thread, TAInputStream stream) { char* id; char* area; char* res; // Prepare id = readString(&stream); area = readPointer(&stream); START_TARGET_OPERATION(thread); // Execute res = tgetstr(id, &area); END_TARGET_OPERATION(thread); // Response writePointer(thread, res); writePointer(thread, area); sendResponse(thread); return taDefaultVerdict; }
/** processAnnounce is done by a child (to let the daemon process other * messages, including ours). Then the child is left running (he only knows the * value of answ_id_num) and waits for SIGDELETE to use this value. */ void ForwMachine::processAnnounce() { if ((pid=fork())==0) // store pid in the parent { // Send announce to the answerer, and wait for response message("-------------- ForwMachine : sending ANNOUNCE to %s",answ_user); tcAnsw->ctl_transact(ANNOUNCE, caller_id_num); // Copy answer and id_num from the response struct message("-------------- ForwMachine : got a response"); NEW_CTL_RESPONSE rp; // build our response struct tcAnsw->getResponseItems(&rp.answer, &answ_id_num, 0L); // answ_id_num stores id_num for delete. rp.type = ANNOUNCE; rp.vers = TALK_VERSION; rp.id_num = htonl(our_id_num); message("Storing response id_num %d",answ_id_num); // Now send the response to the caller print_response("-- => response (processAnnounce)", &rp); sendResponse(caller_ctl_addr, &rp); // -- Now wait for SIGDELETE // store static ref to this forwmachine in this child. pForwMachine = this; // register signal hander if (signal(SIGDELETE,&sig_handler)==SIG_ERR) message("ERROR for SIGUSR2"); message("Signal handler registered. Waiting..."); // infinite loop waiting for signals while(1) sleep(100); } message("Forwmachine started for Announce (now) and Delete (later). pid : %d",pid); // new_process(); // We DON'T register new process. // in case of re-announce, this forwmach will be forgotten. // we don't want ktalkd to wait infinitely for it to die, it won't. }