void static_lifetime_init( const contextt &context, codet &dest) { dest=code_blockt(); // Do assignments based on "value". context.foreach_operand_in_order( [&dest] (const symbolt& s) { if(s.static_lifetime) init_variable(dest, s); } ); // call designated "initialization" functions context.foreach_operand_in_order( [&dest] (const symbolt& s) { if(s.type.initialization() && s.type.is_code()) { code_function_callt function_call; function_call.function() = symbol_expr(s); dest.move_to_operands(function_call); } } ); }
// nalezy uwazac, gdy wykonujemy shella który ma kontrole pracy i jest wolany z innego shell, ktory ma swoja kontrole pracy void initShell() { firstGroup = NULL; // deskryptor pliku dla standardowego wejscia shellTerminal = STDIN_FILENO; init_variable(); struct sigaction act; act.sa_handler = SIG_IGN; /* set up signal handler */ act.sa_flags = 0; // kiedy shell przejmuje kontrole, powinien ignorowac ponizsze sygnaly, zeby samemu sie przypadkowo nie killnac sigaction(SIGINT, &act, NULL); sigaction(SIGQUIT, &act, NULL); sigaction(SIGCHLD, &act, NULL); sigaction(SIGTSTP, &act, NULL); sigaction(SIGTTIN, &act, NULL); sigaction(SIGTTOU, &act, NULL); // stworzenie nowej grupy, nowe procesy beda do niej nalezaly shellPGID = getpid (); setpgid (0, shellPGID); // przejecie kontroli nad terminalem tcsetpgrp (shellTerminal, shellPGID); // zapisanie domyslnych atrybutow terminala dla shella tcgetattr (shellTerminal, &shellModes); }
void mysh_param(char **env, t_struct *pile) { int flag; int n; n = 0; flag = 0; pile->my_env = 0; pile->hist = 0; pile->save_cd = 0; while (env[n] != 0) { if (env[n] != 0 && my_strncmp(PWD, env[n], 3) == 0) catch_pwd(env[n], pile); add_elem_to_liste(env[n], &pile->my_env); n++; if (env[n] != 0) flag = 1; } if (flag == 1) while (pile->my_env->prev) pile->my_env = pile->my_env->prev; pile->home = my_aff_param_list(pile->my_env, HOME); init_variable(pile); fichier_conf(pile); aff_prompt(pile); }
static void play_event_prescan(void *p) { MidiEvent *ev = (MidiEvent *)p; int ch; for(ch = 0; ch < MAX_CHANNELS; ch++){ if(note_channel[ch] != NULL){ NADisposeNoteChannel(gNoteAllocator, note_channel[ch]); note_channel[ch] = NULL; } instrument_number[ch] = -1; instrument_name[ch][0] = '\0'; drum_part[ch] = false; channel[ch].bank_lsb = 0; channel[ch].bank_msb = 0; } drum_part[9] = true; for(;; ev++){ ch = ev->channel; if(ev->type == ME_NOTEON && note_channel[ch] == NULL){ //MidiEvent *ev; ev->channel = ch; ev->a = 0; set_instrument(ev); } else if(ev->type == ME_PROGRAM){ set_instrument(ev); } else if(ev->type == ME_TONE_BANK_LSB && ev->a != channel[ch].bank_lsb){ channel[ch].bank_lsb = ev->a; } else if(ev->type == ME_TONE_BANK_MSB && ev->a != channel[ch].bank_msb){ channel[ch].bank_msb = ev->a; if(play_system_mode == XG_SYSTEM_MODE && (ev->a == 126 || ev->a == 127) && !drum_part[ch]) drum_part[ch] = true; } else if(ev->type == ME_DRUMPART && !drum_part[ch]){ //MidiEvent *ev; ev->channel = ch; ev->a = channel[ch].program; set_instrument(ev); drum_part[ch] = true; } else if(ev->type == ME_RESET){ play_system_mode = ev->a; } else if(ev->type == ME_EOT){ prescan = 1; for(ch = 0; ch < MAX_CHANNELS; ch++){ channel[ch].bank_lsb = 0; channel[ch].bank_msb = 0; } init_variable(); break; } } }
variable flux_flush_state(opts o,interpreter *i) { variable v=init_variable(); int buf=0; if (i->cast_int(&buf,o,0)) v=i->double_variable(flush_state(buf)); return v; }
variable flux_flush_buffer(opts o,interpreter *i) { variable v=init_variable(); int buf=0; if (i->cast_int(&buf,o,0)) flush_buffer(buf); return v; }
variable flux_set_style(opts o,interpreter *i) { variable v=init_variable(); int buffer=0; int style=0; if (i->cast_int(&buffer,o,0) && i->cast_int(&style,o,1)) set_style(buffer,style); return v; }
variable flux_load_buffer(opts o,interpreter *i) { variable v=init_variable(); int buf=0; char *str; if (i->cast_int(&buf,o,0) && i->cast_string(&str,o,1)) load_buffer(str,buf); return v; }
variable flux_buffer_new_series(opts o,interpreter *i) { variable v=init_variable(); int b=0; if (i->cast_int(&b,o,0)) { buffer_new_series(b); } return v; }
variable flux_buffer_length(opts o,interpreter *i) { variable v=init_variable(); int b=0; if (i->cast_int(&b,o,0)) { return i->int_variable(buffer_length(b)); } return v; }
variable math_sqrt(opts o,interpreter *i) { double arg=0.0; variable v=init_variable(); if (i->cast_double(&arg,o,0)) { v=i->double_variable(sqrt(arg)); } return v; }
static plc_t init_values(int operand, const variable_t var, plc_t plc){ char * val = NULL; if((val = get_param_val("VALUE", var->params))){ return init_variable(plc, operand, var->index, val); } return plc; }
//This plots a graph using gnuplot variable flux_plot_graph(opts o,interpreter *i) { variable v=init_variable(); int buffer=0; char *filename=NULL; if (i->cast_int(&buffer,o,0) && i->cast_string(&filename,o,1)) { plot_graph(buffer,filename); } return v; }
variable flux_approx(opts o,interpreter *i) { variable v=init_variable(); int b=0; double x=0.0; if (i->cast_int(&b,o,0) && i->cast_double(&x,o,1)) { return i->double_variable(approx(b,x)); } return v; }
variable flux_set_flush(opts o,interpreter *i) { variable v=init_variable(); int buf=0; int state=0; if (i->cast_int(&buf,o,0) && i->cast_int(&state,o,1)) { set_flush(buf,state); } return v; }
variable flux_write_buffer(opts o,interpreter *i) { variable v=init_variable(); int buffer=0; char *ptr; if (i->cast_int(&buffer,o,0) && i->cast_string(&ptr,o,1)) { write_buffer(ptr,buffer); } return v; }
variable flux_get_value(opts o,interpreter *i) { variable v=init_variable(); int b=0; int m=0; int x=0; if (i->cast_int(&b,o,0) && i->cast_int(&m,o,1) && i->cast_int(&x,o,2)) { return i->double_variable(get_value(b,m,x)); } return v; }
variable flux_buffer_flip(opts o,interpreter *i) { variable v=init_variable(); int b=0; int x=0; int y=0; if (i->cast_int(&b,o,0) && i->cast_int(&x,o,1) && i->cast_int(&y,o,2)) { flip_xy(b,x,y); } return v; }
variable flux_set_value(opts o,interpreter *i) { variable v=init_variable(); int b=0; int m=0; int x=0; double y; if (i->cast_int(&b,o,0) && i->cast_int(&m,o,1) && i->cast_int(&x,o,2) && i->cast_double(&y,o,3)) { set_value(b,m,x,y); } return v; }
int main(int argc, char** argv) { unsigned short int udpPort; if(argc != 3) { fprintf(stderr, "usage: %s UDP_port filename_to_write\n\n", argv[0]); exit(1); } init_variable(); udpPort = (unsigned short int)atoi(argv[1]); bind_udp(udpPort); reliablyReceive(udpPort, argv[2]); }
variable flux_add_value(opts o,interpreter *i) { variable v=init_variable(); double x=0.0; double y=0.0; double z=0.0; int buf=-1; if (i->cast_int(&buf,o,0) && i->cast_double(&x,o,1) && i->cast_double(&y,o,2)) { if (i->cast_double(&z,o,3)) buffer_add_value(buf,x,y,z); else buffer_add_value(buf,x,y); } return v; }
variable flux_new_buffer(opts o,interpreter *i) { int buf=0; char *str; char *filename; variable v=init_variable(); if (i->cast_string(&str,o,0)) { if (i->cast_string(&filename,o,1)) v=i->int_variable((buf=new_buffer(str,filename))); else v=i->int_variable((buf=new_buffer(str))); } else v=i->int_variable((buf=new_buffer())); return v; }
/* Creates a variable named NAME in dictionary DICT having type TYPE (ALPHA or NUMERIC) and, if type==ALPHA, width WIDTH. Returns a pointer to the newly created variable if successful. On failure (which indicates that a variable having the specified name already exists), returns NULL. */ struct variable * create_variable (struct dictionary *dict, const char *name, int type, int width) { if (find_dict_variable (dict, name)) return NULL; { struct variable *new_var; dict->var = Realloc (dict->var, dict->nvar + 1, struct variable *); new_var = dict->var[dict->nvar] = Calloc (1, struct variable); new_var->index = dict->nvar; dict->nvar++; init_variable (dict, new_var, name, type, width); return new_var; } }
//This is a very important function. It writes all registered buffers, all variables and the command history to the directory specified in the first argument. Also, it generates eps-files from the switching histogram buffer and log-normalized escape rate buffer. variable flux_write_all_data(opts o,interpreter *i) { char *s; char *vars; FILE *f; char buffer[1024]; variable v=init_variable(); if (i->cast_string(&s,o,0)) { sprintf(buffer,"mkdir \"./data/%s\"",s); system(buffer); sprintf(buffer,"./data/%s/history.ini",s); f=fopen(buffer,"w"); if(f==NULL) return v; if (i->get_history()!=NULL) fwrite((void *)(i->get_history()),strlen((i->get_history()))+1,1,f); fclose(f); for(int x=0;x<n_buffers();x++) { if (buffer_filename(x)!=NULL && buffer_empty(x)==0) { sprintf(buffer,"write_buffer(%d,\"./data/%s/%s\");",x,s,buffer_filename(x)); i->eval_str(buffer,1); sprintf(buffer,"plot_buffer(%d,\"./data/%s/%s.eps\");",x,s,buffer_filename(x)); i->eval_str(buffer,1); } } sprintf(buffer,"./data/%s/vars.ini",s); f=fopen(buffer,"w"); if(f==NULL) return v; vars=i->output_all_variables(); fwrite((void *)vars,strlen(vars),1,f); fclose(f); free(vars); } return v; }
static int acntl(int request, void *arg) { int rc, ch; switch(request) { case PM_REQ_MIDI: if(!prescan) play_event_prescan(arg); rc = wait_event_time(arg); if(RC_IS_SKIP_FILE(rc)) return rc; qt_play_event(arg); return RC_NONE; case PM_REQ_INST_NAME: ch = (int)*(char **)arg; *(char **)arg = instrument_name[ch]; return 0; case PM_REQ_GETSAMPLES: *(int32 *)arg = current_samples(); return 0; case PM_REQ_PLAY_START: init_variable(); case PM_REQ_DISCARD: case PM_REQ_FLUSH: for(ch = 0; ch < MAX_CHANNELS; ch++){ if(note_channel[ch] != NULL){ NADisposeNoteChannel(gNoteAllocator, note_channel[ch]); note_channel[ch] = NULL; } channel[ch].bank_lsb = 0; channel[ch].bank_msb = 0; } trace_flush(); return 0; } return -1; }
int main(int argc,char **argv) { INFO(char *dbg="Main(init): "); native_startup(argc, argv); /*** init modules ***/ INFO(printf("%sSharedMemory\n",dbg)); init_sharedmem(&dope); INFO(printf("%sTimer\n",dbg)); init_timer(&dope); INFO(printf("%sTick\n",dbg)); init_tick(&dope); INFO(printf("%sRelax\n",dbg)); init_relax(&dope); INFO(printf("%sKeymap\n",dbg)); init_keymap(&dope); INFO(printf("%sThread\n",dbg)); init_thread(&dope); INFO(printf("%sCache\n",dbg)); init_cache(&dope); INFO(printf("%sHashTable\n",dbg)); init_hashtable(&dope); INFO(printf("%sApplication Manager\n",dbg)); init_appman(&dope); INFO(printf("%sTokenizer\n",dbg)); init_tokenizer(&dope); INFO(printf("%sMessenger\n",dbg)); init_messenger(&dope); INFO(printf("%sScript\n",dbg)); init_script(&dope); INFO(printf("%sClipping\n",dbg)); init_clipping(&dope); INFO(printf("%sScreen Driver\n",dbg)); init_scrdrv(&dope); INFO(printf("%sInput\n",dbg)); init_input(&dope); INFO(printf("%sViewManager\n",dbg)); init_viewman(&dope); INFO(printf("%sConvertFNT\n",dbg)); init_conv_fnt(&dope); INFO(printf("%sFontManager\n",dbg)); init_fontman(&dope); INFO(printf("%sGfxScreen16\n",dbg)); init_gfxscr16(&dope); INFO(printf("%sGfxImage16\n",dbg)); init_gfximg16(&dope); INFO(printf("%sGfxImage32\n",dbg)); init_gfximg32(&dope); INFO(printf("%sGfxImageYUV420\n",dbg)); init_gfximgyuv420(&dope); INFO(printf("%sGfx\n",dbg)); init_gfx(&dope); INFO(printf("%sRedrawManager\n",dbg)); init_redraw(&dope); INFO(printf("%sUserState\n",dbg)); init_userstate(&dope); INFO(printf("%sWidgetManager\n",dbg)); init_widman(&dope); INFO(printf("%sScope\n",dbg)); init_scope(&dope); INFO(printf("%sButton\n",dbg)); init_button(&dope); INFO(printf("%sEntry\n",dbg)); init_entry(&dope); INFO(printf("%sVariable\n",dbg)); init_variable(&dope); INFO(printf("%sLabel\n",dbg)); init_label(&dope); INFO(printf("%sLoadDisplay\n",dbg)); init_loaddisplay(&dope); INFO(printf("%sBackground\n",dbg)); init_background(&dope); INFO(printf("%sScrollbar\n",dbg)); init_scrollbar(&dope); INFO(printf("%sScale\n",dbg)); init_scale(&dope); INFO(printf("%sFrame\n",dbg)); init_frame(&dope); INFO(printf("%sContainer\n",dbg)); init_container(&dope); INFO(printf("%sGrid\n",dbg)); init_grid(&dope); INFO(printf("%sWinLayout\n",dbg)); init_winlayout(&dope); INFO(printf("%sWindow\n",dbg)); init_window(&dope); INFO(printf("%sScreen\n",dbg)); init_screen(&dope); INFO(printf("%sScheduler\n",dbg)); if (config_don_scheduler) { // init_don_scheduler(&dope); printf("NOOOOOOOOOOOOOOOOOOO\n"); } else init_simple_scheduler(&dope); INFO(printf("%sVScreenServer\n",dbg)); init_vscr_server(&dope); INFO(printf("%sVScreen\n",dbg)); init_vscreen(&dope); INFO(printf("%sVTextScreen\n",dbg)); init_vtextscreen(&dope); INFO(printf("%sServer\n",dbg)); init_server(&dope); INFO(printf("%screate screen\n",dbg)); { static GFX_CONTAINER *scr_ds; gfx = pool_get("Gfx 1.0"); screen = pool_get("Screen 1.0"); userstate = pool_get("UserState 1.0"); scr_ds = gfx->alloc_scr("default"); curr_scr = screen->create(); curr_scr->scr->set_gfx(curr_scr, scr_ds); userstate->set_max_mx(gfx->get_width(scr_ds)); userstate->set_max_my(gfx->get_height(scr_ds)); } INFO(printf("%sstarting server\n",dbg)); if ((server = pool_get("Server 1.0"))) server->start(); INFO(printf("%sstarting scheduler\n",dbg)); if ((sched = pool_get("Scheduler 1.0"))) sched->process_mainloop(); return 0; }
BallNode::BallNode(Quaternion orientation, Vector3 position) { m_orientation = orientation; m_position = position; init_variable(); }
BallNode::BallNode(void) { target = NULL; init_variable(); }
static int acntl(int request, void *arg) { switch (request){ case PM_REQ_GETFRAGSIZ: *((int *)arg) = BUFLEN; return 0; //case PM_REQ_GETQSIZ: if (total_bytes == -1) return -1; *((int *)arg) = sizeof(globals.buffer); return 0; /*case PM_REQ_GETFILLABLE: if (total_bytes == -1) return -1; if(!(dpm.encoding & PE_MONO)) i >>= 1; if(dpm.encoding & PE_16BIT) i >>= 1; *((int *)arg) = i; return 0;*/ /*case PM_REQ_GETFILLED: i = pstatus.queue; if(!(dpm.encoding & PE_MONO)) i >>= 1; if(dpm.encoding & PE_16BIT) i >>= 1; *((int *)arg) = i; return 0;*/ //case PM_REQ_GETSAMPLES: *((int *)arg) = globals.samples*2; /*{ static int c=0; if( c%0x100000==0 ){ ctl->cmsg(CMSG_INFO, VERB_VERBOSE, "getsamples = %d", *((int *)arg)); } }*/ return 0; case PM_REQ_DISCARD: AudioDeviceStop(globals.device, appIOProc); init_variable(); return 0; case PM_REQ_PLAY_START: init_variable(); return 0; case PM_REQ_FLUSH: case PM_REQ_OUTPUT_FINISH: while( globals.soundPlaying ){ trace_loop(); usleep(1000); } init_variable(); return 0; default: break; } return -1; }
/*return value == 0 sucess == -1 fails */ static int open_output(void) { OSStatus err = 0; //no err UInt32 count, bufferSize; AudioDeviceID device = kAudioDeviceUnknown; AudioStreamBasicDescription format; // get the default output device for the HAL count = sizeof(globals.device); // it is required to pass the size of the data to be returned err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &count, (void *) &device); if (err != 0) goto Bail; // get the buffersize that the default device uses for IO count = sizeof(globals.deviceBufferSize); // it is required to pass the size of the data to be returned err = AudioDeviceGetProperty(device, 0, 0, kAudioDevicePropertyBufferSize, &count, &bufferSize); if (err != 0) goto Bail; if( globals.deviceBufferSize>BUFLEN ){ fprintf(stderr, "globals.deviceBufferSize NG: %ld\n", globals.deviceBufferSize); exit(1); } // get a description of the data format used by the default device count = sizeof(globals.deviceFormat); // it is required to pass the size of the data to be returned err = AudioDeviceGetProperty(device, 0, 0, kAudioDevicePropertyStreamFormat, &count, &format); if (err != 0) goto Bail; FailWithAction(format.mFormatID != kAudioFormatLinearPCM, err = -1, Bail); // bail if the format is not linear pcm // everything is ok so fill in these globals globals.device = device; globals.deviceBufferSize = bufferSize; globals.deviceFormat = format; init_variable(); err = AudioDeviceAddIOProc(globals.device, appIOProc, 0 ); // setup our device with an IO proc if (err != 0) goto Bail; globals.deviceFormat.mSampleRate = dpm.rate; #if 0 globals.deviceFormat.mFormatFlags = kLinearPCMFormatFlagIsBigEndian | kLinearPCMFormatFlagIsPacked | kLinearPCMFormatFlagIsSignedInteger; globals.deviceFormat.mBytesPerPacket = 4; globals.deviceFormat.mBytesPerFrame = 4; globals.deviceFormat.mBitsPerChannel = 0x10; err = AudioDeviceSetProperty(device, &inWhen, 0, 0, kAudioDevicePropertyStreamFormat, count, &globals.deviceFormat); if (err != 0) goto Bail; #endif #if 0 fprintf(stderr, "deviceBufferSize = %d\n", globals.deviceBufferSize); fprintf(stderr, "mSampleRate = %g\n", globals.deviceFormat.mSampleRate); fprintf(stderr, "mFormatID = 0x%08x\n", globals.deviceFormat.mFormatID); fprintf(stderr, "mFormatFlags = 0x%08x\n", globals.deviceFormat.mFormatFlags); fprintf(stderr, "mBytesPerPacket = 0x%08x\n", globals.deviceFormat.mBytesPerPacket); fprintf(stderr, "mBytesPerFrame = 0x%08x\n", globals.deviceFormat.mBytesPerFrame); fprintf(stderr, "mBitsPerChannel = 0x%08x\n", globals.deviceFormat.mBitsPerChannel); #endif Bail: return (err); }