eapol/eapol_framework/eapol_common/am/include/abs_eap_am_file_input.h
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  EAP and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #if !defined(_ABS_EAP_AM_FILE_INPUT_H_)
       
    21 #define _ABS_EAP_AM_FILE_INPUT_H_
       
    22 
       
    23 
       
    24 #include "eap_tools.h"
       
    25 #include "eap_array.h"
       
    26 
       
    27 //--------------------------------------------------
       
    28 
       
    29 enum eap_file_io_direction_e
       
    30 {
       
    31 	eap_file_io_direction_read,
       
    32 	eap_file_io_direction_write,
       
    33 };
       
    34 
       
    35 //--------------------------------------------------
       
    36 
       
    37 enum eap_file_type_e
       
    38 {
       
    39 	eap_file_type_none,
       
    40 	eap_file_type_file,
       
    41 	eap_file_type_directory,
       
    42 };
       
    43 
       
    44 //--------------------------------------------------
       
    45 
       
    46 class eap_variable_data_c;
       
    47 
       
    48 
       
    49 class abs_eap_file_stat_c
       
    50 {
       
    51 private:
       
    52 
       
    53 public:
       
    54 
       
    55 	virtual ~abs_eap_file_stat_c()
       
    56 	{
       
    57 	}
       
    58 
       
    59 	abs_eap_file_stat_c()
       
    60 	{
       
    61 	}
       
    62 
       
    63 	virtual const eap_variable_data_c * const get_file_name() const = 0;
       
    64 
       
    65 	virtual const eap_file_type_e get_file_type() const = 0;
       
    66 
       
    67 	/**
       
    68 	 * Object must indicate it's validity.
       
    69 	 * If object initialization fails this function must return false.
       
    70 	 * @return This function returns the validity of this object.
       
    71 	 */
       
    72 	virtual bool get_is_valid() const = 0;
       
    73 };
       
    74 
       
    75 //--------------------------------------------------
       
    76 
       
    77 /// This is interface to EAP file input.
       
    78 /** The EAP file input is used in configuration file read operations.
       
    79  */
       
    80 class EAP_EXPORT abs_eap_am_file_input_c
       
    81 {
       
    82 
       
    83 private:
       
    84 
       
    85 	/**
       
    86 	 * The set_is_valid() function sets the state of the object valid.
       
    87 	 * The creator of this object calls this function after it is initialized. 
       
    88 	 */
       
    89 	virtual void set_is_valid() = 0;
       
    90 
       
    91 public:
       
    92 
       
    93 	/**
       
    94 	 * The destructor of the abs_eap_am_file_input_c class does nothing special.
       
    95 	 */
       
    96 	virtual ~abs_eap_am_file_input_c()
       
    97 	{
       
    98 	}
       
    99 
       
   100 	/**
       
   101 	 * The constructor of the abs_eap_am_file_input_c does nothing special.
       
   102 	 */
       
   103 	abs_eap_am_file_input_c()
       
   104 	{
       
   105 	}
       
   106 
       
   107 	/**
       
   108 	 * This function checks the file of name file_name exists.
       
   109 	 * It returns eap_status_ok if file exists
       
   110 	 * in other cases some error status.
       
   111 	 * @param file_nameis the pathname of the tested file.
       
   112 	 */
       
   113 	virtual eap_status_e file_exists(const eap_variable_data_c * const file_name) = 0;
       
   114 
       
   115 	/**
       
   116 	 * This function deletes the file of name if file_name exists.
       
   117 	 * It returns eap_status_ok if file did exist and it was deleted
       
   118 	 * in other cases some error status.
       
   119 	 * @param file_nameis the pathname of the deleted file.
       
   120 	 */
       
   121 	virtual eap_status_e file_delete(const eap_variable_data_c * const file_name) = 0;
       
   122 
       
   123 	/**
       
   124 	 * This function copies the file source_file_name to file target_file_name.
       
   125 	 * @param target_file_name is the pathname of the target file.
       
   126 	 * @param source_file_name is the pathname of the source file.
       
   127 	 */
       
   128 	virtual eap_status_e file_copy(
       
   129 		const eap_variable_data_c * const target_file_name,
       
   130 		const eap_variable_data_c * const source_file_name) = 0;
       
   131 
       
   132 	/**
       
   133 	 * This function opens file of name file_name.
       
   134 	 * @param file_name is the pathname of the opened file.
       
   135 	 * @param dir is the I/O direction (eap_file_io_direction_read or eap_file_io_direction_write).
       
   136 	 */
       
   137 	virtual eap_status_e file_open(
       
   138 		const eap_variable_data_c * const file_name,
       
   139 		const eap_file_io_direction_e dir) = 0;
       
   140 
       
   141 	/**
       
   142 	 * This function closes the file.
       
   143 	 */
       
   144 	virtual eap_status_e file_close() = 0;
       
   145 
       
   146 	/**
       
   147 	 * This function returns size of a file.
       
   148 	 */
       
   149 	virtual u32_t file_size() = 0;
       
   150 
       
   151 	/**
       
   152 	 * This function reads data from a file.
       
   153 	 * Maximum size read is the buffer size.
       
   154 	 * @param buffer must be initialised to reguired size.
       
   155 	 */
       
   156 	virtual eap_status_e file_read(eap_variable_data_c * const buffer) = 0;
       
   157 
       
   158 	/**
       
   159 	 * This function write data to a file.
       
   160 	 * Maximum size write is the buffer size.
       
   161 	 * @param buffer includes the written data.
       
   162 	 */
       
   163 	virtual eap_status_e file_write(const eap_variable_data_c * const buffer) = 0;
       
   164 
       
   165 	/**
       
   166 	 * This function reads line from file.
       
   167 	 * @param The read line will be copied to line parameter.
       
   168 	 */
       
   169 	virtual eap_status_e file_read_line(eap_variable_data_c * const line) = 0;
       
   170 
       
   171 	/**
       
   172 	 * This function reads word from file.
       
   173 	 * @param The read word will be copied to word parameter.
       
   174 	 */
       
   175 	virtual eap_status_e file_read_word(eap_variable_data_c * const word) = 0;
       
   176 
       
   177 
       
   178 	/**
       
   179 	 * This function opens directory of name directory_name.
       
   180 	 * @param file_name is the pathname of the opened directory.
       
   181 	 */
       
   182 	virtual eap_status_e directory_open(
       
   183 		const eap_variable_data_c * const directory_name) = 0;
       
   184 
       
   185 	/**
       
   186 	 * This function reads the files and directories from open directory.
       
   187 	 * @param directory_list includes the stattus of each file and directory in open directory.
       
   188 	 */
       
   189 	virtual eap_status_e directory_read(
       
   190 		eap_array_c<abs_eap_file_stat_c> * const directory_list) = 0;
       
   191 
       
   192 	/**
       
   193 	 * This function closes the directory.
       
   194 	 */
       
   195 	virtual eap_status_e directory_close() = 0;
       
   196 
       
   197 	/**
       
   198 	 * Object must indicate it's validity.
       
   199 	 * If object initialization fails this function must return false.
       
   200 	 * @return This function returns the validity of this object.
       
   201 	 */
       
   202 	virtual bool get_is_valid() = 0;
       
   203 
       
   204 	/**
       
   205 	 * Function creates an object on a platform.
       
   206 	 */
       
   207 	static abs_eap_am_file_input_c * new_abs_eap_am_file_input_c(
       
   208 		abs_eap_am_tools_c * const tools);
       
   209 
       
   210 }; // class abs_eap_am_file_input_c
       
   211 
       
   212 #endif //#if !defined(_ABS_EAP_AM_FILE_INPUT_H_)
       
   213 
       
   214 //--------------------------------------------------
       
   215 
       
   216 
       
   217 
       
   218 // End.