direntry_type Struct Reference

Embedded File System directory. More...

#include <net.h>

Data Fields

char dir [MAX_NAME_LEN]
 
char name [MAX_NAME_LEN]
 
int32_t size
 
uint32_t access
 
int8_t type
 
uint32_t offset
 
uint32_t max_offset
 
uint32_t pos
 
uint32_t rw
 
uint32_t timeout
 
SOCKET * data_con
 
char * buffer
 
int32_t error
 
char * auth_key
 
char * auth_name
 
int32_t index
 
char(* get_byte )(uint32_t, uint32_t)
 
int32_t(* put_byte )(uint32_t, char)
 
uint16_t(* read_block )(char *, uint32_t, uint32_t, uint16_t)
 

Detailed Description

The direntry_type structure is used to specify a directory/file for the EFS. It's used for FTP, HTTP or telnet servers.

Examples:
FTPServer.c, HTTPdynamic.c, HTTPjava.c, and Telnet.c.

Field Documentation

dir

Directory name

max. 60 characters, no spaces

Examples:
FTPServer.c, and Telnet.c.
name

File name

max. 60 characters, no spaces

int32_t size

File size

Examples:
HTTPdynamic.c, and HTTPjava.c.
access

File access

use defines

  • FTP_READ - Read files
  • FTP_CREATE - Create new files
  • FTP_WRITE - Overwrite or delete existing files
  • FTP_RW - Read and write permission
  • FTP_RAM - File located in RAM
  • HTTP_GZIP - activate HTTP server "Content-Encoding: gzip"
int8_t type

File type 'A'-ASCII, 'B'-bin or 'I'-hex

uint32_t offset

Location of data in RAM or FLASH

Examples:
Telnet.c.
uint32_t max_offset

Maximum address offset

uint32_t pos

Position of data pointer

rw

Read write flag

use defines

  • FTP_READ - Read file
  • FTP_WRITE - Write file
timeout

Timeout counter

Note
for internal use only
SOCKET* data_con

Connected data socket

buffer

Data buffer for transfer

Note
the temporary data buffer for file transmission must be dynamic; it is freed automatically after file transmission. Allocate at least 1500 bytes.
//**************************************************************************
// malloc some space for transmission
//**************************************************************************
buffer = (char *) malloc (1500 * sizeof (char));
if ( buffer == NULL ) // out of memory
{
net_send_string (server, out_of_memory_msg);
}
else
{
//************************************************************************
// initialize sending
//************************************************************************
dir -> data_con = server; // actual server connection
dir -> buffer = buffer; // data buffer
...
}
error

Error_code

check previous transmission for errors:

//**************************************************************************
// check success
//**************************************************************************
if ( dir -> error < 0 )
{
switch (dir -> error)
{
net_send_string (server, "BIOS protect error\r\n");
break;
net_send_string (server, "Intel hex checksum error\r\n");
break;
net_send_string (server, "Intel hex error\r\n");
break;
net_send_string (server, "sector erase error\r\n");
break;
net_send_string (server, "FLASH program error\r\n");
break;
net_send_string (server, "buffer under-run error\r\n");
break;
net_send_string (server, "out of memory error\r\n");
break;
net_send_string (server, "out of range error\r\n");
break;
default:
net_send_string (server, "Unknown error!\r\n");
}
}
Examples:
Telnet.c.
auth_key

Authentication key

used for secure webpages; key is set automatically by function http_set_authentication()

auth_name

Authentication name

used for secure webpages; name is set automatically by function http_set_authentication()

index

Directory index

  • root directory - 0
  • subdirectory - 1
Examples:
HTTPdynamic.c, and HTTPjava.c.
get_byte

File read callback function

overwritable function to read external data (e.g. from SPI FLASH)

put_byte

File write callback function

overwritable function to write external data (e.g. to SPI FLASH)

uint16_t(* read_block) (char *, uint32_t, uint32_t, uint16_t)

File blockread callback function