/*
 * The Spar Library - modular math parser
 * Copyright (C) 2000,2001 Davide Angelocola <davide178@inwind.it>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA  02111-1307, USA.
 *
 */

#ifndef _sl_io_h_
#define _sl_io_h_

#include <spar/sl_conf.h>

__BEGIN_DECLS
/** 
 *  Gets a double variable by stdin. Also check the constant and variable
 *  table. Returns SL_SUCCESS on success, otherwise SL_ERROR.
 */
int sl_input_double (const char *msg, double *value);

/**
 *  Gets an identifier by stdin, checks the input string length and copy
 *  only the first SL_IDENTIFIER_LENGHT char into the "msg" string.
 *  Returns SL_SUCCESS on success, otherwise SL_ERROR.
 */
int sl_input_identifier (const char *msg, char *identifier);

/**
 *  Gets an message by stdin, checks the input string length and copy
 *  only the first SL_MESSAGE_LENGHT char into the "msg" string.
 *  Returns SL_SUCCESS on success, otherwise SL_ERROR.
 */

int sl_input_message (const char *msg, char *message);

/** 
 *  Write a string to stdout stream without a new line char.
 */
void sl_write (const char *, ...);


/**
 *  Write a string to stdout stream with a new line char.
 */
void sl_writeln (const char *, ...);

/**
 *  Write a string to the specified stream stream without a new line char.
 *  This is useful to create logfiles.
 */
void sl_writef (const char *, const char *, ...);

/**
 *  Write a string to the specified stream stream. Prints also a new line char. 
 *  This is useful to create logfiles.
 */
void sl_writefln (const char *, const char *, ...);


/**
 *  Sets the precision which the numbers are showed. The fist param means
 *  the number of digits to print before the point, whereas, the second one
 *  means the number of digits to print after the point. 
 */
void sl_writer_set_precision (int, int);

/**
 *  Prints a value with the default precision or using the last call of
 *  set_precision().
 */
void sl_write_value (double);
void sl_writeln_value (double n);

/**
 *   Prints a value with the precision passed as params, so the 
 *   sl_writer_set_precision is ignored.
 */
void sl_write_value_with_precision (double n, int integer, int decimal);
void sl_writeln_value_with_precision (double n, int integer, int decimal);

/**
 *  Prints a value with the default precision or using the last call of
 *  set_precision(). Prints also a message (label), the output is something
 *  like this (using this call sl_write_value_with_label ("f", 4.)):
 *
 *  		f = 4
 */
void sl_write_value_with_label (const char *msg, double v);
void sl_writeln_value_with_label (const char *msg, double v);

__END_DECLS struct precision_s
{
  int integer;
  int decimal;
};

typedef struct precision_s sl_precision;


#endif /* _sl_io_h_ */


syntax highlighted by Code2HTML, v. 0.9.1