int rlCommandlineInterface::printf(const char *format, ...) { va_list ap; va_start(ap,format); int ret = rlvsnprintf(line, sizeof(line) - 1, format, ap); va_end(ap); if(ret < 0) return ret; if(spawn != NULL) { return spawn->printf("%s",line); } else if(sock != NULL) { if(sock->isConnected() == 0) return -1; int ret = sock->printf("%s",line); return ret; } else if(tty != NULL) { return tty->writeBlock((unsigned char *) line, strlen(line)); } else { int ret = ::printf("%s",line); fflush(stdout); return ret; } }
int rlSocket::printf(const char *format, ...) { int ret; char message[rl_PRINTF_LENGTH]; // should be big enough va_list ap; va_start(ap,format); ret = rlvsnprintf(message, rl_PRINTF_LENGTH - 1, format, ap); va_end(ap); if(ret < 0) return ret; return write(message,strlen(message)); }
int rlIniFile::printf(const char *section, const char *name, const char *format, ...) { int ret; char buf[rl_PRINTF_LENGTH]; // should be big enough va_list ap; va_start(ap,format); ret = rlvsnprintf(buf, rl_PRINTF_LENGTH - 1, format, ap); va_end(ap); if(ret > 0) setText(section, name, buf); return ret; }
int rlUdpSocket::printf(rlIpAdr *dest, const char *format, ...) { int ret; char message[rl_PRINTF_LENGTH]; // should be big enough va_list ap; va_start(ap,format); ret = rlvsnprintf(message, rl_PRINTF_LENGTH - 1, format, ap); va_end(ap); if(ret < 0) return ret; return sendto(message,strlen(message)+1,dest); }
int rlDebugPrintf(const char *format, ...) { int ret; char message[rl_PRINTF_LENGTH]; // should be big enough if(rlDebugPrintfState == 0) return 0; va_list ap; va_start(ap,format); ret = rlvsnprintf(message, rl_PRINTF_LENGTH - 1, format, ap); va_end(ap); if(ret < 0) return ret; return printf("%s",message); }
int rlString::printf(const char *format, ...) { int ret; char mystring[rl_PRINTF_LENGTH]; // should be big enough va_list ap; va_start(ap,format); ret = rlvsnprintf(mystring, rl_PRINTF_LENGTH - 1, format, ap); va_end(ap); if(ret < 0) return ret; delete [] txt; txt = new char [strlen(mystring)+1]; ::strcpy(txt, mystring); return ret; }
int rlLastLinePrintf(const char *format, ...) { int ret,i; char message[rl_PRINTF_LENGTH]; // should be big enough va_list ap; va_start(ap,format); ret = rlvsnprintf(message, rl_PRINTF_LENGTH - 1, format, ap); va_end(ap); if(ret < 0) return ret; message[79] = '\0'; printf("%c[80D",27); // move 80 columns left printf("%s",message); for(i=strlen(message); i<80; i++) printf(" "); return 80; }