RPi Locator and Display Services
lcd_display_service.c File Reference
+ Include dependency graph for lcd_display_service.c:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 11 of file lcd_display_service.c.

References gd_ch_intfName, gd_ch_ipAddress, gd_ch_program_name, gd_pch_effective_userid, gd_pch_message, get_default_interface_name_and_ipv4_address(), PACKAGE_VERSION, SD_DEBUG, SD_NOTICE, skn_display_manager_do_work(), skn_get_number_of_cpu_cores(), skn_get_userids(), skn_handle_display_command_line(), skn_program_name_and_description_set(), skn_signal_manager_shutdown(), skn_signal_manager_startup(), and SZ_INFO_BUFF.

11  {
12 
13  int index = 0;
14  pthread_t sig_thread;
15  sigset_t signal_set;
16  long l_thread_complete = 0;
17 
18  char request[SZ_INFO_BUFF];
19 
20  memset(request, 0, sizeof(request));
21  snprintf(request, sizeof(request), "%02ld Cpus Online.", skn_get_number_of_cpu_cores() );
22 
24  "lcd_display_service",
25  "LCD 4x20 Display Provider."
26  );
27 
28  /* Parse any command line options,
29  * - check request string override */
30  if (skn_handle_display_command_line(argc, argv) == EXIT_FAILURE) {
31  exit(EXIT_FAILURE);
32  }
33  if (gd_pch_message != NULL) {
34  strncpy(request, gd_pch_message, (SZ_INFO_BUFF - 1));
35  free(gd_pch_message); // from strdup()
36  gd_pch_message = request;
37  } else if (argc == 2) {
38  strcpy(request, argv[1]);
39  }
41  skn_logger(SD_NOTICE, "%s-%s is in startup mode as user(%s)", gd_ch_program_name, PACKAGE_VERSION, gd_pch_effective_userid);
42 
43  skn_logger(SD_DEBUG, "Welcome Message [%s]", request);
44 
45  /*
46  * Set the global interface name and ip address parms */
48 
49  /*
50  * Setup signal handling before we start
51  */
52  if (skn_signal_manager_startup(&sig_thread, &signal_set, &l_thread_complete) == EXIT_FAILURE ) {
53  exit(EXIT_FAILURE);
54  }
55 
56  /* **********************************************
57  * Do Work Forever
58  * - initialize needed resources
59  * - start user threads
60  */
61 
62  /*
63  * Do the marvelous work of putting message on display */
65 
66  /*
67  * Free any allocated resources before exiting
68  * - collect user threads
69  * - close open resources
70  */
71  skn_logger(SD_NOTICE, "Application beginning orderly shutdown...");
72 
73  /*
74  * Cleanup signal handler before exit
75  */
76  index = skn_signal_manager_shutdown(sig_thread, &signal_set, &l_thread_complete);
77 
78  skn_logger(SD_NOTICE, "\n============================\nShutdown Complete\n============================\n");
79 
80  exit(index);
81 }
long skn_get_number_of_cpu_cores()
int skn_signal_manager_shutdown(pthread_t sig_thread, sigset_t *psignal_set, long *l_thread_complete)
#define SD_DEBUG
void get_default_interface_name_and_ipv4_address(char *intf, char *ipv4)
int skn_handle_display_command_line(int argc, char **argv)
char gd_ch_intfName[SZ_CHAR_BUFF]
char * gd_pch_message
uid_t skn_get_userids()
#define SZ_INFO_BUFF
Definition: cmdDC.c:56
char gd_ch_program_name[SZ_INFO_BUFF]
int skn_signal_manager_startup(pthread_t *psig_thread, sigset_t *psignal_set, long *l_thread_complete)
#define SD_NOTICE
int skn_display_manager_do_work(char *client_request_message)
char * gd_pch_effective_userid
char gd_ch_ipAddress[SZ_CHAR_BUFF]
void skn_program_name_and_description_set(const char *name, const char *desc)
#define PACKAGE_VERSION
Definition: cmdDC.c:19

+ Here is the call graph for this function: