#include <stdlib.h>

int efc_initialize_() {
	return e_initialize();
}
int efc_initialize() {
	return e_initialize();
}

int efc_end_() {
	return e_end();
}
int efc_end() {
	return e_end();
}

int efc_transpmonitor_(int *state) {
	return e_transpMonitor(*state);
}
int efc_transpmonitor(int *state) {
	return e_transpMonitor(*state);
}

int efc_register_(char *application, char *user, char *host, char *id, int *collect) {
	return e_register(application, user, host, id, *collect);
}
int efc_register(char *application, char *user, char *host, char *id, int *collect) {
	return e_register(application, user, host, id, *collect);
}

int efc_graphwindowcreate_(char *gw, int *rows, int *columns) {
	/* printf("efc_graphwindowcreate: %d %d\n", *rows,  *columns); */
	return e_GraphWindowCreate(gw, *rows, *columns);
}
int efc_graphwindowcreate(char *gw, int *rows, int *columns) {

	return e_GraphWindowCreate(gw, *rows, *columns);
}

int efc_graphcreate_(char *graph, int *type) {
	return e_GraphCreate(graph, *type);
}
int efc_graphcreate(char *graph, int *type) {
	return e_GraphCreate(graph, *type);
}

int efc_graphwindowaddgraph_(char *gw, char *graph, int *row, int *column) {
	return e_GraphWindowAddGraph(gw, graph, *row, *column); 
}
int efc_graphwindowaddgraph(char *gw, char *graph, int *row, int *column) {
	return e_GraphWindowAddGraph(gw, graph, *row, *column); 
}

int efc_fxdatasetcreate_(char *dataset, int *npts, double *x, double *fx) {
	int i;
	  /* printf("efc_fxdatasetcreate_ ---%s---\n", dataset); */

	/* for (i=0; i<*npts; i++) {
		printf("%lf %lf\n", x[i], fx[i]);
	} */

	return e_FxDatasetCreate(dataset, *npts, x, fx);
}
int efc_fxdatasetcreate(char *dataset, int *npts, double *x, double *fx) {
	return e_FxDatasetCreate(dataset, *npts, x, fx);
}


int efc_fxtdatasetcreate_(char *dataset, int *npts, double *x, double *fx, double *time) {
	int i;
	    /* printf("efc_fxtdatasetcreate_  %s %d\n", dataset, *npts); */
	    /* printf("   time = %lf\n", *time); */

	    /* for (i=0; i<*npts; i++) {
		    printf("   %lf %20.15lf\n", x[i], fx[i]);
	       } */

	return e_FxtDatasetCreate(dataset, *npts, x, fx, *time);
}
int efc_fxtdatasetcreate(char *dataset, int *npts, double *x, double *fx, double *time) {
	return e_FxtDatasetCreate(dataset, *npts, x, fx, *time);
}

int efc_graphaddfxdataset_(char *graph, char *dataset) {
	   /* printf("efc_graphaddfxdataset: %s %s\n", graph, dataset); */
	return e_GraphAddFxDataset(graph, dataset);
}
int efc_graphaddfxdataset(char *graph, char *dataset) {
	return e_GraphAddFxDataset(graph, dataset);
}

int efc_graphaddfxdatasetid_(char *graph, int *id) {
	   /* printf("efc_graphaddfxdatasetid: %s %d\n", graph, *id); */
	return e_GraphAddFxDatasetID(graph, *id);
}
int efc_graphaddfxdatasetid(char *graph, int *id) {
	return e_GraphAddFxDatasetID(graph, *id);
}

int efc_graphsetxaxis_(char *graph, int *type) {
	return e_GraphSetXAxis(graph, *type);
}

int efc_graphsetxaxis(char *graph, int *type) {
	return e_GraphSetXAxis(graph, *type);
}

int efc_graphsetyaxis_(char *graph, int *type) {
	return e_GraphSetYAxis(graph, *type);
}
int efc_graphsetyaxis(char *graph, int *type) {
	return e_GraphSetYAxis(graph, *type);
}

int efc_graphsetxrange_(char *graph, double *xmin, double *xmax) {
	    /* printf("efc_graphsetxrange: %s %lf %lf\n", graph, *xmin, *xmax); */
	return e_GraphSetXRange(graph, *xmin, *xmax);
}

int efc_graphsetxrange(char *graph, double *xmin, double *xmax) {
	return e_GraphSetXRange(graph, *xmin, *xmax);
}

int efc_graphsetyrange_(char *graph, double *ymin, double *ymax) {
	return e_GraphSetYRange(graph, *ymin, *ymax);
}

int efc_graphsetyrange(char *graph, double *ymin, double *ymax) {
	return e_GraphSetYRange(graph, *ymin, *ymax);
}

int efc_graphsetxlabel_(char *graph, char *label) {
	return e_GraphSetXLabel(graph, label);
}
int efc_graphsetxlabel(char *graph, char *label) {
	return e_GraphSetXLabel(graph, label);
}

int efc_graphsetylabel_(char *graph, char *label) {
	return e_GraphSetYLabel(graph, label);
}
int efc_graphsetylabel(char *graph, char *label) {
	return e_GraphSetYLabel(graph, label);
}

int efc_graphsettitle_(char *graph, char *title, char *smallTitle) {
	return e_GraphSetTitle(graph, title, smallTitle);
}
int efc_graphsettitle(char *graph, char *title, char* smallTitle) {
	return e_GraphSetTitle(graph, title, smallTitle);
}

int efc_graphsetindexlabel_(char *graph, char *label) {
	return e_GraphSetIndexLabel(graph, label);
}
int efc_graphsetindexlabel(char *graph, char *label) {
	return e_GraphSetIndexLabel(graph, label);
}

int efc_graphwindowdisplay_(char *gw) {
	return e_GraphWindowDisplay(gw);
}
int efc_graphwindowdisplay(char *gw) {
	return e_GraphWindowDisplay(gw);
}

int efc_graphwindowcreatefile_(char *gw) {
	return e_GraphWindowCreateFile(gw);
}
int efc_graphwindowcreatefile(char *gw) {
	return e_GraphWindowCreateFile(gw);
}

int efc_graphwindowappendfile_(char *gw) {
	return e_GraphWindowAppendFile(gw);
}
int efc_graphwindowappendfile(char *gw) {
	return e_GraphWindowAppendFile(gw);
}

int efc_graphwindowclosefile_(char *gw, int *poll) {
	return e_GraphWindowCloseFile(gw, *poll);
}
int efc_graphwindowclosefile(char *gw, int *poll) {
	return e_GraphWindowCloseFile(gw, *poll);
}

int efc_fxtdatasetdisplay_(char *gw, char *graphname, char *setname) {
	return e_FxtDatasetDisplay(gw, graphname, setname);
}
int efc_fxtdatasetdisplay(char *gw, char *graphname, char *setname) {
	return e_FxtDatasetDisplay(gw, graphname, setname);
}

int efc_fxtdatasetdisplayid_(char *gw, char *graphname, int *id) {
        return e_FxtDatasetDisplayID(gw, graphname, *id);
}
int efc_fxtdatasetdisplayid(char *gw, char *graphname, int *id) {
        return e_FxtDatasetDisplayID(gw, graphname, *id);
}

int efc_graphshowlegend_(char *graph, int *show) {
	return e_GraphShowLegend(graph, *show);
}
int efc_graphshowlegend(char *graph, int *show) {
	return e_GraphShowLegend(graph, *show);
}

int efc_showlines_(char *dataset, int *show) {
	return e_ShowLines(dataset, *show);
}
int efc_showlines(char *dataset, int *show) {
	return e_ShowLines(dataset, *show);
}

int efc_showmarkers_(char *dataset, int *show) {
	return e_ShowMarkers(dataset, *show);
}
int efc_showmarkers(char *dataset, int *show) {
	return e_ShowMarkers(dataset, *show);
}

int efc_graphaddlegendtitle_(char *graph, char *title) {
	  /* printf("efc_graphaddlegendtitle_ %s %s\n", graph, title); */
	return e_GraphAddLegendTitle(graph, title);
}
int efc_graphaddlegendtitle(char *graph, char *title) {
	return e_GraphAddLegendTitle(graph, title);
}


int efc_graphsetplotarea(char *graph, double *location, double *width, double *height) {
  return efc_graphsetplotarea_(graph, location, width, height);
}
int efc_graphsetplotarea_(char *graph, double *location, double *width, double *height) {
	float loc[2];

	loc[0] = (float) location[0];
	loc[1] = (float) location[1];

	return e_GraphSetPlotArea(graph, loc, (float) *width, (float) *height);
}

int efc_graphaddlabel(char *graph, char *label, double *location, char *font, char *style, double *sz, char *color){
  return efc_graphaddlabel_(graph, label, location, font, style, sz, color);
}
int efc_graphaddlabel_(char *graph, char *label, double *location, char *font, char *style, double *sz, char *color) {
	float loc[2];
	float col[3];
	float h;

	loc[0] = (float) location[0];
	loc[1] = (float) location[1];

	h = (float) *sz;

	return e_GraphAddLabel(graph, label, loc, font, style, (float) *sz, color);
}

int efc_surfacecreate(char *surface, char *graph) {
	return e_SurfaceCreate(surface, graph);
}
int efc_surfacecreate_(char *surface, char *graph) {
	return e_SurfaceCreate(surface, graph);
}

int efc_datasetaddpoints(char *gw, char *graph, char *dataset, int *npoints, double *x, double *fx) {
	  /* printf("efc_datasetaddpints_ ---%s---%s---%s---\n", gw, graph, dataset); */
	return e_DatasetAddPoints(gw, graph, dataset, *npoints, x, fx);
}
int efc_datasetaddpoints_(char *gw, char *graph, char *dataset, int *npoints, double *x, double *fx) {
	  /* printf("efc_datasetaddpints_ ---%s---%s---%s---\n", gw, graph, dataset); */
	return e_DatasetAddPoints(gw, graph, dataset, *npoints, x, fx);
}

int efc_free() {
	return e_free();
}
int efc_free_() {
	return e_free();
}

int efc_closewindows() {
	return e_CloseWindows();
}
int efc_closewindows_() {
	return e_CloseWindows();
}

int efc_fxycreate(char *graph, int *nx, int *ny, double *xy, double *xcoords, double *ycoords) {
  return efc_fxycreate_(graph, nx, ny, xy, xcoords, ycoords);
}
int efc_fxycreate_(char *graph, int *nx, int *ny, double *xy, double *xcoords, double *ycoords) {

	int i, j, loc = 0;
	double *fxy;

	   /* printf("efc_fxycreate_ %d %d\n", *nx, *ny); */

	fxy = (double *) malloc(sizeof(double) * *nx * *ny); 

	for (i=0; i<*nx; i++) {
		for (j=0; j<*ny; j++) {
			   /* printf("%lf\n", xy[j* (*nx) + i]); */
			fxy[loc] = xy[j* (*nx) + i];
			loc++;
		}
	}

	return e_FxyCreate(graph, *nx, *ny, fxy, xcoords, ycoords);
}

int efc_fxysetcontour(char *name, int *ncontours, double *contours) {
	return e_FxySetContour(name, *ncontours, contours);
}
int efc_fxysetcontour_(char *name, int *ncontours, double *contours) {
	return e_FxySetContour(name, *ncontours, contours);
}

int efc_graphaddfxy(char *graph, char *name) {
	return e_GraphAddFxy(graph, name);
}
int efc_graphaddfxy_(char *graph, char *name) {
	return e_GraphAddFxy(graph, name);
}

int efc_sendfile(char *filename){
	return e_SendFile(filename);
}

int efc_sendfile_(char *filename){
        return e_SendFile(filename);
}

int efc_tablecreate(char *tablename){
	return e_TableCreate(tablename);
}

int efc_tablecreate_(char *tablename){
	return e_TableCreate(tablename);
}

int efc_tableaddcolumn(char *tablename, char *colname){
	return e_TableAddColumn(tablename, colname);
}

int efc_tableaddcolumn_(char *tablename, char *colname){
	return e_TableAddColumn(tablename, colname);
}

int efc_tableaddcolumnid(char *tablename, int *id){
	return e_TableAddColumn(tablename, *id);
}

int efc_tableaddcolumnid_(char *tablename, int *id){
	return e_TableAddColumn(tablename, *id);
}

int efc_columncreateblank(char *colname){
	return e_ColumnCreateBlank(colname);
}

int efc_columncreateblank_(char *colname){
	return e_ColumnCreateBlank(colname);
}

int efc_columnaddrow(char *colname, char *cell){
	return e_ColumnAddRow(colname, cell);
}

int efc_columnaddrow_(char *colname, char *cell){
	return e_ColumnAddRow(colname, cell);
}

int efc_graphwindowaddtable(char *windowname, char *tablename, int *row, int *column){
	return e_GraphWindowAddTable(windowname, tablename, *row, *column);
}

int efc_graphwindowaddtable_(char *windowname, char *tablename, int *row, int *column){
	return e_GraphWindowAddTable(windowname, tablename, *row, *column);
}

int efc_graphsetxgrid(char *graphname, int *grid){
	return e_GraphSetXGrid(graphname, *grid);
}

int efc_graphsetxgrid_(char *graphname, int *grid){
	return e_GraphSetXGrid(graphname, *grid);
}

int efc_graphsetygrid(char *graphname, int *grid){
	return e_GraphSetYGrid(graphname, *grid);
}

int efc_graphsetygrid_(char *graphname, int *grid){
	return e_GraphSetYGrid(graphname, *grid);
}

int efc_columnsetrowlabels(char *colname, int *labels){
	return e_ColumnSetRowLabels(colname, *labels);
}

int efc_columnsetrowlabels_(char *colname, int *labels){
	return e_ColumnSetRowLabels(colname, *labels);
}

int efc_columnsetbgcolor(char *colname, char *color){
	return e_ColumnSetBGColor(colname, color);
}

int efc_columnsetbgcolor_(char *colname, char *color){
	return e_ColumnSetBGColor(colname, color);
}

int efc_columnsetheader(char *colname, char *header){
	return e_ColumnSetHeader(colname, header);
}

int efc_columnsetheader_(char *colname, char *header){
	return e_ColumnSetHeader(colname, header);
}

int efc_columnsetfontname(char *colname, char *fontname){
	return e_ColumnSetFontName(colname, fontname);
}

int efc_columnsetfontname_(char *colname, char *fontname){
	return e_ColumnSetFontName(colname, fontname);
}

int efc_columnsetfontstyle(char *colname, char *fontstyle){
	return e_ColumnSetFontName(colname, fontstyle);
}

int efc_columnsetfontstyle_(char *colname, char *fontstyle){
	return e_ColumnSetFontStyle(colname, fontstyle);
}

int efc_columnsetfontsize(char *colname, int *fontsize){
	return e_ColumnSetFontSize(colname, *fontsize);
}

int efc_columnsetfontsize_(char *colname, int *fontsize){
	return e_ColumnSetFontSize(colname, *fontsize);
}

int efc_tableaddtoptext(char *tablename, char *text, char *font, char *style, int *fontsize, char *color, char *bgcolor){
	return e_TableAddTopText(tablename, text, font, style, *fontsize, color, bgcolor);
}

int efc_tableaddtoptext_(char *tablename, char *text, char *font, char *style, int *fontsize, char *color, char *bgcolor){
	return e_TableAddTopText(tablename, text, font, style, *fontsize, color, bgcolor);
}

int efc_columnsetfontcolor(char *colname, char *fontcolor){
	return e_ColumnSetFontColor(colname, fontcolor);
}

int efc_columnsetfontcolor_(char *colname, char *fontcolor){
	return e_ColumnSetFontColor(colname, fontcolor);
}

int efc_tableaddbottomtext(char *tablename, char *text, char *font, char *style, int *fontsize, char *color, char *bgcolor){
	return e_TableAddBottomText(tablename, text, font, style, *fontsize, color, bgcolor);
}

int efc_tableaddbottomtext_(char *tablename, char *text, char *font, char *style, int *fontsize, char *color, char *bgcolor){
	return e_TableAddBottomText(tablename, text, font, style, *fontsize, color, bgcolor);
}

int efc_graphsetzaxis(char *graphname, int *loglin){
	return e_GraphSetZAxis(graphname, *loglin);
}

int efc_graphsetzaxis_(char *graphname, int *loglin){
	return e_GraphSetZAxis(graphname, *loglin);
}
