home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6571.LZX / examples / cres / cres.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-24  |  1.1 KB  |  57 lines

  1. /* Copyright (c) 1993 SAS Institute, Inc, Cary, NC, USA */
  2. /* All Rights Reserved. */
  3.  
  4. #include <proto/exec.h>
  5. #include <proto/dos.h>
  6. #include <string.h>
  7.  
  8. char *first;
  9. char *second;
  10. int check = 5;
  11.  
  12. /* Can't use printf since it is not reentrant and will crash */
  13. /* your machine if you make the non-cres version of this     */
  14. /* program resident as per the instructions.                 */
  15.  
  16. static int myprintf(char *ctl, ...);
  17.  
  18. int main(int argc, char *argv[])
  19. {
  20.    first = argv[0];
  21.  
  22.    if (argc > 1)
  23.    {
  24.       second = argv[1];
  25.    }
  26.    else
  27.    {
  28.       second = "<Not Given>";
  29.    }
  30.  
  31.    myprintf("You named me \"%s\", and my first parameter is \"%s\"\n",
  32.             first, second);
  33.  
  34.    if (check == 5)
  35.    {
  36.       myprintf("Everything checks O.K.!\n");
  37.    }
  38.    else
  39.    {
  40.       myprintf("Something's wrong!  'check' = %ld\n", check);
  41.    }
  42.  
  43.    check = *second;
  44. }
  45.  
  46. static int myprintf(char *ctl, ...)
  47. {
  48.    long *arg1;
  49.    char buffer[256];
  50.  
  51.    arg1 = (long *)(&ctl + 1);
  52.    RawDoFmt(ctl, arg1, (void (*))"\x16\xc0\x4e\x75", buffer);
  53.    Write(Output(), buffer, strlen(buffer));
  54.  
  55.    return 0;
  56. }
  57.