void SPI::Initialize(bool isMaster, bool isFullDuplex, SPI_BAUD_RATE baudRate, bool isClockPhase2, bool isClockPolarity1, bool isLSBFirst, bool isSetSSM, bool is16Bit) { if (is16Bit) SetDFF_16bit(); Enable(true); isClockPhase2 ? SetClockPhaseSecond() : SetClockPhaseFirst(); isClockPolarity1 ? SetClockPolarity1() : SetClockPolarity0(); isLSBFirst ? SetFrameFormatLSBFirst() : SetFrameFormatMSBFirst(); SetSSM (isSetSSM); if (isMaster) { SetBaudRate (baudRate); if (isSetSSM) { SetSSI(true); } } else { SetSSI(false); } SetFullDuplex(isFullDuplex); SetMaster(isMaster); }
static Bool ScreenInit(ScreenPtr pScreen, int argc, char **argv) { ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); modesettingPtr ms = modesettingPTR(pScrn); VisualPtr visual; pScrn->pScreen = pScreen; if (!SetMaster(pScrn)) return FALSE; #ifdef GLAMOR_HAS_GBM if (ms->drmmode.glamor) ms->drmmode.gbm = glamor_egl_get_gbm_device(pScreen); #endif /* HW dependent - FIXME */ pScrn->displayWidth = pScrn->virtualX; if (!drmmode_create_initial_bos(pScrn, &ms->drmmode)) return FALSE; if (ms->drmmode.shadow_enable) { ms->drmmode.shadow_fb = calloc(1, pScrn->displayWidth * pScrn->virtualY * ((pScrn->bitsPerPixel + 7) >> 3)); if (!ms->drmmode.shadow_fb) ms->drmmode.shadow_enable = FALSE; }
void CRuleEntity::KeyValue( KeyValueData *pkvd ) { if (FStrEq(pkvd->szKeyName, "master")) { SetMaster( ALLOC_STRING(pkvd->szValue) ); pkvd->fHandled = true; } else CBaseEntity::KeyValue( pkvd ); }
static Bool ScreenInit(SCREEN_INIT_ARGS_DECL) { ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); modesettingPtr ms = modesettingPTR(pScrn); VisualPtr visual; pScrn->pScreen = pScreen; if (!SetMaster(pScrn)) return FALSE; /* HW dependent - FIXME */ pScrn->displayWidth = pScrn->virtualX; if (!drmmode_create_initial_bos(pScrn, &ms->drmmode)) return FALSE; if (ms->drmmode.shadow_enable) { ms->drmmode.shadow_fb = calloc(1, pScrn->displayWidth * pScrn->virtualY * ((pScrn->bitsPerPixel + 7) >> 3)); if (!ms->drmmode.shadow_fb) ms->drmmode.shadow_enable = FALSE; }
bool CPartyDef::r_Verb( CScript &s, CTextConsole *pSrc ) { ADDTOCALLSTACK("CPartyDef::r_Verb"); EXC_TRY("Verb"); ASSERT(pSrc); LPCTSTR pszKey = s.GetKey(); CScriptObj *pRef; if ( r_GetRef(pszKey, pRef) ) { if ( pszKey[0] ) { if ( !pRef ) return true; CScript script(pszKey, s.GetArgStr()); return pRef->r_Verb(script, pSrc); } } int iIndex = FindTableSorted(pszKey, sm_szVerbKeys, COUNTOF(sm_szVerbKeys) - 1); switch ( iIndex ) { case PDV_ADDMEMBER: case PDV_ADDMEMBERFORCED: { bool bForced = (iIndex == PDV_ADDMEMBERFORCED); CGrayUID toAdd = static_cast<CGrayUID>(s.GetArgVal()); CChar *pCharAdd = toAdd.CharFind(); CChar *pCharMaster = GetMaster().CharFind(); if ( !pCharAdd || IsInParty(pCharAdd) ) return false; if ( pCharMaster && !bForced ) pCharMaster->SetKeyNum("PARTY_LASTINVITE", (long long)toAdd); return CPartyDef::AcceptEvent(pCharAdd, GetMaster(), bForced); } break; case PDV_CLEARTAGS: { LPCTSTR pszArg = s.GetArgStr(); SKIP_SEPARATORS(pszArg); m_TagDefs.ClearKeys(pszArg); } break; case PDV_CREATE: return true; case PDV_DISBAND: return Disband(GetMaster()); case PDV_MESSAGE: break; case PDV_REMOVEMEMBER: { CGrayUID toRemove; LPCTSTR pszArg = s.GetArgStr(); if ( *pszArg == '@' ) { pszArg++; size_t nMember = Exp_GetVal(pszArg); if ( !m_Chars.IsValidIndex(nMember) ) return false; toRemove = m_Chars.GetChar(nMember); } else toRemove = static_cast<CGrayUID>(s.GetArgVal()); if ( toRemove ) return RemoveMember(toRemove, GetMaster()); return false; } break; case PDV_SETMASTER: { CGrayUID newMaster; LPCTSTR pszArg = s.GetArgStr(); if ( *pszArg == '@' ) { pszArg++; size_t nMember = Exp_GetVal(pszArg); if ( nMember == 0 || !m_Chars.IsValidIndex(nMember) ) return false; newMaster = m_Chars.GetChar(nMember); } else newMaster = static_cast<CGrayUID>(s.GetArgVal()); if ( newMaster ) return SetMaster(newMaster.CharFind()); return false; } break; case PDV_SYSMESSAGE: { CGrayUID toSysmessage; LPCTSTR pszArg = s.GetArgStr(); TCHAR *pUid = Str_GetTemp(); size_t x = 0; if ( *pszArg == '@' ) { pszArg++; if ( *pszArg != '@' ) { LPCTSTR __pszArg = pszArg; while ( *pszArg != ' ' ) { pszArg++; x++; } strcpylen(pUid, __pszArg, ++x); size_t nMember = Exp_GetVal(pUid); if ( !m_Chars.IsValidIndex(nMember) ) return false; toSysmessage = m_Chars.GetChar(nMember); } } else { LPCTSTR __pszArg = pszArg; while ( *pszArg != ' ' ) { pszArg++; x++; } strcpylen(pUid, __pszArg, ++x); toSysmessage = static_cast<CGrayUID>(Exp_GetVal(pUid)); } SKIP_SEPARATORS(pszArg); if ( toSysmessage ) { CChar *pSend = toSysmessage.CharFind(); pSend->SysMessage(pszArg); } else SysMessageAll(pszArg); } break; case PDV_TAGLIST: m_TagDefs.DumpKeys(pSrc, "TAG."); break; default: return false; } return true; EXC_CATCH; EXC_DEBUG_START; EXC_ADD_SCRIPTSRC; EXC_DEBUG_END; return false; }
int main(int argc, char *argv[]) { uid_t uid, euid; int portarg = 0, fd; #ifdef SAVE_MAXCLIENT_STATS FILE *mcsfp; #endif memset(&me, 0, sizeof(aClient)); if ((timeofday = time(NULL)) == -1) { (void) fprintf(stderr, "ERROR: Clock Failure (%d)\n", errno); exit(errno); } build_version(); Count.server = 1; /* us */ Count.oper = 0; Count.chan = 0; Count.local = 0; Count.total = 0; Count.invisi = 0; Count.unknown = 0; Count.max_loc = 0; Count.max_tot = 0; Count.today = 0; Count.weekly = 0; Count.monthly = 0; Count.yearly = 0; Count.start = NOW; Count.day = NOW; Count.week = NOW; Count.month = NOW; Count.year = NOW; #ifdef SAVE_MAXCLIENT_STATS mcsfp=fopen(DPATH "/.maxclients", "r"); if(mcsfp!=NULL) { fscanf(mcsfp, "%d %d %li %li %li %ld %ld %ld %ld", &Count.max_loc, &Count.max_tot, &Count.weekly, &Count.monthly, &Count.yearly, &Count.start, &Count.week, &Count.month, &Count.year); fclose(mcsfp); } #endif /* * this code by [email protected] * it is intended to keep the ircd from being swapped out. BSD * swapping criteria do not match the requirements of ircd */ #ifdef INITIAL_DBUFS dbuf_init(); /* set up some dbuf stuff to control paging */ #endif sbrk0 = (char *) sbrk((size_t) 0); uid = getuid(); euid = geteuid(); #ifdef PROFIL (void) monstartup(0, etext); (void) moncontrol(1); (void) signal(SIGUSR1, s_monitor); #endif myargv = argv; (void) umask(077); /* better safe than sorry --SRB */ memset((char *) &me, '\0', sizeof(me)); setup_signals(); /* * * All command line parameters have the syntax "-fstring" or "-f * string" (e.g. the space is optional). String may be empty. Flag * characters cannot be concatenated (like "-fxyz"), it would * conflict with the form "-fstring". */ while (--argc > 0 && (*++argv)[0] == '-') { char *p = argv[0] + 1; int flag = *p++; if (flag == '\0' || *p == '\0') { if (argc > 1 && argv[1][0] != '-') { p = *++argv; argc -= 1; } else p = ""; } switch (flag) { case 'a': bootopt |= BOOT_AUTODIE; break; case 'c': bootopt |= BOOT_CONSOLE; break; case 'q': bootopt |= BOOT_QUICK; break; case 'd': (void) setuid((uid_t) uid); dpath = p; break; case 'o': /* Per user local daemon... */ (void) setuid((uid_t) uid); bootopt |= BOOT_OPER; break; #ifdef CMDLINE_CONFIG case 'f': (void) setuid((uid_t) uid); configfile = p; break; # ifdef KPATH case 'k': (void) setuid((uid_t) uid); klinefile = p; break; # endif #endif case 'h': strncpyzt(me.name, p, sizeof(me.name)); break; case 'i': bootopt |= BOOT_INETD | BOOT_AUTODIE; break; case 'p': if ((portarg = atoi(p)) > 0) portnum = portarg; break; case 's': bootopt |= BOOT_STDERR; break; case 't': (void) setuid((uid_t) uid); bootopt |= BOOT_TTY; break; case 'v': (void) printf("ircd %s\n", version); exit(0); case 'x': #ifdef DEBUGMODE (void) setuid((uid_t) uid); debuglevel = atoi(p); debugmode = *p ? p : "0"; bootopt |= BOOT_DEBUG; break; #else (void) fprintf(stderr, "%s: DEBUGMODE must be defined for -x y\n", myargv[0]); exit(0); #endif default: bad_command(); break; } } if (chdir(dpath)) { perror("chdir"); exit(-1); } if ((uid != euid) && !euid) { (void) fprintf(stderr, "ERROR: do not run ircd setuid root. Make it setuid a normal user.\n"); exit(-1); } if (argc > 0) return bad_command(); /* This should exit out */ initialize_ssl(); motd = (aMotd *) NULL; helpfile = (aMotd *) NULL; motd_tm = NULL; #ifdef SHORT_MOTD shortmotd = NULL; #endif read_motd(MOTD); read_help(HELPFILE); #ifdef SHORT_MOTD read_shortmotd(SHORTMOTD); #endif clear_client_hash_table(); clear_channel_hash_table(); clear_scache_hash_table(); /* server cache name table */ clear_ip_hash_table(); /* client host ip hash table */ initlists(); initclass(); initwhowas(); initstats(); init_tree_parse(msgtab); init_send(); NOW = time(NULL); open_debugfile(); NOW = time(NULL); init_fdlist(&serv_fdlist); init_fdlist(&oper_fdlist); init_fdlist(&listen_fdlist); #ifndef NO_PRIORITY init_fdlist(&busycli_fdlist); #endif init_fdlist(&default_fdlist); { int i; for (i = MAXCONNECTIONS + 1; i > 0; i--) { default_fdlist.entry[i] = i - 1; } } if ((timeofday = time(NULL)) == -1) { #ifdef USE_SYSLOG syslog(LOG_WARNING, "Clock Failure (%d), TS can be corrupted", errno); #endif sendto_ops("Clock Failure (%d), TS can be corrupted", errno); } #ifdef WINGATE_NOTICE strcpy(ProxyMonURL, "http://"); strncpyzt((ProxyMonURL + 7), DEFAULT_PROXY_INFO_URL, (TOPICLEN + 1) - 7); strncpyzt(ProxyMonHost, MONITOR_HOST, (HOSTLEN + 1)); #endif if (portnum < 0) portnum = PORTNUM; me.port = portnum; (void) init_sys(); me.flags = FLAGS_LISTEN; #ifndef _WIN32 if (bootopt & BOOT_INETD) { me.fd = 0; local[0] = &me; me.flags = FLAGS_LISTEN; } else #endif me.fd = -1; #ifdef USE_SYSLOG # define SYSLOG_ME "ircd" openlog(SYSLOG_ME, LOG_PID | LOG_NDELAY, LOG_FACILITY); #endif if ((fd = openconf(configfile)) == -1) { Debug((DEBUG_FATAL, "Failed in reading configuration file %s", configfile)); (void) printf("Couldn't open configuration file %s\n", configfile); exit(-1); } (void) initconf(bootopt, fd); /* comstuds SEPARATE_QUOTE_KLINES_BY_DATE code */ #ifdef SEPARATE_QUOTE_KLINES_BY_DATE { struct tm *tmptr; char timebuffer[20], filename[200]; tmptr = localtime(&NOW); (void) strftime(timebuffer, 20, "%y%m%d", tmptr); ircsprintf(filename, "%s.%s", klinefile, timebuffer); if ((fd = openconf(filename)) == -1) { Debug((DEBUG_ERROR, "Failed reading kline file %s", filename)); (void) printf("Couldn't open kline file %s\n", filename); } else (void) initconf(0, fd); } #else # ifdef KPATH if ((fd = openconf(klinefile)) == -1) { Debug((DEBUG_ERROR, "Failed reading kline file %s", klinefile)); (void) printf("Couldn't open kline file %s\n", klinefile); } else (void) initconf(0, fd); # endif #endif if (!(bootopt & BOOT_INETD)) { static char star[] = "*"; aConfItem *aconf; u_long vaddr; if ((aconf = find_me()) && portarg <= 0 && aconf->port > 0) portnum = aconf->port; Debug((DEBUG_ERROR, "Port = %d", portnum)); if ((aconf->passwd[0] != '\0') && (aconf->passwd[0] != '*')) vaddr = inet_addr(aconf->passwd); else vaddr = (u_long) NULL; if (inetport(&me, star, portnum, vaddr)) { if (bootopt & BOOT_STDERR) fprintf(stderr, "Couldn't bind to primary port %d\n", portnum); #ifdef USE_SYSLOG (void) syslog(LOG_CRIT, "Couldn't bind to primary port %d\n", portnum); #endif exit(1); } } else if (inetport(&me, "*", 0, 0)) { if (bootopt & BOOT_STDERR) fprintf(stderr, "Couldn't bind to port passed from inetd\n"); #ifdef USE_SYSLOG (void) syslog(LOG_CRIT, "Couldn't bind to port passed from inetd\n"); #endif exit(1); } (void) get_my_name(&me, me.sockhost, sizeof(me.sockhost) - 1); if (me.name[0] == '\0') strncpyzt(me.name, me.sockhost, sizeof(me.name)); me.hopcount = 0; me.authfd = -1; me.confs = NULL; me.next = NULL; me.user = NULL; me.from = &me; SetMe(&me); make_server(&me); me.serv->up = me.name; me.lasttime = me.since = me.firsttime = NOW; (void) add_to_client_hash_table(me.name, &me); /* We don't want to calculate these every time they are used :) */ sprintf(REPORT_DO_DNS, REPORT_DO_DNS_, me.name); sprintf(REPORT_FIN_DNS, REPORT_FIN_DNS_, me.name); sprintf(REPORT_FIN_DNSC, REPORT_FIN_DNSC_, me.name); sprintf(REPORT_FAIL_DNS, REPORT_FAIL_DNS_, me.name); sprintf(REPORT_DO_ID, REPORT_DO_ID_, me.name); sprintf(REPORT_FIN_ID, REPORT_FIN_ID_, me.name); sprintf(REPORT_FAIL_ID, REPORT_FAIL_ID_, me.name); R_do_dns = strlen(REPORT_DO_DNS); R_fin_dns = strlen(REPORT_FIN_DNS); R_fin_dnsc = strlen(REPORT_FIN_DNSC); R_fail_dns = strlen(REPORT_FAIL_DNS); R_do_id = strlen(REPORT_DO_ID); R_fin_id = strlen(REPORT_FIN_ID); R_fail_id = strlen(REPORT_FAIL_ID); check_class(); if (bootopt & BOOT_OPER) { aClient *tmp = add_connection(&me, 0); if (!tmp) exit(1); SetMaster(tmp); } else write_pidfile(); Debug((DEBUG_NOTICE, "Server ready...")); #ifdef USE_SYSLOG syslog(LOG_NOTICE, "Server Ready"); #endif NOW = time(NULL); #ifndef NO_PRIORITY check_fdlists(); #endif if ((timeofday = time(NULL)) == -1) { #ifdef USE_SYSLOG syslog(LOG_WARNING, "Clock Failure (%d), TS can be corrupted", errno); #endif sendto_ops("Clock Failure (%d), TS can be corrupted", errno); } #ifdef DUMP_DEBUG dumpfp=fopen("dump.log", "w"); #endif io_loop(); return 0; }