Пример #1
0
void dec_ie_facility_centrex(unsigned char *p, Q931_info_t *qi, unsigned char *centrex, int facility_len, char *cnip, int cnip_len, int nt, struct misdn_bchannel *bc)
{

    int i = 0;
    *cnip = '\0';

    if (facility_len >= 2)
    {
        if (centrex[i++] != FACILITY_CENTREX)
            return;
        if (centrex[i++] != CENTREX_ID)
            return;
    }

    /* loop sub IEs of facility */
    while(facility_len > i+1)
    {
        if (centrex[i+1]+i+1 > facility_len)
        {
            printf("%s: ERROR: short read of centrex facility.\n", __FUNCTION__);
            return;
        }
        switch(centrex[i])
        {
        case 0x80:
            strnncpy(cnip, &centrex[i+2], centrex[i+1], cnip_len);
            cb_log(4,0,"    CENTREX cnip='%s'\n", cnip);
            break;
        }
        i += 1+centrex[i+1];
    }
}
void dec_ie_called_pn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, unsigned char *number, int number_len, int nt, struct misdn_bchannel *bc)
{
	*type = -1;
	*plan = -1;
	*number = '\0';

	if (!nt)
	{
		p = NULL;
		if (qi->called_nr)
			p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->called_nr + 1;
	}
	if (!p)
		return;
	if (p[0] < 2)
	{
		printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
		return;
	}

	*type = (p[1]&0x70) >> 4;
	*plan = p[1] & 0xf;
	strnncpy(number, p+2, p[0]-1, number_len);

	if (MISDN_IE_DEBG) printf("    type=%d plan=%d number='%s'\n", *type, *plan, number);
}
/*===========================================================================
 *
 * Class CSrResourceHandler Method - bool AddBsaFileRecord (pRecord);
 *
 *=========================================================================*/
bool CSrResourceHandler::AddBsaFileRecord (CSrBsaFileRecord* pRecord) {
  CSrResourceFolder* pFolder = &m_RootFolder;
  CSrResourceFolder* pNextFolder;
  CSrResourceFile*   pFile;
  char               PathBuffer[256];
  char*		     pParse;

	/* Parse out the full path */
  strnncpy(PathBuffer, pRecord->GetFullPath(), 250);
  pParse = strtok(PathBuffer, "\\");

  while (pParse != NULL) {
    pNextFolder = pFolder->GetFolderCreate(pParse);
    if (pNextFolder == NULL) return (false);

    pParse  = strtok(NULL, "\\");
    pFolder = pNextFolder;
  }

	/* Add the resource to the folder */
  pFile = pFolder->GetFileCreate(pRecord->GetFilename());
  if (pFile == NULL) return (false);

  pFile->AddInstance(pRecord);

  return (true);
}
Пример #4
0
void CEditUndo::SetString (const TCHAR* pString) {
  DEFINE_FUNCTION("CEditUndo::SetString()");

  DestroyArrayPointer(m_pString);
  m_StringLength = 0;

  if (pString) {
    m_StringLength = _tcslen(pString);
    CreateArrayPointer(m_pString, TCHAR, m_StringLength + 4);
    strnncpy(m_pString, pString, m_StringLength+1);
  }

}
Пример #5
0
int main()
{
	char *t = "bbb";
	char *s = malloc(mystrlen(t) + 1);

	printf("s0: %s\n", strnncpy(s, t, 1));
	// strncpy(s, t, 1);	
	// printf("s1: %s\n", ptr);
	// strncpy(s, t, 2);	
	// printf("s2: %s\n", ptr);
	// strncpy(s, t, 3);	
	// printf("s3: %s\n", ptr);
	// strncpy(s, t, 4);	
	// printf("s4: %s\n", ptr);
}
Пример #6
0
/*===========================================================================
 *
 * Function - bool MakePathEx (pPath);
 *
 * Creates multiple levels of paths. Returns false on any error.
 *
 *=========================================================================*/
bool MakePathEx (const SSCHAR* pPath) {
  SSCHAR  TempPath[_MAX_PATH+1];
  SSCHAR  TempDrive[8] = "c:\\";
  SSCHAR  InitialPath[_MAX_PATH+1];
  SSCHAR* pParse;
  int     iResult;

	/* Ignore invalid input */
  if (pPath == NULL) return (false);
  strnncpy(TempPath, pPath, _MAX_PATH);
  
	/* Save the initial directory */
  _getcwd(InitialPath, _MAX_PATH - 2);
  TerminatePath(InitialPath);
  pParse = strtok(TempPath, "\\");

  while (pParse != NULL && *pParse != NULL_CHAR) {

    		/* Does the given directory/drive exist? */
    if (pParse[1] == ':') {
      TempDrive[0] = pParse[0];
      iResult = _chdir(TempDrive);
    }
    else {
      iResult = _chdir(pParse);
    }

		/* Attempt to make the given directory */
    if (iResult != 0) {
      iResult = _mkdir(pParse);
      
      if (iResult < 0) {
        AddSrGeneralError("Failed to create the directory '%s'!", pParse);
	return (false);
      }

      iResult = _chdir(pParse);      
      if (iResult != 0) return (false);
    }

    pParse = strtok(NULL, "\\");
  }

	/* Restore the initial path and return success */
  _chdir(InitialPath);
  return (true);
}
void dec_ie_calling_pn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, int *screen, unsigned char *number, int number_len, int nt, struct misdn_bchannel *bc)
{
	*type = -1;
	*plan = -1;
	*present = -1;
	*screen = -1;
	*number = '\0';

	if (!nt)
	{
		p = NULL;
		if (qi->calling_nr)
			p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->calling_nr + 1;
	}
	if (!p)
		return;
	if (p[0] < 1)
	{
		printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
		return;
	}

	*type = (p[1]&0x70) >> 4;
	*plan = p[1] & 0xf;
	if (!(p[1] & 0x80))
	{
		if (p[0] < 2)
		{
			printf("%s: ERROR: IE too short (%d).\n", __FUNCTION__, p[0]);
			return;
		}
		*present = (p[2]&0x60) >> 5;
		*screen = p[2] & 0x3;
		strnncpy(number, p+3, p[0]-2, number_len);
	} else
	{
Пример #8
0
static void near MsgAreaWrite(MAINFO *pmi, int closeit)
{
  static int mai_fd=-1;
  static int ma_fd=-1;
  unsigned size;
  OVRLIST ol;
  struct _mfidx mfi;

  if (!do_marea)
    return;

  if (!pmi && ma_fd != -1 && closeit)
  {
    MAREA ma;
    long pos=lseek(ma_fd, 0L, SEEK_END);

    /* Find out the position of the last area in the file, so that we       *
     * can fix the wraparound pointer in the first record to point          *
     * to it.                                                               */

    pos -= cbLast + ADATA_START;

    lseek(ma_fd, ADATA_START, SEEK_SET);

    if (read(ma_fd, (char *)&ma, sizeof ma) != sizeof ma)
    {
      printf("Error reading final msg area data!\n");
      exit(1);
    }

    lseek(ma_fd, ADATA_START, SEEK_SET);

    ma.cbPrior=-pos;

    if (write(ma_fd, (char *)&ma, sizeof ma) != sizeof ma)
    {
      printf("Error writing final msg area data!\n");
      exit(1);
    }

    close(ma_fd);
    close(mai_fd);
    ma_fd=-1;
    return;
  }

  if (ma_fd==-1 && !closeit)
  {
    char fname[PATHLEN];
    dword dwId;
    
    dwId =MAREA_ID;

    if (strings[prm.marea_name]==0)
    {
      printf("Error!  MSGAREA.CTL cannot be SILTed separately.  Use\n"
             "\"SILT MAX\" and ensure that you have a \"Messages marea\"\n"
             "keyword in the Session Section.\n");
      exit(1);
    }

    strcpy(fname, strings + prm.marea_name);
    strcat(fname, ".dat");

    if ((ma_fd=sopen(fname, O_CREAT | O_TRUNC | O_RDWR | O_BINARY,
                     SH_DENYNO, S_IREAD | S_IWRITE))==-1)
    {
      printf("\nCan't open msg area data file %s!\n", fname);
      exit(1);
    }

    if (write(ma_fd, (char*) &dwId, sizeof dwId) != sizeof dwId)
    {
      printf("\aError writing key to msg data file %s\n", fname);
      exit(1);
    }

    strcpy(fname, strings + prm.marea_name);
    strcat(fname, ".idx");

    if ((mai_fd=sopen(fname, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY,
                      SH_DENYNO, S_IREAD | S_IWRITE))==-1)
    {
      printf("\nCan't open msg area index file %s!\n", fname);
      exit(1);
    }
  }

  if (pmi)
  {
    /* Fill out the structure length information */

    pmi->ma.cbArea=sizeof(pmi->ma);
    pmi->ma.cbHeap=pmi->h.end - pmi->h.heap;
    pmi->ma.cbPrior=cbLast;

    /* Record the size of this area */

    cbLast=pmi->ma.cbArea + pmi->ma.cbHeap +
           pmi->ma.num_override * sizeof(OVERRIDE);

    /* Default to Squish format */

    if (!pmi->ma.type)
      pmi->ma.type=MSGTYPE_SQUISH;

    if ((pmi->ma.attribs & (MA_PUB|MA_PVT))==0)
      pmi->ma.attribs |= MA_PUB;

    /* Strip the trailing backslash for Squish-style msg areas */

    if (pmi->ma.type & MSGTYPE_SQUISH)
    {
      char *p=pmi->h.heap + pmi->ma.path;
      int len;

      if (p[len=strlen(p)-1]==PATH_DELIM)
        p[len]=0;
    }

    /* Write the location of this area to the index file */

    strnncpy(mfi.name, pmi->h.heap + pmi->ma.name, sizeof(mfi.name));
    mfi.name_hash=SquishHash(pmi->h.heap + pmi->ma.name);
    mfi.ofs=tell(ma_fd);


    /* Touch the area's header, if necessary */

    if ((pmi->ma.attribs & (MA_DIVBEGIN|MA_DIVEND))==0)
      assert_msgarea(pmi->h.heap + pmi->ma.path, pmi->ma.type,
                     pmi->ma.killbyage, pmi->ma.killbynum,
                     pmi->ma.killskip);

    /* Do a little bit of error checking */

    if (pmi->ma.attribs & (MA_AUDIT) &&
        pmi->ma.type != MSGTYPE_SQUISH)
    {
      printf("\n\aError!  Style Audit can only be used in Squish areas! (area ending on line %d)\n",
             linenum);
      Compiling(-1, NULL, NULL);

      pmi->ma.attribs &= ~MA_AUDIT;
    }

    if (pmi->ma.attribs & (MA_ATTACH) &&
        pmi->ma.type != MSGTYPE_SQUISH)
    {
      printf("\n\aError!  Style Attach can only be used in Squish areas! (area ending on line %d)\n",
             linenum);
      Compiling(-1, NULL, NULL);

      pmi->ma.attribs &= ~MA_ATTACH;
    }

    /* Write the header to disk */

    if (write(mai_fd, (char *)&mfi, sizeof mfi) != sizeof mfi)
      ErrWrite();

    /* Write the main area data structure */

    if (write(ma_fd, (char *)&pmi->ma, sizeof pmi->ma) != sizeof pmi->ma)
      ErrWrite();

    /* Write all of the message area overrides */

    for (ol=pmi->ol; ol; ol=ol->next)
      if (write(ma_fd, (char *)&ol->or, sizeof ol->or) != sizeof ol->or)
        ErrWrite();

    /* Figure out the size of the zstr heap and write it, too */

    size=pmi->h.end-pmi->h.heap;

    if (write(ma_fd, (char *)pmi->h.heap, size) != (signed)size)
      ErrWrite();
  }

#ifdef MAX_TRACKER
  if (*toNewOwner)
  {
    TRK t;

    if ((t=TrkOpen("TRK", TRUE)) != NULL)
    {
      TrkSetDefaultOwner(t, pmi->h.heap + pmi->ma.name, toNewOwner);
      TrkClose(t);
    }

    *toNewOwner=0;
  }
#endif
}
Пример #9
0
static void mix_setdefaults()
{
#define strnncpy(a,b) strncpy(a, b, sizeof(a)); a[sizeof(a)-1] = '\0'

	strnncpy(DISCLAIMFILE , DEFAULT_DISCLAIMFILE);
	strnncpy(FROMDSCLFILE , DEFAULT_FROMDSCLFILE);
	strnncpy(MSGFOOTERFILE, DEFAULT_MSGFOOTERFILE);
	strnncpy(POP3CONF     , DEFAULT_POP3CONF);
	strnncpy(HELPFILE     , DEFAULT_HELPFILE);
	strnncpy(REQUESTDIR   , DEFAULT_REQUESTDIR);
	strnncpy(ABUSEFILE    , DEFAULT_ABUSEFILE);
	strnncpy(REPLYFILE    , DEFAULT_REPLYFILE);
	strnncpy(USAGEFILE    , DEFAULT_USAGEFILE);
	strnncpy(USAGELOG     , DEFAULT_USAGELOG);
	strnncpy(BLOCKFILE    , DEFAULT_BLOCKFILE);
	strnncpy(ADMKEYFILE   , DEFAULT_ADMKEYFILE);
	strnncpy(KEYFILE      , DEFAULT_KEYFILE);
	strnncpy(PGPKEY       , DEFAULT_PGPKEY);
	strnncpy(DSAPARAMS    , DEFAULT_DSAPARAMS);
	strnncpy(DHPARAMS     , DEFAULT_DHPARAMS);
	strnncpy(MIXRAND      , DEFAULT_MIXRAND);
	strnncpy(SECRING      , DEFAULT_SECRING);
	strnncpy(PUBRING      , DEFAULT_PUBRING);
	strnncpy(IDLOG        , DEFAULT_IDLOG);
	strnncpy(STATS        , DEFAULT_STATS);
	strnncpy(PGPMAXCOUNT  , DEFAULT_PGPMAXCOUNT);
	strnncpy(DESTBLOCK    , DEFAULT_DESTBLOCK);
	strnncpy(DESTALLOW    , DEFAULT_DESTALLOW);
	strnncpy(DESTALLOW2   , DEFAULT_DESTALLOW2);
	strnncpy(SOURCEBLOCK  , DEFAULT_SOURCEBLOCK);
	strnncpy(HDRFILTER    , DEFAULT_HDRFILTER);
	strnncpy(REGULAR      , DEFAULT_REGULAR);
	strnncpy(POOL         , DEFAULT_POOL);
	strnncpy(TYPE1LIST    , DEFAULT_TYPE1LIST);
	strnncpy(TYPE2REL     , DEFAULT_TYPE2REL);
	strnncpy(PIDFILE      , DEFAULT_PIDFILE);

	strnncpy(PGPREMPUBRING, DEFAULT_PGPREMPUBRING);
	strnncpy(PGPREMPUBASC , DEFAULT_PGPREMPUBASC);
	strnncpy(PGPREMSECRING, DEFAULT_PGPREMSECRING);
	strnncpy(NYMSECRING   , DEFAULT_NYMSECRING);
	strnncpy(NYMDB        , DEFAULT_NYMDB);
	strnncpy(STAREX       , DEFAULT_STAREX);
	strnncpy(ALLPINGERSURL, DEFAULT_ALLPINGERSURL);
	strnncpy(ALLPINGERSFILE, DEFAULT_ALLPINGERSFILE);
	strnncpy(WGET         , DEFAULT_WGET);
	strnncpy(STATSSRC     , DEFAULT_STATSSRC);

	strnncpy(MIXDIR       , "");
	strnncpy(POOLDIR      , "");

/* programs */
#ifdef WIN32
	strnncpy(SENDMAIL     , "outfile");
#else /* end of WIN32 */
	strnncpy(SENDMAIL     , "/usr/lib/sendmail -t");
#endif /* else if not WIN32 */
	strnncpy(SENDANONMAIL , "");
	strnncpy(NEWS         , "");
	strnncpy(TYPE1        , "");

/* addresses */
	strnncpy(MAILtoNEWS   , "[email protected],[email protected]");
	strnncpy(REMAILERNAME , "Anonymous Remailer");
	strnncpy(ANONNAME     , "Anonymous");
	strnncpy(REMAILERADDR , "");
	strnncpy(ANONADDR     , "");
	strnncpy(COMPLAINTS   , "");
	strnncpy(SMTPRELAY    , "");
	SMTPPORT              = 25;
	AUTOREPLY             = 0;

#ifdef USE_SOCK
  	strnncpy(HELONAME     , "");
	strnncpy(ENVFROM      , "");
	POP3DEL               = 0;
	POP3SIZELIMIT         = 0;
	POP3TIME              = 60 * 60;

#endif /* USE_SOCK */

	strnncpy(SHORTNAME    , "");

/* 	configuration */
	REMAIL        = 0;
	MIX           = 1;
	PGP           = 1;
	UNENCRYPTED   = 0;
	REMIX         = 1;
	REPGP         = 1;
	STATSAUTOUPDATE = 0;
	STATSINTERVAL = 8 * 60 * 60;
	strnncpy(EXTFLAGS, "");

    strnncpy(PRECEDENCE, "");
	POOLSIZE      = 0;
	RATE          = 100;
	INDUMMYP      = 3;	/* add dummy messages with probability p for each message added to the pool */
	OUTDUMMYP     = 10;	/* add dummy messages with probability p each time we send from the pool */
	INDUMMYMAXP   = 84;	/* for both of the above:  while (rnd < p) { senddummy(); }  */
	OUTDUMMYMAXP  = 96;     /* set max INDUMMYP and OUTDUMMYP such that 24 and 5.25 dummy messages will */
	MIDDLEMAN     = 0;      /* be generated on average. More than this is insane. */
	AUTOBLOCK     = 1;
	STATSDETAILS  = 1;
	strnncpy(FORWARDTO, "*");
	SIZELIMIT     = 0;		/* maximal size of remailed messages */
	INFLATEMAX    = 50;		/* maximal size of Inflate: padding */
	MAXRANDHOPS   = 5;
	BINFILTER     = 0;		/* filter binary attachments? */
	LISTSUPPORTED = 1;		/* list supported remailers in remailer-conf reply? */
	PACKETEXP     = 7 * SECONDSPERDAY;	/* Expiration time for old packets */
	IDEXP         = 7 * SECONDSPERDAY;	/* 0 = no ID log !! */
	SENDPOOLTIME  = 0;              /* frequency for sending pool messages */
	MAILINTIME    = 5 * 60;		/* frequency for processing MAILIN mail */

	KEYLIFETIME      =  6 * 30 * SECONDSPERDAY;	/* default validity period for keys. */
	KEYOVERLAPPERIOD =      30 * SECONDSPERDAY;	/* when keys have this amount of time */
	                                                /* left before expiration, create  */
	                                        	/* new ones when ./mix -K is run.*/
	KEYGRACEPERIOD   =       7 * SECONDSPERDAY;	/* accept mail to the old key for this */
	                                        	/* amount of time after it has expired. */


	strnncpy(ERRLOG      , "");
	strnncpy(ADDRESS     , "");
	strnncpy(NAME        , "");

	strnncpy(ORGANIZATION, "Anonymous Posting Service");
	strnncpy(MID         , "y");

/* client config */
	NUMCOPIES = 1;
	strnncpy(CHAIN, "*,*,*,*");
	VERBOSE = 2;
	DISTANCE = 2;
	MINREL = 98;
	RELFINAL = 99;
	MAXLAT = 36 * 60 * 60;
	MINLAT = 5 * 60;
	strnncpy(PGPPUBRING, "");
	strnncpy(PGPSECRING, "");
#ifdef COMPILEDPASS
	strnncpy(PASSPHRASE, COMPILEDPASS);
#else /* end of COMPILEDPASS */
	strnncpy(PASSPHRASE, "");
#endif /* else if not COMPILEDPASS */
	strnncpy(MAILIN    , "");
	strnncpy(MAILBOX   , "mbox");
	strnncpy(MAILABUSE , "");
	strnncpy(MAILBLOCK , "");
#ifdef WIN32
	strnncpy(MAILUSAGE , "nul:");
	strnncpy(MAILANON  , "nul:");
	strnncpy(MAILERROR , "nul:");
#else /* end of WIN32 */
	strnncpy(MAILUSAGE , "/dev/null");
	strnncpy(MAILANON  , "/dev/null");
	strnncpy(MAILERROR , "/dev/null");
#endif /* else if not WIN32 */
	strnncpy(MAILBOUNCE, "");

	CLIENTAUTOFLUSH = 1;
	MAXRECIPIENTS   = 5;

	TIMESKEW_FORWARD = 2*7*24*60*60;
	TIMESKEW_BACK = 12*60*60;
	TEMP_FAIL = 75;
}
Пример #10
0
/*
 * Special format:
 *  "%*s", number, string : print number-width string
 */
int vsprintf(char *buf, char *fmt, va_list args)
{
	char *dst = buf;
	unsigned int u;		/* value for %u/%x */
	int d;			/* value for %d */
	char *s;		/* value for %s */
	void *p;		/* value for %p */
	int zero;		/* completion with 0 */
	int width;		/* width field */
	int left;		/* left aligned */
	int len;		/* parsed string length */
	int swidth;		/* special format: %*s */

	while (*fmt) {
		if (*fmt != '%') {
			*dst++ = *fmt++;
			continue;
		}
		fmt++;		/* skip '%' */
		zero = 0;
		width = 0;
		swidth = 0;
		left = 0;
		/* handle alignment direction */
		while (*fmt == '+' || *fmt == '-') {
			left = (*fmt == '-');
			fmt++;
		}
		/* handle width */
		while (*fmt == '0') {	/* 0 completion */
			zero = 1;
			fmt++;
		}
		if (*fmt >= '1' && *fmt <= '9')
			width = strtoi(fmt, &fmt, 10);
		/* handle undefinite width of string */
		if (*fmt == '*') {
			swidth = va_arg(args, int);
			width = 0;	/* zero standard width */
			fmt++;
		}
		/* handle format char */
		switch (*fmt) {
		case '%':
			*dst = '%';
			len = 1;
			break;
		case 'c':
			*dst = va_arg(args, char);
			len = 1;
			break;
		case 'd':
			d = va_arg(args, int);
			len = itostr(d, dst, 10);
			break;
		case 'u':
			u = va_arg(args, unsigned int);
			len = utostr(u, dst, 10);
			break;
		case 'x':
			u = va_arg(args, unsigned int);
			len = utostr(u, dst, 16);
			break;
		case 'p':
			p = va_arg(args, void *);
			*dst++ = '0';
			*dst++ = 'x';
			len = utostr((unsigned int)p, dst, 16);
			break;
		case 's':
			s = va_arg(args, char *);
			if (swidth > 0)
				len = strnncpy(dst, s, swidth);
			else
				len = strcpy(dst, s);
			break;
		}
		if (width > len) {
			if (left) {
				memset(dst + len, ' ',  width - len);
			} else {
				memmove(dst + width - len, dst, len);
				memset(dst, zero ? '0' : ' ', width - len);
			}
			len = width;
		}
		fmt++;
		dst += len;
	}
Пример #11
0
static int near Process_Modem_Response(char *rsp)
{
  int gotbaud=FALSE;
  int gotarq=FALSE;
  char *s;
  
  if (eqstri(rsp, PRM(m_ring)))
  {
    if (*PRM(m_answer))
      mdm_cmd(PRM(m_answer));
  }
  else if (eqstrni(rsp, PRM(m_connect), strlen(PRM(m_connect))))
  {
    baud=0L;
    *arq_info='\0';

    /* Now parse all of the junk out of the connect string */

    for (s=rsp+strlen(PRM(m_connect)); *s; )
    {
      if (*s==' ')  /* Do nothing */
        s++;
      else if (*s=='V' && !gotarq) /* DigiDial "CONNECT V120 57600" messages */
      {
        char *space=strchr(s, ' ');

        if (space)
        {
          strncpy(arq_info, s+1, space-s-1);
          arq_info[space-s-1]=0;
          gotarq=TRUE;

          s=space+1;
        }
        else s++;
      }
      else if (eqstrni(rsp,"fast",4))
      {
        if (!gotbaud)
        {
          baud=9600L;
          s += 4;
          gotbaud=TRUE;
        }
        else s++;
      }
      else if (isdigit(*s))
      {
        if (!gotbaud)
        {
          baud=atol(s);
         
          while (isdigit(*s))
            s++;
        
          gotbaud=TRUE;
        }
        else s++;
      }
      else if (*s=='/' && !gotarq)
      {
        gotarq=TRUE;
        strnncpy(arq_info, ++s, ARQ_LEN-1);
      }
      else s++;
    }

    if (!baud)
      baud=300L;
    else if (baud==1275L || baud==75 || baud==7512L || baud==212L ||
             baud==12L)
    {
      baud=1200L;
    }

    /* Set the right baud rate on that com port */

    mdm_baud(current_baud=Decimal_Baud_To_Mask((unsigned int)baud));
    local=FALSE;

    logit(log_wfc_connect,
          baud,
          *arq_info ? " (" : blank_str,
          arq_info,
          *arq_info ? ")" : blank_str);

    Update_Status(wfc_connected);

    /* If we get a pipe, VMP or telnet connection, it should be
     * instantaneous.  However, due to an SIO 1.4x bug, we need
     * to give the line a bit of time to settle.
     */

    if (eqstri(arq_info, "pipe") || stristr(arq_info, "/vmp") ||
        stristr(arq_info, "/tel"))
    {
      Delay(20);
    }
    else
    {
      Mdm_Flow(FLOW_OFF);

      /* Wait five secs or until we get two <cr>s or <esc>s */

      Clear_MNP_Garbage();

      mdm_dump(DUMP_ALL);
      Mdm_Flow(FLOW_ON);
    }

    #ifdef UNIX
	/* On UNIX we need to tell the comm api that our device
	   has a carrier else WFC will be dancing with "No carrier" */
	mdm_nowonline();
    #endif

    if (!carrier())
    {
      logit(log_byebye);
      
      /* Reinitialize the modem */

      WFC_Init_Modem();
      Update_Status(wfc_waiting);
      
      baud=0L;
      *arq_info='\0';
/*      local=TRUE;*/
      return 0;
    }
    
    #ifdef OS_2
      ComWatchDog(hcModem, TRUE, 5);      /* enable,  5 sec timeout */
    #endif

    return 1;
  }

  return 0;
}