software/drivers/sd8887/src/wlan/mapp/uaputl/uaputl.c
/**
 *  @brief Parses a command line
 *
 *  @param line     The line to parse
 *  @param args     Pointer to the argument buffer to be filled in
 *  @return         Number of arguments in the line or EOF
 */
@brief Parses a command line
@param line     The line to parse
@param args     Pointer to the argument buffer to be filled in
@return         Number of arguments in the line or EOF
@brief Parses a command line @param line The line to parse @param args Pointer to the argument buffer to be filled in @return Number of arguments in the line or EOF
static int
parse_line(char *line, char *args[])
{
	int arg_num = 0;
	int is_start = 0;
	int is_quote = 0;
	int is_escape = 0;
	int length = 0;
	int i = 0;
	int j = 0;
	arg_num = 0;
	length = strlen(line);
	is_start = 0;
	is_quote = 0;
	for (i = 0; i < length; i++) {
		if (is_start == 0) {
			if (line[i] == ' ') {
				continue;
			} else if (line[i] == '\t') {
				continue;
			} else if (line[i] == '\n') {
				break;
			} else {
				is_start = 1;
				args[arg_num] = &line[i];
				arg_num++;
			}
		}
		if (is_start == 1) {
			if ((line[i] == '\\') && (i < (length - 1))) {
				if (line[i + 1] == '"') {
					is_escape = 1;
					for (j = i; j < length - 1; j++) {
						line[j] = line[j + 1];
					}
					line[length - 1] = '\0';
					continue;
				}
			}
			if (line[i] == '#') {
				if (is_quote == 0) {
					line[i] = '\0';
					arg_num--;
				}
				break;
			}
			if (line[i] == '=') {
				if (is_quote == 0) {
					line[i] = '\0';
					is_start = 0;
					continue;
				}
			}
			if (line[i] == ',') {
				if (is_quote == 0) {
					line[i] = '\0';
					is_start = 0;
					continue;
				}
			}
			if ((line[i] == ',') && (is_quote == 0)) {
				line[i] = ' ';
				continue;
			}
		}
		if (line[i] == '\n') {
			line[i] = '\0';
		}
		if (line[i] == '"') {
			if (is_escape) {
				is_escape = 0;
			} else {
				is_quote = (is_quote == 1) ? 0 : 1;
			}
			continue;
		}
		if (((line[i] == ' ') || (line[i] == '\t')) && (is_quote == 0)) {
			line[i] = '\0';
			is_start = 0;
			continue;
		}
	}
	return arg_num;
}
static int parse_line ( char * line , char * args [ ] ) { int arg_num = 0 ; int is_start = 0 ; int is_quote = 0 ; int is_escape = 0 ; int length = 0 ; int i = 0 ; int j = 0 ; arg_num = 0 ; length = strlen ( line ) ; is_start = 0 ; is_quote = 0 ; for ( i = 0 ; i < length ; i ++ ) { if ( is_start == 0 ) { if ( line [ i ] == ' ' ) { continue ; } else if ( line [ i ] == ' \t ' ) { continue ; } else if ( line [ i ] == ' \n ' ) { break ; } else { is_start = 1 ; args [ arg_num ] = & line [ i ] ; arg_num ++ ; } } if ( is_start == 1 ) { if ( ( line [ i ] == ' \\ ' ) && ( i < ( length - 1 ) ) ) { if ( line [ i + 1 ] == ' ' ) { is_escape = 1 ; for ( j = i ; j < length - 1 ; j ++ ) { line [ j ] = line [ j + 1 ] ; } line [ length - 1 ] = ' \0 ' ; continue ; } } if ( line [ i ] == ' ' ) { if ( is_quote == 0 ) { line [ i ] = ' \0 ' ; arg_num -- ; } break ; } if ( line [ i ] == ' ' ) { if ( is_quote == 0 ) { line [ i ] = ' \0 ' ; is_start = 0 ; continue ; } } if ( line [ i ] == ' ' ) { if ( is_quote == 0 ) { line [ i ] = ' \0 ' ; is_start = 0 ; continue ; } } if ( ( line [ i ] == ' ' ) && ( is_quote == 0 ) ) { line [ i ] = ' ' ; continue ; } } if ( line [ i ] == ' \n ' ) { line [ i ] = ' \0 ' ; } if ( line [ i ] == ' ' ) { if ( is_escape ) { is_escape = 0 ; } else { is_quote = ( is_quote == 1 ) ? 0 : 1 ; } continue ; } if ( ( ( line [ i ] == ' ' ) || ( line [ i ] == ' \t ' ) ) && ( is_quote == 0 ) ) { line [ i ] = ' \0 ' ; is_start = 0 ; continue ; } } return arg_num ; }
@brief Parses a command line
  @param line     The line to parse
  @param args     Pointer to the argument buffer to be filled in
  @return         Number of arguments in the line or EOF
@brief Parses a command line @param line The line to parse @param args Pointer to the argument buffer to be filled in @return Number of arguments in the line or EOF
/* Process line */ /* Find number of arguments */ /* Ignore leading spaces */ /* Ignore comments */ /* Separate by '=' */ /* Separate by ',' */ /* Change ',' to ' ', but not inside quotes */ /* Remove newlines */ /* Check for quotes */ /* no change in is_quote */