davide carboni / Mbed 2 deprecated pymite_http_get

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sli.h Source File

sli.h

Go to the documentation of this file.
00001 /*
00002 # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall.
00003 #
00004 # This file is part of the PyMite VM.
00005 # The PyMite VM is free software: you can redistribute it and/or modify
00006 # it under the terms of the GNU GENERAL PUBLIC LICENSE Version 2.
00007 #
00008 # The PyMite VM is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00011 # A copy of the GNU GENERAL PUBLIC LICENSE Version 2
00012 # is seen in the file COPYING in this directory.
00013 */
00014 
00015 
00016 #ifndef __SLI_H__
00017 #define __SLI_H__
00018 
00019 
00020 /**
00021  * \file
00022  * \brief Standard Library Interface
00023  *
00024  * PyMite requires a few functions from a few different
00025  * standard C libraries (memory, string, etc).
00026  * If your microcontroller has these libraries,
00027  * set the constant to 1 for each library available.
00028  * This will cause a macro to be defined which wraps
00029  * the function for use by PyMite.
00030  * Otherwise, leave the constant as 0, and PyMite will
00031  * use the function defined in sli.c
00032  * Some of the functions in sli.c will need to be ported
00033  * to the target system.
00034  */
00035 
00036 
00037 /**
00038  * If the compiler has string.h, set HAVE_STRING to 1;
00039  * otherwise, leave it 0 and the sli functions will be used.
00040  */
00041 #define HAVE_STRING_H 0
00042 
00043 
00044 /*
00045  * This section creates a macro or a function prototype
00046  * for each library based on the corresponding constant.
00047  * For example, if HAVE_STRING_H is defined to non-zero,
00048  * the system <string.h> file will be included,
00049  * and a macro "sli_strcmp" will be created to wrap the strcmp()
00050  * function.  But if HAVE_STRING is zero, the sli_strcmp()
00051  * prototype will be declared and sli_strcmp() must be
00052  * implemented in sli.c
00053  */
00054 
00055 #if HAVE_STRING_H
00056 
00057 #include <string.h>
00058 
00059 #define sli_memcpy(to, from, n) memcpy((to), (from), (n))
00060 #define sli_strcmp(s1, s2)      strcmp((s1),(s2))
00061 #define sli_strlen(s)           strlen(s)
00062 #define sli_strncmp(s1, s2, n)  strncmp((s1),(s2),(n))
00063 
00064 #else
00065 
00066 /**
00067  * Copies a block of memory in RAM.
00068  *
00069  * @param   to The destination address.
00070  * @param   from The source address.
00071  * @param   n The number of bytes to copy.
00072  * @return  The initial pointer value of the destination
00073  * @see     mem_copy
00074  */
00075 void *sli_memcpy(unsigned char *to, unsigned char const *from, unsigned int n);
00076 
00077 /**
00078  * Compares two strings.
00079  *
00080  * @param   s1 Ptr to string 1.
00081  * @param   s2 Ptr to string 2.
00082  * @return  value that is less then, equal to or greater than 0
00083  *          depending on whether s1's encoding is
00084  *          less than, equal to, or greater than s2's.
00085  */
00086 int sli_strcmp(char const *s1, char const *s2);
00087 
00088 /**
00089  * Obtain string length.
00090  *
00091  * @param   s ptr to string.
00092  * @return  number of bytes in string.
00093  */
00094 int sli_strlen(char const *s);
00095 
00096 /**
00097  * Compare strings for a specific length.
00098  *
00099  * @param   s1 ptr to string 1.
00100  * @param   s2 ptr to string 2.
00101  * @param   n number of chars to compare
00102  * @return  value that is less then, equal to or greater than 0
00103  *          depending on whether s1's encoding is
00104  *          less than, equal to, or greater than s2's.
00105  */
00106 int sli_strncmp(char const *s1, char const *s2, unsigned int n);
00107 
00108 #endif /* HAVE_STRING_H */
00109 
00110 /**
00111  * Copy a value repeatedly into a block of memory
00112  *
00113  * @param   dest the destination address.
00114  * @param   val the value.
00115  * @param   n the number of bytes to copy.
00116  * @return  Nothing
00117  * @see     memset
00118  */
00119 void sli_memset(unsigned char *dest, const char val, unsigned int n);
00120 
00121 #endif /* __SLI_H__ */