Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
    int		    loop = 1;
    struct passwd   *pw;

    /*
     * Find out who is on the keyboard or automated the keyboard.
     */
    pw = getpwuid(geteuid());
    if (strcmp(pw->pw_name, (char *)"ftnd")) {
	printf("ERROR: only user \"ftnd\" may use this program\n");
        exit(FTNERR_INIT_ERROR);
    }

    /*
     * Read the global configuration data, registrate connection
     */
    config_check(getenv("FTND_ROOT"));
    config_read();
    if (strlen(CFG.debuglog) == 0)
	snprintf(CFG.debuglog, 15, "debug.log");
    InitClient(pw->pw_name, (char *)"ftnsetup", CFG.location, CFG.logfile, 0x1f, CFG.error_log, CFG.mgrlog, CFG.debuglog);

    /*
     * Setup several signals so when the program terminate's it
     * will properly close the curses screens.
     */
    signal(SIGINT, (void (*))die);
    signal(SIGBUS, (void (*))die);
    signal(SIGSEGV,(void (*))die);
    signal(SIGTERM,(void (*))die);
    signal(SIGKILL,(void (*))die);
    signal(SIGIOT, (void (*))die);

    oldmask = umask(002);

    do_quiet = TRUE;
    Syslog(' ', " ");
    Syslog(' ', "FTNSETUP v%s started by %s", VERSION, pw->pw_name);
    if (init)
	Syslog('+', "Cmd: ftnsetup init");

    if ((argc == 2) && (strncmp(tl(argv[1]), "i", 1) == 0))
	init = TRUE;
    else
	screen_start((char *)"ftnsetup");
    
    if (lockprogram((char *)"ftnsetup")) {
	printf("\n\7Another ftnsetup is already running, abort.\n\n");
	die(FTNERR_NO_PROGLOCK);
    }

    bbs_free = FALSE;
    initdatabases();
	
    if (!init) {
	do {
	    IsDoing("Browsing Menu");
	    clr_index();
	    set_color(WHITE, BLACK);
	    ftnd_mvprintw( 5, 6, "0.    MAIN SETUP");
	    set_color(CYAN, BLACK);
	    ftnd_mvprintw( 7, 6, "1.    Edit Global configuration");
	    ftnd_mvprintw( 8, 6, "2.    Edit Fido Networks");
	    ftnd_mvprintw( 9, 6, "3.    Edit Archiver Programs");
	    ftnd_mvprintw(10, 6, "4.    Edit Virus Scanners");
	    ftnd_mvprintw(11, 6, "5.    Edit Modem types");
	    ftnd_mvprintw(12, 6, "6.    Edit TTY lines info");
	    ftnd_mvprintw(13, 6, "7.    Edit Fidonet Nodes");
	    ftnd_mvprintw(14, 6, "8.    Edit BBS Setup");
	    ftnd_mvprintw(15, 6, "9.    Edit Mail Setup");
	    ftnd_mvprintw(16, 6, "10.   Edit File Echo's setup");
	    ftnd_mvprintw(17, 6, "11.   Edit Newfiles Groups");
	    ftnd_mvprintw( 7,46, "12.   Edit Newfiles Reports");
	    ftnd_mvprintw( 8,46, "13.   Edit FileFind Setup");
	    ftnd_mvprintw( 9,46, "14.   Edit Files Database");
	    ftnd_mvprintw(10,46, "15.   Edit BBS Users");
	    ftnd_mvprintw(11,46, "16.   Edit Services");
	    ftnd_mvprintw(12,46, "17.   Edit Domains");
	    ftnd_mvprintw(13,46, "18.   Edit Task Manager");
	    ftnd_mvprintw(14,46, "19.   Edit Routing Table");
	    ftnd_mvprintw(15,46, "20.   Edit Internet BBS Chat");
	    ftnd_mvprintw(16,46, "21.   Show software information");
	    ftnd_mvprintw(17,46, "22.   Create site documents");
 
	    switch(select_menu(22)) {
		case 0:
			loop = 0;
			break;
		case 1:
			global_menu();
			break;
		case 2:
			EditFidonet();
			break;
		case 3:
			EditArchive();
			break;
		case 4:
			EditVirus();
			break;
		case 5:
			EditModem();
			break;
		case 6:
			EditTtyinfo();
			break;
		case 7:
			EditNodes();
			break;
		case 8:
			bbs_menu();
			break;
		case 9:
			mail_menu();
			break;
		case 10:
			tic_menu();
			break;
		case 11:
			EditNGroup();
			break;
		case 12:	
			EditNewfiles();
			break;
		case 13:
			EditFilefind();
			break;
		case 14:
			EditFDB();
			break;
		case 15:
			EditUsers();
			break;
		case 16:
			EditService();
			break;
		case 17:
			EditDomain();
			break;
		case 18:
			task_menu();
			break;
		case 19:
			EditRoute();
			break;
		case 20:
			EditIBC();
			break;
		case 21:
			soft_info();
			break;
		case 22:
			site_docs();
			break;
	    }
	} while (loop == 1);
    }

    die(FTNERR_OK);
    return 0;
}
// Wait for command to be cleared, signifying receipt
int32_t screen_init(int32_t ChipSelect, int32_t DataCommand, int32_t TheData, int32_t TheClock, int32_t Reset, int32_t VCC_state, int32_t Type)
{
  // Startup the SPI system
  screen_start();
  // Initialize variables and initialize the display
  self->CS = ChipSelect;
  self->DC = DataCommand;
  self->DATA = TheData;
  self->CLK = TheClock;
  self->RST = Reset;
  self->vccstate = VCC_state;
  self->displayType = Type;
  if (self->displayType == TYPE_128X32) {
    self->displayWidth = SSD1306_LCDWIDTH;
    self->displayHeight = SSD1306_LCDHEIGHT32;
  } else {
    self->displayWidth = SSD1306_LCDWIDTH;
    self->displayHeight = SSD1306_LCDHEIGHT64;
  }
  // Setup reset and pin direction  
  screen_HIGH(self->RST);
  // VDD (3.3V) goes high at start; wait for a ms
  waitcnt(((CLKFREQ / 100000) + CNT));
  // force reset low
  screen_LOW(self->RST);
  // wait 10ms
  waitcnt(((CLKFREQ / 100000) + CNT));
  // remove reset
  screen_HIGH(self->RST);
  if (self->displayType == TYPE_128X32) {
    // ************************************
    // Init sequence for 128x32 OLED module
    // ************************************
    screen_ssd1306_Command(SSD1306_DISPLAYOFF);
    screen_ssd1306_Command(SSD1306_SETDISPLAYCLOCKDIV);
    screen_ssd1306_Command(128);
    screen_ssd1306_Command(SSD1306_SETMULTIPLEX);
    screen_ssd1306_Command(31);
    screen_ssd1306_Command(SSD1306_SETDISPLAYOFFSET);
    screen_ssd1306_Command(0);
    screen_ssd1306_Command((SSD1306_SETSTARTLINE | 0x0));
    screen_ssd1306_Command(SSD1306_CHARGEPUMP);
    if (self->vccstate == SSD1306_EXTERNALVCC) {
      screen_ssd1306_Command(16);
    } else {
      screen_ssd1306_Command(20);
    }
    screen_ssd1306_Command(SSD1306_MEMORYMODE);
    screen_ssd1306_Command(0);
    screen_ssd1306_Command((SSD1306_SEGREMAP | 0x1));
    screen_ssd1306_Command(SSD1306_COMSCANDEC);
    screen_ssd1306_Command(SSD1306_SETCOMPINS);
    screen_ssd1306_Command(2);
    screen_ssd1306_Command(SSD1306_SETCONTRAST);
    screen_ssd1306_Command(143);
    screen_ssd1306_Command(SSD1306_SETPRECHARGE);
    if (self->vccstate == SSD1306_EXTERNALVCC) {
      screen_ssd1306_Command(34);
    } else {
      // SSD1306_SWITCHCAPVCC 
      screen_ssd1306_Command(241);
    }
    screen_ssd1306_Command(SSD1306_SETVCOMDETECT);
    screen_ssd1306_Command(64);
    screen_ssd1306_Command(SSD1306_DISPLAYALLON_RESUME);
    screen_ssd1306_Command(SSD1306_NORMALDISPLAY);
    // --turn on oled panel
    screen_ssd1306_Command(SSD1306_DISPLAYON);
  } else {
    // ************************************   
    // Init sequence for 128x64 OLED module
    // ************************************
    screen_ssd1306_Command(SSD1306_DISPLAYOFF);
    // low col = 0
    screen_ssd1306_Command(SSD1306_SETLOWCOLUMN);
    // hi col = 0
    screen_ssd1306_Command(SSD1306_SETHIGHCOLUMN);
    // line #0
    screen_ssd1306_Command(SSD1306_SETSTARTLINE);
    screen_ssd1306_Command(SSD1306_SETCONTRAST);
    if (self->vccstate == SSD1306_EXTERNALVCC) {
      screen_ssd1306_Command(159);
    } else {
      screen_ssd1306_Command(207);
    }
    screen_ssd1306_Command(161);
    screen_ssd1306_Command(SSD1306_NORMALDISPLAY);
    screen_ssd1306_Command(SSD1306_DISPLAYALLON_RESUME);
    screen_ssd1306_Command(SSD1306_SETMULTIPLEX);
    screen_ssd1306_Command(63);
    screen_ssd1306_Command(SSD1306_SETDISPLAYOFFSET);
    // No offset                            
    screen_ssd1306_Command(0);
    screen_ssd1306_Command(SSD1306_SETDISPLAYCLOCKDIV);
    screen_ssd1306_Command(128);
    screen_ssd1306_Command(SSD1306_SETPRECHARGE);
    if (self->vccstate == SSD1306_EXTERNALVCC) {
      screen_ssd1306_Command(34);
    } else {
      screen_ssd1306_Command(241);
    }
    screen_ssd1306_Command(SSD1306_SETVCOMDETECT);
    screen_ssd1306_Command(64);
    screen_ssd1306_Command(SSD1306_SETCOMPINS);
    screen_ssd1306_Command(18);
    screen_ssd1306_Command(SSD1306_MEMORYMODE);
    screen_ssd1306_Command(0);
    screen_ssd1306_Command((SSD1306_SEGREMAP | 0x1));
    screen_ssd1306_Command(SSD1306_COMSCANDEC);
    screen_ssd1306_Command(SSD1306_CHARGEPUMP);
    if (self->vccstate == SSD1306_EXTERNALVCC) {
      screen_ssd1306_Command(16);
    } else {
      screen_ssd1306_Command(20);
    }
    // --turn on oled panel
    screen_ssd1306_Command(SSD1306_DISPLAYON);
  }
  self->crsrX = 0;
  self->crsrY = 0;
  self->charSize = LARGE;
  invert(0);
  //screen_AutoUpdateOff();              // commented 8/23 5:26 PM
  //clear();
  return 0;
}