Exemple #1
0
int main (int ac, char **av)
{
    CC_SFILE *s = (CC_SFILE *) NULL;
    int rval = 0;

    rval = parseargs (ac, av);
    if (rval) return 0;

    CCutil_printlabel ();

    s = CCutil_snet_open (hostname, CCtsp_DOMINO_PORT);
    if (!s) {
        fprintf (stderr, "CCutil_snet_open failed\n");
        rval = 1;  goto CLEANUP;
    }

    if (stopboss) {
        printf ("stop the boss\n");  fflush (stdout);
        rval = CCutil_swrite_char (s, CCtsp_DOMINO_EXIT);
        CCcheck_rval (rval, "CCutil_swrite_char failed (EXIT)");
    } else if (sendgraph) {
        printf ("Send graph id = %d\n", graphid);  fflush (stdout);
        rval = CCutil_swrite_char (s, CCtsp_DOMINO_GRAPH);
        CCcheck_rval (rval, "CCutil_swrite_char failed (GRAPH)");
        rval = CCutil_swrite_int (s, graphid);
        CCcheck_rval (rval, "CCutil_swrite_int failed");
        rval = CCutil_swrite_int (s, 2*graphid);
        CCcheck_rval (rval, "CCutil_swrite_int failed");
        rval = CCutil_swrite_int (s, 3*graphid);
        CCcheck_rval (rval, "CCutil_swrite_int failed");
    } else if (getdominos) {
        printf ("get the domino list\n");  fflush (stdout);
        rval = CCutil_swrite_char (s, CCtsp_DOMINO_SEND);
        CCcheck_rval (rval, "CCutil_swrite_char failed (SEND)");
        rval = receive_dominos (s);
        CCcheck_rval (rval, "receive_dominos failed");
    } else {
        printf ("Nothing to do.\n"); fflush (stdout);
    }

CLEANUP:

    if (s) CCutil_sclose (s);
    return rval;
}
Exemple #2
0
int CClp_swrite_warmstart(CC_SFILE *file, CClp_warmstart *warm)
{     /* WRITES warmstart information from the f. */
      int i, j;
      const char *name = SOLVER;
      for (i = 0; i < 4; i++)
         if (CCutil_swrite_char(file, name[i])) return 1;
      if (CCutil_swrite_int(file, warm->ncols)) return 1;
      if (CCutil_swrite_int(file, warm->nrows)) return 1;
      for (j = 0; j < warm->ncols; j++)
         if (CCutil_swrite_bits (file, warm->cstat[j], 2)) return 1;
      for (i = 0; i < warm->nrows; i++)
         if (CCutil_swrite_bits (file, warm->rstat[i], 1)) return 1;
      return 0;
}
Exemple #3
0
int main (int ac, char **av)
{
    int rval;
    CC_SFILE *f = (CC_SFILE *) NULL;

#ifdef CC_NETREADY
    rval = parseargs (ac, av);
    if (rval) return 0;

    if ((unsigned int) hostport == 0) {
        if (tellcutboss)      hostport = (unsigned int) CCtsp_CUT_PORT;
        else if (telldomboss) hostport = (unsigned int) CCtsp_DOMINO_PORT;
        else                  hostport = (unsigned int) CCtsp_HOST_PORT;
    }
    
    f = CCutil_snet_open (hostname, hostport);
    if (f == (CC_SFILE *) NULL) {
        fprintf (stderr, "Could not open connection to host %s\n", hostname);
        rval = 1; goto CLEANUP;
    }

    if (tellcutboss) {
        if (savepool) {
            rval = CCutil_swrite_char (f, CCtsp_POOL_SAVECUTS);
            if (rval) {
                fprintf (stderr, "CCutil_swrite_char failed\n");
                goto CLEANUP;
            }
        } else if (send_exit) {
            rval = CCutil_swrite_char (f, CCtsp_POOL_EXIT);
            if (rval) {
                fprintf (stderr, "CCutil_swrite_char failed\n");
                goto CLEANUP;
            }
        } else {
            fprintf (stderr, "Nothing to send to cutboss\n");
            rval = 1; goto CLEANUP;
        }
    } else if (telldomboss) {
        if (send_exit) {
            rval = CCutil_swrite_char (f, CCtsp_DOMINO_EXIT);
            if (rval) {
                fprintf (stderr, "CCutil_swrite_char failed\n");
                goto CLEANUP;
            }
        } else {
            fprintf (stderr, "Nothing to send to domboss\n");
            rval = 1; goto CLEANUP;
        }
    } else {
        if (deadnode >= 0) {
            rval = CCutil_swrite_char (f, CCtsp_BBREQ_DEADNODE);
            if (rval) {
                fprintf (stderr, "CCutil_swrite_char failed\n");
                goto CLEANUP;
            }
            rval = CCutil_swrite_int (f, deadnode);
            if (rval) {
                fprintf (stderr, "CCutil_swrite_int failed\n");
                goto CLEANUP;
            }
        } else if (send_exit) {
            rval = CCutil_swrite_char (f, CCtsp_BBREQ_EXIT);
            if (rval) {
                fprintf (stderr, "CCutil_swrite_char failed\n");
                goto CLEANUP;
            }
        } else {
            fprintf (stderr, "Nothing to send to boss\n");
            rval = 1; goto CLEANUP;
        }
    }

    rval = CCutil_sclose (f);
    f = (CC_SFILE *) NULL;
    if (rval) {
        fprintf (stderr, "CCutil_sclose failed\n");
        goto CLEANUP;
    }
    
    rval = 0;
  CLEANUP:
    if (f != (CC_SFILE *) NULL) {
        CCutil_sclose (f);
    }
    return rval;
#else /* CC_NETREADY */
    fprintf (stderr, "Networking disabled\n");
    return 1;
#endif /* CC_NETREADY */
}