/* Microchip Technology Inc. and its subsidiaries.  You may use this software 
 * and any derivatives exclusively with Microchip products. 
 * 
 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS".  NO WARRANTIES, WHETHER 
 * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 
 * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 
 * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 
 * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 
 *
 * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 
 * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 
 * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 
 * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE 
 * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS 
 * IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF 
 * ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
 *
 * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 
 * TERMS. 
 */

/* 
 * File:   
 * Author: 
 * Comments:
 * Revision history: 
 */

#include <xc.h>
#include <stdio.h>

// This is a guard condition so that contents of this file are not included
// more than once.  
#ifndef STRING_OPS_H
#define	STRING_OPS_H

/*
 * Convertir enteros.
 * 
 * Todas devuelven siguiente posicion en la que se debe escribir.
 * Ademas se puede decidir si aņadir caracter de final de string
 * o no. De esta manera se pueden modificar cifras en una cadena
 * de caracteres sin tener que reescribirla entera.
 
 * p_int: print integer, 
 * p_lint: print long integer (32b), 
 * p_llint: print long long integer (64b),
 * p_int_fl: print integer fl*
 * p_uint_fl: print unsigned integer fl,
 
 ** fl -> fixed length: Permite escoger la longitud del 
            string generado, a riesgo de ser mas corto 
            que algunos de los valores posibles,
  
 * Parametros
    * -buffer: (char*) buffer,
    * -val: ([u,l,ll]int o float) valor a convertir en string
    * -precision: (char)
    * -len: (int) longitud el string a generar (solo en fl)
    * -endWithNull: (char) 1 Terminar con NULL / No terminar con NULL
    * -max: ultima posicion del buffer
 ****************************************/
char* p_llint(char* buffer, long long int val, char endWithNull, char* max);
char* p_lint(char* buffer, long int val, char endWithNull, char* max);
char* p_int(char* buffer, int val, char endWithNull, char* max);
char* p_int_fl(char* buffer, int val, char len, char endWithNull, char* max);
char* p_lint_fl(char* buffer, long int val, char len, char endWithNull, char* max);
char* p_uint_fl(char* buffer, unsigned int val, char len, char endWithNull, char* max);
char* p_int_ec(char* buffer, int val, char endWithNull,char ec, char* max);
/*
 * Strings: asignar, concatenar, medir, etc.
 * 
 * Todas devuelven siguiente posicion en la que se debe escribir. 

 * Assign: Sobreescribe un buffer con el contenido de un string.
 * Parametros
    * -buffer: buffer,
    * -strB: string a guardar en el buffer,
    * -max: ultima posicion del buffer
 *****************************************/
char* assign(char* buffer, char* strB, char* max);
/* Append: Aņade un string al final de un buffer (primera posi-
 *         cion en la que encuentra NULL)
 * Parametros
    * -strA: buffer,
    * -strB: string a aņadir al final del buffer,
    * -max: ultima posicion del buffer (strA)
 ***********************************************/
char* append(char* strA, char* strB, char* max);
/* Concat: Concatena dos strings y almacena el resultado en un 
 *         buffer
 * Parametros
    * -buffer: buffer,
    * -strA: string a unir por su extremo derecho con strB,
    * -strB: string a unir por su extremo izquierdo con strA,
    * -max: ultima posicion del buffer
 ****************************************/
char* concat(char* buffer, char* strA, char* strB, char* max);
/* Length: Devuelve la longitud de un string (hasta el primer 
 *         NULL)
 * Parametros
    * -string: Cadena de caracteres a medir.
 ****************************************/
int length(char* string);


#endif /*STRING_OPS_H*/