home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / makedce.zip / EXAMPLES.ZIP / examples / Alias / manager.c < prev    next >
C/C++ Source or Header  |  1994-05-08  |  3KB  |  152 lines

  1. /*
  2.  * COMPONENT_NAME:  MakeDCE/examples/alias/manager.c
  3.  *
  4.  * FUNCTIONS: 
  5.  *
  6.  * ORIGINS: 72
  7.  *
  8.  * OBJECT CODE ONLY SOURCE MATERIALS
  9.  *
  10.  */
  11. /*
  12.  * (c) Copyright 1990, 1991 OPEN SOFTWARE FOUNDATION, INC.
  13.  * ALL RIGHTS RESERVED
  14.  */
  15. #include <stdio.h>
  16. #include "umacros.h"
  17. #include "list.h"
  18.  
  19. long op0
  20. (a, b, c)
  21.       /* [in, out] */ long *a;
  22.       /* [in, out] */ long *b;
  23.       /* [in, out] */ long *c;
  24. {
  25.     long failures = 0;
  26.  
  27.     if (a != b || a != c)
  28.     {
  29.         fprintf(stderr, "Pointers passed to op0 don't have same values!\n");
  30.         failures++;
  31.     }
  32.  
  33.     *a *= 2;
  34.     *b *= 3;
  35.     *c *= 4;
  36.     return failures;
  37. }
  38.  
  39. long op1
  40. (a, b, c)
  41.     /* [in, out] */ long_t *a;
  42.     /* [in, out] */ long_t *b;
  43.     /* [in, out] */ long_t *c;
  44. {
  45.     long failures = 0;
  46.  
  47.     if (a != b || a != c)
  48.     {
  49.         fprintf(stderr, "Pointers passed to op1 don't have same values!\n");
  50.         failures++;
  51.     }
  52.  
  53.     *a *= 2;
  54.     *b *= 3;
  55.     *c *= 4;
  56.     return failures;
  57. }
  58.  
  59. long op2
  60. (a, b, c, s)
  61.     /* [in, out] */ long_t *a;
  62.     /* [in, out] */ long_t *b;
  63.     /* [in, out] */ long_t *c;
  64.     /* [in] */ long s;
  65. {
  66.     long i, failures = 0;
  67.  
  68.     if (a != b || a != c)
  69.     {
  70.         fprintf(stderr, "Pointers passed to op2 don't have same values!\n");
  71.         failures++;
  72.     }
  73.  
  74.     for (i = 0 ; i < s ; i++)
  75.     {
  76.         a[i] *= 2;
  77.         b[i] *= 3;
  78.         c[i] *= 4;
  79.     }
  80.     return failures;
  81. }
  82.  
  83. long op3
  84. (plist)
  85.     /* [in, out] */ node_t **plist;
  86. {
  87.     node_t *node_p, *temp_p;
  88.     int toggle;
  89.  
  90.     /*
  91.      * Reverse the circular doubly-linked list, creating new storage
  92.      * for half the nodes.
  93.      */
  94.     if (*plist == NULL)
  95.         return;
  96.  
  97.     /*
  98.      * Make a first pass, replacing half the nodes with new nodes that
  99.      * contain the same non-pointer data.
  100.      */
  101.     node_p = *plist;
  102.     toggle = 0;
  103.     do
  104.     {
  105.         if (toggle++)
  106.         {
  107.             temp_p = (node_t *)malloc(sizeof(node_t));
  108.             temp_p->l = node_p->l;
  109.             temp_p->flink = node_p->flink;
  110.             temp_p->blink = node_p->blink;
  111.             node_p->blink->flink = temp_p;
  112.             node_p->flink->blink = temp_p;
  113.         }
  114.         node_p = node_p->flink;
  115.     } while (node_p != *plist);
  116.  
  117.     /*
  118.      * Now reverse the list.
  119.      */
  120.     node_p = *plist;
  121.     do
  122.     {
  123.         temp_p = node_p->flink;
  124.         node_p->flink = node_p->blink;
  125.         node_p->blink = temp_p;
  126.         node_p = temp_p;
  127.     } while (node_p != *plist);
  128.  
  129.     /*
  130.      * Make the listhead point at the new first element.  node_p points at the
  131.      * former first element which has been switched to be the last element, so
  132.      * its forward link points at the new first element.
  133.      */
  134.     *plist = node_p->flink;
  135.  
  136.     return 0;
  137. }
  138.  
  139. long op4
  140. (list)
  141.     /* [in, out] */ struct_list_t *list;
  142. {
  143.     while (list != NULL)
  144.     {
  145.         if (list->struct_ptr) list->struct_ptr->l -= 7;
  146.         list->struct_ref->l *= 3;
  147.         list = list->next;
  148.     }
  149.  
  150.     return 0;
  151. }
  152.