brewco/brewco.c

changeset 464
4a624c071ca9
parent 459
1f88be70f253
child 465
3aac3276689d
equal deleted inserted replaced
463:a1da58215b65 464:4a624c071ca9
44 extern int slcdHandle; 44 extern int slcdHandle;
45 extern int sock; 45 extern int sock;
46 #ifdef USE_SIMULATOR 46 #ifdef USE_SIMULATOR
47 extern int SIM_cooler; 47 extern int SIM_cooler;
48 #endif 48 #endif
49 char *etcpath = NULL;
50 char *varpath = NULL;
51
49 52
50 53
51 #ifndef HAVE_WIRINGPI_H 54 #ifndef HAVE_WIRINGPI_H
52 pthread_t threads[5]; 55 pthread_t threads[5];
53 #endif 56 #endif
562 565
563 566
564 int main(int argc, char *argv[]) 567 int main(int argc, char *argv[])
565 { 568 {
566 int rc = 0, c, i; 569 int rc = 0, c, i;
570 char *homepath = NULL;
567 571
568 while (1) { 572 while (1) {
569 int option_index = 0; 573 int option_index = 0;
570 static struct option long_options[] = { 574 static struct option long_options[] = {
571 {"debug", 0, 0, 'c'}, 575 {"debug", 0, 0, 'c'},
588 openlog("brewco", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_USER); 592 openlog("brewco", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_USER);
589 syslog(LOG_NOTICE, "mbsePi-apps brewco v%s starting", VERSION); 593 syslog(LOG_NOTICE, "mbsePi-apps brewco v%s starting", VERSION);
590 if (debug) 594 if (debug)
591 fprintf(stdout, "mbsePi-apps brewco v%s starting\n", VERSION); 595 fprintf(stdout, "mbsePi-apps brewco v%s starting\n", VERSION);
592 596
597 /*
598 * Set home directory path
599 */
600 if (getenv((char *)"USER") == NULL) {
601 homepath = xstrcpy((char *)"/root");
602 } else {
603 homepath = xstrcpy(getenv((char *)"HOME"));
604 }
605 varpath = xstrcpy(homepath);
606 varpath = xstrcat(varpath, (char *)"/.brewco/var/");
607 etcpath = xstrcpy(homepath);
608 etcpath = xstrcat(etcpath, (char *)"/.brewco/etc/");
609 mkdirs(varpath, 0755);
610 mkdirs(etcpath, 0755);
611
612 fprintf(stdout, "home: %s etc=%s var=%s\n", homepath, etcpath, varpath);
593 if (rdconfig()) { 613 if (rdconfig()) {
594 fprintf(stderr, "Error reading configuration\n"); 614 fprintf(stderr, "Error reading configuration\n");
595 syslog(LOG_NOTICE, "Error reading configuration: halted"); 615 syslog(LOG_NOTICE, "Error reading configuration: halted");
596 return 1; 616 return 1;
597 } 617 }

mercurial