home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / win_lrn / dll / example.c < prev    next >
C/C++ Source or Header  |  1988-10-20  |  3KB  |  169 lines

  1. typedef double far *LPDOUBLE;
  2. typedef char   far *LPSTR;
  3.  
  4.  
  5. /* ------------------------------ AA */
  6. int far pascal TestBool(a)
  7. int a;
  8. {
  9.    return (!a);
  10. }
  11.  
  12. /* ------------------------------ */
  13. LPDOUBLE far pascal TestDouble(a)
  14. double a;
  15. {
  16.    static double temp;
  17.  
  18.    temp = a*2.0;
  19.    return (LPDOUBLE)&temp;
  20. }
  21.  
  22. /* ------------------------------ */
  23. LPSTR far pascal TestChar(s)
  24. LPSTR s;
  25. {
  26.      static char buffer[128];
  27.      char *t;
  28.  
  29.      t = buffer;
  30.      while (*s++) {
  31.           *t++ = '$';
  32.      }
  33.      *t = '\0';
  34.      return (LPSTR) buffer;
  35. }
  36.  
  37. /* ------------------------------ */
  38. LPSTR far pascal TestByte()
  39. {
  40.      static char buff[24];
  41.  
  42.      buff[0] = 9;    /* a contains the # of characters to return */
  43.      buff[1] = 'H';
  44.      buff[2] = 'i';
  45.      buff[3] = ' ';
  46.      buff[4] = 'T';
  47.      buff[5] = 'h';
  48.      buff[6] = 'e';
  49.      buff[7] = 'r';
  50.      buff[8] = 'e';
  51.      buff[9] = '.';
  52.  
  53.    return (LPSTR) buff;
  54. }
  55.  
  56. /* ------------------------------ */
  57. double far pascal TestFloatBuff(a)
  58. double *a;
  59. {
  60.  
  61.    *a = 2.0;
  62.    return (double) *a;
  63. }
  64.  
  65. /* ------------------------------ */
  66. LPSTR far pascal TestZBuff(a)
  67. LPSTR a;
  68. {
  69.  
  70.    a[0] = 'G';
  71.    a[1] = 'r';
  72.    a[2] = 'e';
  73.    a[3] = 'e';
  74.    a[4] = 't';
  75.    a[5] = 'i';
  76.    a[6] = 'n';
  77.    a[7] = 'g';
  78.    a[8] = 's';
  79.    a[9] = '\0';
  80.  
  81.    return (LPSTR) a;
  82. }
  83.  
  84. /* ------------------------------ */
  85. LPSTR far pascal TestByteBuff(a)
  86. LPSTR a;
  87. {
  88.  
  89.    a[0] = 8;
  90.    a[1] = 'G';
  91.    a[2] = 'o';
  92.    a[3] = 'o';
  93.    a[4] = 'd';
  94.    a[5] = ' ';
  95.    a[6] = 'd';
  96.    a[7] = 'a';
  97.    a[8] = 'y';
  98.  
  99.    return (LPSTR) a;
  100. }
  101.  
  102. /* ------------------------------ */
  103. unsigned int far pascal TestUInt(a)
  104. unsigned int a;
  105. {
  106.    return (2*a);
  107. }
  108.  
  109. /* ------------------------------ */
  110. int far pascal TestInt(a)
  111. int a;
  112. {
  113.    return (2*a);
  114. }
  115.  
  116. /* ------------------------------ */
  117. long far pascal TestLong(a)
  118. long a;
  119. {
  120.    return (2*a);
  121. }
  122.  
  123.  
  124.  
  125. /* ============================== */
  126.  
  127. typedef unsigned short  WORD;
  128. typedef struct fp {
  129.      WORD rows;
  130.      WORD columns;
  131.      double Array[1];
  132. } FP;
  133. typedef struct gp {
  134.      WORD rows;
  135.      WORD columns;
  136.      double Array[6];
  137. } GP;
  138. typedef FP far *LPFP;
  139. typedef GP far *LPGP;
  140.  
  141.  
  142. /* ------------------------------ */
  143. LPDOUBLE far pascal TestAddK(a)
  144. LPFP a;
  145. {
  146.      int i,items;
  147.      static double value;
  148.  
  149.      value = 0.0;
  150.      items = a->rows * a->columns;
  151.      for (i=0 ; i<items ; i++)
  152.         value += a->Array[i];
  153.      return (LPDOUBLE)&value;
  154. }
  155.  
  156. LPGP far pascal ChangeK(a)
  157. LPFP a;
  158. {
  159.      int i,items;
  160.      static GP b;
  161.  
  162.      items = a->rows * a->columns;
  163.      b.rows = 2; b.columns = 3;
  164.      for (i=0 ; i<items ; i++)
  165.          b.Array[i] = a->Array[i] + 1;
  166.      return (LPGP)&b;
  167. }
  168.  
  169.