home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d583 / aroff.lha / ARoff / Sources / amiga.c < prev    next >
C/C++ Source or Header  |  1992-01-04  |  2KB  |  124 lines

  1. /*
  2.  * Quelques fonctions UNIX qui n'existent pas sur l'Aztec
  3.  * (c)1991 par Denis GOUNELLE
  4.  */
  5.  
  6. long strtol( str , ptr , base )
  7. register unsigned char *str ;
  8. unsigned char **ptr ;
  9. long base ;
  10.  
  11. {
  12.   register long result, sign , digit ;
  13.  
  14.   sign = 1 ;
  15.   result = 0 ;
  16.  
  17. /* passe les espaces en tête */
  18.  
  19.   while ( isspace( *str ) ) str++ ;
  20.  
  21. /* regarde s'il y a un signe */
  22.  
  23.   if ( *str == '-' )
  24.   {
  25.     sign = -1 ;
  26.     str++ ;
  27.   }
  28.   else if ( *str == '+' ) str++ ;
  29.  
  30. /* decode le nombre */
  31.  
  32.   while ( isascii( *str ) && isalnum( *str ) )
  33.   {
  34.     digit = (long)toupper( *str ) - 48 ;
  35.     if ( digit > 9 ) digit -= 7 ;
  36.     if ( digit > base ) break ;
  37.     result *= base ;
  38.     result += digit ;
  39.     str++ ;
  40.   }
  41.  
  42.   if ( ptr ) *ptr = str ;
  43.   if ( sign < 0 ) result = - result ;
  44.   return( result ) ;
  45. }
  46.  
  47. /****************************************************************************
  48.  *
  49.  * bzero() and bcopy() have been rewritten in assembly language : that makes
  50.  * ARoff about 2 times faster...
  51.  * I've left the old C fonction code so that you can see what they do
  52.  *
  53.  ****************************************************************************
  54.  
  55. void bzero( ptr , len )
  56. register char *ptr ;
  57. register long len ;
  58.  
  59. {
  60.   while ( len > 0 )
  61.   {
  62.     *ptr = '\0' ;
  63.     ptr++ ;
  64.     len-- ;
  65.   }
  66. }
  67.  
  68. void bcopy( src , dst , len )
  69. register char *src , *dst ;
  70. register long len ;
  71.  
  72. {
  73.   while ( len > 0 )
  74.   {
  75.     *dst = *src ;
  76.     dst++ ;
  77.     src++ ;
  78.     len-- ;
  79.   }
  80. }
  81. *****************************************************************************/
  82.  
  83. #asm
  84.  
  85. _bzero:
  86.     move.l    4(sp),a0
  87.     move.l    8(sp),d0
  88.     beq.s    _bzend
  89.     subq.l    #1,d0
  90.     moveq    #0,d1
  91. _bzbcl:
  92.     move.b    d1,(a0)+
  93.     dbra    d0,_bzbcl
  94. _bzend:
  95.     rts
  96. _bcopy:
  97.     move.l    4(sp),a0
  98.     move.l    8(sp),a1
  99.     move.l    12(sp),d1
  100.     beq.s    _bcend
  101.     subq.l    #1,d1
  102. _bcbcl:
  103.     move.b    (a0)+,(a1)+
  104.     dbra    d1,_bcbcl
  105. _bcend:
  106.     rts
  107. ;
  108.     public    _bzero
  109.     public    _bcopy
  110.  
  111. #endasm
  112.  
  113. /*************************************************************************/
  114.  
  115. #ifdef AZTEC_C
  116.  
  117. long Chk_Abort()
  118. {
  119.   return( 0 ) ;
  120. }
  121.  
  122. #endif
  123.  
  124.