StatusInvulnerable::StatusInvulnerable(const Id & owner, double delay) : CreatureStatus(CRESTATUS_INVULNERABLE, owner), m_bFading(true) { TimeInit(&m_fadeDelay, INVUL_DELAY); TimeInit(&m_invulDelay, delay); Creature *pCre = (Creature *)IDPageQuery(m_owner); if(pCre) { pCre->SetFlag(CRE_FLAG_INVUL, true); OBJSetToLast(pCre->GetOBJ()); } }
int main(int argc, char *argv[]) { const char *pszTemp; TimeInit(); setup_logging(argv[0],True); charset_initialise(); if (argc < 2 || argc > 3) printf("Usage: testprns printername [printcapfile]\n"); else { dbf = sys_fopen("test.log", "w"); if (dbf == NULL) { printf("Unable to open logfile.\n"); } else { DEBUGLEVEL = 3; pszTemp = (argc < 3) ? PRINTCAP_NAME : argv[2]; printf("Looking for printer %s in printcap file %s\n", argv[1], pszTemp); if (!pcap_printername_ok(argv[1], pszTemp)) printf("Printer name %s is not valid.\n", argv[1]); else printf("Printer name %s is valid.\n", argv[1]); fclose(dbf); } } return (0); }
/************************************************************************* * STARTUP TASK - Prints out checksum and waits for c press. When C is pressed, * starts LCD and Demo Task, then deletes itself * Functions included: CalcChkSum, LcdDispStrg, DisplayCheckSum * Creates: LCDDemoTask and DemoCntrlTask *************************************************************************/ static void StartTask(void *p_arg) { (void)p_arg; /* Avoid compiler warning */ OSTickInit(); DBUG_PORT |= PP7; KeyInit(); TimeInit(); LcdInit(TRUE,TRUE,FALSE); SetTheTime();//for reset purposes (void)OSTaskCreate(UITask, /* Create UITask */ (void *)0, (void *)&UITaskStk[UITASK_STK_SIZE], UITASK_PRIO); (void)OSTaskCreate(TimeDispTask, /* Create TimeDispTask */ (void *)0, (void *)&TimeDispTaskStk[TIMEDISPTASK_STK_SIZE], TIMEDISPTASK_PRIO); (void)OSTaskCreate(TransmitTask, /* Create UITask */ (void *)0, (void *)&TransmitTaskStk[TRANSMITTASK_STK_SIZE], TRANSMIT_PRIO); (void)OSTaskCreate(ReceiveTask, /* Create UITask */ (void *)0, (void *)&ReceiveTaskStk[RECEIVETASK_STK_SIZE], RECEIVE_PRIO); DBUG_PORT &= ~PP7; (void)OSTaskDel(STARTTASK_PRIO); FOREVER() { } }
void KernelMain() { EarlyConsoleInit(); ArchInit(); ThrEarlyInit(); TimeInit(); ShutdownInit(); /* Set up the device-related subsystems. */ IcInit(); /* Once we've set up the ICFS framework, there are several * areas of Whitix (like the slab code) that need to expose * their internal information. */ SlabInfoInit(); ModuleInfoInit(); ThrInit(); VfsInit(); DevFsInit(); DeviceInit(); MiscInit(); LoadInit(); StartInit(); /* This is where the idle thread idles, after returning from StartInit in startup.c */ ThrIdleFunc(); }
/************************************************************************* * STARTUP TASK - Prints out checksum and waits for c press. When C is pressed, * starts LCD and Demo Task, then deletes itself * Functions included: CalcChkSum, LcdDispStrg, DisplayCheckSum * Creates: LCDDemoTask and DemoCntrlTask *************************************************************************/ static void StartTask(void *p_arg) { (void)p_arg; /* Avoid compiler warning */ OSTickInit(); TimeInit(); /* Initialize uC/OS-II */ KeyInit(); //LcdInit(); LcdInit(TRUE,TRUE,FALSE); DBUG_PORT |= PP7; //LcdClrDisp(); //LcdMoveCursor(1,5); (void)OSTaskCreate(UITask, /* Create UITask */ (void *)0, (void *)&UITaskStk[UITASK_STK_SIZE], UITASK_PRIO); (void)OSTaskCreate(TimeDispTask, /* Create TimeDispTask */ (void *)0, (void *)&TimeDispTaskStk[TIMEDISPTASK_STK_SIZE], TIMEDISPTASK_PRIO); //LcdDispChar(1,1,CLOCK_LAYER,'2'); DBUG_PORT &= ~PP7; (void)OSTaskDel(STARTTASK_PRIO); FOREVER() { //do nothing } }
//returns true if ready to be removed PRIVATE bool _fxSmokeUpdate(fxSmoke *mainDat, fxSmoke_par *theSmoke) { double t = TimeGetTime(&theSmoke->delayTimer)/TimeGetDelay(&theSmoke->delayTimer); //moving if(!theSmoke->bFading) { if(t <= 1) { theSmoke->loc[eX] = theSmoke->sLoc[eX] + t*(theSmoke->eLoc[eX]-theSmoke->sLoc[eX]); theSmoke->loc[eY] = theSmoke->sLoc[eY] + t*(theSmoke->eLoc[eY]-theSmoke->sLoc[eY]); theSmoke->loc[eZ] = theSmoke->sLoc[eZ] + t*(theSmoke->eLoc[eZ]-theSmoke->sLoc[eZ]); theSmoke->clr[eA] = t; } else { //initialize fading theSmoke->bFading = true; TimeInit(&theSmoke->delayTimer, mainDat->fadeDelay); TimeReset(&theSmoke->delayTimer); } } //fading else { if(t <= 1) theSmoke->clr[eA] = 1.0f - t; else //we are done return true; } return false; }
///////////////////////////////////////////////////////////////////////////// //Stun ///////////////////////////////////////////////////////////////////////////// StatusStun::StatusStun(const Id & owner, double delay) : CreatureStatus(CRESTATUS_STUN, owner), m_parFX(0) { TimeInit(&m_stunDelay, delay); string fxTxtFile = GAMEFOLDER; fxTxtFile += "\\"; fxTxtFile += "Textures\\Particles\\star.tga"; Creature *pCre = (Creature *)IDPageQuery(m_owner); if(pCre) { fxGlow_init fx; fx.glowTxt = TextureCreate(0, fxTxtFile.c_str(), false, 0); if(fx.glowTxt) { fx.r = fx.g = fx.b = 255; fx.scaleStart = 0; fx.scaleEnd = pCre->BoundGetRadius()*2; fx.delay = delay*0.125; fx.bRepeat = true; m_parFX = PARFXCreate(ePARFX_GLOW, &fx, -1, pCre->GetOBJ(), -1, 0); } } }
int main(int argc, char *argv[]) { char *desthost; pstring configfile; TimeInit(); setup_logging(argv[0],True); charset_initialise(); pstrcpy(configfile,CONFIGFILE); if (argc < 2) { fprintf(stderr,"smbfilter <desthost> <netbiosname>\n"); exit(1); } desthost = argv[1]; if (argc > 2) { netbiosname = argv[2]; } if (!lp_load(configfile,True,False,False)) { DEBUG(0,("Unable to load config file\n")); } start_filter(desthost); return 0; }
///////////////////////////////////// // Name: // Purpose: // Output: // Return: ///////////////////////////////////// PUBLIC RETCODE OBJSetState(hOBJ obj, int state) { if((state >= obj->numStates) || (state < 0)) return RETCODE_OUTOFBOUND; if(state == obj->curState) return RETCODE_SUCCESS; obj->curState = state; obj->curFrame = obj->states[obj->curState].startFrame; //set up timer TimeInit(&obj->ticker, obj->states[obj->curState].delay); hOBJ thisObj; for(LISTPTR::iterator i = obj->objNode->begin(); i != obj->objNode->end(); ++i) { thisObj = (hOBJ)(*i); if(TESTFLAGS(thisObj->status, OBJ_SYNCSTATE)) OBJSetState(thisObj, state); } return RETCODE_SUCCESS; }
int main(int argc, char *argv[]) { pid_t pid; int i, n; static pstring servicesf = CONFIGFILE; char buf[12]; TimeInit(); setup_logging(argv[0],True); charset_initialise(); lp_load(servicesf,False,False,False); message_init(); if (argc != 3) { fprintf(stderr, "%s: Usage - %s pid count\n", argv[0], argv[0]); exit(1); } pid = atoi(argv[1]); n = atoi(argv[2]); message_register(MSG_PONG, pong_message); for (i=0;i<n;i++) { message_send_pid(pid, MSG_PING, NULL, 0, True); } while (pong_count < i) { message_dispatch(); msleep(1); } /* Now test that the duplicate filtering code works. */ pong_count = 0; safe_strcpy(buf, "1234567890", sizeof(buf)-1); for (i=0;i<n;i++) { message_send_pid(getpid(), MSG_PING, NULL, 0, False); message_send_pid(getpid(), MSG_PING, buf, 11, False); } for (i=0;i<n;i++) { message_dispatch(); msleep(1); } if (pong_count != 2) { fprintf(stderr, "Duplicate filter failed (%d).\n", pong_count); exit(1); } return (0); }
void Geyser::GeyserSetActivateDelay(double delay) { if(delay < 0) GeyserSetAlwaysActive(true); else { TimeInit(&m_activeDelay, delay); GeyserSetAlwaysActive(false); } }
bool SchedulingInited; void SchedulingInit() { if(!SchedulingInited) { MemoryInit(); TimeInit(); ControlRequests=1; CurrentTask=SystemTasks=NULL; ActiveScheduler=NullScheduler; InterruptVectorCount=0; SystemLock=LockCreate(); //CurrentSP=NULL; SchedulingInited=TRUE; } }
MTButton3D::MTButton3D(const Id & parentID, hCFG cfg, const char *section) : MenuItem(parentID, MITM_TYPE_BUTTON3D, cfg, section), m_btnOBJ(0), m_startLoc(0,0,0), m_endLoc(0,0,0), m_startAlpha(0), m_endAlpha(0) { char buff[MAXCHARBUFF]={0}; ///////////////////////////////////////////////////////////////// //load the button model hMDL mdl=0; if(CfgGetItemStr(cfg, section, "btnMDL", buff)) { string mdlPath = GAMEFOLDER; mdlPath += "\\"; mdlPath += buff; mdl = MDLCreate(0, mdlPath.c_str()); } //load animation of cursor and the model if(CfgGetItemStr(cfg, section, "btnAnim", buff) && mdl) { string mdlAnimPath = GAMEFOLDER; mdlAnimPath += "\\"; mdlAnimPath += buff; //create the object m_btnOBJ = OBJCreate(0, mdl, 0,0,0, eOBJ_ANIMATE, mdlAnimPath.c_str()); } else m_btnOBJ = OBJCreate(0, mdl, 0,0,0, eOBJ_STILL, 0); //we don't want it to be shown with the world //we will update and display the object manually if(m_btnOBJ) OBJActivate(m_btnOBJ, false); ///////////////////////////////////////////////////////////////// //Load other components if(CfgGetItemStr(cfg, section, "sLoc", buff)) sscanf(buff, "%f,%f,%f", &m_startLoc.x, &m_startLoc.y, &m_startLoc.z); if(CfgGetItemStr(cfg, section, "eLoc", buff)) sscanf(buff, "%f,%f,%f", &m_endLoc.x, &m_endLoc.y, &m_endLoc.z); m_startAlpha = CfgGetItemFloat(cfg, section, "sAlpha"); m_endAlpha = CfgGetItemFloat(cfg, section, "eAlpha"); TimeInit(&m_delay, CfgGetItemFloat(cfg, section, "delay")); }
StatusTeleport::StatusTeleport(const Id & owner, const D3DXVECTOR3 & loc) : CreatureStatus(CRESTATUS_TELEPORT, owner), m_bFading(true), m_dest(loc) { TimeInit(&m_delay, TELE_DELAY); Creature *pCre = (Creature *)IDPageQuery(m_owner); if(pCre) { pCre->SetFlag(CRE_FLAG_INVUL, true); OBJSetToLast(pCre->GetOBJ()); } }
StatusTeleport::StatusTeleport(const Id & owner, const char *targetName) : CreatureStatus(CRESTATUS_TELEPORT, owner), m_bFading(true), m_bGO(false) { if(g_world) { g_world->TargetGet(targetName, m_dest); TimeInit(&m_delay, TELE_DELAY); } Creature *pCre = (Creature *)IDPageQuery(m_owner); if(pCre) pCre->SetFlag(CRE_FLAG_INVUL, true); }
///////////////////////////////////// // Name: OBJDuplicate // Purpose: duplicates a given object // Output: stuff happens // Return: new clone object ///////////////////////////////////// PUBLIC hOBJ OBJDuplicate(hOBJ obj, unsigned int newID, float x, float y, float z) { hOBJ newObj; newObj = OBJCreate(newID, obj->theMdl, x, y, z, eOBJ_STILL, 0); if(newObj) { newObj->curFrame = obj->curFrame; newObj->curState = obj->curState; SETFLAG(newObj->status, obj->status); //set orientation OBJSetOrientation(newObj, (float*)obj->orient); //copy the animation newObj->numStates = obj->numStates; if(obj->numStates > 0) { newObj->states = (gfxObjMdlState*)GFX_MALLOC(sizeof(gfxObjMdlState)*obj->numStates); if(!newObj->states) { ASSERT_MSG(0, "Unable to allocate new object", "Error in OBJDuplicate"); _destroyObj(&newObj); return 0; } memcpy(newObj->states, obj->states, sizeof(gfxObjMdlState)*obj->numStates); TimeInit(&newObj->ticker, TimeGetDelay(&newObj->ticker)); } //copy children hOBJ thisChildObj, newChildObj; for(LISTPTR::iterator i = obj->objNode->begin(); i != obj->objNode->end(); ++i) { thisChildObj = (hOBJ)(*i); newChildObj = OBJDuplicate(thisChildObj, thisChildObj->ID, thisChildObj->wrldTrans[eX], thisChildObj->wrldTrans[eY], thisChildObj->wrldTrans[eZ]); if(newChildObj) OBJAddChild(newObj, newChildObj, thisChildObj->parentJointInd, TESTFLAGS(thisChildObj->status, OBJ_SYNCSTATE)); } } return newObj; }
int main(int argc, char **argv) { int rc; START_CRITICAL(); ProcessInit(); TimeInit(); IOInit(); #ifdef TRAPINTS TrapInts(); #endif END_CRITICAL(); { /* analisis de los argumentos */ int in; int out=1; int count=1; for (in=1; in<argc; in++) if (strcmp(argv[in],"-slice")==0 && ++in<argc) { char *pc; for (pc= argv[in]; *pc!='\0'; pc++) if (! ('0'<= *pc && *pc<='9')) nFatalError("main", "Invalid option -slice %s", argv[in]); nSetTimeSlice(atoi(argv[in])); } else if (strcmp(argv[in],"-noblocking")==0) nSetNonBlockingStdio(); else { argv[out++]= argv[in]; count++; } argc= count; } rc= nMain(argc, argv); nExitSystem(rc); return rc; /* nunca llega aca */ }
PRIVATE void _fxSmokeAppend(fxSmoke *mainDat, float trans[eMaxPt], float eTrans[eMaxPt]) { fxSmoke_par newSmokePar={0}; //set start location newSmokePar.sLoc[eX] = _GFXMathRand(mainDat->min[eX], mainDat->max[eX]) + trans[eX]; newSmokePar.sLoc[eY] = _GFXMathRand(mainDat->min[eY], mainDat->max[eY]) + trans[eY]; newSmokePar.sLoc[eZ] = _GFXMathRand(mainDat->min[eZ], mainDat->max[eZ]) + trans[eZ]; //set color newSmokePar.clr[eR] = mainDat->r; newSmokePar.clr[eG] = mainDat->g; newSmokePar.clr[eB] = mainDat->b; newSmokePar.clr[eA] = 1; //set end location memcpy(newSmokePar.eLoc, eTrans, sizeof(newSmokePar.eLoc)); switch(mainDat->axis) { case 0: newSmokePar.eLoc[eX] = newSmokePar.sLoc[eX]; break; case 1: newSmokePar.eLoc[eY] = newSmokePar.sLoc[eY]; break; case 2: newSmokePar.eLoc[eZ] = newSmokePar.sLoc[eZ]; break; } //set delay TimeInit(&newSmokePar.delayTimer, mainDat->spdDelay); //the smoke will move and fade in first newSmokePar.bFading = false; //append mainDat->smokes->push_back(newSmokePar); }
int main(void) { UINT8 data; BIT_SET(L_OUT_DDR,L_OUT_PIN); //L_OUT pin is output BIT_SET(K_OUT_DDR,K_OUT_PIN); //K_OUT pin is output K_OUT(1); L_OUT(1); uart1_init(10400); uart_init(115200); //Set up UART TimeInit(); //set up time //set up printf fdevopen(uart_putchar, NULL); printf("Hello world\n"); while (1) { if (uart1_kbhit()) { data=uart1_getchar(); printf("0x%02X ",data); //uart_putchar(data); } if (uart_kbhit()) { data=uart_getchar(); uart1_putchar(data); } } }
int ShroomShooter::Callback(unsigned int msg, unsigned int wParam, int lParam) { switch(msg) { case ENTITYMSG_CFGLOAD: { char buff[MAXCHARBUFF]={0}; hCFG cfg = (hCFG)wParam; //Load the model for spit if(CfgGetItemStr(cfg, "special", "attackModel", buff)) { string mdlPath = GAMEFOLDER; mdlPath += "\\"; mdlPath += buff; m_spitMdl = MDLCreate(0, mdlPath.c_str()); } //Load the texture for spit trails if(CfgGetItemStr(cfg, "special", "attackTrail", buff)) { string txtPath = GAMEFOLDER; txtPath += "\\"; txtPath += buff; m_spitFXTxt = TextureCreate(0, txtPath.c_str(), false, 0); } //load color if(CfgGetItemStr(cfg, "special", "attackClr", buff)) { int r,g,b; sscanf(buff, "%d,%d,%d", &r,&g,&b); m_r=r; m_g=g; m_b=b; } //load attack stuff m_attackSpd = CfgGetItemFloat(cfg, "special", "attackSpd"); double atkDelay = CfgGetItemFloat(cfg, "special", "attackDelay"); TimeInit(&m_attackDelay, atkDelay); } break; case ENTITYMSG_UPDATE: { int state = OBJGetCurState(GetOBJ()); if(state != SHROOMSHOOTER_ANIM_SHOOT && state != SHROOMSHOOTER_ANIM_OUCH) { if(TimeElapse(&m_attackDelay)) { //set to attack state OBJSetState(GetOBJ(), SHROOMSHOOTER_ANIM_SHOOT); //spit sound //CREPlaySound(19); } } if(OBJIsStateEnd(GetOBJ())) { if(state == SHROOMSHOOTER_ANIM_SHOOT) { //create spit projectile if(m_spitMdl) { D3DXVECTOR3 spitLoc; OBJJointGetWorldLoc(GetOBJ(), OBJJointGetIndex(GetOBJ(), "mouth"), (float*)spitLoc); new Spit(GetID(), spitLoc, m_attackSpd, m_spitMdl, m_spitFXTxt, m_r, m_g, m_b); } } //random idle int newIdleState = Random(SHROOMSHOOTER_ANIM_IDLE1, SHROOMSHOOTER_ANIM_IDLE_MAX); OBJSetState(GetOBJ(), newIdleState); } } break; case ENTITYMSG_ENTITYCOLLIDE: break; case ENTITYMSG_REQUESTSOUND: switch(wParam) { case SND_REQ_PROJ_HIT_CRE: *((int*)lParam) = 20; break; } break; } return RETCODE_SUCCESS; }
void NTPInit(void) { NTPState = NTP_HOME; g_NTPOk = FALSE; TimeInit(); }
/**************************************************************************** main program ****************************************************************************/ int main(int argc,char *argv[]) { fstring base_directory; char *pname = argv[0]; int opt; extern FILE *dbf; extern char *optarg; extern int optind; pstring query_host; BOOL nt_domain_logon = False; static pstring servicesf = CONFIGFILE; pstring term_code; char *p; #ifdef KANJI pstrcpy(term_code, KANJI); #else /* KANJI */ *term_code = 0; #endif /* KANJI */ *query_host = 0; *base_directory = 0; DEBUGLEVEL = 2; setup_logging(pname,True); TimeInit(); charset_initialise(); pid = getpid(); uid = getuid(); gid = getgid(); mid = pid + 100; myumask = umask(0); umask(myumask); if (getenv("USER")) { pstrcpy(username,getenv("USER")); /* modification to support userid%passwd syntax in the USER var 25.Aug.97, [email protected] */ if ((p=strchr(username,'%'))) { *p = 0; pstrcpy(password,p+1); got_pass = True; memset(strchr(getenv("USER"),'%')+1,'X',strlen(password)); } strupper(username); } /* modification to support PASSWD environmental var 25.Aug.97, [email protected] */ if (getenv("PASSWD")) pstrcpy(password,getenv("PASSWD")); if (*username == 0 && getenv("LOGNAME")) { pstrcpy(username,getenv("LOGNAME")); strupper(username); } if (argc < 2) { usage(pname); exit(1); } if (*argv[1] != '-') { pstrcpy(service, argv[1]); /* Convert any '/' characters in the service name to '\' characters */ string_replace( service, '/','\\'); argc--; argv++; if (count_chars(service,'\\') < 3) { usage(pname); printf("\n%s: Not enough '\\' characters in service\n",service); exit(1); } if (argc > 1 && (*argv[1] != '-')) { got_pass = True; pstrcpy(password,argv[1]); memset(argv[1],'X',strlen(argv[1])); argc--; argv++; } } while ((opt = getopt(argc, argv,"s:B:O:M:S:i:Nn:d:Pp:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF) switch (opt) { case 'm': max_protocol = interpret_protocol(optarg,max_protocol); break; case 'O': pstrcpy(user_socket_options,optarg); break; case 'S': pstrcpy(desthost,optarg); strupper(desthost); nt_domain_logon = True; break; case 'B': iface_set_default(NULL,optarg,NULL); break; case 'D': pstrcpy(base_directory,optarg); break; case 'i': pstrcpy(scope,optarg); break; case 'U': { char *lp; pstrcpy(username,optarg); if ((lp=strchr(username,'%'))) { *lp = 0; pstrcpy(password,lp+1); got_pass = True; memset(strchr(optarg,'%')+1,'X',strlen(password)); } } break; case 'W': pstrcpy(workgroup,optarg); break; case 'E': dbf = stderr; break; case 'I': { dest_ip = *interpret_addr2(optarg); if (zero_ip(dest_ip)) exit(1); have_ip = True; } break; case 'n': pstrcpy(myname,optarg); break; case 'N': got_pass = True; break; case 'd': if (*optarg == 'A') DEBUGLEVEL = 10000; else DEBUGLEVEL = atoi(optarg); break; case 'l': slprintf(debugf,sizeof(debugf)-1,"%s.client",optarg); break; case 'p': port = atoi(optarg); break; case 'c': cmdstr = optarg; got_pass = True; break; case 'h': usage(pname); exit(0); break; case 's': pstrcpy(servicesf, optarg); break; case 't': pstrcpy(term_code, optarg); break; default: usage(pname); exit(1); } if (!*query_host && !*service) { usage(pname); exit(1); } DEBUG(3,("%s client started (version %s)\n",timestring(),VERSION)); if(!get_myname(myhostname,NULL)) { DEBUG(0,("Failed to get my hostname.\n")); } if (!lp_load(servicesf,True)) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf); } codepage_initialise(lp_client_code_page()); interpret_coding_system(term_code); if (*workgroup == 0) pstrcpy(workgroup,lp_workgroup()); load_interfaces(); get_myname((*myname)?NULL:myname,NULL); strupper(myname); #ifdef NTDOMAIN if (nt_domain_logon) { int ret = 0; slprintf(service,sizeof(service), "\\\\%s\\IPC$",query_host); strupper(service); connect_as_ipc = True; DEBUG(5,("NT Domain Logon. Service: %s\n", service)); if (cli_open_sockets(port)) { if (!cli_send_login(NULL,NULL,True,True,NULL)) return(1); do_nt_login(desthost, myhostname, Client, cnum); cli_send_logout(); close_sockets(); } return(ret); } #endif if (cli_open_sockets(port)) { if (!process(base_directory)) { close_sockets(); return(1); } close_sockets(); } else return(1); return(0); }
PROTECTED RETCODE fxLightningYFunc(hPARFX thisPARFX, DWORD message, LPARAM dumbParam, WPARAM otherParam) { fxLightningY *thisData = (fxLightningY *)thisPARFX->data; switch(message) { case PARFXM_UPDATE: { double t = TimeGetTime(&thisData->onTimer)/TimeGetDelay(&thisData->onTimer); if(t > 1){ t = 1; TimeReset(&thisData->onTimer); } //update alpha if(thisData->clr[eA] < 1 && dumbParam != PARFX_UPDATE_DEAD) { thisData->clr[eA] = t; if(thisData->clr[eA] == 1) { TimeReset(&thisData->onTimer); } } else if(thisData->clr[eA] > 0 && dumbParam == PARFX_UPDATE_DEAD) { thisData->clr[eA] = 1.0f - t; if(thisData->clr[eA] == 0) { TimeReset(&thisData->onTimer); } } ///////////////////////////////////////////////////////////////// //update nodes float trans[eMaxPt] = {0}; hOBJ obj = PARFXGetOBJ(thisPARFX); if(obj) { PARFXGetOBJLoc(thisPARFX, obj, trans); } for(int i = 0; i < thisData->numNodes; i++) { t = TimeGetTime(&thisData->Nodes[i].timeMove)/TimeGetDelay(&thisData->Nodes[i].timeMove); if(t > 1) t = 1; thisData->Nodes[i].curLoc[eX] = thisData->Nodes[i].sLoc[eX] + t*(thisData->Nodes[i].eLoc[eX] - thisData->Nodes[i].sLoc[eX]); thisData->Nodes[i].curLoc[eZ] = thisData->Nodes[i].sLoc[eZ] + t*(thisData->Nodes[i].eLoc[eZ] - thisData->Nodes[i].sLoc[eZ]); if(t == 1) { TimeReset(&thisData->Nodes[i].timeMove); //our new start memcpy(thisData->Nodes[i].sLoc, thisData->Nodes[i].curLoc, sizeof(thisData->Nodes[i].sLoc)); //our new end thisData->Nodes[i].eLoc[eX] = _GFXMathRand(thisData->min[eX], thisData->max[eX]) + trans[eX]; thisData->Nodes[i].eLoc[eY] = thisData->min[eY] + ((float)i/(float)thisData->numNodes)*(thisData->max[eY] - thisData->min[eY]) + trans[eY]; thisData->Nodes[i].eLoc[eZ] = _GFXMathRand(thisData->min[eZ], thisData->max[eZ]) + trans[eZ]; } } if(thisData->clr[eA] == 0 && dumbParam == PARFX_UPDATE_DEAD) { return RETCODE_BREAK; } } break; case PARFXM_DISPLAY: if(FrustrumCheckBox( thisData->min[eX], thisData->min[eY], thisData->min[eZ], thisData->max[eX], thisData->max[eY], thisData->max[eZ])) { float t = 0, max=thisData->maxParticle; D3DXVECTOR3 ptOut, pt0, pt1, pt2, pt3; float particleCount=0; int prevInd=0, ind=0, nextInd=1, next2Ind=2; do { memcpy((float*)pt0, thisData->Nodes[prevInd].curLoc, sizeof(thisData->Nodes[prevInd].curLoc)); memcpy((float*)pt1, thisData->Nodes[ind].curLoc, sizeof(thisData->Nodes[ind].curLoc)); memcpy((float*)pt2, thisData->Nodes[nextInd].curLoc, sizeof(thisData->Nodes[nextInd].curLoc)); memcpy((float*)pt3, thisData->Nodes[next2Ind].curLoc, sizeof(thisData->Nodes[next2Ind].curLoc)); //cat-mull-rom curve magic D3DXVec3CatmullRom(&ptOut, &pt0, &pt1, &pt2, &pt3, t); //draw the darn thing TextureBltBillboard(thisData->lightningTxt, (float*)ptOut, thisData->scale, thisData->clr); particleCount++; t = particleCount/max; if(t > 1) { ind++; particleCount = 0; t = 0; } prevInd = ind - 1; if(prevInd < 0) prevInd = 0; nextInd = ind + 1; if(nextInd >= thisData->numNodes) nextInd = thisData->numNodes-1; next2Ind = ind + 2; if(next2Ind >= thisData->numNodes) next2Ind = thisData->numNodes-1; } while(ind < thisData->numNodes); } break; case PARFXM_CREATE: { fxLightningY_init *initDat = (fxLightningY_init *)dumbParam; fxLightningY *newData = (fxLightningY *)GFX_MALLOC(sizeof(fxLightningY)); if(!newData) return RETCODE_FAILURE; newData->lightningTxt = initDat->lightningTxt; TextureAddRef(newData->lightningTxt); newData->clr[eR] = initDat->r/255.0f; newData->clr[eG] = initDat->g/255.0f; newData->clr[eB] = initDat->b/255.0f; newData->clr[eA] = 0; newData->scale = initDat->scale; memcpy(newData->min, initDat->min, sizeof(newData->min)); memcpy(newData->max, initDat->max, sizeof(newData->max)); newData->maxParticle = 20;//initDat->maxParticle; TimeInit(&newData->onTimer, initDat->delayOn); TimeReset(&newData->onTimer); newData->delayMove = initDat->delayMove; newData->numNodes = initDat->maxPoint; newData->Nodes = (lightningNode *)GFX_MALLOC(sizeof(lightningNode)*newData->numNodes); if(!newData->Nodes) return RETCODE_FAILURE; //////////////////////////////////////////////////////////////// //initialize the nodes float trans[eMaxPt] = {0}; hOBJ obj = PARFXGetOBJ(thisPARFX); if(obj) { PARFXGetOBJLoc(thisPARFX, obj, trans); } for(int i = 0; i < newData->numNodes; i++) { newData->Nodes[i].sLoc[eX] = _GFXMathRand(newData->min[eX], newData->max[eX]) + trans[eX]; newData->Nodes[i].sLoc[eY] = newData->min[eY] + ((float)i/(float)newData->numNodes)*(newData->max[eY] - newData->min[eY]) + trans[eY]; newData->Nodes[i].sLoc[eZ] = _GFXMathRand(newData->min[eZ], newData->max[eZ]) + trans[eZ]; memcpy(newData->Nodes[i].curLoc, newData->Nodes[i].sLoc, sizeof(newData->Nodes[i].curLoc)); newData->Nodes[i].eLoc[eX] = _GFXMathRand(newData->min[eX], newData->max[eX]) + trans[eX]; newData->Nodes[i].eLoc[eY] = newData->min[eY] + ((float)i/(float)newData->numNodes)*(newData->max[eY] - newData->min[eY]) + trans[eY]; newData->Nodes[i].eLoc[eZ] = _GFXMathRand(newData->min[eZ], newData->max[eZ]) + trans[eZ]; TimeInit(&newData->Nodes[i].timeMove, newData->delayMove); } thisPARFX->data = newData; } break; case PARFXM_DESTROY: { if(thisData) { if(thisData->Nodes) GFX_FREE(thisData->Nodes); if(thisData->lightningTxt) TextureDestroy(&thisData->lightningTxt); } } break; } return RETCODE_SUCCESS; }
int main(int argc, const char *argv[]) { static bool is_daemon; static bool opt_interactive; static bool Fork = true; static bool no_process_group; static bool log_stdout; poptContext pc; char *p_lmhosts = NULL; int opt; enum { OPT_DAEMON = 1000, OPT_INTERACTIVE, OPT_FORK, OPT_NO_PROCESS_GROUP, OPT_LOG_STDOUT }; struct poptOption long_options[] = { POPT_AUTOHELP {"daemon", 'D', POPT_ARG_NONE, NULL, OPT_DAEMON, "Become a daemon(default)" }, {"interactive", 'i', POPT_ARG_NONE, NULL, OPT_INTERACTIVE, "Run interactive (not a daemon)" }, {"foreground", 'F', POPT_ARG_NONE, NULL, OPT_FORK, "Run daemon in foreground (for daemontools & etc)" }, {"no-process-group", 0, POPT_ARG_NONE, NULL, OPT_NO_PROCESS_GROUP, "Don't create a new process group" }, {"log-stdout", 'S', POPT_ARG_NONE, NULL, OPT_LOG_STDOUT, "Log to stdout" }, {"hosts", 'H', POPT_ARG_STRING, &p_lmhosts, 0, "Load a netbios hosts file"}, {"port", 'p', POPT_ARG_INT, &global_nmb_port, 0, "Listen on the specified port" }, POPT_COMMON_SAMBA { NULL } }; TALLOC_CTX *frame; NTSTATUS status; /* * Do this before any other talloc operation */ talloc_enable_null_tracking(); frame = talloc_stackframe(); setup_logging(argv[0], DEBUG_DEFAULT_STDOUT); load_case_tables(); global_nmb_port = NMB_PORT; pc = poptGetContext("nmbd", argc, argv, long_options, 0); while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case OPT_DAEMON: is_daemon = true; break; case OPT_INTERACTIVE: opt_interactive = true; break; case OPT_FORK: Fork = false; break; case OPT_NO_PROCESS_GROUP: no_process_group = true; break; case OPT_LOG_STDOUT: log_stdout = true; break; default: d_fprintf(stderr, "\nInvalid option %s: %s\n\n", poptBadOption(pc, 0), poptStrerror(opt)); poptPrintUsage(pc, stderr, 0); exit(1); } }; poptFreeContext(pc); global_in_nmbd = true; StartupTime = time(NULL); sys_srandom(time(NULL) ^ sys_getpid()); if (!override_logfile) { char *lfile = NULL; if (asprintf(&lfile, "%s/log.nmbd", get_dyn_LOGFILEBASE()) < 0) { exit(1); } lp_set_logfile(lfile); SAFE_FREE(lfile); } fault_setup(); dump_core_setup("nmbd", lp_logfile()); /* POSIX demands that signals are inherited. If the invoking process has * these signals masked, we will have problems, as we won't receive them. */ BlockSignals(False, SIGHUP); BlockSignals(False, SIGUSR1); BlockSignals(False, SIGTERM); #if defined(SIGFPE) /* we are never interested in SIGFPE */ BlockSignals(True,SIGFPE); #endif /* We no longer use USR2... */ #if defined(SIGUSR2) BlockSignals(True, SIGUSR2); #endif if ( opt_interactive ) { Fork = False; log_stdout = True; } if ( log_stdout && Fork ) { DEBUG(0,("ERROR: Can't log to stdout (-S) unless daemon is in foreground (-F) or interactive (-i)\n")); exit(1); } if (log_stdout) { setup_logging(argv[0], DEBUG_STDOUT); } else { setup_logging( argv[0], DEBUG_FILE); } reopen_logs(); DEBUG(0,("nmbd version %s started.\n", samba_version_string())); DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE)); if (!lp_load_initial_only(get_dyn_CONFIGFILE())) { DEBUG(0, ("error opening config file '%s'\n", get_dyn_CONFIGFILE())); exit(1); } if (nmbd_messaging_context() == NULL) { return 1; } if ( !reload_nmbd_services(False) ) return(-1); if(!init_names()) return -1; reload_nmbd_services( True ); if (strequal(lp_workgroup(),"*")) { DEBUG(0,("ERROR: a workgroup name of * is no longer supported\n")); exit(1); } set_samba_nb_type(); if (!is_daemon && !is_a_socket(0)) { DEBUG(0,("standard input is not a socket, assuming -D option\n")); is_daemon = True; } if (is_daemon && !opt_interactive) { DEBUG( 2, ( "Becoming a daemon.\n" ) ); become_daemon(Fork, no_process_group, log_stdout); } #if HAVE_SETPGID /* * If we're interactive we want to set our own process group for * signal management. */ if (opt_interactive && !no_process_group) setpgid( (pid_t)0, (pid_t)0 ); #endif if (nmbd_messaging_context() == NULL) { return 1; } #ifndef SYNC_DNS /* Setup the async dns. We do it here so it doesn't have all the other stuff initialised and thus chewing memory and sockets */ if(lp_we_are_a_wins_server() && lp_dns_proxy()) { start_async_dns(); } #endif if (!directory_exist(lp_lockdir())) { mkdir(lp_lockdir(), 0755); } pidfile_create("nmbd"); status = reinit_after_fork(nmbd_messaging_context(), nmbd_event_context(), procid_self(), false); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("reinit_after_fork() failed\n")); exit(1); } if (!nmbd_setup_sig_term_handler()) exit(1); if (!nmbd_setup_sig_hup_handler()) exit(1); /* get broadcast messages */ if (!serverid_register(procid_self(), FLAG_MSG_GENERAL | FLAG_MSG_NMBD | FLAG_MSG_DBWRAP)) { DEBUG(1, ("Could not register myself in serverid.tdb\n")); exit(1); } messaging_register(nmbd_messaging_context(), NULL, MSG_FORCE_ELECTION, nmbd_message_election); #if 0 /* Until winsrepl is done. */ messaging_register(nmbd_messaging_context(), NULL, MSG_WINS_NEW_ENTRY, nmbd_wins_new_entry); #endif messaging_register(nmbd_messaging_context(), NULL, MSG_SHUTDOWN, nmbd_terminate); messaging_register(nmbd_messaging_context(), NULL, MSG_SMB_CONF_UPDATED, msg_reload_nmbd_services); messaging_register(nmbd_messaging_context(), NULL, MSG_SEND_PACKET, msg_nmbd_send_packet); TimeInit(); DEBUG( 3, ( "Opening sockets %d\n", global_nmb_port ) ); if ( !open_sockets( is_daemon, global_nmb_port ) ) { kill_async_dns_child(); return 1; } /* Determine all the IP addresses we have. */ load_interfaces(); /* Create an nmbd subnet record for each of the above. */ if( False == create_subnets() ) { DEBUG(0,("ERROR: Failed when creating subnet lists. Exiting.\n")); kill_async_dns_child(); exit(1); } /* Load in any static local names. */ if (p_lmhosts) { set_dyn_LMHOSTSFILE(p_lmhosts); } load_lmhosts_file(get_dyn_LMHOSTSFILE()); DEBUG(3,("Loaded hosts file %s\n", get_dyn_LMHOSTSFILE())); /* If we are acting as a WINS server, initialise data structures. */ if( !initialise_wins() ) { DEBUG( 0, ( "nmbd: Failed when initialising WINS server.\n" ) ); kill_async_dns_child(); exit(1); } /* * Register nmbd primary workgroup and nmbd names on all * the broadcast subnets, and on the WINS server (if specified). * Also initiate the startup of our primary workgroup (start * elections if we are setup as being able to be a local * master browser. */ if( False == register_my_workgroup_and_names() ) { DEBUG(0,("ERROR: Failed when creating my my workgroup. Exiting.\n")); kill_async_dns_child(); exit(1); } if (!initialize_nmbd_proxy_logon()) { DEBUG(0,("ERROR: Failed setup nmbd_proxy_logon.\n")); kill_async_dns_child(); exit(1); } if (!nmbd_init_packet_server()) { kill_async_dns_child(); exit(1); } TALLOC_FREE(frame); process(); kill_async_dns_child(); return(0); }
int main(int argc,const char *argv[]) { /* shall I run as a daemon */ bool is_daemon = false; bool interactive = false; bool Fork = true; bool no_process_group = false; bool log_stdout = false; char *ports = NULL; char *profile_level = NULL; int opt; poptContext pc; bool print_build_options = False; enum { OPT_DAEMON = 1000, OPT_INTERACTIVE, OPT_FORK, OPT_NO_PROCESS_GROUP, OPT_LOG_STDOUT }; struct poptOption long_options[] = { POPT_AUTOHELP {"daemon", 'D', POPT_ARG_NONE, NULL, OPT_DAEMON, "Become a daemon (default)" }, {"interactive", 'i', POPT_ARG_NONE, NULL, OPT_INTERACTIVE, "Run interactive (not a daemon)"}, {"foreground", 'F', POPT_ARG_NONE, NULL, OPT_FORK, "Run daemon in foreground (for daemontools, etc.)" }, {"no-process-group", '\0', POPT_ARG_NONE, NULL, OPT_NO_PROCESS_GROUP, "Don't create a new process group" }, {"log-stdout", 'S', POPT_ARG_NONE, NULL, OPT_LOG_STDOUT, "Log to stdout" }, {"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" }, {"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"}, {"profiling-level", 'P', POPT_ARG_STRING, &profile_level, 0, "Set profiling level","PROFILE_LEVEL"}, POPT_COMMON_SAMBA POPT_COMMON_DYNCONFIG POPT_TABLEEND }; struct smbd_parent_context *parent = NULL; TALLOC_CTX *frame; NTSTATUS status; uint64_t unique_id; struct tevent_context *ev_ctx; struct messaging_context *msg_ctx; /* * Do this before any other talloc operation */ talloc_enable_null_tracking(); frame = talloc_stackframe(); setup_logging(argv[0], DEBUG_DEFAULT_STDOUT); load_case_tables(); smbd_init_globals(); TimeInit(); #ifdef HAVE_SET_AUTH_PARAMETERS set_auth_parameters(argc,argv); #endif pc = poptGetContext("smbd", argc, argv, long_options, 0); while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case OPT_DAEMON: is_daemon = true; break; case OPT_INTERACTIVE: interactive = true; break; case OPT_FORK: Fork = false; break; case OPT_NO_PROCESS_GROUP: no_process_group = true; break; case OPT_LOG_STDOUT: log_stdout = true; break; case 'b': print_build_options = True; break; default: d_fprintf(stderr, "\nInvalid option %s: %s\n\n", poptBadOption(pc, 0), poptStrerror(opt)); poptPrintUsage(pc, stderr, 0); exit(1); } } poptFreeContext(pc); if (interactive) { Fork = False; log_stdout = True; } if (log_stdout) { setup_logging(argv[0], DEBUG_STDOUT); } else { setup_logging(argv[0], DEBUG_FILE); } if (print_build_options) { build_options(True); /* Display output to screen as well as debug */ exit(0); } #ifdef HAVE_SETLUID /* needed for SecureWare on SCO */ setluid(0); #endif set_remote_machine_name("smbd", False); if (interactive && (DEBUGLEVEL >= 9)) { talloc_enable_leak_report(); } if (log_stdout && Fork) { DEBUG(0,("ERROR: Can't log to stdout (-S) unless daemon is in foreground (-F) or interactive (-i)\n")); exit(1); } /* we want to re-seed early to prevent time delays causing client problems at a later date. (tridge) */ generate_random_buffer(NULL, 0); /* get initial effective uid and gid */ sec_init(); /* make absolutely sure we run as root - to handle cases where people are crazy enough to have it setuid */ gain_root_privilege(); gain_root_group_privilege(); fault_setup(); dump_core_setup("smbd", lp_logfile()); /* we are never interested in SIGPIPE */ BlockSignals(True,SIGPIPE); #if defined(SIGFPE) /* we are never interested in SIGFPE */ BlockSignals(True,SIGFPE); #endif #if defined(SIGUSR2) /* We are no longer interested in USR2 */ BlockSignals(True,SIGUSR2); #endif /* POSIX demands that signals are inherited. If the invoking process has * these signals masked, we will have problems, as we won't recieve them. */ BlockSignals(False, SIGHUP); BlockSignals(False, SIGUSR1); BlockSignals(False, SIGTERM); /* Ensure we leave no zombies until we * correctly set up child handling below. */ CatchChild(); /* we want total control over the permissions on created files, so set our umask to 0 */ umask(0); reopen_logs(); DEBUG(0,("smbd version %s started.\n", samba_version_string())); DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE)); DEBUG(2,("uid=%d gid=%d euid=%d egid=%d\n", (int)getuid(),(int)getgid(),(int)geteuid(),(int)getegid())); /* Output the build options to the debug log */ build_options(False); if (sizeof(uint16) < 2 || sizeof(uint32) < 4) { DEBUG(0,("ERROR: Samba is not configured correctly for the word size on your machine\n")); exit(1); } if (!lp_load_initial_only(get_dyn_CONFIGFILE())) { DEBUG(0, ("error opening config file '%s'\n", get_dyn_CONFIGFILE())); exit(1); } /* Init the security context and global current_user */ init_sec_ctx(); /* * Initialize the event context. The event context needs to be * initialized before the messaging context, cause the messaging * context holds an event context. * FIXME: This should be s3_tevent_context_init() */ ev_ctx = server_event_context(); if (ev_ctx == NULL) { exit(1); } /* * Init the messaging context * FIXME: This should only call messaging_init() */ msg_ctx = server_messaging_context(); if (msg_ctx == NULL) { exit(1); } /* * Reloading of the printers will not work here as we don't have a * server info and rpc services set up. It will be called later. */ if (!reload_services(NULL, -1, False)) { exit(1); } /* ...NOTE... Log files are working from this point! */ DEBUG(3,("loaded services\n")); init_structs(); #ifdef WITH_PROFILE if (!profile_setup(msg_ctx, False)) { DEBUG(0,("ERROR: failed to setup profiling\n")); return -1; } if (profile_level != NULL) { int pl = atoi(profile_level); struct server_id src; DEBUG(1, ("setting profiling level: %s\n",profile_level)); src.pid = getpid(); set_profile_level(pl, src); } #endif if (!is_daemon && !is_a_socket(0)) { if (!interactive) DEBUG(0,("standard input is not a socket, assuming -D option\n")); /* * Setting is_daemon here prevents us from eventually calling * the open_sockets_inetd() */ is_daemon = True; } if (is_daemon && !interactive) { DEBUG( 3, ( "Becoming a daemon.\n" ) ); become_daemon(Fork, no_process_group, log_stdout); } generate_random_buffer((uint8_t *)&unique_id, sizeof(unique_id)); set_my_unique_id(unique_id); #if HAVE_SETPGID /* * If we're interactive we want to set our own process group for * signal management. */ if (interactive && !no_process_group) setpgid( (pid_t)0, (pid_t)0); #endif if (!directory_exist(lp_lockdir())) mkdir(lp_lockdir(), 0755); if (is_daemon) pidfile_create("smbd"); status = reinit_after_fork(msg_ctx, ev_ctx, procid_self(), false); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("reinit_after_fork() failed\n")); exit(1); } smbd_server_conn->msg_ctx = msg_ctx; smbd_setup_sig_term_handler(); smbd_setup_sig_hup_handler(ev_ctx, msg_ctx); /* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */ if (smbd_memcache() == NULL) { exit(1); } memcache_set_global(smbd_memcache()); /* Initialise the password backed before the global_sam_sid to ensure that we fetch from ldap before we make a domain sid up */ if(!initialize_password_db(false, ev_ctx)) exit(1); if (!secrets_init()) { DEBUG(0, ("ERROR: smbd can not open secrets.tdb\n")); exit(1); } if (lp_server_role() == ROLE_DOMAIN_BDC || lp_server_role() == ROLE_DOMAIN_PDC) { struct loadparm_context *lp_ctx = loadparm_init_s3(NULL, loadparm_s3_context()); if (!open_schannel_session_store(NULL, lp_ctx)) { DEBUG(0,("ERROR: Samba cannot open schannel store for secured NETLOGON operations.\n")); exit(1); } TALLOC_FREE(lp_ctx); } if(!get_global_sam_sid()) { DEBUG(0,("ERROR: Samba cannot create a SAM SID.\n")); exit(1); } if (!sessionid_init()) { exit(1); } if (!connections_init(True)) exit(1); if (!locking_init()) exit(1); if (!messaging_tdb_parent_init(ev_ctx)) { exit(1); } if (!notify_internal_parent_init(ev_ctx)) { exit(1); } if (!serverid_parent_init(ev_ctx)) { exit(1); } if (!W_ERROR_IS_OK(registry_init_full())) exit(1); /* Open the share_info.tdb here, so we don't have to open after the fork on every single connection. This is a small performance improvment and reduces the total number of system fds used. */ if (!share_info_db_init()) { DEBUG(0,("ERROR: failed to load share info db.\n")); exit(1); } status = init_system_info(); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("ERROR: failed to setup system user info: %s.\n", nt_errstr(status))); return -1; } if (!init_guest_info()) { DEBUG(0,("ERROR: failed to setup guest info.\n")); return -1; } if (!file_init(smbd_server_conn)) { DEBUG(0, ("ERROR: file_init failed\n")); return -1; } /* This MUST be done before start_epmd() because otherwise * start_epmd() forks and races against dcesrv_ep_setup() to * call directory_create_or_exist() */ if (!directory_create_or_exist(lp_ncalrpc_dir(), geteuid(), 0755)) { DEBUG(0, ("Failed to create pipe directory %s - %s\n", lp_ncalrpc_dir(), strerror(errno))); return -1; } if (is_daemon && !interactive) { if (rpc_epmapper_daemon() == RPC_DAEMON_FORK) { start_epmd(ev_ctx, msg_ctx); } } if (!dcesrv_ep_setup(ev_ctx, msg_ctx)) { exit(1); } /* only start other daemons if we are running as a daemon * -- bad things will happen if smbd is launched via inetd * and we fork a copy of ourselves here */ if (is_daemon && !interactive) { if (rpc_lsasd_daemon() == RPC_DAEMON_FORK) { start_lsasd(ev_ctx, msg_ctx); } if (!_lp_disable_spoolss() && (rpc_spoolss_daemon() != RPC_DAEMON_DISABLED)) { bool bgq = lp_parm_bool(-1, "smbd", "backgroundqueue", true); if (!printing_subsystem_init(ev_ctx, msg_ctx, true, bgq)) { exit(1); } } } else if (!_lp_disable_spoolss() && (rpc_spoolss_daemon() != RPC_DAEMON_DISABLED)) { if (!printing_subsystem_init(ev_ctx, msg_ctx, false, false)) { exit(1); } } if (!is_daemon) { /* inetd mode */ TALLOC_FREE(frame); /* Started from inetd. fd 0 is the socket. */ /* We will abort gracefully when the client or remote system goes away */ smbd_server_conn->sock = dup(0); /* close our standard file descriptors */ if (!debug_get_output_is_stdout()) { close_low_fds(False); /* Don't close stderr */ } #ifdef HAVE_ATEXIT atexit(killkids); #endif /* Stop zombies */ smbd_setup_sig_chld_handler(ev_ctx); smbd_process(ev_ctx, smbd_server_conn); exit_server_cleanly(NULL); return(0); } parent = talloc_zero(ev_ctx, struct smbd_parent_context); if (!parent) { exit_server("talloc(struct smbd_parent_context) failed"); } parent->interactive = interactive; if (!open_sockets_smbd(parent, ev_ctx, msg_ctx, ports)) exit_server("open_sockets_smbd() failed"); /* do a printer update now that all messaging has been set up, * before we allow clients to start connecting */ printing_subsystem_update(ev_ctx, msg_ctx, false); TALLOC_FREE(frame); /* make sure we always have a valid stackframe */ frame = talloc_stackframe(); smbd_parent_loop(ev_ctx, parent); exit_server_cleanly(NULL); TALLOC_FREE(frame); return(0); }
void main() { task* TI1; task* TI2; char* Data; char* Encoded; register unsigned int i; _asm; di ld sp,#0xffff ld a,#0x0 ld bc,#0x0 ld de,#0x0 ld hl,#0x0 ld ix,#0x0 ld iy,#0x0 _endasm; _SimWriteProtect((void*)0x0000, (void*)0x3fff); _SimPrintString("\n-------------------\n"); _SimPrintString("System reset\n"); _SimPrintString("-------------------\n"); IntsOff(); _SimPrintString("Interrupts disabled. Booting...\n"); TestMemory(); HardwareInit(); LocksInit(); SchedulingInit(); SupervisorMode(); TimeInit(); SystemInit(); MemoryInit(); //KeyboardInit(); //TapeInit(); ConsoleInit(); ConsoleWrite("LJL OS 0.1 FOR ZX SPECTRUM 48\n"); ConsoleWrite("\nCONSOLE OUTPUT\n\n"); /* TapeSave((void*)0x4000, (void*)0x5800); TapeLoad((void*)0x4000, (void*)0x5800); for(i=0; i<0x4000; i+=0x100) { ConsoleWrite("."); SaveBlock((void*)i); } Halt("Saved"); */ MainEntry=Task1; TI1=CreateTask(MainEntry, 100); MainEntry=Task2; TI2=CreateTask(MainEntry, 100); ConsoleWrite("TASKS CREATED\n"); SetScheduler(DefaultScheduler); ConsoleWrite("SCHEDULER SET\n"); Resume(); //ConsoleWrite("RESUMING\n"); //if(!IsMultitasking()) Halt("NOT MULTITASKING"); for(;;); Halt("SYSTEM SHUTDOWN"); }
/**************************************************************************** ** main program **************************************************************************** */ int main(int argc, const char *argv[]) { pstring logfile; static BOOL opt_interactive; poptContext pc; static char *p_lmhosts = dyn_LMHOSTSFILE; static BOOL no_process_group = False; struct poptOption long_options[] = { POPT_AUTOHELP {"daemon", 'D', POPT_ARG_VAL, &is_daemon, True, "Become a daemon(default)" }, {"interactive", 'i', POPT_ARG_VAL, &opt_interactive, True, "Run interactive (not a daemon)" }, {"foreground", 'F', POPT_ARG_VAL, &Fork, False, "Run daemon in foreground (for daemontools & etc)" }, {"no-process-group", 0, POPT_ARG_VAL, &no_process_group, True, "Don't create a new process group" }, {"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" }, {"hosts", 'H', POPT_ARG_STRING, &p_lmhosts, 'H', "Load a netbios hosts file"}, {"port", 'p', POPT_ARG_INT, &global_nmb_port, NMB_PORT, "Listen on the specified port" }, POPT_COMMON_SAMBA { NULL } }; load_case_tables(); global_nmb_port = NMB_PORT; pc = poptGetContext("nmbd", argc, argv, long_options, 0); while (poptGetNextOpt(pc) != -1) {}; poptFreeContext(pc); global_in_nmbd = True; StartupTime = time(NULL); sys_srandom(time(NULL) ^ sys_getpid()); if (!override_logfile) { slprintf(logfile, sizeof(logfile)-1, "%s/log.nmbd", dyn_LOGFILEBASE); lp_set_logfile(logfile); } fault_setup((void (*)(void *))fault_continue ); dump_core_setup("nmbd"); /* POSIX demands that signals are inherited. If the invoking process has * these signals masked, we will have problems, as we won't receive them. */ BlockSignals(False, SIGHUP); BlockSignals(False, SIGUSR1); BlockSignals(False, SIGTERM); CatchSignal( SIGHUP, SIGNAL_CAST sig_hup ); CatchSignal( SIGTERM, SIGNAL_CAST sig_term ); #if defined(SIGFPE) /* we are never interested in SIGFPE */ BlockSignals(True,SIGFPE); #endif /* We no longer use USR2... */ #if defined(SIGUSR2) BlockSignals(True, SIGUSR2); #endif if ( opt_interactive ) { Fork = False; log_stdout = True; } if ( log_stdout && Fork ) { DEBUG(0,("ERROR: Can't log to stdout (-S) unless daemon is in foreground (-F) or interactive (-i)\n")); exit(1); } setup_logging( argv[0], log_stdout ); reopen_logs(); DEBUG( 0, ( "Netbios nameserver version %s started.\n", SAMBA_VERSION_STRING) ); DEBUGADD( 0, ( "%s\n", COPYRIGHT_STARTUP_MESSAGE ) ); if ( !reload_nmbd_services(False) ) return(-1); if(!init_names()) return -1; reload_nmbd_services( True ); if (strequal(lp_workgroup(),"*")) { DEBUG(0,("ERROR: a workgroup name of * is no longer supported\n")); exit(1); } set_samba_nb_type(); if (!is_daemon && !is_a_socket(0)) { DEBUG(0,("standard input is not a socket, assuming -D option\n")); is_daemon = True; } if (is_daemon && !opt_interactive) { DEBUG( 2, ( "Becoming a daemon.\n" ) ); become_daemon(Fork, no_process_group); } #if HAVE_SETPGID /* * If we're interactive we want to set our own process group for * signal management. */ if (opt_interactive && !no_process_group) setpgid( (pid_t)0, (pid_t)0 ); #endif #ifndef SYNC_DNS /* Setup the async dns. We do it here so it doesn't have all the other stuff initialised and thus chewing memory and sockets */ if(lp_we_are_a_wins_server() && lp_dns_proxy()) { start_async_dns(); } #endif if (!directory_exist(lp_lockdir(), NULL)) { mkdir(lp_lockdir(), 0755); } pidfile_create("nmbd"); message_init(); message_register(MSG_FORCE_ELECTION, nmbd_message_election, NULL); #if 0 /* Until winsrepl is done. */ message_register(MSG_WINS_NEW_ENTRY, nmbd_wins_new_entry, NULL); #endif message_register(MSG_SHUTDOWN, nmbd_terminate, NULL); message_register(MSG_SMB_CONF_UPDATED, msg_reload_nmbd_services, NULL); message_register(MSG_SEND_PACKET, msg_nmbd_send_packet, NULL); TimeInit(); DEBUG( 3, ( "Opening sockets %d\n", global_nmb_port ) ); if ( !open_sockets( is_daemon, global_nmb_port ) ) { kill_async_dns_child(); return 1; } /* Determine all the IP addresses we have. */ load_interfaces(); /* Create an nmbd subnet record for each of the above. */ if( False == create_subnets() ) { DEBUG(0,("ERROR: Failed when creating subnet lists. Exiting.\n")); kill_async_dns_child(); exit(1); } /* Load in any static local names. */ load_lmhosts_file(p_lmhosts); DEBUG(3,("Loaded hosts file %s\n", p_lmhosts)); /* If we are acting as a WINS server, initialise data structures. */ if( !initialise_wins() ) { DEBUG( 0, ( "nmbd: Failed when initialising WINS server.\n" ) ); kill_async_dns_child(); exit(1); } /* * Register nmbd primary workgroup and nmbd names on all * the broadcast subnets, and on the WINS server (if specified). * Also initiate the startup of our primary workgroup (start * elections if we are setup as being able to be a local * master browser. */ if( False == register_my_workgroup_and_names() ) { DEBUG(0,("ERROR: Failed when creating my my workgroup. Exiting.\n")); kill_async_dns_child(); exit(1); } /* We can only take signals in the select. */ BlockSignals( True, SIGTERM ); process(); if (dbf) x_fclose(dbf); kill_async_dns_child(); return(0); }
int main(int argc, char *argv[]) { FILE *f; pstring fname; int uid, c; static pstring servicesf = CONFIGFILE; extern char *optarg; int verbose = 0, brief =0; BOOL processes_only=False; int last_pid=0; struct session_record *ptr; TimeInit(); setup_logging(argv[0],True); charset_initialise(); DEBUGLEVEL = 0; dbf = fopen("/dev/null","w"); if (getuid() != geteuid()) { printf("smbstatus should not be run setuid\n"); return(1); } while ((c = getopt(argc, argv, "pds:u:b")) != EOF) { switch (c) { case 'b': brief = 1; break; case 'd': verbose = 1; break; case 'p': processes_only = 1; break; case 's': pstrcpy(servicesf, optarg); break; case 'u': /* added by OH */ Ucrit_addUsername(optarg); /* added by OH */ break; default: fprintf(stderr, "Usage: %s [-d] [-p] [-s configfile] [-u username]\n", *argv); /* changed by OH */ return (-1); } } get_myname(myhostname, NULL); if (!lp_load(servicesf,False)) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf); return (-1); } if (verbose) { printf("using configfile = %s\n", servicesf); printf("lockdir = %s\n", *lp_lockdir() ? lp_lockdir() : "NULL"); } pstrcpy(fname,lp_lockdir()); standard_sub_basic(fname); trim_string(fname,"","/"); pstrcat(fname,"/STATUS..LCK"); f = fopen(fname,"r"); if (!f) { printf("Couldn't open status file %s\n",fname); if (!lp_status(-1)) printf("You need to have status=yes in your smb config file\n"); return(0); } else if (verbose) { printf("Opened status file %s\n", fname); } uid = getuid(); if (!processes_only) { printf("\nSamba version %s\n",VERSION); if (brief) { printf("PID Username Machine Time logged in\n"); printf("-------------------------------------------------------------------\n"); } else { printf("Service uid gid pid machine\n"); printf("----------------------------------------------\n"); } } while (!feof(f)) { if (fread(&crec,sizeof(crec),1,f) != 1) break; if ( crec.magic == 0x280267 && process_exists(crec.pid) && Ucrit_checkUsername(uidtoname(crec.uid)) /* added by OH */ ) { if (brief) { ptr=srecs; while (ptr!=NULL) { if ((ptr->pid==crec.pid)&&(strncmp(ptr->machine,crec.machine,30)==0)) { if (ptr->start > crec.start) ptr->start=crec.start; break; } ptr=ptr->next; } if (ptr==NULL) { ptr=(struct session_record *) malloc(sizeof(struct session_record)); ptr->uid=crec.uid; ptr->pid=crec.pid; ptr->start=crec.start; strncpy(ptr->machine,crec.machine,30); ptr->machine[30]='\0'; ptr->next=srecs; srecs=ptr; } } else { Ucrit_addPid(crec.pid); /* added by OH */ if (processes_only) { if (last_pid != crec.pid) printf("%d\n",crec.pid); last_pid = crec.pid; /* XXXX we can still get repeats, have to add a sort at some time */ } else printf("%-10.10s %-8s %-8s %5d %-8s (%s) %s", crec.name,uidtoname(crec.uid),gidtoname(crec.gid),crec.pid, crec.machine,crec.addr, asctime(LocalTime(&crec.start))); } } } fclose(f); if (processes_only) exit(0); if (brief) { ptr=srecs; while (ptr!=NULL) { printf("%-8d%-10.10s%-30.30s%s",ptr->pid,uidtoname(ptr->uid),ptr->machine,asctime(LocalTime(&(ptr->start)))); ptr=ptr->next; } printf("\n"); exit(0); } printf("\n"); locking_init(1); if (share_mode_forall(print_share_mode) <= 0) printf("No locked files\n"); printf("\n"); share_status(stdout); locking_end(); return (0); }
PROTECTED RETCODE fx3DExplodeFunc(hPARFX thisPARFX, DWORD message, LPARAM dumbParam, WPARAM otherParam) { fx3DExplode *thisData = (fx3DExplode *)thisPARFX->data; switch(message) { case PARFXM_UPDATE: { double tDelay = TimeGetTime(&thisData->delayTimer)/TimeGetDelay(&thisData->delayTimer); if(tDelay <= 1) { float pt[eMaxPt], vec[eMaxPt], fDir[eMaxPt], normal[eMaxPt], t = 1; //update alpha float alpha = MAX_3DEXPLODE_ALPHA - tDelay; for(int i = 0; i < thisData->maxParticle; i++) { //set the diffuse material GFXMATERIAL mat; for(int iMat = 0; iMat < OBJGetNumMaterial(thisData->particles[i].obj); iMat++) { OBJGetMaterial(thisData->particles[i].obj, iMat, &mat); mat.Diffuse.a = alpha; OBJSetMaterial(thisData->particles[i].obj, iMat, &mat); } //update particle 'X' direction thisData->particles[i].xDir[eX] += thisData->dirAcc[eX]; thisData->particles[i].xDir[eY] += thisData->dirAcc[eY]; thisData->particles[i].xDir[eZ] += thisData->dirAcc[eZ]; //move the object fDir[eX] = thisData->particles[i].dir[eX]*thisData->spd + thisData->particles[i].xDir[eX]; fDir[eY] = thisData->particles[i].dir[eY]*thisData->spd + thisData->particles[i].xDir[eY]; fDir[eZ] = thisData->particles[i].dir[eZ]*thisData->spd + thisData->particles[i].xDir[eZ]; OBJTranslate(thisData->particles[i].obj, fDir, true); OBJGetLoc(thisData->particles[i].obj, pt); vec[eX] = pt[eX] - thisData->particles[i].orgLoc[eX]; vec[eY] = pt[eY] - thisData->particles[i].orgLoc[eY]; vec[eZ] = pt[eZ] - thisData->particles[i].orgLoc[eZ]; if(PARFXCollision(thisPARFX, thisData->particles[i].orgLoc, pt, &t, normal)) { //bounce off float nd = normal[eX]*fDir[eX] + normal[eY]*fDir[eY] + normal[eZ]*fDir[eZ]; D3DXVECTOR3 refl; refl.x = fDir[eX] - (2*nd*normal[eX]); refl.y = fDir[eY] - (2*nd*normal[eY]); refl.z = fDir[eZ] - (2*nd*normal[eZ]); D3DXVec3Normalize(&refl, &refl); thisData->particles[i].dir[eX] = refl.x; thisData->particles[i].dir[eY] = refl.y; thisData->particles[i].dir[eZ] = refl.z; //set the object location pt[eX] = thisData->particles[i].orgLoc[eX] + t*vec[eX]; pt[eY] = thisData->particles[i].orgLoc[eY] + t*vec[eY]; pt[eZ] = thisData->particles[i].orgLoc[eZ] + t*vec[eZ]; OBJTranslate(thisData->particles[i].obj, pt, false); memcpy(thisData->particles[i].xDir, thisData->dir, sizeof(thisData->dir)); } } } else return RETCODE_BREAK; } break; case PARFXM_DISPLAY: { PARFXUnPrepare(); for(int i = 0; i < thisData->maxParticle; i++) { OBJUpdateFrame(thisData->particles[i].obj); OBJDisplay(thisData->particles[i].obj); } PARFXPrepare(); } break; case PARFXM_CREATE: { fx3DExplode_init *initDat = (fx3DExplode_init *)dumbParam; fx3DExplode *newData = (fx3DExplode *)GFX_MALLOC(sizeof(fx3DExplode)); if(!newData) return RETCODE_FAILURE; //fill-in stuff newData->spd = initDat->spd; memcpy(newData->dir, initDat->dir, sizeof(initDat->dir)); memcpy(newData->dirAcc, initDat->dirAcc, sizeof(initDat->dirAcc)); TimeInit(&newData->delayTimer, initDat->delay); newData->maxParticle = initDat->maxParticle; //allocate particles newData->particles = (fx3DExplodePar *)GFX_MALLOC(sizeof(fx3DExplodePar)*newData->maxParticle); if(!newData) return RETCODE_FAILURE; float center[eMaxPt] = {0}; hOBJ obj = PARFXGetOBJ(thisPARFX); if(obj) PARFXGetOBJLoc(thisPARFX, obj, center); else memcpy(center, initDat->center, sizeof(center)); D3DXVECTOR3 dir; //initialize particles for(int i = 0; i < newData->maxParticle; i++) { newData->particles[i].orgLoc[eX] = _GFXMathRand(initDat->min[eX], initDat->max[eX])+center[eX]; newData->particles[i].orgLoc[eY] = _GFXMathRand(initDat->min[eY], initDat->max[eY])+center[eY]; newData->particles[i].orgLoc[eZ] = _GFXMathRand(initDat->min[eZ], initDat->max[eZ])+center[eZ]; newData->particles[i].obj = OBJCreate(0, initDat->mdl, newData->particles[i].orgLoc[eX], newData->particles[i].orgLoc[eY], newData->particles[i].orgLoc[eZ], eOBJ_STILL, 0); OBJActivate(newData->particles[i].obj, false); dir.x = _GFXMathRand(-1, 1); dir.y = _GFXMathRand(-1, 1); dir.z = _GFXMathRand(-1, 1); D3DXVec3Normalize(&dir, &dir); newData->particles[i].dir[eX] = dir.x; newData->particles[i].dir[eY] = dir.y; newData->particles[i].dir[eZ] = dir.z; memcpy(newData->particles[i].xDir, newData->dir, sizeof(newData->dir)); } thisPARFX->data = newData; } break; case PARFXM_DESTROY: if(thisData) { } break; } return RETCODE_SUCCESS; }
long FAR PASCAL WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; RECT rect; switch(message) { case WM_CREATE: ghDC = GetDC(hWnd); if (!bSetupPixelFormat(ghDC)) PostQuitMessage (0); ghRC = wglCreateContext(ghDC); if (!ghRC) { MessageBox(NULL, "Could not initialize GL", "ERROR", MB_OK); PostQuitMessage (0); } if (!wglMakeCurrent(ghDC, ghRC)) { MessageBox(NULL, "wglMakeCurrent failed", "ERROR", MB_OK); PostQuitMessage (0); } GetClientRect(hWnd, &rect); initializeGL(rect.right, rect.bottom); // Other Initialisation should go here initText(); TimeInit(); TerrainInit("hmap.raw"); break; case WM_PAINT: ghDC = BeginPaint(hWnd, &ps); EndPaint(hWnd, &ps); return TRUE; case WM_SIZE: GetClientRect(hWnd, &rect); resize(rect.right, rect.bottom); break; case WM_CLOSE: if (ghRC) wglDeleteContext(ghRC); if (ghDC) ReleaseDC(hWnd, ghDC); ghRC = 0; ghDC = 0; DestroyWindow (hWnd); break; case WM_DESTROY: if (ghRC) wglDeleteContext(ghRC); if (ghDC) ReleaseDC(hWnd, ghDC); PostQuitMessage (0); break; case WM_KEYDOWN: KeyDown(wParam); break; } return DefWindowProc(hWnd, message, wParam, lParam); }