Initial commit
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
71
casadm/safeclib/safe_str_lib.h
Normal file
71
casadm/safeclib/safe_str_lib.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*------------------------------------------------------------------
|
||||
* safe_str_lib.h -- Safe C Library String APIs
|
||||
*
|
||||
* October 2008, Bo Berry
|
||||
*
|
||||
* Copyright (c) 2008-2011, 2013 by Cisco Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef __SAFE_STR_LIB_H__
|
||||
#define __SAFE_STR_LIB_H__
|
||||
|
||||
#include "safe_lib.h"
|
||||
|
||||
/*
|
||||
* The shortest string is a null string!!
|
||||
*/
|
||||
#define RSIZE_MIN_STR ( 1 )
|
||||
|
||||
/* maximum sring length */
|
||||
#define RSIZE_MAX_STR ( 4UL << 10 ) /* 4KB */
|
||||
|
||||
|
||||
/* The makeup of a password */
|
||||
#define SAFE_STR_MIN_LOWERCASE ( 2 )
|
||||
#define SAFE_STR_MIN_UPPERCASE ( 2 )
|
||||
#define SAFE_STR_MIN_NUMBERS ( 1 )
|
||||
#define SAFE_STR_MIN_SPECIALS ( 1 )
|
||||
|
||||
#define SAFE_STR_PASSWORD_MIN_LENGTH ( 6 )
|
||||
#define SAFE_STR_PASSWORD_MAX_LENGTH ( 32 )
|
||||
|
||||
/* set string constraint handler */
|
||||
extern constraint_handler_t
|
||||
set_str_constraint_handler_s(constraint_handler_t handler);
|
||||
|
||||
/* fitted string copy */
|
||||
extern errno_t
|
||||
strncpy_s(char *dest, rsize_t dmax, const char *src, rsize_t slen);
|
||||
|
||||
/* string length */
|
||||
extern rsize_t
|
||||
strnlen_s (const char *s, rsize_t smax);
|
||||
|
||||
/* string tokenizer */
|
||||
extern char *
|
||||
strtok_s(char *s1, rsize_t *s1max, const char *src, char **ptr);
|
||||
|
||||
#endif /* __SAFE_STR_LIB_H__ */
|
Reference in New Issue
Block a user