home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / VP2SRC.ZIP / AREASBBS.C < prev    next >
Text File  |  1991-04-20  |  21KB  |  683 lines

  1. /*
  2.   $Header: areasbbs.c 3.3 87/12/12 00:40:08 Bob Exp $
  3.  
  4.                           The Conference Mail System
  5.  
  6.               This module was originally written by Bob Hartman
  7.                        Sysop of FidoNet node 1:132/101
  8.  
  9.    Spark Software, 427-3 Amherst St, CS 2032, Suite 232, Nashua, NH 03061
  10.  
  11.  The Conference Mail System  is a  complete Echomail processing package.  It
  12.  is a superset of the original  Echomail utilities created by Jeff Rush, and
  13.  also contains ideas gleaned from the  ARCmail,  Renum,  oMMM, MGM, and Opus
  14.  programs that were created by various software authors.
  15.  
  16.  This program source code is being released with the following provisions:
  17.  
  18.  1.  You are  free to make  changes to this source  code for use on your own
  19.  machine,  however,  altered source files may not be distributed without the
  20.  consent of Spark Software.
  21.  
  22.  2.  You may distribute "patches"  or  "diff" files for any changes that you
  23.  have made, provided that the "patch" or "diff" files are also sent to Spark
  24.  Software for inclusion in future releases of the entire package.   A "diff"
  25.  file for the source archives may also contain a compiled version,  provided
  26.  it is  clearly marked as not  being created  from the original source code.
  27.  No other  executable  versions may be  distributed without  the  consent of
  28.  Spark Software.
  29.  
  30.  3.  You are free to include portions of this source code in any program you
  31.  develop, providing:  a) Credit is given to Spark Software for any code that
  32.  may is used, and  b) The resulting program is free to anyone wanting to use
  33.  it, including commercial and government users.
  34.  
  35.  4.  There is  NO  technical support  available for dealing with this source
  36.  code, or the accompanying executable files.  This source  code  is provided
  37.  as is, with no warranty expressed or implied (I hate legalease).   In other
  38.  words, if you don't know what to do with it,  don't use it,  and if you are
  39.  brave enough to use it, you're on your own.
  40.  
  41.  Spark Software may be contacted by modem at (603) 888-8179 (node 1:132/101)
  42.  on the public FidoNet network, or at the address given above.
  43.  
  44.  To use this code you will need Microsoft C version 4.0, and also Microsoft
  45.  Macro Assembler version 4.0.
  46.  
  47. */
  48.  
  49. /*
  50.    $Log:    areasbbs.c $
  51.  * Revision 3.3  87/12/12  00:40:08  Bob
  52.  * Source code release
  53.  *
  54. */
  55.  
  56. #include <stdio.h>
  57. #include <ctype.h>
  58. #include <malloc.h>
  59. #include <string.h>
  60. #include <stdlib.h>
  61. #include <math.h>
  62. #include <process.h>
  63. #include "fastecho.h"
  64.  
  65. #define DEBUG 0
  66.  
  67. /* Remember to change the security check routine also! */
  68. #ifdef OS2
  69. char *NAME="\r\n--- VPurge[OS/2] V%s\r\n";
  70. #else  /* OS2 */
  71. char *NAME="\r\n--- VPurge [DOS] V%s\r\n";
  72. #endif /* OS2 */
  73.  
  74. extern SEACONFIG config;
  75. extern AREAS_PTR areas[];
  76. extern char board_name[], sysop_name[];
  77. extern int tot_areas;
  78. extern char bbsfile[];
  79. extern int seen_aka;
  80. char tmpjunk[256], tmpjunk1[80], tmpjunk2[80];
  81. extern char *areaserr;
  82. int priv_net = 0;
  83. int boss_net = 0;
  84. int boss_node = 0;
  85. int zone_zone[10];
  86. int zone_net[10];
  87. int zone_node[10];
  88. int num_zone = 0;
  89. int pass_thru = -1;
  90. int route_thru = -1;
  91. int bad_msgs = -1;
  92. int do_pickup = 0;
  93. int mail_dir = -1;
  94. char pickup_dir[64];
  95. extern PW_PTR pw[];
  96. extern int num_pw;
  97.  
  98. int compile_areas (char *fname)
  99. {
  100.     FILE *f;
  101.     char *p, *q, *r;
  102.     int i, k, last_net, err, intt1, intt2, last_zone;
  103.     int *tmpzone, *tmpnet, *tmpnode;
  104.     AREAS *aptr, *aptr1;
  105.     PW_PTR pptr;
  106.  
  107.     tmpzone = (int *) malloc (sizeof(int) * 100);
  108.     tmpnet = (int *) malloc (sizeof(int) * 100);
  109.     tmpnode = (int *) malloc (sizeof (int) * 100);
  110.  
  111.     if ((tmpnet == NULL) || (tmpnode == NULL) || (tmpzone == NULL))
  112.         {
  113.         printf (areaserr);
  114.         exit (2);
  115.         }
  116.  
  117.     strncpy (bbsfile, fname, 80);
  118.     if (bbsfile[0] == '\0')
  119.         strcpy (bbsfile, "AREAS.BBS");
  120.  
  121.     if ((f = fopen (bbsfile, "r")) == NULL)
  122.         {
  123. #if DEBUG
  124. printf ("Could not open AREAS file\n");
  125. #endif
  126.         free ((char *) tmpzone);
  127.         free ((char *) tmpnet);
  128.         free ((char *) tmpnode);
  129.         return (-1);
  130.         }
  131.  
  132. #if DEBUG
  133. printf ("Going into areasbbs loop\n");
  134. #endif
  135.     tot_areas = -1;
  136.     while (echo_fgets (tmpjunk, 256, f) != 0)
  137.         {
  138.         /* Was it a comment line? */
  139.         if (tmpjunk[0] == ';')
  140.             {
  141.             /* Yes it was, so continue */
  142.             continue;
  143.             }
  144. #if DEBUG
  145. printf ("Got '%s'\n", tmpjunk);
  146. #endif
  147.  
  148.       /* Was it a special FastEcho line? */
  149.       if (tmpjunk[0] == '-')
  150.          {
  151.          /* Yes it was, so do whatever it says */
  152.          if (strnicmp (tmpjunk, "-ZONEGATE=", 10) == 0)
  153.             {
  154.             /* It is a ZONEGATE statement */
  155.             q = &tmpjunk[10];
  156.             i = 0;
  157.             last_zone = config.net[1];
  158.             while (*q)
  159.                {
  160.                zone_net[num_zone] = atoi (q);
  161.                while (*q)
  162.                   {
  163.                   if (*q == '/')
  164.                      break;
  165.                   else
  166.                      ++q;
  167.                   }
  168.                if (*q == '/')
  169.                   {
  170.                   ++q;
  171.                   zone_node[num_zone] = atoi (q);
  172.                   last_zone = zone_net[num_zone];
  173.                   }
  174.                else
  175.                   {
  176.                   zone_node[num_zone] = zone_net[num_zone];
  177.                   zone_net[num_zone] = last_zone;
  178.                   }
  179.                ++num_zone;
  180.                while (*q)
  181.                   {
  182.                   if (isdigit(*q))
  183.                      ++q;
  184.                   else
  185.                      break;
  186.                   }
  187.                while (*q)
  188.                   {
  189.                   if (isspace(*q))
  190.                      ++q;
  191.                   else
  192.                      break;
  193.                   }
  194.                }
  195.             continue;
  196.             }
  197.          if (strnicmp (tmpjunk, "-PASSWORD=", 9) == 0)
  198.             {
  199.             /* It is a PASSWORD statement */
  200.             q = &tmpjunk[10];
  201.             intt1 = atoi (q);
  202.             while (*q)
  203.                {
  204.                if (!isdigit(*q))
  205.                   break;
  206.                else
  207.                   ++q;
  208.                }
  209.             if (*q == '/')
  210.                {
  211.                ++q;
  212.                intt2 = atoi (q);
  213.                }
  214.             else
  215.                {
  216.                intt2 = intt1;
  217.                intt1 = config.net[1];
  218.                }
  219.             while (*q)
  220.                {
  221.                if (isdigit(*q) || isspace(*q))
  222.                   ++q;
  223.                else
  224.                   break;
  225.                }
  226.             p = q;
  227.             while (*q)
  228.                {
  229.                if (isspace (*q))
  230.                   {
  231.                   *q = '\0';
  232.                   break;
  233.                   }
  234.                ++q;
  235.                }
  236.  
  237.             /* If we are here we have the proper net/node for the password
  238.                and we are pointing at the password itself, now just fill
  239.                in the proper fields and increment the counter */
  240.             pptr = pw[num_pw] = (PW_PTR) calloc (1, sizeof (PW));
  241.             if (pptr == NULL)
  242.                 {
  243.                 printf (areaserr);
  244.                 exit (2);
  245.                 }
  246.  
  247.             pptr->net = intt1;
  248.             pptr->node = intt2;
  249.             /* Length of password hoped for */
  250.             intt1 = strlen(p);
  251.             /* Max it out at 8 */
  252.             intt2 = (intt1>8)?8:intt1;
  253.             /* Allocate 9 bytes */
  254.             pptr->password = calloc (1, 9);
  255.             /* Copy in what we have */
  256.             strncpy (pptr->password, p, intt2);
  257.             for (intt1 = 0; intt1 < 8; intt1++)
  258.                pptr->password[intt1] = (char) toupper (pptr->password[intt1]);
  259.             ++num_pw;
  260.             continue;
  261.             }
  262. #if POINT_TYPE
  263.          else if (strnicmp (tmpjunk, "-PICKUPDIR=", 11) == 0)
  264.             {
  265.             q = &tmpjunk[11];
  266.             while (*q && !isspace (*q))
  267.                ++q;
  268.             *q = '\0';
  269.             strcpy (pickup_dir, &tmpjunk[11]);
  270.             do_pickup = 1;
  271.             continue;
  272.             }
  273.          else if (strnicmp (tmpjunk, "-POINTNET=", 10) == 0)
  274.             {
  275.             /* It is a POINTNET statement */
  276.             q = &tmpjunk[10];
  277.             priv_net = atoi (q);
  278. #if DEBUG
  279. printf ("Point network '%d' found\n", priv_net);
  280. #endif
  281.             continue;
  282.             }
  283.          else if (strnicmp (tmpjunk, "-BOSSNODE=", 10) == 0)
  284.             {
  285.             q = &tmpjunk[10];
  286.             boss_net = atoi (q);
  287.             while (*q)
  288.                {
  289.                if (*q == '/')
  290.                   break;
  291.                else
  292.                   ++q;
  293.                }
  294.             if (*q == '/')
  295.                {
  296.                ++q;
  297.                boss_node = atoi (q);
  298.                }
  299.             else
  300.                {
  301.                boss_node = boss_net;
  302.                boss_net = config.net[1];
  303.                }
  304.             continue;
  305.             }
  306. #endif
  307.          continue;
  308.          }
  309.  
  310.         p = tmpjunk;
  311.         q = tmpjunk1;
  312.  
  313.         /* Extract first word */
  314.         if (get_word (&p, q) == 0)
  315.             {
  316.             continue;
  317.             }
  318.  
  319.         /* Is this the header stuff? */
  320.         if (tot_areas == -1)
  321.             {
  322.             /* It is, so create the board name and sysop name */
  323.             q = (char *) (tmpjunk + strlen (tmpjunk) - 1);
  324.             while ((q >= tmpjunk) && (isspace (*q)))
  325.             *q-- = '\0';
  326.             if ((q = strrchr (tmpjunk, '!')) != NULL)
  327.                 {
  328.                 r = q-1;
  329.                 while (isspace (*r))
  330.                     {
  331.                     *r-- = '\0';
  332.                     }
  333.                 *q++ = '\0';
  334.                 while (isspace (*q))
  335.                     ++q;
  336.  
  337.                 strncpy (sysop_name, q, 126);
  338.                 strncpy (board_name, tmpjunk, 126);
  339.                 tot_areas = 0;
  340.                 continue;
  341.                 }
  342.             else
  343.                 {
  344.                 strncpy (board_name, tmpjunk, 126);
  345.                 tot_areas = 0;
  346.                 continue;
  347.                 }
  348.             }
  349.  
  350.         q = tmpjunk1;
  351.         if (q[strlen(q)-1] == '\\')
  352.             q[strlen(q)-1] = '\0';
  353.         while (*q)
  354.             {
  355.             *q = (char) toupper (*q);
  356.             ++q;
  357.             }
  358.         strcpy (tmpjunk2, tmpjunk1);
  359.  
  360.         /* Is it a legitimate directory? */
  361.         if (!(filedir (tmpjunk1, 0, tmpjunk1, ST_DIRECT) & ST_DIRECT))
  362.             {
  363.             strcpy (tmpjunk1,tmpjunk2);
  364.             /* Not a directory, continue on */
  365.             if (get_fido_sys (tmpjunk1, 1))
  366.                 {
  367.                 continue;
  368.                 }
  369.             }
  370.         else
  371.             strcpy (tmpjunk1, tmpjunk2);
  372.  
  373.         /* It is the message path directly */
  374.         aptr = areas[tot_areas] = (AREAS_PTR) calloc (1, sizeof (AREAS));
  375.         if (aptr == NULL)
  376.             {
  377.             printf (areaserr);
  378.             exit (2);
  379.             }
  380.         aptr->msg_path = malloc ((unsigned) (strlen(tmpjunk1)+1));
  381.         if (aptr->msg_path == NULL)
  382.             {
  383.             printf (areaserr);
  384.             exit (2);
  385.             }
  386.         strcpy (aptr->msg_path, tmpjunk1);
  387.         q = aptr->msg_path;
  388.         while (*q)
  389.             {
  390.             *q = (char) toupper(*q);
  391.             ++q;
  392.             }
  393.  
  394.         /* Now get the next word into the area name field */
  395.         q = tmpjunk1;
  396.         if (get_word (&p, q) == 0)
  397.             {
  398.             continue;
  399.             }
  400.  
  401.         while (*q)
  402.             {
  403.             *q = (char) toupper (*q);
  404.             ++q;
  405.             }
  406.  
  407.         aptr->area_name = malloc ((unsigned) (strlen (tmpjunk1)+1));
  408.         if (aptr->area_name == NULL)
  409.             {
  410.             printf (areaserr);
  411.             exit (2);
  412.             }
  413.         strcpy (aptr->area_name, tmpjunk1);
  414.         if (strcmp (tmpjunk1, "PASSTHRU") == 0)
  415.          {
  416.          aptr->flags |= PASS_THRU;
  417.          pass_thru = tot_areas;
  418.          }
  419.       else if (strcmp (tmpjunk1, "ROUTETHRU") == 0)
  420.          {
  421.          aptr->flags |= ROUTETHRU;
  422.          route_thru = tot_areas;
  423.          }
  424.       else if (strcmp (tmpjunk1, "BAD_MSGS") == 0)
  425.          {
  426.          aptr->flags |= BAD_MSGS;
  427.          bad_msgs = tot_areas;
  428.          }
  429.       else if (strcmp (tmpjunk1, "aMAIL_DIR") == 0)
  430.          {
  431.          aptr->flags |= MAIL_DIR;
  432.          mail_dir = tot_areas;
  433.          }
  434.  
  435. #ifdef VPURGE
  436. #if DEBUG
  437.         printf ("Checking for V_PURGE now.\n");
  438. #endif
  439.         if (strchr(tmpjunk, '#') != NULL)
  440.             {
  441. #if DEBUG
  442.             printf ("Setting V_PURGE now.\n");
  443. #endif
  444.             aptr->flags |= V_PURGE;
  445.             }
  446. #endif
  447.  
  448.         /* Finally, get all of the net/node pairs */
  449.         i = 0;
  450.         last_net = config.net[1];
  451.         while (get_word (&p, tmpjunk1) != 0)
  452.             {
  453.             if ((err = sscanf (tmpjunk1, "%d:%d/%d", &(tmpzone[i]), &(tmpnet[i]),
  454.             &(tmpnode[i]))) < 3)
  455.             {
  456.             if (err == 0)
  457.                continue;
  458.  
  459.             tmpzone[i] = config.zone[1];
  460.             if ((err = sscanf (tmpjunk1, "%d/%d", &(tmpnet[i]),
  461.                                &(tmpnode[i]))) < 2)
  462.                {
  463.                tmpnode[i] = tmpnet[i];
  464.                tmpnet[i] = last_net;
  465.                }
  466.             }
  467.  
  468. #if DEBUG
  469. printf ("Using %d:%d/%d for i=%d\n", tmpzone[i], tmpnet[i], tmpnode[i], i);
  470. #endif
  471.  
  472.             for (k = 0; k < i; k++)
  473.                 {
  474.                 if ((tmpnet[k] == tmpnet[i]) &&
  475.                      (tmpnode[k] == tmpnode[i]) &&
  476.                 (tmpzone[k] == tmpzone[i]))
  477.                     {
  478.                     break;
  479.                     }
  480.                 }
  481.             if (k >= i)
  482.             {
  483.             last_net = tmpnet[i];
  484.                 ++i;
  485.             }
  486.             }
  487.         aptr->num_nodes = i;
  488.         aptr->zone = (int *) malloc ((unsigned) (sizeof(int) * (i + seen_aka)));
  489.         aptr->net = (int *) malloc ((unsigned) (sizeof(int) * (i + seen_aka)));
  490.         aptr->node = (int *) malloc ((unsigned) (sizeof (int) * (i + seen_aka)));
  491.       aptr->handle = (int *) malloc ((unsigned) (sizeof (int) * (i + seen_aka)));
  492.       aptr->aname = (char **) malloc ((unsigned) (sizeof (char *) * (i + seen_aka)));
  493.         if ((aptr->net == NULL) || (aptr->node == NULL) || (aptr->zone == NULL) ||
  494.           (aptr->handle == NULL) || (aptr->aname == NULL))
  495.             {
  496.             printf (areaserr);
  497.             exit (2);
  498.             }
  499.         for (i = 0; i < aptr->num_nodes; i++)
  500.             {
  501.          aptr->zone[i] = tmpzone[i];
  502.             aptr->net[i] = tmpnet[i];
  503.             aptr->node[i] = tmpnode[i];
  504.          }
  505.       for (i = 0; i < aptr->num_nodes + seen_aka; i++)
  506.          {
  507.          aptr->handle[i] = -1;
  508.          aptr->aname[i] = aptr->area_name;
  509.             }
  510.       if (tot_areas > 0)
  511.          {
  512.          for (i = 0; i < tot_areas; i++)
  513.             {
  514.             if (strcmp (aptr->msg_path, areas[i]->msg_path) == 0)
  515.                {
  516.                aptr->msgs_in_area = areas[i]->msgs_in_area;
  517.                aptr->flags |= SIBLING;
  518.                areas[i]->flags |= PARENT;
  519.  
  520.                /* Now add to the PARENT */
  521.                aptr1 = areas[i];
  522.  
  523.                 aptr1->zone = (int *) realloc ((char *) aptr1->zone, (unsigned) (sizeof(int) *
  524.                   (aptr1->num_nodes + aptr->num_nodes + seen_aka)));
  525.                 aptr1->net = (int *) realloc ((char *) aptr1->net, (unsigned) (sizeof(int) *
  526.                   (aptr1->num_nodes + aptr->num_nodes + seen_aka)));
  527.                 aptr1->node = (int *) realloc ((char *) aptr1->node, (unsigned) (sizeof (int) *
  528.                   (aptr1->num_nodes + aptr->num_nodes + seen_aka)));
  529.                aptr1->handle = (int *) realloc ((char *) aptr1->handle, (unsigned) (sizeof (int) *
  530.                   (aptr1->num_nodes + aptr->num_nodes + seen_aka)));
  531.                aptr1->aname = (char **) realloc ((char *) aptr1->aname, (unsigned) (sizeof (char *) *
  532.                   (aptr1->num_nodes + aptr->num_nodes + seen_aka)));
  533.                 if ((aptr1->net == NULL) || (aptr1->node == NULL) || (aptr1->zone == NULL) ||
  534.                    (aptr1->handle == NULL) || (aptr1->aname == NULL))
  535.                     {
  536.                     printf (areaserr);
  537.                     exit (2);
  538.                     }
  539.                 for (k = aptr1->num_nodes; k < aptr1->num_nodes+aptr->num_nodes; k++)
  540.                     {
  541.                     aptr1->zone[k] = aptr->zone[k-aptr1->num_nodes];
  542.                     aptr1->net[k] = aptr->net[k-aptr1->num_nodes];
  543.                     aptr1->node[k] = aptr->node[k-aptr1->num_nodes];
  544.                   }
  545.                 for (k = aptr1->num_nodes; k < aptr1->num_nodes+aptr->num_nodes; k++)
  546.                     {
  547.                     aptr1->handle[k] = aptr->handle[k-aptr1->num_nodes];
  548.                     aptr1->aname[k] = aptr->aname[k-aptr1->num_nodes];
  549.                   }
  550.                aptr1->num_nodes += aptr->num_nodes;
  551.                 sort_em (&(aptr1->zone[0]), &(aptr1->net[0]), &(aptr1->node[0]),
  552.                     aptr1->num_nodes, 1, &(aptr1->handle[0]),
  553.                   &(aptr1->aname[0]));
  554.                break;
  555.                }
  556.             }
  557.          if (i >= tot_areas)
  558.             {
  559.             aptr->msgs_in_area = (int *) calloc (1, sizeof (int));
  560.             *(aptr->msgs_in_area) = -1;
  561.             }
  562.          }
  563.       else
  564.          {
  565.          aptr->msgs_in_area = (int *) calloc (1, sizeof (int));
  566.         *(aptr->msgs_in_area) = -1;
  567.          }
  568.  
  569. #if DEBUG
  570. printf ("\nRECAP1\n\n");
  571. for (i = 0; i < tot_areas; i++)
  572. {
  573. printf ("AREA #%2d: DIR='%s' NAME='%s'\n", i, areas[i]->msg_path,
  574. areas[i]->area_name);
  575. for (k = 0; k < areas[i]->num_nodes; k++)
  576. printf ("NODE %d=%d:%d/%d:%s\n", k, areas[i]->zone[k], areas[i]->net[k], areas[i]->node[k], areas[i]->aname[k]);
  577. }
  578. #endif
  579.  
  580.         sort_em (&(aptr->zone[0]), &(aptr->net[0]), &(aptr->node[0]),
  581.             aptr->num_nodes, 1, &(aptr->handle[0]), &(aptr->aname[0]));
  582.  
  583. #if DEBUG
  584. for (k = 0; k < aptr->num_nodes; k++)
  585. printf ("Net/node[%d] = %d:%d/%d\n", k, aptr->zone[k], aptr->net[k], aptr->node[k]);
  586. #endif
  587.  
  588.         ++tot_areas;
  589.         }
  590.  
  591. #if DEBUG
  592. printf ("\nRECAP\n\n");
  593. for (i = 0; i < tot_areas; i++)
  594. {
  595. printf ("AREA #%2d: DIR='%s' NAME='%s'\n", i, areas[i]->msg_path,
  596. areas[i]->area_name);
  597. for (k = 0; k < areas[i]->num_nodes; k++)
  598. printf ("NODE %d=%d:%d/%d:%s\n", k, areas[i]->zone[k], areas[i]->net[k], areas[i]->node[k], areas[i]->aname[k]);
  599. }
  600. #endif
  601.  
  602.     free ((char *) tmpzone);
  603.     free ((char *) tmpnet);
  604.     free ((char *) tmpnode);
  605.     fclose (f);
  606.     if (num_zone)
  607.     {
  608.         sort_em (&(zone_zone[1]), &(zone_net[1]), &(zone_node[1]), num_zone-1, 0, NULL, NULL);
  609.     }
  610.     return (0);
  611. }
  612.  
  613. void sort_em(
  614.     int   zones[],
  615.     int   nets[],
  616.     int   nodes[],
  617.     int   num_nodes,
  618.     int   others,
  619.     int   o1[],
  620.     char *o2[])
  621. {
  622.     register int i, j;
  623.     int tmp1, tmp2, tmp3, swaps;
  624.     char *tmp4;
  625.  
  626.     i = 0;
  627.     j = num_nodes;
  628.     swaps = 1;
  629.  
  630.     while (swaps)
  631.     {
  632.         for (j--, i = 0, swaps = 0; i < j; i++)
  633.         {
  634.             if ((nets[i] > nets[i+1]) ||
  635.                  ((nets[i] == nets[i+1]) && (nodes[i] > nodes[i+1])))
  636.                 {
  637.             tmp3 = zones[i];
  638.                 tmp1 = nets[i];
  639.                 tmp2 = nodes[i];
  640.             zones[i] = zones[i+1];
  641.                 nets[i] = nets[i+1];
  642.                 nodes[i] = nodes[i+1];
  643.             zones[i+1] = tmp3;
  644.                 nets[i+1] = tmp1;
  645.                 nodes[i+1] = tmp2;
  646.             if (others)
  647.                {
  648.                tmp1 = o1[i];
  649.                tmp4 = o2[i];
  650.                o1[i] = o1[i+1];
  651.                o2[i] = o2[i+1];
  652.                o1[i+1] = tmp1;
  653.                o2[i+1] = tmp4;
  654.                }
  655.             ++swaps;
  656.                 }
  657.          }
  658.       }
  659.  
  660. /*
  661.   for (i = 0; i < num_nodes; i++)
  662.   {
  663.     printf ("%d = %d/%d\n", i, nets[i], nodes[i]);
  664.   }
  665.  
  666.     for (i = 0; i < num_nodes; i++)
  667.         for (j = i+1; j < num_nodes; j++)
  668.             {
  669.             if ((nets[j] < nets[i]) ||
  670.                  ((nets[j] == nets[i]) && (nodes[j] < nodes[i])))
  671.                 {
  672.                 tmp1 = nets[i];
  673.                 tmp2 = nodes[i];
  674.                 nets[i] = nets[j];
  675.                 nodes[i] = nodes[j];
  676.                 nets[j] = tmp1;
  677.                 nodes[j] = tmp2;
  678.                 }
  679.             }
  680. */
  681. }
  682.  
  683.