int main(int argc, char **argv) { struct import * hDll; int a,b,c,d; if((hDll = (struct import *)_ksys_cofflib_load(dllname)) == 0) { debug_out_str("can't load lib\n"); return 1; } link(hDll, imports); debug_out_str("dll loaded\n"); if(dll_start(1) == 0) { debug_out_str("dll_start failed\n"); return 1; } con_init(-1, -1, -1, -1, caption); for(i = 0; i < 256; i++) { con_printf("Color 0x%02X: ", i); con_write_asciiz("Text sample."); con_printf(" printf %s test %d\n", "small", i); } con_exit(0); debug_out_str("all right's ;)\n"); }
int mem_check_integrity( int block_number ) { int i, ErrorCount; ubyte * CheckData; CheckData = (ubyte *)((char *)MallocBase[block_number] + MallocSize[block_number]); ErrorCount = 0; for (i=0; i<CHECKSIZE; i++ ) if (CheckData[i] != CHECKBYTE ) { ErrorCount++; con_printf(CON_CRITICAL, "OA: %p ", &CheckData[i] ); } if (ErrorCount && (!out_of_memory)) { con_printf(CON_CRITICAL, "\nMEM_OVERWRITE: Memory after the end of allocated block overwritten.\n" ); PrintInfo( block_number ); con_printf(CON_CRITICAL, "\t%d/%d check bytes were overwritten.\n", ErrorCount, CHECKSIZE ); Int3(); } return ErrorCount; }
void cmd_recdemo(){ // Begins recording a demo. int m; // Check if we're allready recording/playing. if(player_connected!=1||map_type!=MAP_IWAD){ con_printf("not connected to an iwad map"); return; } if(player_recording!=0){ con_printf("demo buffers in use"); return; } if(internal_setdemoname(parse_words[1])==0){ // Initiate the demo. m=sizeof(DEMO_CELL)*10000; bufdemo=(DEMO_CELL *)malloc(m); demo_count=0; demo_header.ver=DJDOOM_VER; strcpy(demo_header.mapname,mapname); // Display recording statistics. sprintf(saybuf,"version %d demo (%s)",demo_header.ver,demo_header.mapname); con_printf(saybuf); player_recording=1; } else{ con_printf("bad demo name"); } }
/* Initialise audio */ int digi_mixer_init() { digi_sample_rate = SAMPLE_RATE_44K; if (MIX_DIGI_DEBUG) con_printf(CON_DEBUG,"digi_init %d (SDL_Mixer)\n", MAX_SOUNDS); if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) Error("SDL audio initialisation failed: %s.", SDL_GetError()); if (Mix_OpenAudio(digi_sample_rate, MIX_OUTPUT_FORMAT, MIX_OUTPUT_CHANNELS, SOUND_BUFFER_SIZE)) { //edited on 10/05/98 by Matt Mueller - should keep running, just with no sound. con_printf(CON_URGENT,"\nError: Couldn't open audio: %s\n", SDL_GetError()); GameArg.SndNoSound = 1; return 1; } Mix_AllocateChannels(digi_max_channels); Mix_Pause(0); // Attempt to load jukebox jukebox_load(); //jukebox_list(); digi_initialised = 1; oplmus_init(); return 0; }
static int IPXOpenSocket(socket_t *sk, int port) { int sock; /* sock here means Linux socket handle */ int opt; struct sockaddr_ipx ipxs; socklen_t len; struct sockaddr_ipx ipxs2; /* do a socket call, then bind to this port */ sock = socket(AF_IPX, SOCK_DGRAM, PF_IPX); if (sock == -1) { con_printf(CON_URGENT,"IPX: could not open IPX socket.\n"); return -1; } opt = 1; /* Permit broadcast output */ if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &opt, sizeof(opt)) == -1) { con_printf(CON_URGENT,"IPX: could not set socket option for broadcast.\n"); return -1; } ipxs.sipx_family = AF_IPX; ipxs.sipx_network = *((unsigned int *)&MyAddress[0]); /* ipxs.sipx_network = htonl(MyNetwork); */ bzero(ipxs.sipx_node, 6); /* Please fill in my node name */ ipxs.sipx_port = htons(port); /* now bind to this port */ if (bind(sock, (struct sockaddr *) &ipxs, sizeof(ipxs)) == -1) { con_printf(CON_URGENT,"IPX: could not bind socket to address\n"); close( sock ); return -1; } if( port==0 ) { len = sizeof(ipxs2); if (getsockname(sock,(struct sockaddr *)&ipxs2,&len) < 0) { con_printf(CON_URGENT,"IPX: could not get socket name in IPXOpenSocket\n"); close( sock ); return -1; } else { port = htons(ipxs2.sipx_port); con_printf(CON_URGENT,"IPX: opened dynamic socket %04x\n", port); } } sk->fd = sock; sk->socket = port; IPXGetMyAddress(); return 0; }
static void clcmd_help(int s, char *arg) { unsigned int i; con_printf("Command List:\n"); for(i = 0; i < sizeof(command)/sizeof(*command); i++) con_printf(" %s: %s\n", command[i].name, command[i].help); }
void RBAInit() { int num_cds; int i,j; if (initialised) return; if (SDL_Init(SDL_INIT_CDROM) < 0) { Warning("SDL library initialisation failed: %s.",SDL_GetError()); return; } num_cds = SDL_CDNumDrives(); if (num_cds < 1) { con_printf(CON_NORMAL, "No cdrom drives found!\n"); #if defined(__APPLE__) || defined(macintosh) SDL_QuitSubSystem(SDL_INIT_CDROM); // necessary for rescanning CDROMs #endif return; } for (i = 0; i < num_cds; i++) { if (s_cd) SDL_CDClose(s_cd); s_cd = SDL_CDOpen(i); if (s_cd && CD_INDRIVE(SDL_CDStatus(s_cd))) { for (j = 0; j < s_cd->numtracks; j++) { if (s_cd->track[j].type == SDL_AUDIO_TRACK) break; } if (j != s_cd->numtracks) break; // we've found an audio CD } else if (s_cd == NULL) Warning("Could not open cdrom %i for redbook audio:%s\n", i, SDL_GetError()); } if (i == num_cds) { con_printf(CON_NORMAL, "No audio CDs found\n"); if (s_cd) // if there's no audio CD, say that there's no redbook and hence play MIDI instead { SDL_CDClose(s_cd); s_cd = NULL; } #if defined(__APPLE__) || defined(macintosh) SDL_QuitSubSystem(SDL_INIT_CDROM); // necessary for rescanning CDROMs #endif return; } initialised = 1; }
void *mixer_thread(void *data) { int err; ubyte buffer[SOUND_BUFFER_SIZE]; /* Allow ourselves to be asynchronously cancelled */ pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); while (1) { memset(buffer, 0x80, SOUND_BUFFER_SIZE); LOCK(); audio_mixcallback(NULL,buffer,SOUND_BUFFER_SIZE); UNLOCK(); again: err = snd_pcm_writei(snd_devhandle, buffer, SOUND_BUFFER_SIZE/2); if (err == -EPIPE) { // Sound buffer underrun err = snd_pcm_prepare(snd_devhandle); if (err < 0) { con_printf(CON_CRITICAL, "Can't recover from underrun: %s\n", snd_strerror(err)); } } else if (err == -EAGAIN) { goto again; } else if (err != SOUND_BUFFER_SIZE/2) { // Each frame has size 2 bytes - hence we expect SOUND_BUFFER_SIZE/2 // frames to be written. con_printf(CON_CRITICAL, "Unknown err %d: %s\n", err, snd_strerror(err)); } } return 0; }
/* * Play-time conversion. Performs output conversion only once per sound effect used. * Once the sound sample has been converted, it is cached in SoundChunks[] */ void mixdigi_convert_sound(int i) { SDL_AudioCVT cvt; Uint8 *data = GameSounds[i].data; Uint32 dlen = GameSounds[i].length; int freq = GameSounds[i].freq; //int bits = GameSounds[i].bits; if (SoundChunks[i].abuf) return; //proceed only if not converted yet if (data) { if (MIX_DIGI_DEBUG) con_printf(CON_DEBUG,"converting %d (%d)\n", i, dlen); SDL_BuildAudioCVT(&cvt, AUDIO_U8, 1, freq, MIX_OUTPUT_FORMAT, MIX_OUTPUT_CHANNELS, digi_sample_rate); cvt.buf = malloc(dlen * cvt.len_mult); cvt.len = dlen; memcpy(cvt.buf, data, dlen); if (SDL_ConvertAudio(&cvt)) con_printf(CON_DEBUG,"conversion of %d failed\n", i); SoundChunks[i].abuf = cvt.buf; SoundChunks[i].alen = dlen * cvt.len_mult; SoundChunks[i].allocated = 1; SoundChunks[i].volume = 128; // Max volume = 128 } }
void RBASetVolume(int volume) { #ifdef __linux__ int cdfile, level; struct cdrom_volctrl volctrl; if (!s_cd) return; cdfile = s_cd->id; level = volume*REDBOOK_VOLUME_SCALE/8; if ((level<0) || (level>REDBOOK_VOLUME_SCALE)) { con_printf(CON_CRITICAL, "illegal volume value (allowed values 0-%i)\n",REDBOOK_VOLUME_SCALE); return; } volctrl.channel0 = volctrl.channel1 = volctrl.channel2 = volctrl.channel3 = level; if ( ioctl(cdfile, CDROMVOLCTRL, &volctrl) == -1 ) { con_printf(CON_CRITICAL, "CDROMVOLCTRL ioctl failed\n"); return; } #else volume; #endif }
/** * Copy @p text to the clipboard * * @param[in] text Text to copy to the clipboard * * @retval true On success * @retval false If any of the Windows clipboard functions failed */ bool clipboard_set_text(char *text) { bool retval; HGLOBAL hdst; char *dst; DWORD dst_sz = strlen(text) + sizeof('\0'); /* Allocate and copy the string to the global memory */ hdst = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, dst_sz); dst = (char *)GlobalLock(hdst); util_strlcpy(dst, text, dst_sz); GlobalUnlock(hdst); /* Set clipboard data */ retval = OpenClipboard(NULL); if (!retval) { con_printf("Error opening clipboard\n"); return false; } EmptyClipboard(); retval = SetClipboardData(CF_TEXT, hdst); if (!retval) { con_printf("Error pasting to clipboard\n"); return false; } CloseClipboard(); return true; }
void drp_debug3(void){ int value=0, res=0; unsigned int index; unsigned long block; con_printf("(Destructive) Testing -256block r/w- memSD\r\n"); for(block=0; block<1024; block=block+256){ printf("testing 256Block = %lu\n", block); value=20000; for(index=0; index<=0xFFFF; index++, value++){ con_printf("writing: "); msd_setVar_256BlockExtMem( block, index, value); printf("value[%u] = %d | ", index, value); printf("reading: "); msd_getVar_256BlockExtMem( block, index, &res); printf("value[%u] = %d | ", index, res); printf("comparing: "); if( value==res ){ printf("ok\n"); } else{ con_printf("fail\n"); return; } ClrWdt(); } } //drp_memSD_BlockErase(); }
/** * Execute process @p path with admin privileges * * @note This function will trigger the UAC dialog * * @param[in] path Path to the executable * * @retval true If process was executed successfully * @retval false On error, or if the user declined the UAC */ bool sys_runas_admin(char *path) { BOOL success; SHELLEXECUTEINFO shexe_info; bool isadmin = false; printf("Trying to execute '%s' as admin!\n", path); /* Check if we're already admin */ if (!sys_is_admin(&isadmin)) { con_printf("Unable to determine if we're running elevated.\n"); return false; } if (isadmin) { con_printf("Unable to execute %s as we're already elevated.\n", path); return false; } /* Do the undocumented "runas" trick of ShellExecute() */ memset(&shexe_info, 0, sizeof(shexe_info)); shexe_info.cbSize = sizeof(shexe_info); shexe_info.lpVerb = "runas"; shexe_info.lpFile = path; shexe_info.nShow = SW_MAXIMIZE; success = ShellExecuteEx(&shexe_info); return (success == TRUE); }
void gr_close() { ogl_brightness_r = ogl_brightness_g = ogl_brightness_b = 0; if (gl_initialized) { ogl_smash_texture_list_internal(); } if (grd_curscreen) { if (grd_curscreen->sc_canvas.cv_bitmap.bm_data) d_free(grd_curscreen->sc_canvas.cv_bitmap.bm_data); d_free(grd_curscreen); } ogl_close_pixel_buffers(); #ifdef _WIN32 if (ogl_rt_loaded) OpenGL_LoadLibrary(false); #endif #ifdef OGLES ogles_destroy(); #ifdef RPI con_printf(CON_DEBUG, "RPi: cleanuing up\n"); if (dispman_display != DISPMANX_NO_HANDLE) { rpi_destroy_element(); con_printf(CON_DEBUG, "RPi: closing display\n"); vc_dispmanx_display_close(dispman_display); dispman_display = DISPMANX_NO_HANDLE; } #endif #endif }
void internal_set_gfx_mode(){ // Actually sets the graphics mode. int error,n=player_gfx_mode-1; // Try to set the graphics mode (unless we're allready in it). if(n!=old_gfx_mode){ error=set_gfx_mode(GFX_AUTODETECT,gfx_mode_info[n].width,gfx_mode_info[n].height,0,0); if(error<0){ // DEBUG: Will this error even appear in a bad graphics mode? con_printf("Couldn't initiate the graphics mode!"); } else{ // Get the new screen width/height. screen_width=gfx_mode_info[n].width; screen_height=gfx_mode_info[n].height; set_palette(gamma_pal); // DEBUG: Shouldn't we free the old VGABUF?!! vgabuf=create_bitmap(screen_width,screen_height); sprintf(saybuf,"%d x %d mode set (%dk vgabuf)",screen_width,screen_height,screen_width*screen_height/1024); con_printf(saybuf); // Reset the console height, if the console is down. if(player_connected==1&&player_con==1){ con_height=screen_height/2; } } } // Save the old mode. old_gfx_mode=n; }
// ============================================================================================================ // Reads the FIFO content // Arguments : None // Return : int direcc_b (Value of first address of data buffer) // ============================================================================================================ void gyr_get_FIFO_samples(BOOL verb, GYR_DATA *res_data){ #if (SCH_GYRO_VERBOSE>=2) con_printf("Entered to read FIFO\r\n"); #endif unsigned char dummy = gyr_read_reg(GYR_FIFO_CTRL_REG); unsigned char muestras = (dummy & 0x1F)+1; // Plus one because the first sample is in the position zero of the array #if (SCH_GYRO_VERBOSE>=2) con_printf("SAMPLES (number) recovered \t"); // Samples for ONE axis char ret[6]; itoa(ret, (unsigned int)muestras, 10); con_printf(ret); con_printf("\r\n"); #endif char address[] = {GYR_ADD, GYR_OUT_X_L_RB}; unsigned char buffer[muestras*3*2]; // By 3 because there's 3 axes // By 2 because each sample is two bytes i2c3_master_fgets((char *)buffer, muestras*3*2, address, 2); #if (SCH_GYRO_VERBOSE>=2) con_printf("Samples read ... \r\n"); // for debugging #endif unsigned char *direcc_b; direcc_b = &buffer[0]; gyr_get_data(verb, direcc_b, muestras, res_data); }
// ============================================================================================================ // Reads the temperature of the sensor // Arguments : None // Return : None // ============================================================================================================ void gyr_print_temp(void){ unsigned char dummy = gyr_read_reg(GYR_OUT_TEMP); con_printf("Sensor temperature: \t "); char ret[10]; //itoa(ret, (unsigned int)dummy, 16); sprintf (ret, "0x%X", (unsigned int)dummy); con_printf(ret); con_printf("\r\n"); }
/** * Check whether we're running with elevated privileges * (as Administrator) * * @param[out] isadmin @p true if we're running as admin, @p false otherwise * * @note This function only works if compiled under MinGW * * @retval true On success * @retval false On error */ bool sys_is_admin(bool *isadmin) { #ifdef OS_CYGWIN /* * Under Cygwin the elevation stuff does not work, and the binary crashes * because it cannot find the .DLL anyway */ (void)isadmin; return false; #else HANDLE proc_token; BOOL ok; (void)isadmin; /* Open the current process' token */ ok = OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &proc_token); if (!ok) { con_printf("OpenProcessToken() failed\n"); return false; } TOKEN_ELEVATION_TYPE ele_type; DWORD ele_size; ok = GetTokenInformation(proc_token, TokenElevationType, &ele_type, sizeof(ele_type), &ele_size); if (!ok) { con_printf("GetTokenInformation() failed\n"); return false; } switch (ele_type) { case TokenElevationTypeDefault: /* * TokenElevationTypeDefault is apparently returned when UAC is disabled; does this * also mean we have admin rights? */ case TokenElevationTypeFull: default: *isadmin = true; break; case TokenElevationTypeLimited: *isadmin = false; } con_printf("sys_is_admin() says admin = %s!\n", *isadmin ? "TRUE" : "FALSE"); return true; #endif }
int CanJoinNetgame (tNetgameInfo *game, tAllNetPlayersInfo *people) { // Can this tPlayer rejoin a netgame in progress? int i, nNumPlayers; if (game->gameStatus == NETSTAT_STARTING) return 1; if (game->gameStatus != NETSTAT_PLAYING) { #if 1 con_printf (CONDBG, "Error: Can't join because gameStatus !=NETSTAT_PLAYING\n"); #endif return 0; } if (game->versionMajor == 0 && D2X_MAJOR>0) { #if 1 con_printf (CONDBG, "Error:Can't join because version majors don't match!\n"); #endif return 0; } if (game->versionMajor>0 && D2X_MAJOR == 0) { #if 1 con_printf (CONDBG, "Error:Can't join because version majors2 don't match!\n"); #endif return 0; } // Game is in progress, figure out if this guy can re-join it nNumPlayers = game->nNumPlayers; if (!(game->gameFlags & NETGAME_FLAG_CLOSED)) { // Look for tPlayer that is not connected if (game->nConnected == game->nMaxPlayers) return 2; if (game->bRefusePlayers) return 3; if (game->nNumPlayers < game->nMaxPlayers) return 1; if (game->nConnected<nNumPlayers) return 1; } if (!people) { con_printf (CONDBG, "Error! Can't join because people == NULL!\n"); return 0; } // Search to see if we were already in this closed netgame in progress for (i = 0; i < nNumPlayers; i++) if (!CmpNetPlayers (LOCALPLAYER.callsign, people->players [i].callsign, &networkData.thisPlayer.player.network, &people->players [i].network)) return 1; #if 1 con_printf (CONDBG, "Error: Can't join because at end of list!\n"); #endif return 0; }
void gyr_take_samples(BOOL verb, GYR_DATA *res_data){ gyr_config_GYR_CTRL_REG1(0x01, 0x03); // 200 Hz datarate and 70 cutoff gyr_enable_axis(0x07); // Enable three axes gyr_powermode(0x01); // Enable device __delay_ms(50); config_FIFO_GYR_CTRL_REG(0b00000111); // configure FIFO_GYR_CTRL_REG with watermark if(verb){ gyr_print_remain_samp(); // Obtain the number of remaining samples } gyr_config_FIFO_mode(0x01); // Mode to FIFO mode while(!GYR_INT2){ if(verb){ con_printf("GYR_INT2=0\r\n"); } } __delay_ms(50); if(verb){ gyr_print_FIFO_int_source(); // see FIFO interruption gyr_print_remain_samp(); // Samples to read gyr_print_temp(); // Read the temperature of the sensor } __delay_ms(50); if(verb){ con_printf("showing samples from buffer\r\n"); } gyr_get_FIFO_samples(verb, res_data); // read FIFO data if(verb){ printf("gyr_take_samples\r\n"); printf("X axis : %d\n", (*res_data).a_x ); printf("Y axis : %d\n", (*res_data).a_y ); printf("Z axis : %d\n", (*res_data).a_z ); printf("************************\n"); } __delay_ms(50); gyr_config_FIFO_mode(0x00); // go to bypass mode (in order to go // to FIFO mode again - device requirement) __delay_ms(50); //ClrWdt(); // -------------------------------------------- // Debugging purposes (Change scale to 250 dps) /* gyr_config_GYR_CTRL_REG4(0x01, 0x00, 0x00); con_printf("Scale changed to 250 dps\r\n"); gyr_powermode(0x00); // to powerdown */ }
/* * Add archives to the game. * 1) archives from Sharepath/Data to extend/replace builtin game content * 2) archived demos */ void PHYSFSX_addArchiveContent() { char **list = NULL; static const char *const archive_exts[] = { ".zip", ".7z", NULL }; char *file[2]; int i = 0, content_updated = 0; con_printf(CON_DEBUG, "PHYSFS: Adding archives to the game.\n"); // find files in Searchpath ... list = PHYSFSX_findFiles("", archive_exts); // if found, add them... for (i = 0; list[i] != NULL; i++) { MALLOC(file[0], char, PATH_MAX); MALLOC(file[1], char, PATH_MAX); snprintf(file[0], sizeof(char)*PATH_MAX, "%s", list[i]); PHYSFSX_getRealPath(file[0],file[1]); if (PHYSFS_addToSearchPath(file[1], 0)) { con_printf(CON_DEBUG, "PHYSFS: Added %s to Search Path\n",file[1]); content_updated = 1; } d_free(file[0]); d_free(file[1]); } PHYSFS_freeList(list); list = NULL; #if PHYSFS_VER_MAJOR >= 2 // find files in DEMO_DIR ... list = PHYSFSX_findFiles(DEMO_DIR, archive_exts); // if found, add them... for (i = 0; list[i] != NULL; i++) { MALLOC(file[0], char, PATH_MAX); MALLOC(file[1], char, PATH_MAX); snprintf(file[0], sizeof(char)*PATH_MAX, "%s%s", DEMO_DIR, list[i]); PHYSFSX_getRealPath(file[0],file[1]); if (PHYSFS_mount(file[1], DEMO_DIR, 0)) { con_printf(CON_DEBUG, "PHYSFS: Added %s to %s\n",file[1], DEMO_DIR); content_updated = 1; } d_free(file[0]); d_free(file[1]); } PHYSFS_freeList(list); list = NULL; #endif if (content_updated) { con_printf(CON_DEBUG, "Game content updated!\n"); PHYSFSX_listSearchPathContent(); } }
// ============================================================================================================ // Returns the identification of the device // Arguments : None // Return : None // NOTE : Returned value MUST be 0xD3 (Factory value for L3G4200D three axes gyro) // ============================================================================================================ void whoami(void){ unsigned char who = 0; who = gyr_read_reg(GYR_WHO_AM_I); con_printf("Who_am_I returned: "); char ret[10]; //utoa(ret, (unsigned int)who, 16); sprintf (ret, "0x%X", (unsigned int)who); con_printf(ret); con_printf("\r\n"); }
// ============================================================================================================ // Sees the remaining samples to be read // Arguments : None // Return : None // ============================================================================================================ void gyr_print_remain_samp(void){ unsigned char dummy = gyr_read_reg(GYR_FIFO_SRC_REG); con_printf("FIFO remaining samples to be read :"); unsigned char numero = dummy&0x1F; char ret[10]; //itoa(ret, (unsigned int)numero, 16); sprintf (ret, "0x%X", (unsigned int)numero); con_printf(ret); con_printf("\r\n"); }
void * mem_malloc( unsigned int size, char * var, char * filename, int line, int fill_zero ) { size_t base; void *ptr; int * psize; if (Initialized==0) mem_init(); #if MEMSTATS { unsigned long theFreeMem = 0; if (sMemStatsFileInitialized) { theFreeMem = FreeMem(); fprintf(sMemStatsFile, "\n%9u bytes free before attempting: MALLOC %9u bytes.", theFreeMem, size); } } #endif // end of ifdef memstats if (size==0) { con_printf(CON_CRITICAL, "\nMEM_MALLOC_ZERO: Attempting to malloc 0 bytes.\n" ); con_printf(CON_CRITICAL, "\tVar %s, file %s, line %d.\n", var, filename, line ); Error( "MEM_MALLOC_ZERO" ); Int3(); } ptr = malloc( size + CHECKSIZE ); if (ptr==NULL) { con_printf(CON_CRITICAL, "\nMEM_OUT_OF_MEMORY: Malloc returned NULL\n" ); con_printf(CON_CRITICAL, "\tVar %s, file %s, line %d.\n", var, filename, line ); Error( "MEM_OUT_OF_MEMORY" ); Int3(); } base = (size_t)ptr; if ( base < SmallestAddress ) SmallestAddress = base; if ( (base+size) > LargestAddress ) LargestAddress = base+size; psize = (int *)ptr; psize--; BytesMalloced += *psize; if (fill_zero) memset( ptr, 0, size ); return ptr; }
// ---------------------------------------------------------------------------------------- // Show tPlayer which weapons he has, how much ammo... // Looks like a debug screen now because it writes to mono screen, but that will change... void ShowWeaponStatus (void) { int i; #if TRACE for (i = 0; i < MAX_PRIMARY_WEAPONS; i++) { if (LOCALPLAYER.primaryWeaponFlags & (1 << i)) con_printf (CONDBG, "HAVE"); else con_printf (CONDBG, " "); con_printf (CONDBG, " Weapon: %20s, charges: %4i\n", PRIMARY_WEAPON_NAMES(i), LOCALPLAYER.primaryAmmo [i]); } con_printf (CONDBG, "\n"); for (i = 0; i < MAX_SECONDARY_WEAPONS; i++) { if (LOCALPLAYER.secondaryWeaponFlags & (1 << i)) con_printf (CONDBG, "HAVE"); else con_printf (CONDBG, " "); con_printf (CONDBG, " Weapon: %20s, charges: %4i\n", SECONDARY_WEAPON_NAMES(i), LOCALPLAYER.secondaryAmmo [i]); } con_printf (CONDBG, "\n"); con_printf (CONDBG, "\n"); #endif }
/* *!!! ENABLE *!! SYNTAX *! \tok{\sc ENAble} *! \begin{stack} \tok{ALL} \\ <rdev> \end{stack} *!! XATNYS *!! AUTH A *!! PURPOSE *! Enables a real device. */ static int cmd_enable(struct virt_sys *sys, char *cmd, int len) { u64 devnum; struct device *dev; struct console *con; SHELL_CMD_AUTH(sys, A); if (!strcasecmp(cmd, "ALL")) { con_printf(sys->con, "ENABLE ALL not yet implemented!\n"); return 0; } cmd = __extract_hex(cmd, &devnum); if (IS_ERR(cmd)) return PTR_ERR(cmd); /* device number must be 16-bit */ if (devnum & ~0xffffUL) return -EINVAL; dev = find_device_by_ccuu(devnum); if (IS_ERR(dev)) { con_printf(sys->con, "Device %04llX not found in configuration\n", devnum); return 0; } mutex_lock(&dev->lock); if (dev->in_use) { con_printf(sys->con, "Device %04llX is already in use\n", devnum); goto out_err; } if (!dev->dev->enable) { con_printf(sys->con, "Device type %-4s cannot be enabled\n", type2name(dev->type)); goto out_err; } con = dev->dev->enable(dev); if (IS_ERR(con)) { con_printf(sys->con, "Failed to enable %04llX: %s\n", devnum, errstrings[-PTR_ERR(con)]); goto out_err; } mutex_unlock(&dev->lock); return 0; out_err: mutex_unlock(&dev->lock); dev_put(dev); return 0; }
int thk_silent_time_and_pictures(void *param){ #if (SCH_TASKDEPLOYMENT_VERBOSE>=1) con_printf("\n[thk_silent_time_and_pictures] Mandatory inactivity time...\r\n"); rtc_print(NULL); #endif //1) Silencio el TRX #if (SCH_TRX_ONBOARD==1) #if (SCH_TASKDEPLOYMENT_VERBOSE>=2) con_printf(" * Turning off TX\r\b"); #endif int trx_mode = 2; //TODO: Implement trx_setmode trx_set_operation_mode( (void *)&trx_mode ); #endif //2) tomo foto pay_init_camera(NULL); //int arg = CAM_MODE_VERBOSE; int arg = CAM_MODE_BOTH; pay_take_camera(&arg); pay_stop_camera(NULL); //parar ciclo de Payload //int cam_state = SRP_PAY_XXX_STATE_INACTIVE; PAY_xxx_State cam_state = pay_xxx_state_inactive; pay_set_state_camera(&cam_state); //3) duermo el SUCHAI por 30min #if (SCH_TASKDEPLOYMENT_VERBOSE>=1) con_printf(" * System halted at "); rtc_print(NULL); #endif int mode= *( (int *)param ); if(mode) /* RealTIme */ { // const unsigned int time_out = (0xFFFF) / portTICK_RATE_MS; /* 65,535[s]*/ const unsigned int time_out = (0xFFFF); /* 65,535[s]*/ unsigned int indx2; for(indx2=0; indx2<THK_SILENT_TIME_MIN-1; indx2++) { //vTaskDelay(time_out); __delay_ms(time_out); ClrWdt() } con_printf(" * 65[s] remaining ...\r\n"); //vTaskDelay(time_out); __delay_ms(time_out); ClrWdt() } else /* NO RealTIme */ {
void sdl_keyb_print(void) { unsigned int i; con_printf("Keyboard Bindings:\n"); for(i = 0; i < KEY_MAX; i++) { if ( binds[i].cmd ) { con_printf(" <%s> %s\n", SDL_GetKeyName(i), binds[i].cmd->name); } } }
/** * Work hard to open the file in @p path * * If we don't have admin rights, and we get a permission error, * request elevation. * * If we're admin, this function will fix the permissions of the file in @p path * by granting full control access to everyone. * * * @param[in] path Full path to file * @param[in] mode fopen() mode * * @return * This functions returns a FILE descriptor or NULL on error */ FILE *sys_fopen_force(char *path, char *mode) { FILE *f; bool isadmin; /* Check if we have admin rights */ if (!sys_is_admin(&isadmin)) { isadmin = false; } con_printf("sys_force_open(): %s (admin = %s)\n", path, isadmin ? "TRUE" : "FALSE"); /* We do, fix the permissions of the file before opening it */ if (isadmin) { con_printf("Fixing permissions on %s\n", path); if (!sys_perm_grant(path)) { /* This might happen if the file does not exists, so log it */ con_printf("Error fixing permissions on %s\n", path); } } /* If we get a permission denied, fire the "elevation request event */ f = fopen(path, mode); if (f != NULL) { /* Now return the file descriptor */ return f; } /* * If it is an "access denied" type of error, try to elevate our privileges unless * we're already admin */ if ((errno == EPERM) || (errno == EACCES)) { if (isadmin) { con_printf("We're already admin and still cannot access the file.\n"); } else { con_printf("Access denied when opening %s, requesting elevation\n", path); /* EVENT_SYS_ELEVATE_CHATLOG is usually a point of no return */ event_signal(EVENT_SYS_ELEVATE_REQUEST); } } return NULL; }
void CaenVmeWrite(int32_t BHandle, man_par_t *man) { uint32_t i ; CVErrorCodes ret,old_ret=cvSuccess; if(man->dtsize == cvD64) { con_printf(" Can't execute a D64 Write Cycle"); return ; } con_printf_xy(X_COMM,Y_COMM+1," Write Data [hex] : ") ; con_scanf("%x",&man->data) ; if(man->ncyc == 0) // Infinite Loop con_printf_xy(X_COMM,Y_COMM+2," Running ... Press any key to stop."); for (i=0; ((man->ncyc==0) || (i<man->ncyc)) && !con_kbhit(); i++) { ret = CAENVME_WriteCycle(BHandle,man->addr,&man->data,man->am,man->dtsize); if((i==0) || (ret != old_ret)) { gotoxy(X_COMM,Y_COMM) ; switch (ret) { case cvSuccess : con_printf(" Cycle(s) completed normally\n"); break ; case cvBusError : con_printf(" Bus Error !!!"); break ; case cvCommError : con_printf(" Communication Error !!!"); break ; default : con_printf(" Unknown Error !!!"); break ; } } old_ret = ret; if(man->autoinc) { man->addr += man->dtsize; // Increment address (+1 or +2 or +4) con_printf_xy(X_ADDR,Y_ADDR,"%08X]",man->addr); // Update the screen } } if(man->ncyc == 0) clear_line(Y_COMM+2); }