Beispiel #1
0
response_codes melted_help( command_argument cmd_arg )
{
	int i = 0;
	
	mvcp_response_printf( cmd_arg->response, 10240, "%s", helpstr );
	
	for ( i = 0; vocabulary[ i ].command != NULL; i ++ )
		mvcp_response_printf( cmd_arg->response, 1024,
							"%-10.10s%s\n", 
							vocabulary[ i ].command, 
							vocabulary[ i ].help );

	mvcp_response_printf( cmd_arg->response, 2, "\n" );

	return RESPONSE_SUCCESS_N;
}
Beispiel #2
0
mvcp_response mvcp_response_clone( mvcp_response response )
{
	mvcp_response clone = mvcp_response_init( );
	if ( clone != NULL && response != NULL )
	{
		int index = 0;
		for ( index = 0; index < mvcp_response_count( response ); index ++ )
		{
			char *line = mvcp_response_get_line( response, index );
			mvcp_response_printf( clone, strlen( line ) + 2, "%s\n", line );
		}
	}
	return clone;
}
Beispiel #3
0
void mvcp_response_set_error( mvcp_response response, int error_code, const char *error_string )
{
	if ( response->count == 0 )
	{
		mvcp_response_printf( response, 10240, "%d %s\n", error_code, error_string );
	}
	else
	{
		char temp[ 10240 ];
		int length = sprintf( temp, "%d %s", error_code, error_string );
		response->array[ 0 ] = realloc( response->array[ 0 ], length + 1 );
		strcpy( response->array[ 0 ], temp );
	}
}
Beispiel #4
0
response_codes melted_run( command_argument cmd_arg )
{
	mvcp_response temp = mvcp_parser_run( cmd_arg->parser, (char *)cmd_arg->argument );

	if ( temp != NULL )
	{
		int index = 0;

		mvcp_response_set_error( cmd_arg->response, 
							   mvcp_response_get_error_code( temp ),
							   mvcp_response_get_error_string( temp ) );

		for ( index = 1; index < mvcp_response_count( temp ); index ++ )
			mvcp_response_printf( cmd_arg->response, 10240, "%s\n", mvcp_response_get_line( temp, index ) );

		mvcp_response_close( temp );
	}

	return mvcp_response_get_error_code( cmd_arg->response );
}