Ejemplo n.º 1
0
CLIPPER veri_recv()
{
  unsigned char buffer[100];
  int data=0,i;
  long far *timer_ticks = (long far *) 0x0040006CL;
  long timein = *timer_ticks+1080L;
  char far * str_txt;

  
  if ( PCOUNT == 2 && ISBYREF(BYTES_READ) && ISNUM(BYTES_READ)
                    && ISBYREF(STR_TXT)  && ISCHAR(STR_TXT) )
  {
     str_txt = _parc(STR_TXT);
     
     i = 0;
     while ( ((data & 0x00ff) != 0x03)  &&  ( timein > *timer_ticks ))
     {
       if (pfl_com_sts(port_no) & DATA_READY)
       {
	 data = pfl_com_drecv();
	 buffer[i++] = (unsigned char) (data & 0x00ff);            
       }    
     }  
     
     _storni(i,BYTES_READ);
     _storclen(buffer,i,STR_TXT);
     _retni(NORMAL);
  }
  else
     _retni(INVP);
      
}
Ejemplo n.º 2
0
CLIPPER c_fwrite (void)
{
   int  file_handle;
   char *line;
   USHORT  line_size;
   
   if (PCOUNT == 3 && ISNUM(FILE_HANDLE) && ISCHAR(WRITE_LINE)
                   && ISNUM(LINE_SIZE) && ISBYREF(LINE_SIZE))
   {
      /* convert clipper parameters into C types... */
      file_handle = _parni(FILE_HANDLE);
      line_size = _parni(LINE_SIZE);
      line = _parc(WRITE_LINE);
      
      /* call C write function... */
      if ( _fsWrite(file_handle, line, line_size) < line_size ) 
      {
        _storni (0, LINE_SIZE);
        _ret();
        return;
      }
      
      /* flush the data to file without closing it... */
      if (asm_commit(file_handle))  
        _storni (0, LINE_SIZE);
   }
   else
      /* update line_size to zero... */
      _storni (0, LINE_SIZE);                   

   _ret();  /* returns NIL */
}
Ejemplo n.º 3
0
CLIPPER FILEOPEN()
{
   BYTEP fpFileName;
   FHANDLE hFile = FS_ERROR;
   USHORT uiFlags = FO_READWRITE;
   ERRORP pError;

   if ( ISCHAR( 1 ) )
   {
      fpFileName = _parc( 1 );

      uiFlags |= ( ISLOG( 2 ) && _parl( 2 ) ) ? FO_SHARED : FO_EXCLUSIVE;

      pError = _errNew();
      _errPutSubCode( pError, 1111 );     // subCode determined by caller

      hFile = FileOpener( fpFileName, uiFlags, pError );

      if ( ISBYREF( 1 ) )
         _storc( fpFileName, 1 );
   }

   _retni( hFile );

}
Ejemplo n.º 4
0
/* helper function for the justxxx() functions */
static void do_justify( int iSwitch )
{
   int iNoRet;

   iNoRet = ct_getref() && ISBYREF( 1 );

   if( ISCHAR( 1 ) )
   {
      const char * pcString = hb_parc( 1 );
      HB_SIZE      sStrLen  = hb_parclen( 1 );
      char         cJustChar;
      const char * pc;
      char *       pcRet, * pcw;
      HB_SIZE      sJustOffset;

      if( sStrLen == 0 )
      {
         if( iNoRet )
            hb_ret();
         else
            hb_retc_null();
         return;
      }

      if( hb_parclen( 2 ) > 0 )
         cJustChar = *( hb_parc( 2 ) );
      else if( ISNUM( 2 ) )
         cJustChar = ( char ) ( hb_parnl( 2 ) % 256 );
      else
         cJustChar = 0x20;

      pcRet = ( char * ) hb_xgrab( sStrLen + 1 );

      switch( iSwitch )
      {
         case DO_JUSTIFY_JUSTLEFT:
            pc          = pcString;
            sJustOffset = 0;
            while( ( *pc == cJustChar ) && ( pc < pcString + sStrLen ) )
            {
               sJustOffset++;
               pc++;
            }
            hb_xmemcpy( pcRet, pcString + sJustOffset, (size_t) ( sStrLen - sJustOffset ) );
            for( pcw = pcRet + sStrLen - sJustOffset; pcw < pcRet + sStrLen; pcw++ )
            {
               *pcw = cJustChar;
            }
            break;

         case DO_JUSTIFY_JUSTRIGHT:
            pc          = pcString + sStrLen - 1;
            sJustOffset = 0;
            while( ( *pc == cJustChar ) && ( pc >= pcString ) )
            {
               sJustOffset++;
               pc--;
            }
            for( pcw = pcRet; pcw < pcRet + sJustOffset; pcw++ )
            {
               *pcw = cJustChar;
            }
            hb_xmemcpy( pcRet + sJustOffset, pcString, (size_t) ( sStrLen - sJustOffset ) );
            break;
      }

      if( ISBYREF( 1 ) )
         hb_storclen( pcRet, sStrLen, 1 );

      if( iNoRet )
      {
         hb_ret();
         hb_xfree( pcRet );
      }
      else
         hb_retclen_buffer( pcRet, sStrLen );
   }
   else  /* ISCHAR( 1 ) */
   {
      PHB_ITEM pSubst         = NULL;
      int      iArgErrorMode  = ct_getargerrormode();

      if( iArgErrorMode != CT_ARGERR_IGNORE )
      {
         pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
                                  iSwitch == DO_JUSTIFY_JUSTLEFT ?
                                  CT_ERROR_JUSTLEFT : CT_ERROR_JUSTRIGHT,
                                  NULL, HB_ERR_FUNCNAME, 0,
                                  EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
      }

      if( pSubst != NULL )
         hb_itemReturnRelease( pSubst );
      else if( iNoRet )
         hb_ret();
      else
         hb_retc_null();
   }
}
Ejemplo n.º 5
0
/* helper function for the justxxx() functions */
static void do_justify (int iSwitch)
{

  int iNoRet;

  iNoRet = ct_getref() && ISBYREF( 1 );

  if (ISCHAR (1))
  {

    char *pcString = hb_parc (1);
    size_t sStrLen = hb_parclen (1);
    char cJustChar;
    char *pc, *pcRet;
    size_t sJustOffset;

    if ( sStrLen == 0 )
    {
       if (iNoRet)
       {
          hb_ret();
       }
       else
       {
          hb_retc( "" );
       }
       return;
    }

    if (hb_parclen (2) > 0)
      cJustChar = *(hb_parc (2));
    else if (ISNUM (2))
      cJustChar = (char)( hb_parnl (2) % 256 );
    else
      cJustChar = 0x20;

    pcRet = ( char *)hb_xgrab (sStrLen);

    switch (iSwitch)
    {
      case DO_JUSTIFY_JUSTLEFT:
      {
        pc = pcString;
        sJustOffset = 0;
        while ((*pc == cJustChar) && (pc < pcString+sStrLen))
        {
          sJustOffset++;
          pc++;
        }

        hb_xmemcpy (pcRet, pcString+sJustOffset, sStrLen-sJustOffset);
        for (pc = pcRet+sStrLen-sJustOffset; pc < pcRet+sStrLen; pc++)
        {
          *pc = cJustChar;
        }

      }; break;

      case DO_JUSTIFY_JUSTRIGHT:
      {
        pc = pcString+sStrLen-1;
        sJustOffset = 0;
        while ((*pc == cJustChar) && (pc >= pcString))
        {
          sJustOffset++;
          pc--;
        }

        for (pc = pcRet; pc < pcRet+sJustOffset; pc++)
        {
          *pc = cJustChar;
        }
        hb_xmemcpy (pcRet+sJustOffset, pcString, sStrLen-sJustOffset);

      }; break;

    }

    if (ISBYREF (1))
      hb_storclen (pcRet, sStrLen, 1);

    if (iNoRet)
      hb_ret();
    else
      hb_retclen (pcRet, sStrLen);

    hb_xfree (pcRet);

  }
  else /* ISCHAR (1) */
  {
    PHB_ITEM pSubst = NULL;
    int iArgErrorMode = ct_getargerrormode();
    if (iArgErrorMode != CT_ARGERR_IGNORE)
    {
      pSubst = ct_error_subst ((USHORT)iArgErrorMode, EG_ARG,
                               (iSwitch == DO_JUSTIFY_JUSTLEFT ? CT_ERROR_JUSTLEFT : CT_ERROR_JUSTRIGHT),
                               NULL,
                               (iSwitch == DO_JUSTIFY_JUSTLEFT ? "JUSTLEFT" : "JUSTRIGHT"),
                               0, EF_CANSUBSTITUTE, 2,
                               hb_paramError (1), hb_paramError (2));
    }

    if (pSubst != NULL)
    {
      hb_itemRelease( hb_itemReturnForward( pSubst ) );
    }
    else
    {
      if (iNoRet)
        hb_ret();
      else
        hb_retc ("");
    }
  }

  return;

}
Ejemplo n.º 6
0
CLIPPER read_scan(void)
{
  int barcode_sts;  /* scanner input status */
  int barcode_len;  /* holds the no. of bytes actually read */
  int check_flag = 0;  
  int label_chkdigit,chkdigit;
    
  if ((PCOUNT >= 2) && ISBYREF(BYTES_READ) && ISNUM(BYTES_READ) &&
                     ISBYREF(STR_BUFF) && ISCHAR(STR_BUFF))
  {
     /* verify initial status */
     if (chk_init_flag(POS_SCAN) == 0)
     {
        _retni(DEV_NOT_EXIST);   
        return;
     } /* device not yet initialized */

    /* not in asynchronous scanning mode */
    if (!async_scan)
    {
      _retni(INVP);
      return;
    }
    
    /* read scanner input */
    if ((barcode_sts = pfl_get_label(label_buff)) == -1)
      barcode_sts = READ_ERR;  /* no available data to be fetched */
    else
    {
      barcode_len = barcode_sts & 0x00ff;              /* get label length */
      barcode_sts >>= 8;                               /* label status     */

      barcode_sts = (barcode_sts == 0)? NORMAL: SCAN_ERR;  /* status      */
      
      if ( PCOUNT == 3 )
      {
        int check_flag = _parl(CHECK_FLAG);      
        if (check_flag)
        {  
           barcode_len--;                
                    
           label_chkdigit = (int) label_buff[barcode_len] - 48 ;
           
           chkdigit = checkdgt(label_buff,barcode_len);           

           if ( label_chkdigit !=  chkdigit )
             barcode_sts = SCAN_ERR;
                                       
        }   
        
      }     

      _storni(barcode_len, BYTES_READ);                /* length */
        
      *(label_buff+barcode_len+1) = '\0';              /* insert a NULL character */
      _storclen(label_buff, barcode_len+2, STR_BUFF);  /* bar code data */        
                          
    }
    
    _retni(barcode_sts);
  }
  else