Пример #1
0
int fcloseTIMEOUT_FL(FL_PAR,FILE *fp)
{	int rcode;

	if( fileno(fp) < 0 ){
		porting_dbg("+++EPIPE[%d] fcloseTIMEOUT() for EOF",fileno(fp));
		/*
		return EOF;
		9.8.2 should free the FILE structure.
		*/
		rcode = fcloseFILE(fp);
		return rcode;
	}

	/*
	 * 9.8.2 this code is bad leaving FILE and descriptor unclosed.
	 * added in 2.4.8 maybe (?) intented to close disconnected stream
	 * without causing alarm signal for timeout (and buffer flushing ?).
	if( feof(fp) )
		return EOF;
	 */
	if( feof(fp) /*|| ferror(fp)*/ ){
		if( ferror(fp) || LOG_VERBOSE )
		sv1log("-- fcloseTIMEOUT(%X/%d/S%d) EOF=%d ERR=%d\n",
			p2i(fp),fileno(fp),SocketOf(fileno(fp)),feof(fp),ferror(fp));
		dupclosed_FL(FL_BAR,fileno(fp));
		rcode = Xfclose(FL_BAR,fp);
		return rcode;
	}

	{
	fRETURN_ONTIMEOUTX(fp,-1,EOF,LIN_TIMEOUT+2);
	/*
	rcode = fclose(fp);
	*/
	rcode = Xfclose(FL_BAR,fp);
	DONE_SUCCESSFULLY();
	return rcode;
	}
}
Пример #2
0
static int
clocks_htmloutput(orchids_t *ctx, mod_entry_t *mod, FILE *menufp, html_output_cfg_t *htmlcfg)
{
  FILE *fp;
/*   strhash_elmt_t *helmt; */
  int i;
/*  strhash_t *clocks; */
/*   int nb_clocks; */
  size_t ctx_array_sz;
  myclock_t **ctx_array;
  clockctx_t *modcfg;

  modcfg = mod->config;

  fp = create_html_file(htmlcfg, "orchids-clocks.html", NO_CACHE);
  fprintf_html_header(fp, "Orchids statistics");

  fprintf(fp, "<center><h1>Clocks<h1></center>\n");

  fprintf(fp, "<center>\n");
  fprintf(fp, "<table border=\"0\" cellpadding=\"3\" width=\"600\">\n");
  fprintf(fp, "<tr class=\"h\"><th colspan=\"3\">Clocks</th></tr>\n");
  fprintf(fp, "<tr class=\"hh\"><th>Clock name</th><th>Precision</th><th>Synchronization</th></tr>\n");

  ctx_array = strhash_to_array(modcfg->clocks);
  ctx_array_sz = modcfg->clocks->elmts;
  qsort(ctx_array, ctx_array_sz, sizeof (myclock_t *), qsort_clockcmp);

  for (i = 0; i < ctx_array_sz; i++) {
    fprintf(fp,
            "<tr><td class=\"e%i\">%s</td><td class=\"v%i\">%f</td><td class=\"v%i\">%f</td>\n",
            i%2, ctx_array[i]->name,
            i%2, ctx_array[i]->prec,
            i%2, ctx_array[i]->sync);
  }

  Xfree(ctx_array);

  fprintf(fp, "</table>\n");
  fprintf(fp, "</center>\n");

  fprintf_html_trailer(fp);

  Xfclose(fp);

  fprintf(menufp,
	  "<a href=\"orchids-clocks.html\" "
          "target=\"main\">Clocks</a><br/>\n");

  return (0);
}
Пример #3
0
static int
period_htmloutput(orchids_t *ctx, mod_entry_t *mod, FILE *menufp, html_output_cfg_t *htmlcfg)
{
  FILE *fp;
  int i;
  strhash_elmt_t *helmt;
  size_t ctx_array_sz;
  char **ctx_array;

  fprintf(menufp,
	  "<a href=\"orchids-period.html\" "
          "target=\"main\">Periods</a><br/>\n");

  fp = create_html_file(htmlcfg, "orchids-period.html", NO_CACHE);
  fprintf_html_header(fp, "Orchids frequencies / phases tables");

  fprintf(fp, "<center><h1>Orchids frequencies / phases tables</h1></center>\n");

  ctx_array = NULL;
  ctx_array_sz = 0;
  for (i = 0; i < ctx->temporal->size; i++) {
    for (helmt = ctx->temporal->htable[i]; helmt; helmt = helmt->next) {
      ctx_array_sz++;
      ctx_array = Xrealloc(ctx_array, ctx_array_sz * sizeof (char *));
      ctx_array[ ctx_array_sz - 1 ] = helmt->key;
/*       period_output_gnuplot(); */
    }
  }
  qsort(ctx_array, ctx_array_sz, sizeof (char *), qsort_strcmp);

  fprintf(fp, "%zd context%s<br/><br/><br/>\n",
          ctx_array_sz, ctx_array_sz > 1 ? "s" : "");

  for (i = 0; i < ctx_array_sz; i++)
    fprintf(fp, "%i: %s<br/>\n", i, ctx_array[i]);

  if (ctx_array_sz > 0)
    Xfree(ctx_array);

  fprintf_html_trailer(fp);
  Xfclose(fp);

  return (0);
}