software/drivers/sd8887/src/wlan/mapp/mlanconfig/mlanconfig.c
/**
 *  @brief Get one line from the File
 *
 *  @param fp       File handler
 *  @param str	    Storage location for data.
 *  @param size 	Maximum number of characters to read.
 *  @param lineno	A pointer to return current line number
 *  @return         returns string or NULL
 */
@brief Get one line from the File
@param fp       File handler
@param str      Storage location for data.
@param size         Maximum number of characters to read.
@param lineno       A pointer to return current line number
@return         returns string or NULL
@brief Get one line from the File @param fp File handler @param str Storage location for data . @param size Maximum number of characters to read . @param lineno A pointer to return current line number @return returns string or NULL
char *
mlan_config_get_line(FILE * fp, t_s8 *str, t_s32 size, int *lineno)
{
	char *start, *end;
	int out, next_line;
	if (!fp || !str)
		return NULL;
	do {
read_line:
		if (!fgets(str, size, fp))
			break;
		start = str;
		start[size - 1] = '\0';
		end = start + strlen(str);
		(*lineno)++;
		out = 1;
		while (out && (start < end)) {
			next_line = 0;
			switch (start[0]) {
			case ' ':	
			case '\t':	
				start++;
				break;
			case '#':
			case '\n':
			case '\0':
				next_line = 1;
				break;
			case '\r':
				if (start[1] == '\n')
					next_line = 1;
				else
					start++;
				break;
			default:
				out = 0;
				break;
			}
			if (next_line)
				goto read_line;
		}
		if ((end = strstr(start, "\""))) {
			if (!(end = strstr(end + 1, "\"")))
				end = start;
		} else
			end = start;
		if ((end = strstr(end + 1, "#")))
			*end-- = '\0';
		else
			end = start + strlen(start) - 1;
		out = 1;
		while (out && (start < end)) {
			switch (*end) {
			case ' ':	
			case '\t':	
			case '\n':
			case '\r':
				*end = '\0';
				end--;
				break;
			default:
				out = 0;
				break;
			}
		}
		if (*start == '\0')
			continue;
		return start;
	} while (1);
	return NULL;
}
char * mlan_config_get_line ( FILE * fp , t_s8 * str , t_s32 size , int * lineno ) { char * start , * end ; int out , next_line ; if ( ! fp || ! str ) return NULL ; do { read_line : if ( ! fgets ( str , size , fp ) ) break ; start = str ; start [ size - 1 ] = ' \0 ' ; end = start + strlen ( str ) ; ( * lineno ) ++ ; out = 1 ; while ( out && ( start < end ) ) { next_line = 0 ; switch ( start [ 0 ] ) { case ' ' : case ' \t ' : start ++ ; break ; case ' ' : case ' \n ' : case ' \0 ' : next_line = 1 ; break ; case ' \r ' : if ( start [ 1 ] == ' \n ' ) next_line = 1 ; else start ++ ; break ; default : out = 0 ; break ; } if ( next_line ) goto read_line ; } if ( ( end = strstr ( start , " \" " ) ) ) { if ( ! ( end = strstr ( end + 1 , " \" " ) ) ) end = start ; } else end = start ; if ( ( end = strstr ( end + 1 , " " ) ) ) * end -- = ' \0 ' ; else end = start + strlen ( start ) - 1 ; out = 1 ; while ( out && ( start < end ) ) { switch ( * end ) { case ' ' : case ' \t ' : case ' \n ' : case ' \r ' : * end = ' \0 ' ; end -- ; break ; default : out = 0 ; break ; } } if ( * start == ' \0 ' ) continue ; return start ; } while ( 1 ) ; return NULL ; }
@brief Get one line from the File
  @param fp       File handler
  @param str      Storage location for data.
@brief Get one line from the File @param fp File handler @param str Storage location for data .
/* Remove empty lines and lines starting with # */ /* White space */ /* Tab */ /* Remove # comments unless they are within a double quoted
		 * string. Remove trailing white space. */ /* White space */ /* Tab */