home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Amiga / Workbench / Patches / CopyReplace.lha / Source / Include / SDI_ASM_STD_protos.h < prev    next >
C/C++ Source or Header  |  1998-05-08  |  6KB  |  154 lines

  1. #ifndef SDI_ASM_STD_PROTOS_H
  2. #define SDI_ASM_STD_PROTOS_H
  3.  
  4. /* Includeheader
  5.  
  6.     Name:        SDI_ASM_STD_protos
  7.     Versionstring:    $VER: SDI_ASM_STD_protos.h 1.17 (25.02.1998)
  8.     Author:        SDI
  9.     Distribution:    PD
  10.     Description:    my replacement for standard ANSI functions
  11.  
  12.  1.9   18.11.96 : converted text into english language, changed C++ comments
  13.      to C ones
  14.  1.10  29.11.96 : added printf
  15.  1.11  06.02.97 : added exit prototype
  16.  1.12  28.03.97 : added some additionally defines (AMIGA_TO_ANSI), added
  17.      vsprintf
  18.  1.13  31.05.97 : fixed SDI_isprintf
  19.  1.14  20.07.97 : changed UBYTE ** to STRPTR *
  20.  1.15  27.07.97 : fixed SDI_printf
  21.  1.16  20.02.98 : made code more compiler independent
  22.  1.17  25.02.98 : added vprintf
  23. */
  24.  
  25. /* These are mainly the normal ANSI C functions, but with an ASM interface.
  26. You can replace them by their normal functions supplied with your compiler,
  27. but do not mix them up (one object file standard, the other one SDI).
  28.  
  29. differences:
  30.  toupper and tolower: chars (0x41 to 0x5A) and (0xC0 to 0xDE) are upper
  31.   chars (0x61 to 0x79) and (0xE0 to 0xFE) are lower (some more than in ANSI)
  32.  isprint: chars (0x20 to 0x7E) and (0xA0 to 0xFF) are printable
  33.  sprintf and printf: only support exec/RawDoFmt format strings
  34.   and some I do not remember.
  35.  strtoul and strtol: return NULL in errpos, when '\0'-Byte was last scanned
  36.   character. I do not know, if this is really correct for ANSI.
  37.  
  38.  all: return values may not match ANSI-C ones
  39.  
  40. printf: Use this function only for programs need to work under OS1.3. For
  41. OS2.0 (and up) programs should use dos.library/amiga.lib Printf function.
  42. */
  43.  
  44. #if defined(SDI_TO_ANSI) && (defined(__GNUC__) || defined(__PPC__))
  45.   #include <string.h>
  46.   #include <stdlib.h>
  47.   #include <stdio.h>
  48.   #include <ctype.h>
  49. #else
  50.  
  51. #include <exec/types.h>
  52. #include "SDI_defines.h"
  53.  
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57.  
  58. ASM(BYTE) SDI_strnicmp(    REG(a0,STRPTR),        /* string 1            */
  59.             REG(a1,STRPTR),        /* string 2            */
  60.             REG(d1,ULONG));        /* highest testlength        */
  61. ASM(BYTE) SDI_strncmp(    REG(a0,STRPTR),        /* string 1            */
  62.             REG(a1,STRPTR),        /* string 2            */
  63.             REG(d1,ULONG));        /* highest testlength        */
  64. ASM(UBYTE) SDI_tolower(    REG(d0,UBYTE));        /* character to convert        */
  65. ASM(UBYTE) SDI_toupper(    REG(d0,UBYTE));        /* character to convert        */
  66. ASM(ULONG) SDI_strlen (    REG(a0,STRPTR));    /* string            */
  67. ASM(ULONG) SDI_isprint(    REG(d0,UBYTE));        /* character to convert        */
  68. ASM(ULONG) SDI_isdigit(    REG(d0,UBYTE));        /* character to convert        */
  69. ASM(ULONG) SDI_isxdigit(REG(d0,UBYTE));        /* character to convert        */
  70. ASM(ULONG) SDI_isalnum(    REG(d0,UBYTE));        /* character to convert        */
  71. ASM(ULONG) SDI_isupper(    REG(d0,UBYTE));        /* character to convert        */
  72. ASM(ULONG) SDI_strtoul(    REG(a1,STRPTR),        /* buffer            */
  73.             REG(a0,STRPTR *),    /* UBYTE var for error position    */
  74.             REG(d2,UBYTE));     /* base                */
  75. ASM(ULONG) SDI_strtol(    REG(a1,STRPTR),        /* buffer            */
  76.             REG(a0,STRPTR *),    /* UBYTE var for error position */
  77.             REG(d2,UBYTE));     /* base                */
  78. ASM(STRPTR) SDI_strncpy(REG(a1,STRPTR),        /* string 1            */
  79.             REG(a0,STRPTR),        /* string 2            */
  80.             REG(d1,ULONG));        /* highest copy number        */
  81. ASM(void) SDI_memset(    REG(a1,APTR),        /* buffer            */
  82.             REG(d0,UBYTE),        /* fill character        */
  83.             REG(d1,ULONG));        /* number of bytes        */
  84. ASM(STRPTR) SDI_strchr(    REG(a1,STRPTR),        /* buffer            */
  85.             REG(d0,UBYTE));        /* character to scan for    */
  86. ASM(void) SDI_vsprintf(    REG(a3,STRPTR),        /* buffer            */
  87.             REG(a0,STRPTR),        /* formatstring            */
  88.             REG(a1,APTR));        /* data                */
  89. ASM(void) SDI_vprintf(    REG(a0,STRPTR),        /* formatstring            */
  90.             REG(a1,APTR));        /* data                */
  91. void SDI_sprintf(STRPTR, STRPTR, ...);        /* buffer, formatstring, data    */
  92. void SDI_printf(STRPTR, ...);            /* formatstring, data        */
  93.  
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97.  
  98. #define SDI_stricmp(a,b)    SDI_strnicmp(a,b,~0)
  99. #define SDI_strcmp(a,b)        SDI_strncmp(a,b,~0)
  100. #define SDI_strcpy(a,b)        SDI_strncpy(a,b,~0)
  101.  
  102. /* Set SDI_TO_ANSI if you want to use normal ANSI names. Do not include
  103. the ANSI files stdio.h / stdlib.h ... , because this may result in an error */
  104.  
  105. #ifdef SDI_TO_ANSI
  106.   #define strnicmp    SDI_strnicmp
  107.   #define strncmp    SDI_strncmp
  108.   #define stricmp    SDI_stricmp
  109.   #define strcmp    SDI_strcmp
  110.   #define tolower    SDI_tolower
  111.   #define toupper    SDI_toupper
  112.   #define strlen    SDI_strlen
  113.   #define isprint    SDI_isprint
  114.   #define isdigit    SDI_isdigit
  115.   #define isxdigit    SDI_isxdigit
  116.   #define isalnum    SDI_isalnum
  117.   #define strtoul    SDI_strtoul
  118.   #define strtol    SDI_strtol
  119.   #define strncpy    SDI_strncpy
  120.   #define strcpy    SDI_strcpy
  121.   #define strchr    SDI_strchr
  122.   #define memset    SDI_memset
  123.   #define sprintf    SDI_sprintf
  124.   #define printf    SDI_printf
  125.   #define vsprintf    SDI_vsprintf
  126.   #define vprintf    SDI_vprintf
  127.  
  128.   extern void exit(int);
  129. #endif
  130.  
  131. /* Use the following with care, as they may collide with ANSI-C Standard
  132.    a lot more, than the above ones. The FILE * parameter of the functions
  133.    is converted into a filehandle of dos.library. Do not mix normal ANSI-C
  134.    and these functions! */
  135.  
  136. /* These defines are in experimental state !!! */
  137.  
  138. #ifdef AMIGA_TO_ANSI
  139.   #define memcpy(a,b,c)        CopyMem(b,a,c)
  140.   #define remove(a)        !DeleteFile(a)
  141.   #define rename(a,b)        !Rename(a,b)
  142.   #define putchar(a)        FPutC(Output(),a)
  143.   #define putc(a, b)        FPutC((ULONG) b, a)
  144.   #define getchar()        FGetC(Input())
  145.   #define getc(a)        FGetC((ULONG) a)
  146.   #define ungetc(a,b)        UnGetC((ULONG) b,a)
  147.   #define vprintf(a,b)        VPrintf(a,b)
  148.   #define vfprintf(a,b,c)    VFPrintf((ULONG) a, b, c)
  149.   #define fclose(a)        Close(a)
  150. #endif
  151.  
  152. #endif /* SDI_TO_ANSI && __GNUC__ */
  153. #endif /* SDI_ASM_STD_PROTOS_H */
  154.