예제 #1
0
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;
    }
}
예제 #2
0
파일: rlsocket.cpp 프로젝트: liuxiaohao/pvb
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));
}
예제 #3
0
파일: rlinifile.cpp 프로젝트: 376473984/pvb
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;
}
예제 #4
0
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);
}
예제 #5
0
파일: rlcutil.cpp 프로젝트: daveti/pvb
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);
}
예제 #6
0
파일: rlstring.cpp 프로젝트: chinqkung/pvb
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;
}
예제 #7
0
파일: rlcutil.cpp 프로젝트: daveti/pvb
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;
}