コード例 #1
0
int
xmlNanoFTPGetConnection()
{  
char buf[200];	
int adp[4] = {1,4,2,0};
int portp[2] = {20,4};
#ifdef HAVE_FNPRINTF
int fnp[2] = {10,1};
#endif
int len;
#ifdef HAVE_FNPRINTF

len = fnprintf(buf, sizeof(buf), "PORT %d,%d,%d,%d,%d,%d\r\n",
adp[0] & 0xff, adp[1] & 0xff, fnp[0] & 0xff, adp[3] & 0xff,
 		       fnp[1] & 0xff, portp[1] & 0xff);
#else

#ifndef HAVE_SNPRINTF
  	len = sprintf2(buf, "PORT %d,%d,%d,%d,%d,%d\r\n",
#else /* HAVE_SNPRINTF */
  	len = snprintf2(buf, sizeof(buf), "PORT %d,%d,%d,%d,%d,%d\r\n",
#endif /* HAVE_SNPRINTF */
               adp[0] & 0xff, adp[1] & 0xff, adp[2] & 0xff, adp[3] & 0xff,
 		       portp[0] & 0xff, portp[1] & 0xff);
#endif
return len;
}
コード例 #2
0
ファイル: pty.c プロジェクト: jsarenik/rlwrap
/* returns TRUE if the -N option has been specified, we can read /proc/<command_pid>/wchan,
   (which happens only on linux, as far as I know) and what we read there contains the word "wait"
   meaning (presumably...) that command is waiting for one of its children
   if otherwise returns FALSE
*/
int dont_wrap_command_waits() {
  static char command_wchan[MAXPATHLEN+1];
  static int initialised = FALSE;
  static int wchan_fd;
  static int been_warned = 0;
  char buffer[BUFFSIZE];
  int nread, result = FALSE;

  DEBUG_RANDOM_SLEEP;
  if (!commands_children_not_wrapped)
    return FALSE;
  if (!initialised) {   /* first time we're called after birth of child */
    snprintf2(command_wchan, MAXPATHLEN , "%s/%d/wchan", PROC_MOUNTPOINT, command_pid);
    initialised =  TRUE;
  }
  if (command_is_dead)
    return TRUE;  /* This is lazy!! signal may not have been delivered @@@ */
  wchan_fd =  open(command_wchan, O_RDONLY);
  if (wchan_fd < 0) { 
    if (been_warned++ == 0) {
      mywarn("you probably specified the -N (-no-children) option"
             " - but spying\non %s's wait status does not work on"
             " your system, as we cannot read %s", command_name, command_wchan);
    }
    return FALSE;
  }     


  if (((nread = read(wchan_fd, buffer, BUFFSIZE -1)) > 0)) {
    buffer[nread] =  '\0';
    DPRINTF1(DEBUG_READLINE, "read commands wchan: <%s> ", buffer);
    result = (strstr(buffer, "wait") != NULL);
  }
  close(wchan_fd);
  DEBUG_RANDOM_SLEEP;
  return result;
}