9
0
Fork 0

Add configurable application entry point

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5070 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-08-30 20:13:50 +00:00
parent 98d0ef6c36
commit 2848bbca14
254 changed files with 777 additions and 613 deletions

View File

@ -291,3 +291,7 @@
treads!
* apps/nshlib/nsh.h: Both CONFIG_LIBC_STRERROR and CONFIG_NSH_STRERROR
must be defined to use strerror() with NSH.
* apps/examples/*/*_main.c, system/i2c/i2c_main.c, and others: Added
configuration variable CONFIG_USER_ENTRYPOINT that may be used to change
the default entry from user_start to some other symbol. Contributed by
Kate.

View File

@ -118,7 +118,7 @@ the NuttX configuration file:
CONFIG_BUILTIN_APP_START=<application name>
that application shall be invoked immediately after system starts
*instead* of the normal, default "user_start" entry point.
*instead* of the default "user_start" entry point.
Note that <application name> must be provided as: "hello",
will call:

View File

@ -57,14 +57,6 @@
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_NSH_BUILTIN_APPS
# define MAIN_NAME adc_main
# define MAIN_STRING "adc_main: "
#else
# define MAIN_NAME user_start
# define MAIN_STRING "user_start: "
#endif
/****************************************************************************
* Private Types
****************************************************************************/
@ -223,10 +215,10 @@ static void parse_args(FAR struct adc_state_s *adc, int argc, FAR char **argv)
****************************************************************************/
/****************************************************************************
* Name: user_start/adc_main
* Name: adc_main
****************************************************************************/
int MAIN_NAME(int argc, char *argv[])
int adc_main(int argc, char *argv[])
{
struct adc_msg_s sample[CONFIG_EXAMPLES_ADC_GROUPSIZE];
size_t readsize;
@ -244,11 +236,11 @@ int MAIN_NAME(int argc, char *argv[])
* this test.
*/
message(MAIN_STRING "Initializing external ADC device\n");
message("adc_main: Initializing external ADC device\n");
ret = adc_devinit();
if (ret != OK)
{
message(MAIN_STRING "adc_devinit failed: %d\n", ret);
message("adc_main: adc_devinit failed: %d\n", ret);
errval = 1;
goto errout;
}
@ -276,18 +268,18 @@ int MAIN_NAME(int argc, char *argv[])
*/
#if defined(CONFIG_NSH_BUILTIN_APPS) || defined(CONFIG_EXAMPLES_ADC_NSAMPLES)
message(MAIN_STRING "g_adcstate.count: %d\n", g_adcstate.count);
message("adc_main: g_adcstate.count: %d\n", g_adcstate.count);
#endif
/* Open the ADC device for reading */
message(MAIN_STRING "Hardware initialized. Opening the ADC device: %s\n",
message("adc_main: Hardware initialized. Opening the ADC device: %s\n",
g_adcstate.devpath);
fd = open(g_adcstate.devpath, O_RDONLY);
if (fd < 0)
{
message(MAIN_STRING "open %s failed: %d\n", g_adcstate.devpath, errno);
message("adc_main: open %s failed: %d\n", g_adcstate.devpath, errno);
errval = 2;
goto errout_with_dev;
}
@ -322,17 +314,17 @@ int MAIN_NAME(int argc, char *argv[])
errval = errno;
if (errval != EINTR)
{
message(MAIN_STRING "read %s failed: %d\n",
message("adc_main: read %s failed: %d\n",
g_adcstate.devpath, errval);
errval = 3;
goto errout_with_dev;
}
message(MAIN_STRING "Interrupted read...\n");
message("adc_main: Interrupted read...\n");
}
else if (nbytes == 0)
{
message(MAIN_STRING "No data read, Ignoring\n");
message("adc_main: No data read, Ignoring\n");
}
/* Print the sample data on successful return */
@ -342,7 +334,7 @@ int MAIN_NAME(int argc, char *argv[])
int nsamples = nbytes / sizeof(struct adc_msg_s);
if (nsamples * sizeof(struct adc_msg_s) != nbytes)
{
message(MAIN_STRING "read size=%d is not a multiple of sample size=%d, Ignoring\n",
message("adc_main: read size=%d is not a multiple of sample size=%d, Ignoring\n",
nbytes, sizeof(struct adc_msg_s));
}
else

View File

@ -130,16 +130,6 @@
#define NUM_BUTTONS (MAX_BUTTON - MIN_BUTTON + 1)
#define BUTTON_INDEX(b) ((b)-MIN_BUTTON)
/* Is this being built as an NSH built-in application? */
#ifdef CONFIG_NSH_BUILTIN_APPS
# define MAIN_NAME buttons_main
# define MAIN_STRING "buttons_main: "
#else
# define MAIN_NAME user_start
# define MAIN_STRING "user_start: "
#endif
/****************************************************************************
* Private Types
****************************************************************************/
@ -399,10 +389,10 @@ static int button7_handler(int irq, FAR void *context)
****************************************************************************/
/****************************************************************************
* user_start/buttons_main
* buttons_main
****************************************************************************/
int MAIN_NAME(int argc, char *argv[])
int buttons_main(int argc, char *argv[])
{
uint8_t newset;
irqstate_t flags;

View File

@ -76,14 +76,6 @@
# define MAX_ID (1 << 11)
#endif
#ifdef CONFIG_NSH_BUILTIN_APPS
# define MAIN_NAME can_main
# define MAIN_STRING "can_main: "
#else
# define MAIN_NAME user_start
# define MAIN_STRING "user_start: "
#endif
/****************************************************************************
* Private Types
****************************************************************************/
@ -109,10 +101,10 @@
****************************************************************************/
/****************************************************************************
* Name: user_start/can_main
* Name: can_main
****************************************************************************/
int MAIN_NAME(int argc, char *argv[])
int can_main(int argc, char *argv[])
{
#ifndef CONFIG_EXAMPLES_CAN_READONLY
struct can_msg_s txmsg;
@ -150,31 +142,31 @@ int MAIN_NAME(int argc, char *argv[])
{
nmsgs = strtol(argv[1], NULL, 10);
}
message(MAIN_STRING "nmsgs: %d\n", nmsgs);
message("can_main: nmsgs: %d\n", nmsgs);
#elif defined(CONFIG_EXAMPLES_CAN_NMSGS)
message(MAIN_STRING "nmsgs: %d\n", CONFIG_EXAMPLES_CAN_NMSGS);
message("can_main: nmsgs: %d\n", CONFIG_EXAMPLES_CAN_NMSGS);
#endif
/* Initialization of the CAN hardware is performed by logic external to
* this test.
*/
message(MAIN_STRING "Initializing external CAN device\n");
message("can_main: Initializing external CAN device\n");
ret = can_devinit();
if (ret != OK)
{
message(MAIN_STRING "can_devinit failed: %d\n", ret);
message("can_main: can_devinit failed: %d\n", ret);
errval = 1;
goto errout;
}
/* Open the CAN device for reading */
message(MAIN_STRING "Hardware initialized. Opening the CAN device\n");
message("can_main: Hardware initialized. Opening the CAN device\n");
fd = open(CONFIG_EXAMPLES_CAN_DEVPATH, CAN_OFLAGS);
if (fd < 0)
{
message(MAIN_STRING "open %s failed: %d\n",
message("can_main: open %s failed: %d\n",
CONFIG_EXAMPLES_CAN_DEVPATH, errno);
errval = 2;
goto errout_with_dev;

View File

@ -169,16 +169,6 @@
#define TRACE_BITSET (TRACE_INIT_BITS|TRACE_ERROR_BITS|TRACE_CLASS_BITS|\
TRACE_TRANSFER_BITS|TRACE_CONTROLLER_BITS|TRACE_INTERRUPT_BITS)
/* Entry point **************************************************************/
#ifdef CONFIG_NSH_BUILTIN_APPS
# define MAIN_NAME conn_main
# define MAIN_NAME_STRING "conn"
#else
# define MAIN_NAME user_start
# define MAIN_NAME_STRING "user_start"
#endif
/* Debug ********************************************************************/
#ifdef CONFIG_CPP_HAVE_VARARGS

View File

@ -662,7 +662,7 @@ void board_cdcuninitialize(FAR struct usbdevclass_driver_s *classdev)
}
/****************************************************************************
* user_start/conn_main
* conn_main
*
* Description:
* This is the main program that configures the USB mass storage device
@ -672,7 +672,7 @@ void board_cdcuninitialize(FAR struct usbdevclass_driver_s *classdev)
*
****************************************************************************/
int MAIN_NAME(int argc, char *argv[])
int conn_main(int argc, char *argv[])
{
int ret;
@ -688,7 +688,7 @@ int MAIN_NAME(int argc, char *argv[])
if (g_composite.cmphandle)
{
message(MAIN_NAME_STRING ": ERROR: Already connected\n");
message("conn_main: ERROR: Already connected\n");
return 1;
}
#endif
@ -705,11 +705,11 @@ int MAIN_NAME(int argc, char *argv[])
/* Perform architecture-specific initialization */
message(MAIN_NAME_STRING ": Performing architecture-specific intialization\n");
message("conn_main: Performing architecture-specific intialization\n");
ret = composite_archinitialize();
if (ret < 0)
{
message(MAIN_NAME_STRING ": composite_archinitialize failed: %d\n", -ret);
message("conn_main: composite_archinitialize failed: %d\n", -ret);
return 1;
}
check_test_memory_usage("After composite_archinitialize()");
@ -719,7 +719,7 @@ int MAIN_NAME(int argc, char *argv[])
g_composite.cmphandle = composite_initialize();
if (!g_composite.cmphandle)
{
message(MAIN_NAME_STRING ": composite_initialize failed\n");
message("conn_main: composite_initialize failed\n");
return 1;
}
check_test_memory_usage("After composite_initialize()");
@ -774,7 +774,7 @@ int MAIN_NAME(int argc, char *argv[])
/* Dump trace data */
# ifdef CONFIG_USBDEV_TRACE
message("\n" MAIN_NAME_STRING ": USB TRACE DATA:\n");
message("\n" "conn_main: USB TRACE DATA:\n");
ret = dumptrace();
if (ret < 0)
{
@ -782,18 +782,18 @@ int MAIN_NAME(int argc, char *argv[])
}
check_test_memory_usage("After usbtrace_enumerate()");
# else
message(MAIN_NAME_STRING ": Still alive\n");
message("conn_main: Still alive\n");
# endif
}
#else
message(MAIN_NAME_STRING ": Connected\n");
message("conn_main: Connected\n");
check_test_memory_usage("After composite device connection");
#endif
/* Dump debug memory usage */
message(MAIN_NAME_STRING ": Exiting\n");
message("conn_main: Exiting\n");
#if !defined(CONFIG_NSH_BUILTIN_APPS) && !defined(CONFIG_DISABLE_SIGNALS)
close(g_composite.infd);
close(g_composite.outfd);

View File

@ -81,27 +81,15 @@
# error "You must define CONFIG_NET_BROADCAST"
#endif
/* If CONFIG_NSH_BUILTIN_APPS is defined, then it is assumed that you want
* to execute the DHCPD daemon as an NSH built-in task.
*/
#ifdef CONFIG_NSH_BUILTIN_APPS
# define MAIN_NAME dhcpd_main
# define MAIN_NAME_STRING "dhcpd_main"
#else
# define MAIN_NAME user_start
# define MAIN_NAME_STRING "user_start"
#endif
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Name: user_start/dhcpd_main
* Name: dhcpd_main
****************************************************************************/
int MAIN_NAME(int argc, char *argv[])
int dhcpd_main(int argc, char *argv[])
{
struct in_addr addr;
#if defined(CONFIG_EXAMPLE_DHCPD_NOMAC)

View File

@ -107,16 +107,6 @@
# endif
#endif
/* Is this being built as an NSH built-in application? */
#ifdef CONFIG_NSH_BUILTIN_APPS
# define MAIN_NAME ftpd_start
# define MAIN_STRING "ftpd_start: "
#else
# define MAIN_NAME user_start
# define MAIN_STRING "user_start: "
#endif
/****************************************************************************
* Public Types
****************************************************************************/

View File

@ -217,10 +217,10 @@ int ftpd_daemon(int s_argc, char **s_argv)
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: user_start/ftpd_start
* Name: ftpd_main
****************************************************************************/
int MAIN_NAME(int s_argc, char **s_argv)
int ftpd_main(int s_argc, char **s_argv)
{
/* Check if we have already initialized the network */

View File

@ -53,16 +53,10 @@
****************************************************************************/
/****************************************************************************
* user_start/hello_main
* hello_main
****************************************************************************/
#ifdef CONFIG_EXAMPLES_HELLO_BUILTIN
# define MAIN_NAME hello_main
#else
# define MAIN_NAME user_start
#endif
int MAIN_NAME(int argc, char *argv[])
int hello_main(int argc, char *argv[])
{
printf("Hello, World!!\n");
return 0;

View File

@ -124,24 +124,11 @@ static CHelloWorld g_HelloWorld;
// Public Functions
//***************************************************************************
//***************************************************************************
// user_start
//***************************************************************************
/****************************************************************************
* Name: user_start/nxhello_main
* Name: helloxx_main
****************************************************************************/
#ifdef CONFIG_EXAMPLES_HELLOXX_BUILTIN
extern "C" int helloxx_main(int argc, char *argv[]);
# define MAIN_NAME helloxx_main
# define MAIN_STRING "helloxx_main: "
#else
# define MAIN_NAME user_start
# define MAIN_STRING "user_start: "
#endif
int MAIN_NAME(int argc, char *argv[])
int helloxx_main(int argc, char *argv[])
{
// If C++ initialization for static constructors is supported, then do
// that first
@ -153,7 +140,7 @@ int MAIN_NAME(int argc, char *argv[])
// Exercise an explictly instantiated C++ object
CHelloWorld *pHelloWorld = new CHelloWorld;
printf(MAIN_STRING "Saying hello from the dynamically constructed instance\n");
printf("helloxx_main: Saying hello from the dynamically constructed instance\n");
pHelloWorld->HelloWorld();
// Exercise an C++ object instantiated on the stack
@ -161,14 +148,14 @@ int MAIN_NAME(int argc, char *argv[])
#ifndef CONFIG_EXAMPLES_HELLOXX_NOSTACKCONST
CHelloWorld HelloWorld;
printf(MAIN_STRING "Saying hello from the instance constructed on the stack\n");
printf("helloxx_main: Saying hello from the instance constructed on the stack\n");
HelloWorld.HelloWorld();
#endif
// Exercise an statically constructed C++ object
#ifdef CONFIG_HAVE_CXXINITIALIZE
printf(MAIN_STRING "Saying hello from the statically constructed instance\n");
printf("helloxx_main: Saying hello from the statically constructed instance\n");
g_HelloWorld.HelloWorld();
#endif

View File

@ -141,10 +141,10 @@ static int hidkbd_waiter(int argc, char *argv[])
}
/****************************************************************************
* Name: user_start
* Name: hidkbd_main
****************************************************************************/
int user_start(int argc, char *argv[])
int hidkbd_main(int argc, char *argv[])
{
char buffer[256];
pid_t pid;
@ -154,22 +154,22 @@ int user_start(int argc, char *argv[])
/* First, register all of the USB host HID keyboard class driver */
printf("user_start: Register class drivers\n");
printf("hidkbd_main: Register class drivers\n");
ret = usbhost_kbdinit();
if (ret != OK)
{
printf("user_start: Failed to register the KBD class\n");
printf("hidkbd_main: Failed to register the KBD class\n");
}
/* Then get an instance of the USB host interface */
printf("user_start: Initialize USB host keyboard driver\n");
printf("hidkbd_main: Initialize USB host keyboard driver\n");
g_drvr = usbhost_initialize(0);
if (g_drvr)
{
/* Start a thread to handle device connection. */
printf("user_start: Start hidkbd_waiter\n");
printf("hidkbd_main: Start hidkbd_waiter\n");
#ifndef CONFIG_CUSTOM_STACK
pid = task_create("usbhost", CONFIG_EXAMPLES_HIDKBD_DEFPRIO,

View File

@ -78,10 +78,10 @@
****************************************************************************/
/****************************************************************************
* user_start
* igmp_main
****************************************************************************/
int user_start(int argc, char *argv[])
int igmp_main(int argc, char *argv[])
{
struct in_addr addr;
#if defined(CONFIG_EXAMPLE_IGMP_NOMAC)

View File

@ -152,16 +152,10 @@ static inline int lcdrw_initialize(FAR struct lcdrw_instance_s *inst)
****************************************************************************/
/****************************************************************************
* Name: lcdrw_main/user_start
* Name: lcdrw_main
****************************************************************************/
#ifdef CONFIG_EXAMPLES_LCDRW_BUILTIN
# define MAIN_NAME lcdrw_main
#else
# define MAIN_NAME user_start
#endif
int MAIN_NAME(int argc, char *argv[])
int lcdrw_main(int argc, char *argv[])
{
struct lcdrw_instance_s inst;
nxgl_coord_t row;

View File

@ -267,10 +267,10 @@ static void do_frees(void **mem, const int *size, const int *seq, int n)
****************************************************************************/
/****************************************************************************
* Name: user_start
* Name: mm_main
****************************************************************************/
int user_start(int argc, char *argv[])
int mm_main(int argc, char *argv[])
{
mm_showmallinfo();

View File

@ -104,14 +104,6 @@
# define CONFIG_EXAMPLES_MODBUS_REG_HOLDING_NREGS 130
#endif
#ifdef CONFIG_NSH_BUILTIN_APPS
# define MAIN_NAME modbus_main
# define MAIN_NAME_STRING "modbus_main: "
#else
# define MAIN_NAME user_start
# define MAIN_NAME_STRING "user_start: "
#endif
/****************************************************************************
* Private Types
****************************************************************************/
@ -171,7 +163,7 @@ static inline int modbus_initialize(void)
if (g_modbus.threadstate != STOPPED)
{
fprintf(stderr, MAIN_NAME_STRING
fprintf(stderr, "modbus_main: "
"ERROR: Bad state: %d\n", g_modbus.threadstate);
return EINVAL;
}
@ -181,7 +173,7 @@ static inline int modbus_initialize(void)
status = pthread_mutex_init(&g_modbus.lock, NULL);
if (status != 0)
{
fprintf(stderr, MAIN_NAME_STRING
fprintf(stderr, "modbus_main: "
"ERROR: pthread_mutex_init failed: %d\n", status);
return status;
}
@ -201,7 +193,7 @@ static inline int modbus_initialize(void)
CONFIG_EXAMPLES_MODBUS_BAUD, CONFIG_EXAMPLES_MODBUS_PARITY);
if (mberr != MB_ENOERR)
{
fprintf(stderr, MAIN_NAME_STRING
fprintf(stderr, "modbus_main: "
"ERROR: eMBInit failed: %d\n", mberr);
goto errout_with_mutex;
}
@ -217,7 +209,7 @@ static inline int modbus_initialize(void)
mberr = eMBSetSlaveID(0x34, true, g_slaveid, 3);
if (mberr != MB_ENOERR)
{
fprintf(stderr, MAIN_NAME_STRING
fprintf(stderr, "modbus_main: "
"ERROR: eMBSetSlaveID failed: %d\n", mberr);
goto errout_with_modbus;
}
@ -227,7 +219,7 @@ static inline int modbus_initialize(void)
mberr = eMBEnable();
if (mberr == MB_ENOERR)
{
fprintf(stderr, MAIN_NAME_STRING
fprintf(stderr, "modbus_main: "
"ERROR: eMBEnable failed: %d\n", mberr);
goto errout_with_modbus;
}
@ -270,7 +262,7 @@ static void *modbus_pollthread(void *pvarg)
ret = modbus_initialize();
if (ret != OK)
{
fprintf(stderr, MAIN_NAME_STRING
fprintf(stderr, "modbus_main: "
"ERROR: modbus_initialize failed: %d\n", ret);
return NULL;
}
@ -358,14 +350,14 @@ static void modbus_showusage(FAR const char *progname, int exitcode)
****************************************************************************/
/****************************************************************************
* Name: user_start/modbus_main
* Name: modbus_main
*
* Description:
* This is the main entry point to the demo program
*
****************************************************************************/
int MAIN_NAME(int argc, char *argv[])
int modbus_main(int argc, char *argv[])
{
int option;
int ret;
@ -389,7 +381,7 @@ int MAIN_NAME(int argc, char *argv[])
ret = modbus_create_pollthread();
if (ret != OK)
{
fprintf(stderr, MAIN_NAME_STRING
fprintf(stderr, "modbus_main: "
"ERROR: modbus_create_pollthread failed: %d\n", ret);
exit(EXIT_FAILURE);
}
@ -400,19 +392,19 @@ int MAIN_NAME(int argc, char *argv[])
switch (g_modbus.threadstate)
{
case RUNNING:
printf(MAIN_NAME_STRING "Protocol stack is running\n");
printf("modbus_main: Protocol stack is running\n");
break;
case STOPPED:
printf(MAIN_NAME_STRING "Protocol stack is stopped\n");
printf("modbus_main: Protocol stack is stopped\n");
break;
case SHUTDOWN:
printf(MAIN_NAME_STRING "Protocol stack is shutting down\n");
printf("modbus_main: Protocol stack is shutting down\n");
break;
default:
fprintf(stderr, MAIN_NAME_STRING
fprintf(stderr, "modbus_main: "
"ERROR: Invalid thread state: %d\n",
g_modbus.threadstate);
break;
@ -429,7 +421,7 @@ int MAIN_NAME(int argc, char *argv[])
break;
default:
fprintf(stderr, MAIN_NAME_STRING
fprintf(stderr, "modbus_main: "
"ERROR: Unrecognized option: '%c'\n", option);
modbus_showusage(argv[0], EXIT_FAILURE);
break;

View File

@ -567,10 +567,10 @@ static void succeed_stat(const char *path)
****************************************************************************/
/****************************************************************************
* Name: user_start
* Name: mount_main
****************************************************************************/
int user_start(int argc, char *argv[])
int mount_main(int argc, char *argv[])
{
int ret;
@ -580,18 +580,18 @@ int user_start(int argc, char *argv[])
ret = create_ramdisk();
if (ret < 0)
{
printf("user_start: ERROR failed to create RAM disk\n");
printf("mount_main: ERROR failed to create RAM disk\n");
return 1;
}
#endif
/* Mount the test file system (see arch/sim/src/up_deviceimage.c */
printf("user_start: mounting %s filesystem at target=%s with source=%s\n",
printf("mount_main: mounting %s filesystem at target=%s with source=%s\n",
g_filesystemtype, g_target, g_source);
ret = mount(g_source, g_target, g_filesystemtype, 0, NULL);
printf("user_start: mount() returned %d\n", ret);
printf("mount_main: mount() returned %d\n", ret);
if (ret == 0)
{
@ -737,16 +737,16 @@ int user_start(int argc, char *argv[])
/* Unmount the file system */
printf("user_start: Try unmount(%s)\n", g_target);
printf("mount_main: Try unmount(%s)\n", g_target);
ret = umount(g_target);
if (ret != 0)
{
printf("user_start: ERROR umount() failed, errno %d\n", errno);
printf("mount_main: ERROR umount() failed, errno %d\n", errno);
g_nerrors++;
}
printf("user_start: %d errors reported\n", g_nerrors);
printf("mount_main: %d errors reported\n", g_nerrors);
}
fflush(stdout);

View File

@ -53,18 +53,6 @@
* Definitions
****************************************************************************/
/* If CONFIG_NSH_BUILTIN_APPS is defined, then it is assumed that you want
* to execute the DHCPD daemon as an NSH built-in task.
*/
#ifdef CONFIG_NSH_BUILTIN_APPS
# define MAIN_NAME nettest_main
# define MAIN_NAME_STRING "nettest_main"
#else
# define MAIN_NAME user_start
# define MAIN_NAME_STRING "user_start"
#endif
/****************************************************************************
* Private Data
****************************************************************************/
@ -74,10 +62,10 @@
****************************************************************************/
/****************************************************************************
* user_start
* nettest_main
****************************************************************************/
int MAIN_NAME(int argc, char *argv[])
int nettest_main(int argc, char *argv[])
{
struct in_addr addr;
#ifdef CONFIG_EXAMPLE_NETTEST_NOMAC

View File

@ -84,10 +84,10 @@
****************************************************************************/
/****************************************************************************
* Name: user_start
* Name: nsh_main
****************************************************************************/
int user_start(int argc, char *argv[])
int nsh_main(int argc, char *argv[])
{
int exitval = 0;
int ret;

View File

@ -58,10 +58,10 @@
****************************************************************************/
/****************************************************************************
* Name: user_start
* Name: null_main
****************************************************************************/
int user_start(int argc, char *argv[])
int null_main(int argc, char *argv[])
{
return 0;
}

View File

@ -614,18 +614,10 @@ static int nxeg_initialize(void)
****************************************************************************/
/****************************************************************************
* Name: user_start/nx_main
* Name: nx_main
****************************************************************************/
#ifdef CONFIG_EXAMPLES_NX_BUILTIN
# define MAIN_NAME nx_main
# define MAIN_NAME_STRING "nx_main"
#else
# define MAIN_NAME user_start
# define MAIN_NAME_STRING "user_start"
#endif
int MAIN_NAME(int argc, char *argv[])
int nx_main(int argc, char *argv[])
{
NXEGWINDOW hwnd1;
NXEGWINDOW hwnd2;
@ -637,10 +629,10 @@ int MAIN_NAME(int argc, char *argv[])
/* Initialize */
ret = nxeg_initialize();
message(MAIN_NAME_STRING ": NX handle=%p\n", g_hnx);
message("nx_main: NX handle=%p\n", g_hnx);
if (!g_hnx || ret < 0)
{
message(MAIN_NAME_STRING ": Failed to get NX handle: %d\n", errno);
message("nx_main: Failed to get NX handle: %d\n", errno);
g_exitcode = NXEXIT_NXOPEN;
goto errout;
}
@ -650,29 +642,29 @@ int MAIN_NAME(int argc, char *argv[])
g_fonthandle = nxf_getfonthandle(CONFIG_EXAMPLES_NX_FONTID);
if (!g_fonthandle)
{
message(MAIN_NAME_STRING ": Failed to get font handle: %d\n", errno);
message("nx_main: Failed to get font handle: %d\n", errno);
g_exitcode = NXEXIT_FONTOPEN;
goto errout;
}
/* Set the background to the configured background color */
message(MAIN_NAME_STRING ": Set background color=%d\n", CONFIG_EXAMPLES_NX_BGCOLOR);
message("nx_main: Set background color=%d\n", CONFIG_EXAMPLES_NX_BGCOLOR);
color = CONFIG_EXAMPLES_NX_BGCOLOR;
ret = nx_setbgcolor(g_hnx, &color);
if (ret < 0)
{
message(MAIN_NAME_STRING ": nx_setbgcolor failed: %d\n", errno);
message("nx_main: nx_setbgcolor failed: %d\n", errno);
g_exitcode = NXEXIT_NXSETBGCOLOR;
goto errout_with_nx;
}
/* Create window #1 */
message(MAIN_NAME_STRING ": Create window #1\n");
message("nx_main: Create window #1\n");
nxeg_initstate(&g_wstate[0], 1, CONFIG_EXAMPLES_NX_COLOR1);
hwnd1 = nxeg_openwindow(&g_nxcb, &g_wstate[0]);
message(MAIN_NAME_STRING ": hwnd1=%p\n", hwnd1);
message("nx_main: hwnd1=%p\n", hwnd1);
if (!hwnd1)
{
goto errout_with_nx;
@ -684,14 +676,14 @@ int MAIN_NAME(int argc, char *argv[])
{
(void)sem_wait(&g_semevent);
}
message(MAIN_NAME_STRING ": Screen resolution (%d,%d)\n", g_xres, g_yres);
message("nx_main: Screen resolution (%d,%d)\n", g_xres, g_yres);
/* Set the size of the window 1 */
size.w = g_xres / 2;
size.h = g_yres / 2;
message(MAIN_NAME_STRING ": Set window #1 size to (%d,%d)\n", size.w, size.h);
message("nx_main: Set window #1 size to (%d,%d)\n", size.w, size.h);
ret = nxeg_setsize(hwnd1, &size);
if (ret < 0)
{
@ -703,7 +695,7 @@ int MAIN_NAME(int argc, char *argv[])
* actually do them!
*/
message(MAIN_NAME_STRING ": Sleeping\n\n");
message("nx_main: Sleeping\n\n");
sleep(1);
/* Set the position of window #1 */
@ -711,7 +703,7 @@ int MAIN_NAME(int argc, char *argv[])
pt.x = g_xres / 8;
pt.y = g_yres / 8;
message(MAIN_NAME_STRING ": Set window #1 postion to (%d,%d)\n", pt.x, pt.y);
message("nx_main: Set window #1 postion to (%d,%d)\n", pt.x, pt.y);
ret = nxeg_setposition(hwnd1, &pt);
if (ret < 0)
{
@ -720,13 +712,13 @@ int MAIN_NAME(int argc, char *argv[])
/* Sleep a bit */
message(MAIN_NAME_STRING ": Sleeping\n\n");
message("nx_main: Sleeping\n\n");
sleep(1);
/* Open the toolbar */
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
message(MAIN_NAME_STRING ": Add toolbar to window #1\n");
message("nx_main: Add toolbar to window #1\n");
ret = nxeq_opentoolbar(hwnd1, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT, &g_tbcb, &g_wstate[0]);
if (ret < 0)
{
@ -735,16 +727,16 @@ int MAIN_NAME(int argc, char *argv[])
/* Sleep a bit */
message(MAIN_NAME_STRING ": Sleeping\n\n");
message("nx_main: Sleeping\n\n");
sleep(1);
#endif
/* Create window #2 */
message(MAIN_NAME_STRING ": Create window #2\n");
message("nx_main: Create window #2\n");
nxeg_initstate(&g_wstate[1], 2, CONFIG_EXAMPLES_NX_COLOR2);
hwnd2 = nxeg_openwindow(&g_nxcb, &g_wstate[1]);
message(MAIN_NAME_STRING ": hwnd2=%p\n", hwnd2);
message("nx_main: hwnd2=%p\n", hwnd2);
if (!hwnd2)
{
goto errout_with_hwnd1;
@ -752,12 +744,12 @@ int MAIN_NAME(int argc, char *argv[])
/* Sleep a bit */
message(MAIN_NAME_STRING ": Sleeping\n\n");
message("nx_main: Sleeping\n\n");
sleep(1);
/* Set the size of the window 2 == size of window 1*/
message(MAIN_NAME_STRING ": Set hwnd2 size to (%d,%d)\n", size.w, size.h);
message("nx_main: Set hwnd2 size to (%d,%d)\n", size.w, size.h);
ret = nxeg_setsize(hwnd2, &size);
if (ret < 0)
{
@ -766,7 +758,7 @@ int MAIN_NAME(int argc, char *argv[])
/* Sleep a bit */
message(MAIN_NAME_STRING ": Sleeping\n\n");
message("nx_main: Sleeping\n\n");
sleep(1);
/* Set the position of window #2 */
@ -774,7 +766,7 @@ int MAIN_NAME(int argc, char *argv[])
pt.x = g_xres - size.w - pt.x;
pt.y = g_yres - size.h - pt.y;
message(MAIN_NAME_STRING ": Set hwnd2 postion to (%d,%d)\n", pt.x, pt.y);
message("nx_main: Set hwnd2 postion to (%d,%d)\n", pt.x, pt.y);
ret = nxeg_setposition(hwnd2, &pt);
if (ret < 0)
{
@ -783,11 +775,11 @@ int MAIN_NAME(int argc, char *argv[])
/* Sleep a bit */
message(MAIN_NAME_STRING ": Sleeping\n\n");
message("nx_main: Sleeping\n\n");
sleep(1);
#ifndef CONFIG_EXAMPLES_NX_RAWWINDOWS
message(MAIN_NAME_STRING ": Add toolbar to window #2\n");
message("nx_main: Add toolbar to window #2\n");
ret = nxeq_opentoolbar(hwnd2, CONFIG_EXAMPLES_NX_TOOLBAR_HEIGHT, &g_tbcb, &g_wstate[1]);
if (ret < 0)
{
@ -796,30 +788,30 @@ int MAIN_NAME(int argc, char *argv[])
/* Sleep a bit */
message(MAIN_NAME_STRING ": Sleeping\n\n");
message("nx_main: Sleeping\n\n");
sleep(1);
#endif
/* Give keyboard input to the top window -- should be window #2 */
#ifdef CONFIG_NX_KBD
message(MAIN_NAME_STRING ": Send keyboard input: %s\n", g_kbdmsg1);
message("nx_main: Send keyboard input: %s\n", g_kbdmsg1);
ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_kbdmsg1), g_kbdmsg1);
if (ret < 0)
{
message(MAIN_NAME_STRING ": nx_kbdin failed: %d\n", errno);
message("nx_main: nx_kbdin failed: %d\n", errno);
goto errout_with_hwnd2;
}
/* Sleep a bit */
message(MAIN_NAME_STRING ": Sleeping\n\n");
message("nx_main: Sleeping\n\n");
sleep(1);
#endif
/* Lower window 2 */
message(MAIN_NAME_STRING ": Lower window #2\n");
message("nx_main: Lower window #2\n");
ret = nxeg_lower(hwnd2);
if (ret < 0)
{
@ -828,7 +820,7 @@ int MAIN_NAME(int argc, char *argv[])
/* Sleep a bit */
message(MAIN_NAME_STRING ": Sleeping\n\n");
message("nx_main: Sleeping\n\n");
sleep(1);
/* Put mouse left-button clicks all over the screen and see who responds */
@ -838,30 +830,30 @@ int MAIN_NAME(int argc, char *argv[])
/* Sleep a bit */
message(MAIN_NAME_STRING ": Sleeping\n\n");
message("nx_main: Sleeping\n\n");
sleep(1);
#endif
/* Give keyboard input to the top window -- should be window #1 */
#ifdef CONFIG_NX_KBD
message(MAIN_NAME_STRING ": Send keyboard input: %s\n", g_kbdmsg2);
message("nx_main: Send keyboard input: %s\n", g_kbdmsg2);
ret = nx_kbdin(g_hnx, strlen((FAR const char *)g_kbdmsg2), g_kbdmsg2);
if (ret < 0)
{
message(MAIN_NAME_STRING ": nx_kbdin failed: %d\n", errno);
message("nx_main: nx_kbdin failed: %d\n", errno);
goto errout_with_hwnd2;
}
/* Sleep a bit */
message(MAIN_NAME_STRING ": Sleeping\n\n");
message("nx_main: Sleeping\n\n");
sleep(1);
#endif
/* Raise window 2 */
message(MAIN_NAME_STRING ": Raise window #2\n");
message("nx_main: Raise window #2\n");
ret = nxeg_raise(hwnd2);
if (ret < 0)
{
@ -876,31 +868,31 @@ int MAIN_NAME(int argc, char *argv[])
/* Sleep a bit */
message(MAIN_NAME_STRING ": Sleeping\n\n");
message("nx_main: Sleeping\n\n");
sleep(2);
/* Close the window 2 */
errout_with_hwnd2:
message(MAIN_NAME_STRING ": Close window #2\n");
message("nx_main: Close window #2\n");
(void)nxeg_closewindow(hwnd2, &g_wstate[1]);
/* Close the window1 */
errout_with_hwnd1:
message(MAIN_NAME_STRING ": Close window #1\n");
message("nx_main: Close window #1\n");
(void)nxeg_closewindow(hwnd1, &g_wstate[0]);
errout_with_nx:
#ifdef CONFIG_NX_MULTIUSER
/* Disconnect from the server */
message(MAIN_NAME_STRING ": Disconnect from the server\n");
message("nx_main: Disconnect from the server\n");
nx_disconnect(g_hnx);
#else
/* Close the server */
message(MAIN_NAME_STRING ": Close NX\n");
message("nx_main: Close NX\n");
nx_close(g_hnx);
#endif
errout:

View File

@ -207,10 +207,10 @@ static int nxcon_task(int argc, char **argv)
****************************************************************************/
/****************************************************************************
* Name: user_start
* Name: nxcon_main
****************************************************************************/
int user_start(int argc, char **argv)
int nxcon_main(int argc, char **argv)
{
nxgl_mxpixel_t color;
int fd;
@ -219,7 +219,7 @@ int user_start(int argc, char **argv)
/* General Initialization *************************************************/
/* Reset all global data */
message("user_start: Started\n");
message("nxcon_main: Started\n");
memset(&g_nxcon_vars, 0, sizeof(struct nxcon_state_s));
/* Call all C++ static constructors */
@ -231,7 +231,7 @@ int user_start(int argc, char **argv)
/* NSH Initialization *****************************************************/
/* Initialize the NSH library */
message("user_start: Initialize NSH\n");
message("nxcon_main: Initialize NSH\n");
nsh_initialize();
/* If the Telnet console is selected as a front-end, then start the
@ -252,37 +252,37 @@ int user_start(int argc, char **argv)
/* NX Initialization ******************************************************/
/* Initialize NX */
message("user_start: Initialize NX\n");
message("nxcon_main: Initialize NX\n");
ret = nxcon_initialize();
message("user_start: NX handle=%p\n", g_nxcon_vars.hnx);
message("nxcon_main: NX handle=%p\n", g_nxcon_vars.hnx);
if (!g_nxcon_vars.hnx || ret < 0)
{
message("user_start: Failed to get NX handle: %d\n", errno);
message("nxcon_main: Failed to get NX handle: %d\n", errno);
goto errout;
}
/* Set the background to the configured background color */
message("user_start: Set background color=%d\n", CONFIG_EXAMPLES_NXCON_BGCOLOR);
message("nxcon_main: Set background color=%d\n", CONFIG_EXAMPLES_NXCON_BGCOLOR);
color = CONFIG_EXAMPLES_NXCON_BGCOLOR;
ret = nx_setbgcolor(g_nxcon_vars.hnx, &color);
if (ret < 0)
{
message("user_start: nx_setbgcolor failed: %d\n", errno);
message("nxcon_main: nx_setbgcolor failed: %d\n", errno);
goto errout_with_nx;
}
/* Window Configuration ***************************************************/
/* Create a window */