Index: pobysoC-4.0/src/test-pobyso-01.c
===================================================================
--- pobysoC-4.0/src/test-pobyso-01.c	(revision 0)
+++ pobysoC-4.0/src/test-pobyso-01.c	(revision 128)
@@ -0,0 +1,7 @@
+#include <stdio.h>
+int main()
+{
+    printf("Hello World!\n");
+    return (0);
+}
+

Property changes on: pobysoC-4.0/src/test-pobyso-01.c
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: pobysoC-4.0/src/pobyso.c
===================================================================
--- pobysoC-4.0/src/pobyso.c	(revision 127)
+++ pobysoC-4.0/src/pobyso.c	(revision 128)
@@ -17,6 +17,9 @@
 /* includes of project headers */
 
 /* includes of system headers */
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
 
 /* Other declarations */
 
@@ -39,13 +42,100 @@
   va_end(va);
 } /* End pobyso_autoprint. */
 
+/* @see pobyso.h#pobyso_parse*/
+pobyso_function_t
+pobyso_parse(const char* expression)
+{
+  int expressionLength, i;
+  char *expressionWithSemiCo;
+  sollya_obj_t expressionStringSa;
+  sollya_obj_t expressionSa;
+
+  /* Arguments check. */
+  if (expression == NULL)
+  {
+    pobyso_error_message("pobyso_parse",
+                        "NULL_POINTER_ARGUMENT",
+                        "The expression is a NULL pointer");
+    return(sollya_lib_error());
+  }
+  expressionLength = strlen(expression);
+  if (expressionLength == 0)
+  {
+    pobyso_error_message("pobyso_parse",
+                        "EMPTY_STRING_ARGUMENT",
+                        "The expression is an empty string");
+    return(sollya_lib_error());
+  }
+  /* Search from the last char of the expression until, whichever happens
+   * first:
+   * a ";" is found;
+   * a char  != ';' is found the the ";" is appended.
+   * If the head of the string is reached before any of these two events happens
+   * return an error.
+   */
+  for (i = expressionLength - 1 ; i >= 0 ; i--)
+  {
+    if (expression[i] == ';') /* Nothing special to do:
+                                 try to parse the string*/
+    {
+      /* This ugly cast comes from a deficient definition in Sollya:
+         sollya_lib_string does not take a const char * argument. */
+      expressionStringSa = sollya_lib_string((char*)expression);
+      expressionSa = sollya_lib_parse(expressionStringSa);
+      sollya_lib_free(expressionStringSa);
+      return(expressionSa);
+    }
+    else
+    {
+      if (expression[i] == ' ' || expression[i] == '\t') /* A blank,
+                                                           just continue. */
+      {
+        continue;
+      }
+      else /* a character != ';' and from a blank: create the ';'ed string. */
+      {
+        /* Create a new string for the expression, add the ";" and
+         * and call sollya_lib_parse_string. */
+        expressionWithSemiCo = calloc(i + 3, sizeof(char));
+        if (expressionWithSemiCo == NULL)
+        {
+          pobyso_error_message("pobyso_parse",
+                                "MEMORY_ALLOCATION_ERROR",
+                                "Could not allocate the expression string");
+          return(sollya_lib_error());
+        }
+        strncpy(expressionWithSemiCo, expression, i + 1);
+        expressionWithSemiCo[i + 1] = ';';
+        expressionWithSemiCo[i + 2] = '\0';
+        expressionStringSa = sollya_lib_string(expressionWithSemiCo);
+        expressionSa = sollya_lib_parse(expressionStringSa);
+        free(expressionWithSemiCo);
+        sollya_lib_free(expressionStringSa);
+        return(expressionSa);
+      } /* End character != ';' and from a blank. */
+    /* Create a new string for the expression, add the ";" and
+     * and call sollya_lib_parse_string. */
+    } /* End else. */
+  } /* End for. */
+  /* We get here, it is because we did not find any char == anything different
+   * from ' ' or '\t': the string is empty.
+   */
+  pobyso_error_message("pobyso_parse_string",
+                       "ONLY_BLANK_ARGUMENT",
+                        "The expression is only made of blanks");
+  return(sollya_lib_error());
+
+} /* pobyso_parse_string */
+
 /* @see pobyso.h#pobyso_parse_string*/
-sollya_obj_t
+pobyso_function_t
 pobyso_parse_string(const char* expression)
 {
-  int expressionLength;
+  int expressionLength, i;
   char *expressionWithSemiCo;
   sollya_obj_t expressionSa;
+
   /* Arguments check. */
   if (expression == NULL)
   {
@@ -60,44 +150,77 @@
     pobyso_error_message("pobyso_parse_string",
                         "EMPTY_STRING_ARGUMENT",
                         "The expression is an empty string");
+    return(sollya_lib_error());
   }
-  /* If the final ";" has been forgotten. */
-  if (expression[expressionLength-1] != ';')
+  /* Search from the last char of the expression until, whichever happens
+   * first:
+   * a ";" is found;
+   * a char  != ';' is found the the ";" is appended.
+   * If the head of the string is reached before any of these two events happens
+   * return an error.
+   */
+  for (i = expressionLength - 1 ; i >= 0 ; i--)
   {
-    expressionWithSemiCo = calloc(expressionLength + 2, sizeof(char));
-    if (expressionWithSemiCo == NULL)
+    if (expression[i] == ';') /* Nothing special to do:
+                                 try to parse the string*/
     {
-      pobyso_error_message("pobyso_parse_string",
-                            "MEMORY_ALLOCATION_ERROR",
-                            "Could not allocate the expression string");
-      return(sollya_lib_error());
+      expressionSa = sollya_lib_parse_string(expression);
+      return(expressionSa);
     }
-    expressionWithSemiCo = strcat(expressionWithSemiCo, expression);
-    expressionWithSemiCo = strcat(expressionWithSemiCo, ";");
-    expressionSa = sollya_lib_parse_string(expressionWithSemiCo);
-    free(expressionWithSemiCo);
-    return(expressionSa);
-  } /* End ";" forgotten */
-  else
-  {
-    return(sollya_lib_parse_string(expression));
-  }
+    else
+    {
+      if (expression[i] == ' ' || expression[i] == '\t') /* A blank,
+                                                           just continue. */
+      {
+        continue;
+      }
+      else /* a character != ';' and from a blank: create the ';'ed string. */
+      {
+        /* Create a new string for the expression, add the ";" and
+         * and call sollya_lib_parse_string. */
+        expressionWithSemiCo = calloc(i + 3, sizeof(char));
+        if (expressionWithSemiCo == NULL)
+        {
+          pobyso_error_message("pobyso_parse_string",
+                                "MEMORY_ALLOCATION_ERROR",
+                                "Could not allocate the expression string");
+          return(sollya_lib_error());
+        }
+        strncpy(expressionWithSemiCo, expression, i + 1);
+        expressionWithSemiCo[i + 1] = ';';
+        expressionWithSemiCo[i + 2] = '\0';
+        expressionSa = sollya_lib_parse_string(expressionWithSemiCo);
+        free(expressionWithSemiCo);
+        return(expressionSa);
+      } /* End character != ';' and from a blank. */
+    /* Create a new string for the expression, add the ";" and
+     * and call sollya_lib_parse_string. */
+    } /* End else. */
+  } /* End for. */
+  /* We get here, it is because we did not find any char == anything different
+   * from ' ' or '\t': the string is empty.
+   */
+  pobyso_error_message("pobyso_parse_string",
+                       "ONLY_BLANK_ARGUMENT",
+                        "The expression is only made of blanks");
+  return(sollya_lib_error());
+
 } /* pobyso_parse_string */
 
-void
-pobyso_set_verbosity_off(sollya_obj_t* currentVerbosityLevel)
+sollya_verbosity_t
+pobyso_set_verbosity_off()
 {
   sollya_obj_t verbosityLevelZero;
-  if (currentVerbosityLevel != NULL)
-  {
-     *currentVerbosityLevel = sollya_lib_get_verbosity();
-  }
+  sollya_obj_t currentVerbosityLevel = NULL;
+
+  currentVerbosityLevel = sollya_lib_get_verbosity();
   verbosityLevelZero = sollya_lib_constant_from_int(0);
   sollya_lib_set_verbosity(verbosityLevelZero);
   sollya_lib_clear_obj(verbosityLevelZero);
+  return(currentVerbosityLevel);
 } /* End of pobyso_set_verbosity_off. */
 
-void
+sollya_verbosity_t
 pobyso_set_verbosity_to(sollya_obj_t newVerbosityLevel)
 {
   if (newVerbosityLevel == NULL)
@@ -105,7 +228,7 @@
     pobyso_error_message("pobyso_set_verbosity_to",
                         "NULL_POINTER_ARGUMENT",
                         "The new verbosity level is a NULL pointer");
-    return;
+    return(sollya_lib_error());
   }
   sollya_lib_set_verbosity(newVerbosityLevel);
 } /* End of pobyso_set_verbosity_to. */
Index: pobysoC-4.0/src/pobyso.h
===================================================================
--- pobysoC-4.0/src/pobyso.h	(revision 127)
+++ pobysoC-4.0/src/pobyso.h	(revision 128)
@@ -19,13 +19,34 @@
 
 #ifndef POBYSO_h
 
+/* Typedefs to make code more readable. */
+typedef sollya_obj_t pobyso_error_t;
+typedef sollya_obj_t pobyso_function_t;
+typedef sollya_obj_t pobyso_precision_t;
+typedef sollya_obj_t pobyso_range_t;
+
+typedef sollya_obj_t sollya_verbosity_t;
+
 #define POBYSO_ABSOLUTE 1
 #define POBYSO_RELATIVE 2
+
 /* Mimic the default behavior of interactive Sollya. */
 #define POBYSO_DEFAULT_POINTS 501
 #define POBYSO_INF_NORM_NUM_POINTS (POBYSO_DEFAULT_POINTS)
 #define POBYSO_GUESS_DEGREE_BOUND 1024
 
+
+/* Very thin wrappers around a lot of Sollya functions.
+ */
+static inline pobyso_error_t pobyso_error(void)
+{return(sollya_lib_error());}
+
+static inline int pobyso_is_error(sollya_obj_t errorCandidate)
+{return(sollya_lib_obj_is_error(errorCandidate));}
+
+static inline int pobyso_is_function(sollya_obj_t functionCandidate)
+{return(sollya_lib_obj_is_function(functionCandidate));}
+
 /**
  * Print object(s) to stdout.
  * A very thin wrapper around the lib_sollya_v_autoprint() function.
@@ -50,24 +71,66 @@
  * function.
  * @return a Sollya expression if successes, a Sollya error if fails.
  */
-sollya_obj_t
+pobyso_error_t
+pobyso_parse(const char* expression);
+
+/**
+ * A wrapper around the Sollya Remez function.
+ */
+/**
+ * Parse a string to create a Sollya object.
+ * A very thin wrapper around the sollya_lib_parse_string() function.
+ * If the final ";" is forgotten in the expression, it is added by the
+ * function.
+ * @return a Sollya expression if successes, a Sollya error if fails.
+ */
+pobyso_error_t
 pobyso_parse_string(const char* expression);
 
 /**
+ * A wrapper around the Sollya Remez function with the canonical monomials
+ * base.
+ */
+
+pobyso_function_t
+pobyso_remez_canonical_monomials_base(pobyso_function_t function,
+                                      long int degree,
+                                      pobyso_range_t interval,
+                                      pobyso_function_t weight,
+                                      double quality,
+                                      pobyso_range_t bounds);
+
+/**
+ * A wrapper around the Sollya Remez function with the a sparse monomials
+ * base.
+ */
+
+pobyso_function_t
+pobyso_remez_sparse_monomials_base(pobyso_function_t);
+
+/**
+ * A wrapper around the Sollya Remez function with the canonical monomials
+ * base.
+ */
+
+pobyso_function_t
+pobyso_remez_arbitrary_base(pobyso_function_t);
+
+
+
+/**
  * Set the verbosity mode off (level 0).
- * If currentVerbosity != NULL, currentVerbosity is set
- * to the current verbosity level. It may be used to reset the
- * verbosity level later.
+ * The current level of vebositiy is returned.
  */
-void
-pobyso_set_verbosity_off(sollya_obj_t* currentVerbosityLevel);
+sollya_verbosity_t
+pobyso_set_verbosity_off(void);
 
 /**
  * Set the verbosity level to newVerbosityLevel.
  * @param newVerbosityLevel must be a Sollay object corresponding to an
  *        integer constant.
  */
-void
+sollya_verbosity_t
 pobyso_set_verbosity_to(sollya_obj_t newVerbosityLevel);
 
 #if 0
Index: pobysoC-4.0/src/test-pobyso-01
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: pobysoC-4.0/src/test-pobyso-01
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mime-type
   + application/octet-stream

