⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dt_validator.c

📁 最新MTK手机软件源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
 *
 * Filename:
 * ---------
 *	dt_validator.c
 *
 * Project:
 * --------
 *   MAUI
 *
 * Description:
 * ------------
 *   This file is intends for ....
 *
 * Author:
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
*****************************************************************************/

#define DT_VALIDATOR_C

#include <stdio.h>
#include <string.h>
#include "kal_release.h"
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h"       	/* Task message communiction */
#include "stacklib.h"        	/* Basic type for dll, evshed, stacktimer */
#include "app_buff_alloc.h"
#include "stack_timer.h"
#include "event_shed.h"
#include "stack_config.h"
#include "stack_buff_pool.h"
#include "ctrl_buff_pool.h"
#include "tst_buff_pool.h"
#include "sysconf_statistics.h"

#include "dt_common_enum.h"
#include "dt_context.h"

#include "dt_trc.h"

#include "dt_rspfmttr.h"
#include "dt_utility.h"
#include "dt_aux_msg_hdlr.h"


//#ifdef FMT_NOT_PRESENT 								
//#define DT_MAX_IMAGE_FILE_NAME 30 
//#define DT_MAX_MELODY_FILE_NAME 30 
//#else
#define DT_MAX_IMAGE_FILE_NAME 250 
#define DT_MAX_MELODY_FILE_NAME 250 
//#endif


#ifdef DATA_DOWNLOAD
/*****************************************************************************
* FUNCTION
*  dt_efsw_hdlr
*
* DESCRIPTION
*   This is rmmi function handler for PC tool to delete a file
*   from file system.
*   mtk00714 add on 04/04/30
*
* PARAMETERS
*  source_string_ptr		IN		at cmd string
*
* RETURNS
*  none.
*
* GLOBALS AFFECTED
*  none.
*****************************************************************************/
void dt_efsw_hdlr (dt_string_struct *source_string_ptr)
{
    kal_bool      ret_val = KAL_FALSE;
     kal_uint8		result;
    kal_uint8		op;
    kal_uint16 		data_len;
    kal_uint8 		eof_flag;
    //kal_uint8	   tempdata[DT_UPLOAD_SIZE*2];
    //kal_uint8 	   data[DT_UPLOAD_SIZE];
    kal_uint8    *tempdata = NULL;
    kal_uint8	   *data = NULL;
    kal_uint8		error_cause;
    kal_uint16      write_data_size;
    kal_uint8 const  *rsp_str = NULL;
    kal_uint8        buffer[DT_SHORT_RSP_LEN];
    kal_uint16 string_length = 0;      
    kal_trace(TRACE_GROUP_4, FUNC_DT_EFSW_HDLR_ENTRY);
     
	switch (source_string_ptr->cmd_mode)
    	{
			/* checking the command mode */
	      	case DT_TEST_MODE :
	      	{
	      		ret_val = KAL_TRUE;
	        	break;
	      	}
		case DT_READ_MODE : 
	      	{
 			write_data_size = DT_PTR->write_data_size;
			ret_val = KAL_TRUE;
			DT_PTR->arg_list[0] = (void *)&write_data_size;
			string_length = dt_fast_string_print (
			                               buffer,
			                               (kal_uint8 *)"+EFSW: %u",
			                               DT_PTR->arg_list,
			                               1
			                              );
			        	rsp_str = &buffer[0];
	        	break;
	      	}	
	      	case DT_SET_OR_EXECUTE_MODE : 
      		{
			op = (kal_uint8)dt_int_validator_ext( &error_cause, source_string_ptr, (kal_uint8)DT_COMMA);				                      
      			switch(op)
      			{
#if 0 			
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif 			
	      			case 1:
	      			{
					ret_val = dt_eq_general_fs_access_req(DT_FS_CLOSE, DT_APP_UNKNOWN, NULL, NULL, 0);
					if(ret_val == KAL_TRUE)
					{
						dt_send_l4c_upload_cnf(DT_NO_ERR);
						dt_reset_state();
						return;
					}
					else
					{
						dt_send_l4c_upload_cnf(DT_PTR->cmee_err);							
						dt_reset_state();
						return;
					}
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
		      		}
		      		break;
		      		case 2:
		      		{
	     				eof_flag = (kal_uint8)dt_int_validator( source_string_ptr, (kal_uint8)DT_COMMA);
	     				if(eof_flag>1)
	     				{
						break;
		 	        	}
	     				
        				data_len = (kal_uint16)dt_int_validator(source_string_ptr,(kal_uint8)DT_COMMA);
	     				if(data_len>DT_UPLOAD_SIZE)
	     				{
						break;
		 	        	}

					ASSERT((kal_uint16)(DT_UPLOAD_SIZE*2)<2048);

					tempdata = get_ctrl_buffer(DT_UPLOAD_SIZE*2+1);
					data = get_ctrl_buffer(DT_UPLOAD_SIZE);				

					result = dt_string_validator( source_string_ptr, (kal_uint8)DT_PTR->s_reg.s3, 
																(kal_uint16)(data_len*2+1), (kal_uint8 *)tempdata);
					if(result == DT_VALIDATOR_ERROR)
     					{

						if(tempdata!=NULL)	
							free_ctrl_buffer(tempdata);
						if(data!=NULL)	
							free_ctrl_buffer(data);	
		     					
						break;
		 	        	}
					dt_check_hex_value(tempdata, (kal_uint8 *)data);
					ret_val = dt_eq_general_fs_access_req(DT_FS_WRITE,DT_APP_UNKNOWN, NULL,(kal_uint8 *)data,data_len);					

					if(tempdata!=NULL)	
						free_ctrl_buffer(tempdata);
					if(data!=NULL)	
						free_ctrl_buffer(data); 
 
					if(ret_val == KAL_FALSE)
					{
						dt_send_l4c_upload_cnf(DT_PTR->cmee_err);							
						dt_reset_state();
						return;
					}
					break;
		      		}
		      		break;
	      			default:
	      			{
					break;
      				}
      			}
      			break;
	      	}
         	default :
         	{
            		/* unrecognized format of AT command line */
            		break;
         	}
    	}/* end of the switch */
    	dt_final_rsp_generator(source_string_ptr->src_id, ret_val, (kal_uint8*)rsp_str, string_length);
}


/*****************************************************************************
* FUNCTION
*  dt_efsr_hdlr
*
* DESCRIPTION
*   This is rmmi function handler for PC tool to read a file
*   from file system.
*   mtk00714 add on 04/04/30
*
* PARAMETERS
*  source_string_ptr		IN		at cmd string
*
* RETURNS
*  none.
*
* GLOBALS AFFECTED
*  none.
*****************************************************************************/
void dt_efsr_hdlr (dt_string_struct *source_string_ptr)
{
    kal_bool      ret_val = KAL_FALSE;
    
    kal_trace(TRACE_GROUP_4, FUNC_DT_EFSR_HDLR_ENTRY);
          
    switch (source_string_ptr->cmd_mode)
    {
			/* checking the command mode */
	      case DT_TEST_MODE :
	      {
	      		ret_val = KAL_TRUE;
	        	break;
	      }
	      case DT_ACTIVE_MODE:
	      {
		  	if(DT_PTR->transfer_state != DT_DOWNLOAD_STATE)
		  	{
		  		kal_trace(TRACE_WARNING,WARNING_DT_NOT_DOWNLOAD_STATE,DT_PTR->transfer_state);
				return;
		  	}
			
	      			/* clear download pause timer */
				dt_clear_download_timer();	     

			if(DT_PTR->uart_stop_send_flag == KAL_FALSE)
			{
			   	if(DT_PTR->fd[0] != 0)
			   	{
			   		/* close the file handle and clear the stored infomation*/
					FS_Close(DT_PTR->fd[0]);
					DT_PTR->fd[0] = 0;
					DT_PTR->data_folder= 0;
					DT_PTR->printingDownloadData_flag = KAL_FALSE;
					DT_PTR->printingDownloadData_loopCount = 0;							
			   	}

				if (DT_PTR->download_filename!= NULL)
				{
					free_ctrl_buffer(DT_PTR->download_filename);//filename is allocated in l4c and free here
					DT_PTR->download_filename = NULL;
				}
				
				dt_send_l4c_download_cnf(DT_ERR_USER_ABORT);	
				dt_reset_state();
			}
			else
			{     /*mtk00924_060320: user abort during waiting for uart_ready_to_write_ind, 
			          sending download_cnf when finishing last run of +EFSR*/
				kal_trace(TRACE_WARNING, WARNING_DT_USER_ABORT_WHEN_UART_FULL);
				DT_PTR->abort_download = KAL_TRUE;
			}
				return;

	      }
#if 0	      
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -