Beispiel #1
0
static int receive_dominos (CC_SFILE *s)
{
    int rval = 0;
    int i, count;
    int *list = (int *) NULL;

    rval = CCutil_sread_int (s, &count);
    CCcheck_rval (rval, "CCutil_sread_int failed (count)");

    list = CC_SAFE_MALLOC (count, int);
    CCcheck_NULL (list, "out memory for list");

    for (i = 0; i < count; i++) {
        rval = CCutil_sread_int (s, &list[i]);
        CCcheck_rval (rval, "CCutil_sread_int failed (list)");
    }

    printf ("Dom List: %d\n", count);
    for (i = 0; i < count; i++) {
        printf ("%d ", list[i]);
    }
    printf ("\n"); fflush (stdout);

CLEANUP:

    CC_IFFREE (list, int);
    return rval;
}
Beispiel #2
0
int CClp_sread_warmstart(CC_SFILE *file, CClp_warmstart **warm)
{     /* READS warmstart information from the file. */
      int i, j, ccount, rcount;
      char name[5];
      CClp_free_warmstart(warm);
      for (i = 0; i < 4; i++)
         if (CCutil_sread_char(file, &name[i])) goto fail;
      name[4] = '\0';
      if (strncmp(name, SOLVER, 4))
      {  print("CClp_sread_warmstart: warmstart for another solver (%s)"
            " ignored", name);
         return 0;
      }
      if (CCutil_sread_int(file, &ccount)) goto fail;
      if (CCutil_sread_int(file, &rcount)) goto fail;
      (*warm) = umalloc(sizeof(CClp_warmstart));
      (*warm)->ncols = 0;
      (*warm)->nrows = 0;
      (*warm)->cstat = NULL;
      (*warm)->rstat = NULL;
      (*warm)->cstat = ucalloc(ccount, sizeof(int));
      (*warm)->rstat = ucalloc(rcount, sizeof(int));
      for (j = 0; j < ccount; j++)
         if (CCutil_sread_bits(file, &(((*warm)->cstat)[j]), 2))
            goto fail;
      for (i = 0; i < rcount; i++)
         if (CCutil_sread_bits(file, &(((*warm)->rstat)[i]), 1))
            goto fail;
      (*warm)->ncols = ccount;
      (*warm)->nrows = rcount;
      return 0;
fail: CClp_free_warmstart(warm);
      return 1;
}
Beispiel #3
0
static int serve_file (CC_SFILE *f, char *probfname, int silent)
{
    char request;
    char probbuf[1024];
    int id;
    int rval;

    rval = CCutil_sread_char (f, &request);
    if (rval) {
        fprintf (stderr, "CCutil_sread_char failed\n");
        return rval;
    }
    rval = CCutil_sread_string (f, probbuf, sizeof (probbuf));
    if (rval) {
        fprintf (stderr, "CCutil_sread_string failed\n");
        return rval;
    }
    rval = CCutil_sread_int (f, &id);
    if (rval) {
        fprintf (stderr, "CCutil_sread_int failed\n");
        return rval;
    }

    if (strcmp (probfname, probbuf)) {
        fprintf (stderr, "ERROR - serving %s, request %s\n", probfname,
                 probbuf);
        return rval;
    }

    switch (request) {
      case CCtsp_Pread:
        rval = serve_read (f, probfname, id, silent);
        if (rval) {
            fprintf (stderr, "serve_read failed\n");
            return rval;
        }
        break;
      case CCtsp_Pwrite:
        rval = serve_write (f, probfname, id, silent);
        if (rval) {
            fprintf (stderr, "serve_write failed\n");
            return rval;
        }
        break;
      case CCtsp_Pdelete:
        rval = serve_delete (probname, id);
        if (rval) {
            fprintf (stderr, "serve_delete failed\n");
            return rval;
        }
        break;
      default:
        fprintf (stderr, "Invalid request %c\n", request);
        return 1;
    }

    return 0;
}