/**
 * \file    string.h
 * \brief   String utitilies of system adaptation layer
 *
 * \par     Copyright (c) 2018 UWE Technologies Corp., Ltd. All Rights Reserved.
 * \author  James
 * \date    2018-03-05
 * \version 
 * 
 * \history 
 *  Date        Note
 *  2018-03-05  Original Creation
 * 
 */
 
#ifndef __STRING_H_
#define __STRING_H_


#include <stdarg.h>
#include "types.h"
#include "arch.h"
#if (DMA_MEMCPY_ENABLED)
#include "drv_dma.h"
#endif

int memcmp(const void *, const void *, register int);
int strcmp(const char *, const char *);
int strncmp(const char *, const char *, register int);
int strcasecmp(const char *, const char *);
int strncasecmp(const char *, const char *, register int);
void *memcpy2 (void * dst0, const void * src0, unsigned long len0);
void *memmove2 (void *dst_void, const void *src_void, unsigned long length);
#if (DMA_MEMCPY_ENABLED)
#define memcpy(dst,src,cnt)     drv_dma_memcpy(dst,src,cnt,DRV_DMA_MODE_ADDR_INC)
#define memmove(dst,src,cnt)    drv_dma_memmove(dst,src,cnt)
#else
#define memcpy(dst,src,cnt)     memcpy2(dst,src,cnt)
#define memmove(dst,src,cnt)    memmove2(dst,src,cnt)
#endif
void *memset(register void *, register int, register int);
char *strcat(register char *, register char *);
char *strchr(register char *, register char);
int strlen(register char *);
int strnlen(const char *, unsigned int);
char *strstr(char *, char *);
char *strcpy(register char *, const char *);
char *strncat(register char *, register char *, register int);
char *strncpy(register char *, register char *, register int);
int strspn(char *, char *);
char *strpbrk(char *, register char *);
char *strrchr(register char *, register char);
char *strtok(char *, char *);
char *strtolower(char *);
char *strtoupper(char *);

/** 
 * Convert the hexadecimal format string to hexadecimal number array. Two bytes 
 * characters will be convert to one byte hexadecimal number. 
 *
 * \param dst The hexadecimal number array, unsigned char type
 * \param len The length of hexadecimal number array
 * \param src The source string with hexadecimal format
 * \return    The convertion number of hexadecimal array
 */
int strtohex(unsigned char *dst, char *src, int len);

#if 0  /* deleted by James Gan - 2018-04-06 */
/**
 * getopt initialization
 *
 * Since getopt() can be used by every command 
 * it's variables must be reinitialized prior to each command
 * executed through cli_cmd_parse()...
 *
 * \see
 */
void getopt_init(void);

/**
 * Parse command-line options
 *
 *
 * \param argc argument count
 * \param argv argument vector
 * \param opts options for searching
 * \return If an option was successfully found, then returns the option character. 
 * If all command-line options have been parsed, then returns -1. 
 * If encounters an option character that was not in optstring, then '?' is returned. 
 * If encounters an option with a missing argument, then the return value depends on the first character in optstring: if it is ':', then ':' is returned; otherwise '?' is returned. 
 *
 * \see
 */
int getopt(int argc,char **argv,char *opts);
#endif /* #if 0 */


#endif /* #ifndef __STRING_H_ */

