mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 01:53:35 +08:00
Completes coding of the PWM module
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4200 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
/****************************************************************************
|
||||
* include/apps/apps.h
|
||||
*
|
||||
* Copyright(C) 2011 Uros Platise. All rights reserved.
|
||||
* Author: Uros Platise <uros.platise@isotel.eu>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_APPS_APPS_H
|
||||
#define __INCLUDE_APPS_APPS_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct namedapp_s
|
||||
{
|
||||
const char *name; /* Invocation name and as seen under /sbin/ */
|
||||
int priority; /* Use: SCHED_PRIORITY_DEFAULT */
|
||||
int stacksize; /* Desired stack size */
|
||||
main_t main; /* Entry point: main(int argc, char *argv[]) */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* The "bindir" is file system that supports access to the named applications.
|
||||
* It is typically mounted under /bin.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_APPS_BINDIR
|
||||
struct mountpt_operations;
|
||||
extern const struct mountpt_operations binfs_operations;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: namedapp_isavail
|
||||
*
|
||||
* Description:
|
||||
* Checks for availabiliy of application registerred during compile time.
|
||||
*
|
||||
* Input Parameter:
|
||||
* filename - Name of the linked-in binary to be started.
|
||||
*
|
||||
* Returned Value:
|
||||
* This is an end-user function, so it follows the normal convention:
|
||||
* Returns index of builtin application. If it is not found then it
|
||||
* returns -1 (ERROR) and sets errno appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int namedapp_isavail(FAR const char *appname);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: namedapp_getname
|
||||
*
|
||||
* Description:
|
||||
* Returns pointer to a name of built-in application pointed by the
|
||||
* index.
|
||||
*
|
||||
* Input Parameter:
|
||||
* index, from 0 and on ...
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns valid pointer pointing to the app name if index is valid.
|
||||
* Otherwise NULL is returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN const char *namedapp_getname(int index);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: exec_namedapp
|
||||
*
|
||||
* Description:
|
||||
* Executes builtin named application registered during compile time.
|
||||
* New application is run in a separate task context (and thread).
|
||||
*
|
||||
* Input Parameter:
|
||||
* filename - Name of the linked-in binary to be started.
|
||||
* argv - Argument list
|
||||
*
|
||||
* Returned Value:
|
||||
* This is an end-user function, so it follows the normal convention:
|
||||
* Returns the PID of the exec'ed module. On failure, it.returns
|
||||
* -1 (ERROR) and sets errno appropriately.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int exec_namedapp(FAR const char *appname, FAR const char **argv);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif /* __INCLUDE_APPS_APPS_H */
|
||||
@@ -0,0 +1,224 @@
|
||||
/****************************************************************************
|
||||
* apps/include/ftpc.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_FTPC_H
|
||||
#define __APPS_INCLUDE_FTPC_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdbool.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifndef CONFIG_FTP_DEFTIMEO
|
||||
# define CONFIG_FTP_DEFTIMEO 30
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_FTP_ANONPWD
|
||||
# define CONFIG_FTP_ANONPWD ""
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_FTP_DEFPORT
|
||||
# define CONFIG_FTP_DEFPORT 21
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_FTP_MAXREPLY
|
||||
# define CONFIG_FTP_MAXREPLY 256
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_FTP_TMPDIR
|
||||
# define CONFIG_FTP_TMPDIR "/tmp"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_FTP_BUFSIZE
|
||||
# define CONFIG_FTP_BUFSIZE 1024
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_FTP_MAXPATH
|
||||
# define CONFIG_FTP_MAXPATH 256
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_FTP_SIGNAL
|
||||
# define CONFIG_FTP_SIGNAL SIGUSR1
|
||||
#endif
|
||||
|
||||
/* Interface arguments ******************************************************/
|
||||
/* These definitions describe how a put operation should be performed */
|
||||
|
||||
#define FTPC_PUT_NORMAL 0 /* Just PUT the file on the server */
|
||||
#define FTPC_PUT_APPEND 1 /* Append file to an existing file on the server */
|
||||
#define FTPC_PUT_UNIQUE 2 /* Create a uniquely named file on the server */
|
||||
#define FTPC_PUT_RESUME 3 /* Resume a previously started PUT transfer */
|
||||
|
||||
/* These definitions describe how a get operation should be performed */
|
||||
|
||||
#define FTPC_GET_NORMAL 0 /* Just GET the file from the server */
|
||||
#define FTPC_GET_APPEND 1 /* Append new file to an existing file */
|
||||
#define FTPC_GET_RESUME 3 /* Resume a previously started GET transfer */
|
||||
|
||||
/* Transfer mode encoding */
|
||||
|
||||
#define FTPC_XFRMODE_UNKNOWN 0 /* Nothing has been transferred yet */
|
||||
#define FTPC_XFRMODE_ASCII 1 /* Last transfer was ASCII mode */
|
||||
#define FTPC_XFRMODE_BINARY 2 /* Last transfer was binary mode */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
/* This "handle" describes the FTP session */
|
||||
|
||||
typedef FAR void *SESSION;
|
||||
|
||||
/* This structure provides information to connect to a host FTP server.
|
||||
*
|
||||
* addr - The IPv4 address of the FTP server (or the proxy) for the FTP
|
||||
* server.
|
||||
* port - The port number on the FTP server to connect to (in host byte
|
||||
* order). This is usually port 21 for FTP. You may set this
|
||||
* value to zero to let FTPC select the default port number for
|
||||
* you (it will use CONFIG_FTP_DEFPORT).
|
||||
*/
|
||||
|
||||
struct ftpc_connect_s
|
||||
{
|
||||
struct in_addr addr; /* Server/proxy IP address */
|
||||
uint16_t port; /* Server/proxy port number (usually 21) in network order */
|
||||
};
|
||||
|
||||
/* This structure provides FTP login information */
|
||||
|
||||
struct ftpc_login_s
|
||||
{
|
||||
FAR const char *uname; /* Login uname */
|
||||
FAR const char *pwd; /* Login pwd */
|
||||
FAR const char *rdir; /* Initial remote directory */
|
||||
bool pasv; /* true: passive connection mode */
|
||||
};
|
||||
|
||||
/* This structure describes one simple directory listing. The directory
|
||||
* list container as well the individual filename strings are allocated.
|
||||
* The number of names in tha actual allocated array is variable, given
|
||||
* by the nnames field.
|
||||
*
|
||||
* Since the structure and file names are allocated, they must be freed
|
||||
* by calling ftpc_dirfree() when they are no longer needed. Allocated
|
||||
* name strings maby be "stolen" from the array but the pointer int the
|
||||
* array should be nullified so that the string is not freed by
|
||||
* ftpc_dirfree().
|
||||
*/
|
||||
|
||||
struct ftpc_dirlist_s
|
||||
{
|
||||
unsigned int nnames; /* Number of entries in name[] array */
|
||||
FAR char *name[1]; /* Filename with absolute path */
|
||||
};
|
||||
|
||||
#define SIZEOF_FTPC_DIRLIST(n) \
|
||||
(sizeof(struct ftpc_dirlist_s) + ((n)-1)*sizeof(FAR char *))
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
/* Connection management ****************************************************/
|
||||
|
||||
EXTERN SESSION ftpc_connect(FAR struct ftpc_connect_s *server);
|
||||
EXTERN void ftpc_disconnect(SESSION handle);
|
||||
|
||||
/* FTP commands *************************************************************/
|
||||
|
||||
EXTERN int ftpc_login(SESSION handle, FAR struct ftpc_login_s *login);
|
||||
EXTERN int ftpc_quit(SESSION handle);
|
||||
|
||||
EXTERN int ftpc_chdir(SESSION handle, FAR const char *path);
|
||||
EXTERN FAR char *ftpc_rpwd(SESSION handle);
|
||||
EXTERN int ftpc_cdup(SESSION handle);
|
||||
EXTERN int ftpc_mkdir(SESSION handle, FAR const char *path);
|
||||
EXTERN int ftpc_rmdir(SESSION handle, FAR const char *path);
|
||||
|
||||
EXTERN int ftpc_unlink(SESSION handle, FAR const char *path);
|
||||
EXTERN int ftpc_chmod(SESSION handle, FAR const char *path, FAR const char *mode);
|
||||
EXTERN int ftpc_rename(SESSION handle, FAR const char *oldname, FAR const char *newname);
|
||||
EXTERN off_t ftpc_filesize(SESSION handle, FAR const char *path);
|
||||
EXTERN time_t ftpc_filetime(SESSION handle, FAR const char *filename);
|
||||
|
||||
EXTERN int ftpc_idle(SESSION handle, unsigned int idletime);
|
||||
EXTERN int ftpc_noop(SESSION handle);
|
||||
EXTERN int ftpc_help(SESSION handle, FAR const char *arg);
|
||||
|
||||
/* Directory listings *******************************************************/
|
||||
|
||||
EXTERN FAR struct ftpc_dirlist_s *ftpc_listdir(SESSION handle,
|
||||
FAR const char *dirpath);
|
||||
EXTERN void ftpc_dirfree(FAR struct ftpc_dirlist_s *dirlist);
|
||||
|
||||
/* File transfers ***********************************************************/
|
||||
|
||||
EXTERN int ftpc_getfile(SESSION handle, FAR const char *rname,
|
||||
FAR const char *lname, uint8_t how, uint8_t xfrmode);
|
||||
EXTERN int ftp_putfile(SESSION handle, FAR const char *lname,
|
||||
FAR const char *rname, uint8_t how, uint8_t xfrmode);
|
||||
|
||||
/* FTP response *************************************************************/
|
||||
|
||||
EXTERN FAR char *ftpc_response(SESSION handle);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __APPS_INCLUDE_FTPC_H */
|
||||
@@ -0,0 +1,85 @@
|
||||
/****************************************************************************
|
||||
* apps/netutils/dhcpc.n
|
||||
*
|
||||
* Copyright (C) 2007, 2009-2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* This logic was leveraged from uIP which also has a BSD-style license:
|
||||
*
|
||||
* Copyright (c) 2005, Swedish Institute of Computer Science
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __APPS_NETUTILS_DHCPC_H
|
||||
#define __APPS_NETUTILS_DHCPC_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct dhcpc_state
|
||||
{
|
||||
struct in_addr serverid;
|
||||
struct in_addr ipaddr;
|
||||
struct in_addr netmask;
|
||||
struct in_addr dnsaddr;
|
||||
struct in_addr default_router;
|
||||
uint32_t lease_time; /* Lease expires in this number of seconds */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
EXTERN void *dhcpc_open(const void *mac_addr, int mac_len);
|
||||
EXTERN int dhcpc_request(void *handle, struct dhcpc_state *presult);
|
||||
EXTERN void dhcpc_close(void *handle);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_NETUTILS_DHCPC_H */
|
||||
@@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
* apps/netutils/dhcpd.h
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* This logic was leveraged from uIP which also has a BSD-style license:
|
||||
*
|
||||
* Copyright (c) 2005, Swedish Institute of Computer Science
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __APPS_NETUTILS_DHCPD_H
|
||||
#define __APPS_NETUTILS_DHCPD_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
EXTERN int dhcpd_run(void);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_NETUTILS_DHCPD_H */
|
||||
@@ -0,0 +1,54 @@
|
||||
/****************************************************************************
|
||||
* apps/netutils/httpd.h
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Based on uIP which also has a BSD style license:
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
* Copyright (c) 2001-2005, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_NETUTILS_HTTPD_H
|
||||
#define __APPS_NETUTILS_HTTPD_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
extern void httpd_init(void);
|
||||
extern int httpd_listen(void);
|
||||
|
||||
#endif /* __APPS_NETUTILS_HTTPD_H */
|
||||
Executable
+101
@@ -0,0 +1,101 @@
|
||||
/****************************************************************************
|
||||
* apps/netutils/ipmsfilter.h
|
||||
* User interface to add/remove IP multicast address
|
||||
*
|
||||
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_NETUTILS_IPMSFILTER_H
|
||||
#define __APPS_NETUTILS_IPMSFILTER_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#ifdef CONFIG_NET_IGMP
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
# error "IGMP for IPv6 not supported"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ipmsfilter
|
||||
*
|
||||
* Description:
|
||||
* Add or remove an IP address from a multicast filter set.
|
||||
* (See netutils/uiplib/uip_ipmsfilter.c)
|
||||
*
|
||||
* Parameters:
|
||||
* ifname The name of the interface to use, size must less than IMSFNAMSIZ
|
||||
* multiaddr Multicast group address to add/remove
|
||||
* fmode MCAST_INCLUDE: Add multicast address
|
||||
* MCAST_EXCLUDE: Remove multicast address
|
||||
*
|
||||
* Return:
|
||||
* 0 on sucess; Negated errno on failure
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int ipmsfilter(FAR const char *ifname,
|
||||
FAR const struct in_addr *multiaddr,
|
||||
uint32_t fmode);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_NET_IGMP */
|
||||
#endif /* __APPS_NETUTILS_IPMSFILTER_H */
|
||||
@@ -0,0 +1,65 @@
|
||||
/* includes/apps/netutils/resolv.h
|
||||
* DNS resolver code header file.
|
||||
* Authtor Adam Dunkels <adam@dunkels.com>
|
||||
*
|
||||
* Copyright (c) 2002-2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __APPS_NETUTILS_RESOLVE_H
|
||||
#define __APPS_NETUTILS_RESOLVE_H
|
||||
|
||||
#include <net/uip/uipopt.h>
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* Functions. */
|
||||
|
||||
EXTERN int resolv_init(void);
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
EXTERN void resolv_conf(const struct in6_addr *dnsserver);
|
||||
EXTERN void resolv_getserver(const struct in_addr *dnsserver);
|
||||
EXTERN int resolv_query(const char *name, struct sockaddr_in6 *addr);
|
||||
#else
|
||||
EXTERN void resolv_conf(const struct in_addr *dnsserver);
|
||||
EXTERN void resolv_getserver(struct in_addr *dnsserver);
|
||||
EXTERN int resolv_query(const char *name, struct sockaddr_in *addr);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_NETUTILS_RESOLVE_H */
|
||||
@@ -0,0 +1,66 @@
|
||||
/****************************************************************************
|
||||
* include/apps/netutils/smtp.h
|
||||
* SMTP header file
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Heavily leveraged from uIP 1.0 which also has a BSD-like license:
|
||||
*
|
||||
* Author: Adam Dunkels <adam@dunkels.com>
|
||||
* Copyright (c) 2002, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_NETUTILS_SMTP_H
|
||||
#define __APPS_NETUTILS_SMTP_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <net/uip/uipopt.h>
|
||||
#include <net/uip/uip.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
extern void *smtp_open(void);
|
||||
extern void smtp_configure(void *handle, const char *localhostname,
|
||||
const uip_ipaddr_t *paddr);
|
||||
extern int smtp_send(void *handle, const char *to, const char *cc,
|
||||
const char *from, const char *subject,
|
||||
const char *msg, int msglen);
|
||||
extern void smtp_close(void *handle);
|
||||
|
||||
#endif /* __APPS_NETUTILS_SMTP_H */
|
||||
@@ -0,0 +1,70 @@
|
||||
/****************************************************************************
|
||||
* include/apps/netutils/telnetd.h
|
||||
*
|
||||
* Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* This is a leverage of similar logic from uIP:
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_NETUTILS_TELNETD_H
|
||||
#define __APPS_NETUTILS_TELNETD_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* Start the telnet server -- does not return unless an error occurs */
|
||||
|
||||
EXTERN void telnetd_init(void);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_NETUTILS_TELNETD_H */
|
||||
@@ -0,0 +1,73 @@
|
||||
/****************************************************************************
|
||||
* include/apps/netutils/tftp.h
|
||||
*
|
||||
* Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_NETUTILS_TFTP_H
|
||||
#define __APPS_NETUTILS_TFTP_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
EXTERN int tftpget(const char *remote, const char *local, in_addr_t addr, bool binary);
|
||||
EXTERN int tftpput(const char *local, const char *remote, in_addr_t addr, bool binary);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_NETUTILS_TFTP_H */
|
||||
@@ -0,0 +1,101 @@
|
||||
/****************************************************************************
|
||||
* apps/netutils/thttpd.h
|
||||
*
|
||||
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_NETUTILS_THTTPD_H
|
||||
#define __APPS_NETUTILS_THTTPD_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/symtab.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* These values must be provided by the user before the THTTPD task daemon
|
||||
* is started:
|
||||
*
|
||||
* g_thttpdsymtab: A symbol table describing all of the symbols exported
|
||||
* from the base system. These symbols are used to bind address references
|
||||
* in CGI programs to NuttX.
|
||||
* g_nsymbols: The number of symbols in g_thttpdsymtab[].
|
||||
*
|
||||
* (See examples/nxflat and examples/thttpd for examples of how such a symbol
|
||||
* table may be created.)
|
||||
*/
|
||||
|
||||
EXTERN FAR const struct symtab_s *g_thttpdsymtab;
|
||||
EXTERN int g_thttpdnsymbols;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: thttpd_main
|
||||
*
|
||||
* Description:
|
||||
* This function is the entrypoint into the THTTPD server. It does not
|
||||
* return. It may be called, the normal mechanism for starting the server
|
||||
* is:
|
||||
*
|
||||
* 1) Set is g_thttpdsymtab and g_thttpdnsymbols. The user is required
|
||||
* to provide a symbol table to use for binding CGI programs (if CGI
|
||||
* is enabled. See examples/nxflat and examples/thttpd for examples of
|
||||
* how such a symbol table may be created.)
|
||||
* 2) Call task_create() to start thttpd_main()
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int thttpd_main(int argc, char **argv);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_NETUTILS_THTTPD_H */
|
||||
@@ -0,0 +1,129 @@
|
||||
/****************************************************************************
|
||||
* apps/netutils/uiplib.h
|
||||
* Various non-standard APIs to support netutils. All non-standard and
|
||||
* intended only for internal use.
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Some of these APIs derive from uIP but all of them use the uip_ prefix
|
||||
* to identify them as members of this library. uIP also has a BSD style
|
||||
* license:
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
* Copyright (c) 2002, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_NETUTILS_UIPLIB_H
|
||||
#define __APPS_NETUTILS_UIPLIB_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <net/uip/uipopt.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* SOCK_DGRAM is the preferred socket type to use when we just want a
|
||||
* socket for performing drive ioctls. However, we can't use SOCK_DRAM
|
||||
* if UDP is disabled.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
# define UIPLIB_SOCK_IOCTL SOCK_DGRAM
|
||||
#else
|
||||
# define UIPLIB_SOCK_IOCTL SOCK_STREAM
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* Convert a textual representation of an IP address to a numerical representation.
|
||||
*
|
||||
* This function takes a textual representation of an IP address in
|
||||
* the form a.b.c.d and converts it into a 4-byte array that can be
|
||||
* used by other uIP functions.
|
||||
*
|
||||
* addrstr A pointer to a string containing the IP address in
|
||||
* textual form.
|
||||
*
|
||||
* addr A pointer to a 4-byte array that will be filled in with
|
||||
* the numerical representation of the address.
|
||||
*
|
||||
* Return: 0 If the IP address could not be parsed.
|
||||
* Return: Non-zero If the IP address was parsed.
|
||||
*/
|
||||
|
||||
extern bool uiplib_ipaddrconv(const char *addrstr, uint8_t *addr);
|
||||
|
||||
/* Get and set IP/MAC addresses (Ethernet L2 only) */
|
||||
|
||||
#ifdef CONFIG_NET_ETHERNET
|
||||
extern int uip_setmacaddr(const char *ifname, const uint8_t *macaddr);
|
||||
extern int uip_getmacaddr(const char *ifname, uint8_t *macaddr);
|
||||
#endif
|
||||
|
||||
/* IP address support */
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
extern int uip_gethostaddr(const char *ifname, struct in6_addr *addr);
|
||||
extern int uip_sethostaddr(const char *ifname, const struct in6_addr *addr);
|
||||
extern int uip_setdraddr(const char *ifname, const struct in6_addr *addr);
|
||||
extern int uip_setnetmask(const char *ifname, const struct in6_addr *addr);
|
||||
#else
|
||||
extern int uip_gethostaddr(const char *ifname, struct in_addr *addr);
|
||||
extern int uip_sethostaddr(const char *ifname, const struct in_addr *addr);
|
||||
extern int uip_setdraddr(const char *ifname, const struct in_addr *addr);
|
||||
extern int uip_setnetmask(const char *ifname, const struct in_addr *addr);
|
||||
#endif
|
||||
|
||||
/* HTTP support */
|
||||
|
||||
extern int uip_parsehttpurl(const char *url, uint16_t *port,
|
||||
char *hostname, int hostlen,
|
||||
char *filename, int namelen);
|
||||
|
||||
/* Generic server logic */
|
||||
|
||||
extern void uip_server(uint16_t portno, pthread_startroutine_t handler, int stacksize);
|
||||
|
||||
#endif /* __APPS_NETUTILS_UIPLIB_H */
|
||||
@@ -0,0 +1,149 @@
|
||||
/****************************************************************************
|
||||
* include/apps/netutils/webclient.h
|
||||
* Header file for the HTTP client
|
||||
*
|
||||
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Based remotely on the uIP webclient which also has a BSD style license:
|
||||
*
|
||||
* Author: Adam Dunkels <adam@dunkels.com>
|
||||
* Copyright (c) 2002, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __APPS_NETUTILS_WEBCLIENT_H
|
||||
#define __APPS_NETUTILS_WEBCLIENT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_WEBCLIENT_HOST
|
||||
# include <nuttx/config.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_WEBCLIENT_MAXHTTPLINE
|
||||
# define CONFIG_WEBCLIENT_MAXHTTPLINE 200
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_WEBCLIENT_MAXMIMESIZE
|
||||
# define CONFIG_WEBCLIENT_MAXMIMESIZE 32
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_WEBCLIENT_MAXHOSTNAME
|
||||
# define CONFIG_WEBCLIENT_MAXHOSTNAME 40
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_WEBCLIENT_MAXFILENAME
|
||||
# define CONFIG_WEBCLIENT_MAXFILENAME 100
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public types
|
||||
****************************************************************************/
|
||||
|
||||
/* wget calls a user provided function of the follwoing type to process
|
||||
* each received chuck of the incoming file data. If the system has a file
|
||||
* system, then it may just write the data to a file. Or it may buffer the
|
||||
* file in memory. To facilitate this latter case, the caller may modify
|
||||
* the buffer address in this callback by writing to buffer and buflen. This
|
||||
* may be used, for example, to implement double buffering.
|
||||
*
|
||||
* Input Parameters:
|
||||
* buffer - A pointer to a pointer to a buffer. If the callee wishes to
|
||||
* change the buffer address, it may do so in the callback by writing
|
||||
* to buffer.
|
||||
* offset - Offset to the beginning of valid data in the buffer. Offset
|
||||
* is used to skip over any HTTP header info that may be at the
|
||||
* beginning of the buffer.
|
||||
* datend - The end+1 offset of valid data in the buffer. The total number
|
||||
* of valid bytes is datend - offset.
|
||||
* buflen - A pointer to the length of the buffer. If the callee wishes
|
||||
* to change the size of the buffer, it may write to buflen.
|
||||
*/
|
||||
|
||||
typedef void (*wget_callback_t)(FAR char **buffer, int offset,
|
||||
int datend, FAR int *buflen, FAR void *arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: wget
|
||||
*
|
||||
* Description:
|
||||
* Obtain the requested file from an HTTP server using the GET method.
|
||||
*
|
||||
* Note: If the function is passed a host name, it must already be in
|
||||
* the resolver cache in order for the function to connect to the web
|
||||
* server. It is therefore up to the calling module to implement the
|
||||
* resolver calls and the signal handler used for reporting a resolv
|
||||
* query answer.
|
||||
*
|
||||
* Input Parameters
|
||||
* url - A pointer to a string containing either the full URL to
|
||||
* the file to get (e.g., http://www.nutt.org/index.html, or
|
||||
* http://192.168.23.1:80/index.html).
|
||||
* buffer - A user provided buffer to receive the file data (also
|
||||
* used for the outgoing GET request
|
||||
* buflen - The size of the user provided buffer
|
||||
* callback - As data is obtained from the host, this function is
|
||||
* to dispose of each block of file data as it is received.
|
||||
* arg - User argument passed to callback.
|
||||
*
|
||||
* Returned Value:
|
||||
* 0: if the GET operation completed successfully;
|
||||
* -1: On a failure with errno set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN int wget(FAR const char *url, FAR char *buffer, int buflen,
|
||||
wget_callback_t callback, FAR void *arg);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_NETUTILS_WEBCLIENT_H */
|
||||
@@ -0,0 +1,97 @@
|
||||
/****************************************************************************
|
||||
* include/apps/nsh.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_APPS_NSHLIB_H
|
||||
#define __INCLUDE_APPS_NSHLIB_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_RR_INTERVAL > 0
|
||||
# define SCHED_NSH SCHED_RR
|
||||
#else
|
||||
# define SCHED_NSH SCHED_FIFO
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* Interfaces needed to initialize and execute the NuttShell (NSH).
|
||||
*
|
||||
* nsh_initialize() - This function function should be called one during
|
||||
* application start-up prior to executing nsh_consolemain() or
|
||||
* nsh_telnetmain().
|
||||
*/
|
||||
|
||||
EXTERN void nsh_initialize(void);
|
||||
|
||||
/* The following interfaces maybe to called or started with task_start to
|
||||
* start an NSH instance.
|
||||
*
|
||||
* nsh_consolemain() starts NSH on the console (/dev/console).
|
||||
* nsh_telnetmain() starts a telnet daemon that will allow multiple
|
||||
* connections via telnet.
|
||||
*
|
||||
* These functions do not return.
|
||||
*/
|
||||
|
||||
EXTERN int nsh_consolemain(int argc, char *argv[]);
|
||||
EXTERN int nsh_telnetmain(int argc, char *argv[]);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_APPS_NSHLIB_H */
|
||||
@@ -0,0 +1,465 @@
|
||||
/************************************************************************************
|
||||
* apps/include/tiff.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Reference:
|
||||
* "TIFF, Revision 6.0, Final," June 3, 1992, Adobe Developers Association.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifndef __APPS_INCLUDE_TIFF_H
|
||||
#define __APPS_INCLUDE_TIFF_H
|
||||
|
||||
/************************************************************************************
|
||||
* Included Files
|
||||
************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/nx/nxglib.h>
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
************************************************************************************/
|
||||
/* Configuration ********************************************************************/
|
||||
|
||||
/* TIFF File Format Definitions *****************************************************/
|
||||
/* Values for the IFD field type */
|
||||
|
||||
#define IFD_FIELD_BYTE 1 /* 8-bit unsigned integer */
|
||||
#define IFD_FIELD_ASCII 2 /* 8-bit byte that contains a 7-bit ASCII code.
|
||||
* The last byte must be NUL */
|
||||
#define IFD_FIELD_SHORT 3 /* 16-bit (2-byte) unsigned integer */
|
||||
#define IFD_FIELD_LONG 4 /* 32-bit (4-byte) unsigned integer */
|
||||
#define IFD_FIELD_RATIONAL 5 /* Two LONGs: the first represents the
|
||||
* numerator of a fraction, the second the
|
||||
* denominator */
|
||||
#define IFD_FIELD_SBYTE 6 /* An 8-bit signed (twos-complement) integer */
|
||||
#define IFD_FIELD_UNDEFINED 7 /* An 8-bit byte that may contain anything,
|
||||
* depending on the definition of the field */
|
||||
#define IFD_FIELD_SSHORT 8 /* A 16-bit (2-byte) signed (twos-complement)
|
||||
* integer */
|
||||
#define IFD_FIELD_SLONG 9 /* A 32-bit (4-byte) signed (twos-complement)
|
||||
* integer */
|
||||
#define IFD_FIELD_SRATIONAL 10 /* Two SLONG’s: the first represents the
|
||||
* numerator of a fraction, the second the
|
||||
* denominator */
|
||||
#define IFD_FIELD_FLOAT 11 /* Single precision (4-byte) IEEE format */
|
||||
#define IFD_FIELD_DOUBLE 12 /* Double precision (8-byte) IEEE format */
|
||||
|
||||
/* Values for the IFD tag type */
|
||||
|
||||
#define IFD_TAG_NEWSUBFILETYPE 254 /* NewSubfileType, LONG */
|
||||
# define TAG_NEWSUBFILETYPE_REDUCED (1 << 0) /* Bit 0: Reduced resolution verson of image */
|
||||
# define TAG_NEWSUBFILETYPE_SINGLE (1 << 1) /* Bit 1: Single page of a multi-page image */
|
||||
# define TAG_NEWSUBFILETYPE_TRANSP (1 << 2) /* Bit 2: Defines a transparency mask for image */
|
||||
#define IFD_TAG_SUBFILETYPE 255 /* SubfileType, SHORT */
|
||||
# define TAG_SUBFILETYPE_FULL 1 /* Full-resolution image data */
|
||||
# define TAG_SUBFILETYPE_REDUCED 2 /* Reduced-resolution image data */
|
||||
# define TAG_SUBFILETYPE_SINGLE 3 /* Single page of a multi-page image */
|
||||
#define IFD_TAG_IMAGEWIDTH 256 /* ImageLength, SHORT or LONG (Required) */
|
||||
#define IFD_TAG_IMAGELENGTH 257 /* ImageWidth, SHORT or LONG (Required) */
|
||||
#define IFD_TAG_BITSPERSAMPLE 258 /* BitsPerSample, SHORT (Required
|
||||
* in greyscale and pallette-color image files) */
|
||||
#define IFD_TAG_COMPRESSION 259 /* Compression, SHORT (Required) */
|
||||
# define TAG_COMP_NONE 1 /* No compression */
|
||||
# define TAG_COMP_CCITT 2 /* CCITT Group 3 1-Dimensional Modified Huffman
|
||||
* run length encoding */
|
||||
# define TAG_COMP_T4 3 /* CCITT T.4 bi-level encoding */
|
||||
# define TAG_COMP_T6 4 /* CCITT T.6 bi-level encoding */
|
||||
# define TAG_COMP_LZW 5 /* LZW */
|
||||
# define TAG_COMP_JPEG 6 /* LZW */
|
||||
# define TAG_COMP_PACKBITS 32773 /* PackBits compression */
|
||||
#define IFD_TAG_PMI 262 /* PhotometricInterpretation, SHORT (Required) */
|
||||
# define TAG_PMI_WHITE 0 /* WhiteIsZero */
|
||||
# define TAG_PMI_BLACK 1 /* BlackIsZero */
|
||||
# define TAG_PMI_RGB 2 /* RGB */
|
||||
# define TAG_PMI_PALETTE 3 /* Palette color */
|
||||
# define TAG_PMI_TRANSP 4 /* Transparency mask */
|
||||
# define TAG_PMI_CMYK 5 /* CMYK */
|
||||
# define TAG_PMI_YCbCr 6 /* YCbCr */
|
||||
# define TAG_PMI_CIELAB 8 /* 1976 CIE L*a*b* */
|
||||
#define IFD_TAG_THRESHHOLDING 263 /* Threshholding, SHORT */
|
||||
# define TAG_THRESHHOLD_NONE 1 /* No dithering or halftoning has been applied */
|
||||
# define TAG_THRESHHOLD_ORDERED 2 /* Ordered dither or halftone technique has been applied */
|
||||
# define TAG_THRESHHOLD_RANDOM 3 /* Randomized process has been applied */
|
||||
#define IFD_TAG_CELLWIDTH 264 /* CellWidth, SHORT */
|
||||
#define IFD_TAG_CELLLENGTH 265 /* CellLength, SHORT */
|
||||
#define IFD_TAG_FILLORDER 266 /* FillOrder, SHORT */
|
||||
# define TAG_FILLORDER_HIGH 1 /* Lower column values are stored in the
|
||||
* higher-order bits */
|
||||
# define TAG_FILLORDER_LOW 2 /* Lower column values are stored in the
|
||||
* lower-order bits */
|
||||
#define IFD_TAG_DOCUMENTNAME 269 /* DocumentName, ASCII */
|
||||
#define IFD_TAG_IMAGEDESCRIPTION 270 /* ImageDescription, ASCII */
|
||||
#define IFD_TAG_MAKE 271 /* Make, ASCII */
|
||||
#define IFD_TAG_MODEL 272 /* Model, ASCII */
|
||||
#define IFD_TAG_STRIPOFFSETS 273 /* StripOffsets, SHORT or LONG (Required) */
|
||||
#define IFD_TAG_ORIENTATION 274 /* Orientation, SHORT */
|
||||
# define TAG_ORIENTATION_TL 1 /* (0,0)=top left */
|
||||
# define TAG_ORIENTATION_TR 2 /* (0,0)=top right */
|
||||
# define TAG_ORIENTATION_BR 3 /* (0,0)=bottom right */
|
||||
# define TAG_ORIENTATION_BL 4 /* (0,0)=bottom left */
|
||||
# define TAG_ORIENTATION_LT 5 /* (0,0)=left top */
|
||||
# define TAG_ORIENTATION_RT 6 /* (0,0)=right top */
|
||||
# define TAG_ORIENTATION_RB 7 /* (0,0)=right bottom */
|
||||
# define TAG_ORIENTATION_LB 8 /* (0,0)=left bottom */
|
||||
#define IFD_TAG_SAMPLESPERPIXEL 277 /* SamplesPerPixel, SHORT (Required in
|
||||
* RGB full color files) */
|
||||
#define IFD_TAG_ROWSPERSTRIP 278 /* RowsPerStrip, SHORT or LONG (Required) */
|
||||
#define IFD_TAG_STRIPCOUNTS 279 /* StripByteCounts, SHORT or LONG (Required) */
|
||||
#define IFD_TAG_MINSAMPLEVALUE 280 /* MinSampleValue, SHORT */
|
||||
#define IFD_TAG_MAXSAMPLEVALUE 281 /* MaxSampleValue, SHORT */
|
||||
#define IFD_TAG_XRESOLUTION 282 /* XResolution, RATIONAL (Required) */
|
||||
#define IFD_TAG_YRESOLUTION 283 /* YResolution, RATIONAL (Required) */
|
||||
#define IFD_TAG_PLANARCONFIG 284 /* PlanarConfiguration, SHORT */
|
||||
# define TAG_PLCONFIG_CHUNKY 1 /* Chunky format */
|
||||
# define TAG_PLCONFIG_PLANAR 2 /* Planar format */
|
||||
#define IFD_TAG_PAGENAME 285 /* PageName, ASCII */
|
||||
#define IFD_TAG_XPOSITION 286 /* XPosition, RATIONAL */
|
||||
#define IFD_TAG_YPOSITION 287 /* YPosition, RATIONAL */
|
||||
#define IFD_TAG_FREEOFFSETS 288 /* FreeOffsets, LONG */
|
||||
#define IFD_TAG_FREEBYTECOUNTS 289 /* FreeByteCounts, LONG */
|
||||
#define IFD_TAG_GRAYRESPONSEUNIT 290 /* GrayResponseUnit, SHORT */
|
||||
# define TAG_GRAYRESPUNIT_10THS 1 /* Number represents tenths of a unit */
|
||||
# define TAG_GRAYRESPUNIT_100THS 2 /* Number represents hundredths of a unit */
|
||||
# define TAG_GRAYRESPUNIT_1KTHS 3 /* Number represents thousandths of a unit */
|
||||
# define TAG_GRAYRESPUNIT_10KTHS 4 /* Number represents ten-thousandths of a unit */
|
||||
# define TAG_GRAYRESPUNIT_100KTHS 5 /* Number represents hundred-thousandths of a unit */
|
||||
#define IFD_TAG_GRAYRESPONSECURVE 291 /* GrayResponseCurve, SHORT */
|
||||
#define IFD_TAG_T4OPTIONS 292 /* T4Options, LONG */
|
||||
# define TAG_T4OPTIONS_2D (1 << 0) /* 2-dimensional coding */
|
||||
# define TAG_T4OPTIONS_NONE (1 << 1) /* Uncompressed mode */
|
||||
# define TAG_T4OPTIONS_FILL (1 << 2) /* Fill bits have been added */
|
||||
#define IFD_TAG_T6OPTIONS 293 /* T6Options, LONG */
|
||||
# define TAG_T6OPTIONS_NONE (1 << 1) /* Uncompressed mode allowed */
|
||||
#define IFD_TAG_RESUNIT 296 /* ResolutionUnit, SHORT (Required) */
|
||||
# define TAG_RESUNIT_NONE 1 /* No absolute unit of measurement */
|
||||
# define TAG_RESUNIT_INCH 2 /* Inch (default) */
|
||||
# define TAG_RESUNIT_CENTIMETER 3 /* Centimeter */
|
||||
#define IFD_TAG_PAGENUMBER 297 /* PageNumber, SHORT */
|
||||
#define IFD_TAG_TRANSFERFUNCTION 301 /* TransferFunction, SHORT */
|
||||
#define IFD_TAG_SOFTWARE 305 /* Software, ASCII */
|
||||
#define IFD_TAG_DATETIME 306 /* DateTime, ASCII */
|
||||
#define IFD_TAG_ARTIST 315 /* Artist, ASCII */
|
||||
#define IFD_TAG_HOSTCOMPUTER 316 /* HostComputer, ASCII */
|
||||
#define IFD_TAG_PREDICTOR 317 /* Predictor SHORT */
|
||||
# define TAG_PREDICTOR_NONE 1 /* No prediction scheme used before coding */
|
||||
# define TAG_PREDICTOR_HORIZ 2 /* Horizontal differencing */
|
||||
#define IFD_TAG_WHITEPOINT 318 /* WhitePoint, RATIONAL */
|
||||
#define IFD_TAG_PRIMARYCHROMA 319 /* PrimaryChromaticities, RATIONAL */
|
||||
#define IFD_TAG_COLORMAP 320 /* ColorMap, SHORT (Required in palette
|
||||
* color image files) */
|
||||
#define IFD_TAG_HALFTONEHINTS 321 /* HalftoneHints, SHORT */
|
||||
#define IFD_TAG_TILEWIDTH 322 /* TileWidth, SHORT or LONG */
|
||||
#define IFD_TAG_TILELENGTH 323 /* TileLength, SHORT or LONG */
|
||||
#define IFD_TAG_TILEOFFSETS 324 /* TileOffsets, LONG */
|
||||
#define IFD_TAG_TILEBYTECOUNTS 325 /* TileByteCounts, SHORT or LONG */
|
||||
#define IFD_TAG_INKSET 332 /* InkSet, SHORT */
|
||||
# define TAG_INKSET_CMYK 1 /* CMYK */
|
||||
# define TAG_INKSET_OTHER 2 /* Not CMYK */
|
||||
#define IFD_TAG_INKNAMES 333 /* InkNames, ASCII */
|
||||
#define IFD_TAG_NUMBEROFINKS 334 /* NumberOfInks, SHORT */
|
||||
#define IFD_TAG_DOTRANGE 336 /* DotRange, BYTE or SHORT */
|
||||
#define IFD_TAG_TARGETPRINTER 337 /* TargetPrinter, ASCII */
|
||||
#define IFD_TAG_EXTRASAMPLES 338 /* ExtraSamples, SHORT */
|
||||
# define TAG_EXTSAMP_UNSPEC 0 /* Unspecified */
|
||||
# define TAG_EXTSAMP_ASSOCALPHA 1 /* Associated alpha data */
|
||||
# define TAG_EXTSAMP_UNASSALPHA 2 /* Unassociated alpha data */
|
||||
#define IFD_TAG_SAMPLEFORMAT 339 /* SampleFormat, SHORT */
|
||||
# define TAG_SAMPLEFMT_UNSIGED 1 /* Unsigned integer data */
|
||||
# define TAG_SAMPLEFMT_SIGNED 2 /* Two’s complement signed integer data */
|
||||
# define TAG_SAMPLEFMT_FLOAT 3 /* IEEE floating point data */
|
||||
# define TAG_SAMPLEFMT_UNDEFINED 4 /* Undefined data format */
|
||||
#define IFD_TAG_SMINSAMPLEVALUE 340 /* SMinSampleValue, type matches sample data */
|
||||
#define IFD_TAG_SMAXSAMPLEVALUE 341 /* SMaxSampleValue, type matches sample data */
|
||||
#define IFD_TAG_TRANSFERRANGE 342 /* TransferRange, SHORT */
|
||||
#define IFD_TAG_JPEGPROC 512 /* JPEGProc, SHORT */
|
||||
#define IFD_TAG_JPEGFMT 513 /* JPEGInterchangeFormat, LONG */
|
||||
#define IFD_TAG_JPEGLENGTH 514 /* JPEGInterchangeFormatLength, LONG */
|
||||
#define IFD_TAG_JPEGRESTART 515 /* JPEGRestartInterval, SHORT */
|
||||
#define IFD_TAG_JPEGLLPREDICTORS 517 /* JPEGLosslessPredictors, SHORT */
|
||||
#define IFD_TAG_JPEGPOINTXFORMS 518 /* JPEGPointTransforms, SHORT */
|
||||
#define IFD_TAG_JPEGQTABLES 519 /* JPEGQTables, LONG */
|
||||
#define IFD_TAG_JPEGDCTABLES 520 /* JPEGDCTables, LONG */
|
||||
#define IFD_TAG_JPEGACTABLES 521 /* JPEGACTables, LONG */
|
||||
#define IFD_TAG_YCbCrCOEFFS 529 /* YCbCrCoefficients, RATIONAL */
|
||||
#define IFD_TAG_YCbCrSUBSAMPLING 530 /* YCbCrSubSampling, SHORT */
|
||||
#define IFD_TAG_YCbCrPOSITIONING 531 /* YCbCrPositioning, SHORT */
|
||||
#define IFD_TAG_REFERENCEBW 532 /* ReferenceBlackWhite, RATIONAL */
|
||||
#define IFD_TAG_COPYRIGHT 33432 /* Copyright, ASCII */
|
||||
|
||||
/************************************************************************************
|
||||
* Public Types
|
||||
************************************************************************************/
|
||||
/* TIFF File Format Structure *******************************************************/
|
||||
/* "A TIFF file begins with an 8-byte image file header that points to an
|
||||
* image file directory (IFD). An image file directory contains information
|
||||
* about the image, as well as pointers to the actual image data."
|
||||
*/
|
||||
|
||||
struct tiff_header_s
|
||||
{
|
||||
uint8_t order[2]; /* 0-1: Byte order: "II"=little endian, "MM"=big endian */
|
||||
uint8_t magic[2]; /* 2-3: 42 in appropriate byte order */
|
||||
uint8_t offset[4]; /* 4-7: Offset to the first IFD */
|
||||
};
|
||||
#define SIZEOF_TIFF_HEADER 8
|
||||
|
||||
/* "An Image File Directory (IFD) consists of a 2-byte count of the number
|
||||
* of directory entries (i.e., the number of fields), followed by a sequence
|
||||
* of 12-byte field entries, followed by a 4-byte offset of the next IFD (or
|
||||
* 0 if none).
|
||||
*
|
||||
* Each 12-byte IFD entry has the following format:
|
||||
*/
|
||||
|
||||
struct tiff_ifdentry_s
|
||||
{
|
||||
uint8_t tag[2]; /* 0-1: The Tag that identifies the field */
|
||||
uint8_t type[2]; /* 2-3 The field Type */
|
||||
uint8_t count[4]; /* 4-7: The number of values of the indicated type */
|
||||
uint8_t offset[4]; /* 8-11: The Value Offset (or the value itself) */
|
||||
};
|
||||
#define SIZEOF_IFD_ENTRY 12
|
||||
|
||||
/************************************************************************************/
|
||||
/* Structures needed to interface with the TIFF file creation library )and also
|
||||
* structures used only internally by the TIFF file creation library).
|
||||
*/
|
||||
|
||||
/* This structure describes on strip in tmpfile2 */
|
||||
|
||||
struct tiff_strip_s
|
||||
{
|
||||
uint32_t offset; /* Offset to the strip data in tmpfile1 */
|
||||
uint32_t count; /* Count of pixels in the strip */
|
||||
};
|
||||
|
||||
/* This structure is used only internally by the TIFF file creation library to
|
||||
* manage file offsets.
|
||||
*/
|
||||
|
||||
struct tiff_filefmt_s
|
||||
{
|
||||
uint16_t nifdentries; /* Number of IFD entries */
|
||||
uint16_t soifdoffset; /* Offset to StripOffset IFD entry */
|
||||
uint16_t sbcifdoffset; /* Offset to StripByteCount IFD entry */
|
||||
uint16_t valoffset; /* Offset to first values */
|
||||
uint16_t xresoffset; /* Offset to XResolution values */
|
||||
uint16_t yresoffset; /* Offset to yResolution values */
|
||||
uint16_t swoffset; /* Offset to Software string */
|
||||
uint16_t dateoffset; /* Offset to DateTime string */
|
||||
uint16_t sbcoffset; /* Offset to StripByteCount values */
|
||||
};
|
||||
|
||||
/* These type is used to hold information about the TIFF file under
|
||||
* construction
|
||||
*/
|
||||
|
||||
struct tiff_info_s
|
||||
{
|
||||
/* The first fields are used to pass information to the TIFF file creation
|
||||
* logic via tiff_initialize().
|
||||
*
|
||||
* Filenames. Three file names are required. (1) path to the final
|
||||
* output file and (2) two paths to temporary files. One temporary file
|
||||
* (tmpfile1) will be used to hold the strip image data and the other
|
||||
* (tmpfile2) will be used to hold strip offset and count information.
|
||||
*
|
||||
* colorfmt - Specifies the form of the color data that will be provided
|
||||
* in the strip data. These are the FB_FMT_* definitions
|
||||
* provided in include/nuttx/fb.h. Only the following values
|
||||
* are supported:
|
||||
*
|
||||
* FB_FMT_Y1 BPP=1, monochrome, 0=black
|
||||
* FB_FMT_Y4 BPP=4, 4-bit greyscale, 0=black
|
||||
* FB_FMT_Y8 BPP=8, 8-bit greyscale, 0=black
|
||||
* FB_FMT_RGB16_565 BPP=16 R=6, G=6, B=5
|
||||
* FB_FMT_RGB24 BPP=24 R=8, G=8, B=8
|
||||
*
|
||||
* rps - TIFF RowsPerStrip
|
||||
* imgwidth - TIFF ImageWidth, Number of columns in the image
|
||||
* imgheight - TIFF ImageLength, Number of rows in the image
|
||||
*/
|
||||
|
||||
FAR const char *outfile; /* Full path to the final output file name */
|
||||
FAR const char *tmpfile1; /* Full path to first temporary file */
|
||||
FAR const char *tmpfile2; /* Full path to second temporary file */
|
||||
|
||||
uint8_t colorfmt; /* See FB_FMT_* definitions in include/nuttx/fb.h */
|
||||
nxgl_coord_t rps; /* TIFF RowsPerStrip */
|
||||
nxgl_coord_t imgwidth; /* TIFF ImageWidth, Number of columns in the image */
|
||||
nxgl_coord_t imgheight; /* TIFF ImageLength, Number of rows in the image */
|
||||
|
||||
/* The caller must provide an I/O buffer as well. This I/O buffer will
|
||||
* used for color conversions and as the intermediate buffer for copying
|
||||
* files. The larger the buffer, the better the performance.
|
||||
*/
|
||||
|
||||
FAR uint8_t *iobuffer; /* IO buffer allocated by the caller */
|
||||
unsigned int iosize; /* The size of the I/O buffer in bytes */
|
||||
|
||||
/* The second set of fields are used only internally by the TIFF file
|
||||
* creation logic. These fields must be set to zero initially by the
|
||||
* caller of tiff_initialize(). User logic should not depend upon any
|
||||
* definitions in the following -- they are subject to change without
|
||||
* notice. They are only exposed here so that the caller can allocate
|
||||
* memory for their storage.
|
||||
*/
|
||||
|
||||
uint8_t imgflags; /* Bit-encoded image flags */
|
||||
nxgl_coord_t nstrips; /* Number of strips in tmpfile3 */
|
||||
size_t pps; /* Pixels per strip */
|
||||
size_t bps; /* Bytes per strip */
|
||||
int outfd; /* outfile file descriptor */
|
||||
int tmp1fd; /* tmpfile1 file descriptor */
|
||||
int tmp2fd; /* tmpfile2 file descriptor */
|
||||
off_t outsize; /* Current size of outfile */
|
||||
off_t tmp1size; /* Current size of tmpfile1 */
|
||||
off_t tmp2size; /* Current size of tmpfile2 */
|
||||
|
||||
/* Points to an internal constant structure of file offsets */
|
||||
|
||||
FAR const struct tiff_filefmt_s *filefmt;
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
* Public Function Prototypes
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: tiff_initialize
|
||||
*
|
||||
* Description:
|
||||
* Setup to create a new TIFF file. The overall steps to creating a TIFF file are
|
||||
* as follows:
|
||||
*
|
||||
* 1) Create an initialize a struct tiff_info_s instance
|
||||
* 2) Call tiff_initialize() to setup the file creation
|
||||
* 3) Call tiff_addstrip() repeatedly to add strips to the graphic image
|
||||
* 4) Call tiff_finalize() to complete the file creation.
|
||||
*
|
||||
* Input Parameters:
|
||||
* info - A pointer to the caller allocated parameter passing/TIFF state instance.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
EXTERN int tiff_initialize(FAR struct tiff_info_s *info);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: tiff_addstrip
|
||||
*
|
||||
* Description:
|
||||
* Add an image data strip. The size of the strip in pixels must be equal to
|
||||
* the RowsPerStrip x ImageWidth values that were provided to tiff_initialize().
|
||||
*
|
||||
* Input Parameters:
|
||||
* info - A pointer to the caller allocated parameter passing/TIFF state instance.
|
||||
* buffer - A buffer containing a single row of data.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
EXTERN int tiff_addstrip(FAR struct tiff_info_s *info, FAR const uint8_t *strip);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: tiff_finalize
|
||||
*
|
||||
* Description:
|
||||
* Finalize the TIFF output file, completing the TIFF file creation steps.
|
||||
*
|
||||
* Input Parameters:
|
||||
* info - A pointer to the caller allocated parameter passing/TIFF state instance.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value on failure.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
EXTERN int tiff_finalize(FAR struct tiff_info_s *info);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: tiff_abort
|
||||
*
|
||||
* Description:
|
||||
* Abort the TIFF file creation and create-up resources.
|
||||
*
|
||||
* Input Parameters:
|
||||
* info - A pointer to the caller allocated parameter passing/TIFF state instance.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
EXTERN void tiff_abort(FAR struct tiff_info_s *info);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: tiff_put/get16/32
|
||||
*
|
||||
* Description:
|
||||
* Put and get 16 and 32 values in the correct byte order at the specified position.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dest - The location to store the multi-byte data (put only)
|
||||
* src - The location to get the multi-byte data (get only)
|
||||
*
|
||||
* Returned Value:
|
||||
* None (put)
|
||||
* The extracted value (get)
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
EXTERN void tiff_put16(FAR uint8_t *dest, uint16_t value);
|
||||
EXTERN void tiff_put32(FAR uint8_t *dest, uint32_t value);
|
||||
EXTERN uint16_t tiff_get16(FAR uint8_t *dest);
|
||||
EXTERN uint32_t tiff_get32(FAR uint8_t *dest);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_INCLUDE_TIFF_H */
|
||||
Reference in New Issue
Block a user