/* flaneth - flash and ethernet
   Copyright (C) 2007-2012 Stefan Schuermans <stefan@schuermans.info>
   Copyleft: GNU public license V2 - http://www.gnu.org/copyleft/gpl.html
   a BlinkenArea project - http://www.blinkenarea.org/ */

#ifndef INC_apps_tools
#define INC_spps_tools

#include "dosfs.h"

/**
 * @brief read string from file
 * @param[in] sectorBuf scratch buffer to store a sector
 * @param[in] vi volume information structure
 * @param[in] filename name of file to read
 * @param[out] buf buffer to put string to
 * @param[in] sz size of buffer
 * @return 0 on success, -1 on error
 */
extern char AppsToolsReadStr(uint8_t sectorBuf[SECTOR_SIZE], VOLINFO *vi,
                             const char *filename, char *buf, unsigned int sz);

/**
 * @brief read MAC address from file
 * @param[in] sectorBuf scratch buffer to store a sector
 * @param[in] vi volume information structure
 * @param[in] filename name of file to read
 * @param[out] mac MAC address read
 * @return 0 on success, -1 on error
 */
extern char AppsToolsReadMac(uint8_t sectorBuf[SECTOR_SIZE], VOLINFO *vi,
                             const char *filename, unsigned char mac[6]);

/**
 * @brief read IP address from file
 * @param[in] sectorBuf scratch buffer to store a sector
 * @param[in] vi volume information structure
 * @param[in] filename name of file to read
 * @param[out] ip IP address read
 * @return 0 on success, -1 on error
 */
extern char AppsToolsReadIp(uint8_t sectorBuf[SECTOR_SIZE], VOLINFO *vi,
                            const char *filename, unsigned char ip[4]);

/**
 * @brief read network port from file
 * @param[in] sectorBuf scratch buffer to store a sector
 * @param[in] vi volume information structure
 * @param[in] filename name of file to read
 * @param[out] port network port read
 * @return 0 on success, -1 on error
 */
extern char AppsToolsReadPort(uint8_t sectorBuf[SECTOR_SIZE], VOLINFO *vi,
                              const char *filename, unsigned short *port);

#endif // #ifndef INC_apps_tools

