int execute_workload(CONFIG *cfg) { pthread_t *ithreads, *rthreads, *uthreads; int ret; uint64_t last_inserts, last_reads, last_updates; cfg->phase = WT_PERF_READ; last_inserts = last_reads = last_updates = 0; lprintf(cfg, 0, 1, "Starting read threads"); if (cfg->read_threads != 0 && (ret = start_threads( cfg, cfg->read_threads, &rthreads, read_thread)) != 0) return (ret); if (cfg->insert_threads != 0 && (ret = start_threads( cfg, cfg->insert_threads, &ithreads, insert_thread)) != 0) return (ret); if (cfg->update_threads != 0 && (ret = start_threads( cfg, cfg->update_threads, &uthreads, update_thread)) != 0) return (ret); /* Sanity check reporting interval. */ if (cfg->report_interval > cfg->run_time) cfg->report_interval = cfg->run_time; gettimeofday(&cfg->phase_start_time, NULL); for (cfg->elapsed_time = 0; cfg->elapsed_time < cfg->run_time && g_threads_quit < cfg->read_threads; cfg->elapsed_time += cfg->report_interval) { sleep(cfg->report_interval); lprintf(cfg, 0, 1, "%" PRIu64 " reads, %" PRIu64 " inserts, %" PRIu64 " updates in %d secs", g_nread_ops - last_reads, g_nins_ops - last_inserts, g_nupdate_ops - last_updates, cfg->report_interval); last_reads = g_nread_ops; last_inserts = g_nins_ops; last_updates = g_nupdate_ops; } /* Report if any worker threads didn't finish. */ if (g_threads_quit != 0) lprintf(cfg, WT_ERROR, 0, "Worker thread(s) exited without finishing."); if (cfg->read_threads != 0 && (ret = stop_threads(cfg, cfg->read_threads, rthreads)) != 0) return (ret); if (cfg->insert_threads != 0 && (ret = stop_threads(cfg, cfg->insert_threads, ithreads)) != 0) return (ret); if (cfg->update_threads != 0 && (ret = stop_threads(cfg, cfg->update_threads, uthreads)) != 0) return (ret); return (0); }
int httpd_cgi_conf_compile(int fd, char *raw, char *cgi) { char *nval, *old_www, *new_url; int i; lprintf("[ghost/notice] compiling config options ...\n"); if (!alt_cfg) { lprintf("[ghost/notice] no alternative config hashtable, aborted!\n"); httpd_header(fd, 302, "/config.html"); return 0; } old_www = strdup(hashtable_lookup(cfg, "http-admin-url")); if (!old_www) { lerror("calloc"); httpd_header(fd, 302, "/config.html"); return 0; } for (i = 0; cfg_truthtable[i].tag != NULL; i++) { if (cfg_truthtable[i].tag_mode == STATIC) { continue; } nval = hashtable_lookup(alt_cfg, cfg_truthtable[i].tag); if (nval) { lprintf("[ghost/notice]\t* %s -> %s\n", cfg_truthtable[i].tag, nval); hashtable_insert(cfg, cfg_truthtable[i].tag, nval); hashtable_delete(alt_cfg, cfg_truthtable[i].tag); } } if (!cfg_validate_all(cfg, GLITCH_MODE)) { httpd_www_gerror(fd, "Validation Failed!", raw, \ "Unable to validate new configuration layout. Please refer to the <A HREF=\"/log.html\">log</A> for more details!"); free(old_www); return 0; } proxy_build_limits(); lprintf("[ghost/notice] new config options are now in place!\n"); if (!strcmp(hashtable_lookup(cfg, "http-analyzer"), "off")) { httpd_header(fd, 200, NULL); httpd_msg_page(fd, "HTTP-ANALYZER", -1, NULL, "You have choosen to deactivate the HTTP-ANALYZER option. <BR> \n \ Therefor the Web Interface is no longer accessable. <BR> \n \ You can manually reactivate it by restarting the program!"); free(old_www); return 1; }
int ipmi_tsol_main(struct ipmi_intf * intf, int argc, char ** argv) { struct pollfd fds_wait[3], fds_data_wait[3], *fds; struct sockaddr_in sin, myaddr, *sa_in; socklen_t mylen; char *recvip = NULL; char out_buff[IPMI_BUF_SIZE * 8], in_buff[IPMI_BUF_SIZE]; char buff[IPMI_BUF_SIZE + 4]; int fd_socket, result, i; int out_buff_fill, in_buff_fill; int ip1, ip2, ip3, ip4; int read_only = 0, rows = 0, cols = 0; int port = IPMI_TSOL_DEF_PORT; if (strlen(intf->name) < 3 || strncmp(intf->name, "lan", 3) != 0) { lprintf(LOG_ERR, "Error: Tyan SOL is only available over lan interface"); return -1; } for (i = 0; i<argc; i++) { if (sscanf(argv[i], "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4) == 4) { /* not free'd ...*/ /* recvip = strdup(argv[i]); */ recvip = argv[i]; } else if (sscanf(argv[i], "port=%d", &ip1) == 1) port = ip1; else if (sscanf(argv[i], "rows=%d", &ip1) == 1) rows = ip1; else if (sscanf(argv[i], "cols=%d", &ip1) == 1) cols = ip1; else if (strlen(argv[i]) == 2 && strncmp(argv[i], "ro", 2) == 0) read_only = 1; else if (strlen(argv[i]) == 2 && strncmp(argv[i], "rw", 2) == 0) read_only = 0; else if (strlen(argv[i]) == 7 && strncmp(argv[i], "altterm", 7) == 0) _altterm = 1; else if (strlen(argv[i]) == 4 && strncmp(argv[i], "help", 4) == 0) { print_tsol_usage(); return 0; } else { print_tsol_usage(); return 0; } } /* create udp socket to receive the packet */ memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_port = htons(port); sa_in = (struct sockaddr_in *)&intf->session->addr; result = inet_pton(AF_INET, (const char *)intf->session->hostname, &sa_in->sin_addr); if (result <= 0) { struct hostent *host = gethostbyname((const char *)intf->session->hostname); if (host == NULL ) { lprintf(LOG_ERR, "Address lookup for %s failed", intf->session->hostname); return -1; } if (host->h_addrtype != AF_INET) { lprintf(LOG_ERR, "Address lookup for %s failed. Got %s, expected IPv4 address.", intf->session->hostname, (host->h_addrtype == AF_INET6) ? "IPv6" : "Unknown"); return (-1); } sa_in->sin_family = host->h_addrtype; memcpy(&sa_in->sin_addr, host->h_addr, host->h_length); } fd_socket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (fd_socket < 0) { lprintf(LOG_ERR, "Can't open port %d", port); return -1; } if (-1 == bind(fd_socket, (struct sockaddr *)&sin, sizeof(sin))) { lprintf(LOG_ERR, "Failed to bind socket."); close(fd_socket); return -1; } /* * retrieve local IP address if not supplied on command line */ if (recvip == NULL) { result = intf->open(intf); /* must connect first */ if (result < 0) { close(fd_socket); return -1; } mylen = sizeof(myaddr); if (getsockname(intf->fd, (struct sockaddr *)&myaddr, &mylen) < 0) { lperror(LOG_ERR, "getsockname failed"); close(fd_socket); return -1; } recvip = inet_ntoa(myaddr.sin_addr); if (recvip == NULL) { lprintf(LOG_ERR, "Unable to find local IP address"); close(fd_socket); return -1; } } printf("[Starting %sSOL with receiving address %s:%d]\n", read_only ? "Read-only " : "", recvip, port); set_terminal_size(rows, cols); enter_raw_mode(); /* * talk to smdc to start Console redirect - IP address and port as parameter * ipmitool -I lan -H 192.168.168.227 -U Administrator raw 0x30 0x06 0xC0 0xA8 0xA8 0x78 0x1A 0x0A */ result = ipmi_tsol_start(intf, recvip, port); if (result < 0) { lprintf(LOG_ERR, "Error starting SOL"); close(fd_socket); return -1; } printf("[SOL Session operational. Use %c? for help]\n", intf->session->sol_escape_char); gettimeofday(&_start_keepalive, 0); fds_wait[0].fd = fd_socket; fds_wait[0].events = POLLIN; fds_wait[0].revents = 0; fds_wait[1].fd = fileno(stdin); fds_wait[1].events = POLLIN; fds_wait[1].revents = 0; fds_wait[2].fd = -1; fds_wait[2].events = 0; fds_wait[2].revents = 0; fds_data_wait[0].fd = fd_socket; fds_data_wait[0].events = POLLIN | POLLOUT; fds_data_wait[0].revents = 0; fds_data_wait[1].fd = fileno(stdin); fds_data_wait[1].events = POLLIN; fds_data_wait[1].revents = 0; fds_data_wait[2].fd = fileno(stdout); fds_data_wait[2].events = POLLOUT; fds_data_wait[2].revents = 0; out_buff_fill = 0; in_buff_fill = 0; fds = fds_wait; for (;;) { result = poll(fds, 3, 15*1000); if (result < 0) break; /* send keepalive packet */ tsol_keepalive(intf); if ((fds[0].revents & POLLIN) && (sizeof(out_buff) > out_buff_fill)){ socklen_t sin_len = sizeof(sin); result = recvfrom(fd_socket, buff, sizeof(out_buff) - out_buff_fill + 4, 0, (struct sockaddr *)&sin, &sin_len); /* read the data from udp socket, skip some bytes in the head */ if((result - 4) > 0 ){ int length = result - 4; #if 1 length = (unsigned char)buff[2] & 0xff; length *= 256; length += ((unsigned char)buff[3] & 0xff); if ((length <= 0) || (length > (result - 4))) length = result - 4; #endif memcpy(out_buff + out_buff_fill, buff + 4, length); out_buff_fill += length; } } if ((fds[1].revents & POLLIN) && (sizeof(in_buff) > in_buff_fill)) { result = read(fileno(stdin), in_buff + in_buff_fill, sizeof(in_buff) - in_buff_fill); // read from keyboard if (result > 0) { int bytes; bytes = do_inbuf_actions(intf, in_buff + in_buff_fill, result); if(bytes < 0) { result = ipmi_tsol_stop(intf, recvip, port); do_terminal_cleanup(); return result; } if (read_only) bytes = 0; in_buff_fill += bytes; } } if ((fds[2].revents & POLLOUT) && out_buff_fill) { result = write(fileno(stdout), out_buff, out_buff_fill); // to screen if (result > 0) { out_buff_fill -= result; if (out_buff_fill) { memmove(out_buff, out_buff + result, out_buff_fill); } } } if ((fds[0].revents & POLLOUT) && in_buff_fill) { /* * translate key and send that to SMDC using IPMI * ipmitool -I lan -H 192.168.168.227 -U Administrator raw 0x30 0x03 0x04 0x1B 0x5B 0x43 */ result = ipmi_tsol_send_keystroke(intf, in_buff, __min(in_buff_fill,14)); if (result > 0) { gettimeofday(&_start_keepalive, 0); in_buff_fill -= result; if (in_buff_fill) { memmove(in_buff, in_buff + result, in_buff_fill); } } } fds = (in_buff_fill || out_buff_fill )? fds_data_wait : fds_wait; } return 0; }
void AsyncSocketAccept(SOCKET sock,int event,int error,int connection_type) { SOCKET new_sock; SOCKADDR_IN acc_sin; /* Accept socket address - internet style */ int acc_sin_len; /* Accept socket address length */ SOCKADDR_IN peer_info; int peer_len; struct in_addr peer_addr; connection_node conn; session_node *s; if (event != FD_ACCEPT) { eprintf("AsyncSocketAccept got non-accept %i\n",event); return; } if (error != 0) { eprintf("AsyncSocketAccept got error %i\n",error); return; } acc_sin_len = sizeof acc_sin; new_sock = accept(sock,(struct sockaddr *) &acc_sin,&acc_sin_len); if (new_sock == SOCKET_ERROR) { eprintf("AcceptSocketConnections accept failed, error %i\n", GetLastError()); return; } peer_len = sizeof peer_info; if (getpeername(new_sock,(SOCKADDR *)&peer_info,&peer_len) < 0) { eprintf("AcceptSocketConnections getpeername failed error %i\n", GetLastError()); return; } memcpy(&peer_addr,(long *)&(peer_info.sin_addr),sizeof(struct in_addr)); memcpy(&conn.addr, &peer_addr, sizeof(struct in_addr)); sprintf(conn.name,"%s",inet_ntoa(peer_addr)); // Too out following line to prevent log files from becoming spammed with extra lines. // This line is extraneous because the outcome of the authentication is always posted to logs. // lprintf("Got connection from %s to be authenticated.\n", conn.name); if (connection_type == SOCKET_MAINTENANCE_PORT) { if (!CheckMaintenanceMask(&peer_info,peer_len)) { lprintf("Blocked maintenance connection from %s.\n", conn.name); closesocket(new_sock); return; } } else { if (!CheckBlockList(&peer_addr)) { lprintf("Blocked connection from %s.\n", conn.name); closesocket(new_sock); return; } } conn.type = CONN_SOCKET; conn.socket = new_sock; EnterServerLock(); s = CreateSession(conn); if (s != NULL) { StartAsyncSession(s); switch (connection_type) { case SOCKET_PORT : InitSessionState(s,STATE_SYNCHED); break; case SOCKET_MAINTENANCE_PORT : InitSessionState(s,STATE_MAINTENANCE); break; default : eprintf("AcceptSocketConnections got invalid connection type %i\n",connection_type); } /* need to do this AFTER s->conn is set in place, because the async call writes to that mem address */ if (ConfigBool(SOCKET_DNS_LOOKUP)) { s->conn.hLookup = StartAsyncNameLookup((char *)&peer_addr,s->conn.peer_data); } else { s->conn.hLookup = 0; } } LeaveServerLock(); }
// // W_AddFile // All files are optional, but at least one file must be // found (PWAD, if all required lumps are present). // Files with a .wad extension are wadlink files // with multiple lumps. // Other files are single lumps with the base filename // for the lump name. // // Reload hack removed by Lee Killough // CPhipps - source is an enum // // proff - changed using pointer to wadfile_info_t static void W_AddFile(wadfile_info_t *wadfile) // killough 1/31/98: static, const { wadinfo_t header; lumpinfo_t* lump_p; unsigned i; int length; int startlump; filelump_t *fileinfo, *fileinfo2free=NULL; //killough filelump_t singleinfo; int flags = 0; // open the file and add to directory wadfile->handle = open(wadfile->name,O_RDONLY | O_BINARY); #ifdef HAVE_NET if (wadfile->handle == -1 && D_NetGetWad(wadfile->name)) // CPhipps wadfile->handle = open(wadfile->name,O_RDONLY | O_BINARY); #endif if (wadfile->handle == -1 && strlen(wadfile->name) > 4 && wadfile->src == source_pwad && !strcasecmp(wadfile->name + strlen(wadfile->name) - 4 , ".wad") && D_TryGetWad(wadfile->name)) { wadfile->handle = open(wadfile->name, O_RDONLY | O_BINARY); } if (wadfile->handle == -1) { if ( strlen(wadfile->name)<=4 || // add error check -- killough (strcasecmp(wadfile->name+strlen(wadfile->name)-4 , ".lmp" ) && strcasecmp(wadfile->name+strlen(wadfile->name)-4 , ".gwa" ) ) ) I_Error("W_AddFile: couldn't open %s",wadfile->name); return; } //jff 8/3/98 use logical output routine lprintf (LO_INFO," adding %s\n",wadfile->name); startlump = numlumps; // mark lumps from internal resource if (wadfile->src == source_auto_load) { int len = strlen(PACKAGE_TARNAME ".wad"); int len_file = strlen(wadfile->name); if (len_file >= len) { if (!strcasecmp(wadfile->name + len_file - len, PACKAGE_TARNAME ".wad")) { flags = LUMP_PRBOOM; } } } if ( strlen(wadfile->name)<=4 || ( strcasecmp(wadfile->name+strlen(wadfile->name)-4,".wad") && strcasecmp(wadfile->name+strlen(wadfile->name)-4,".gwa") ) ) { // single lump file fileinfo = &singleinfo; singleinfo.filepos = 0; singleinfo.size = LittleLong(I_Filelength(wadfile->handle)); ExtractFileBase(wadfile->name, singleinfo.name); numlumps++; } else { // WAD file I_Read(wadfile->handle, &header, sizeof(header)); if (strncmp(header.identification,"IWAD",4) && strncmp(header.identification,"PWAD",4)) I_Error("W_AddFile: Wad file %s doesn't have IWAD or PWAD id", wadfile->name); header.numlumps = LittleLong(header.numlumps); header.infotableofs = LittleLong(header.infotableofs); length = header.numlumps*sizeof(filelump_t); fileinfo2free = fileinfo = malloc(length); // killough lseek(wadfile->handle, header.infotableofs, SEEK_SET), I_Read(wadfile->handle, fileinfo, length); numlumps += header.numlumps; } // Fill in lumpinfo lumpinfo = realloc(lumpinfo, numlumps*sizeof(lumpinfo_t)); lump_p = &lumpinfo[startlump]; for (i=startlump ; (int)i<numlumps ; i++,lump_p++, fileinfo++) { lump_p->flags = flags; lump_p->wadfile = wadfile; // killough 4/25/98 lump_p->position = LittleLong(fileinfo->filepos); lump_p->size = LittleLong(fileinfo->size); if (wadfile->src == source_lmp) { // Modifications to place command-line-added demo lumps // into a separate "ns_demos" namespace so that they cannot // conflict with other lump names lump_p->li_namespace = ns_demos; } else { lump_p->li_namespace = ns_global; // killough 4/17/98 } strncpy (lump_p->name, fileinfo->name, 8); lump_p->source = wadfile->src; // Ty 08/29/98 // IWAD file used as recource PWAD must not override TEXTURE1 or PNAMES if (wadfile->src != source_iwad && !strncmp(header.identification,"IWAD",4) && (!strnicmp(fileinfo->name,"TEXTURE1",8) || !strnicmp(fileinfo->name,"PNAMES",6))) { strncpy (lump_p->name, "-IGNORE-", 8); } } free(fileinfo2free); // killough }
void ShaderBuildFromBuffer(Shader_t *shader) { int i,n; int offset; int needsworldinv = LUX_FALSE; ShaderParam_t *parambrowse; // copy stages offset = 0; shader->numStages = l_SHDData.stagesColorInBuffer + l_SHDData.stagesTexGpuInBuffer; shader->stages = reszalloc(sizeof(ShaderStage_t*)*shader->numStages); shader->totalParams = reszalloc(sizeof(ShaderParam_t*)*shader->numTotalParams); // we will need manual matrix paramters shader->cgMode = l_SHDData.cgmode == -1 ? SHADER_PASSMODE_FIXEDARB : l_SHDData.cgmode; if (!(shader->shaderflag & SHADER_NOCOMPILE)) l_SHDData.colorStage = 0; n = 0; for (i = 0; i < l_SHDData.stagesColorInBuffer + l_SHDData.stagesTexGpuInBuffer; i++){ if (i == l_SHDData.colorStage && l_SHDData.stagesColorInBuffer) shader->stages[i]=l_SHDData.stagesColor; else{ ShaderStage_t *stage = l_SHDData.stagesTex[n]; shader->stages[i]=stage; if (stage->paramListHead){ lxListNode_forEach(stage->paramListHead,parambrowse) shader->totalParams[parambrowse->totalid] = parambrowse; needsworldinv |= ShaderParam_needsWorldInv(parambrowse); lxListNode_forEachEnd(stage->paramListHead,parambrowse); } if (stage->stagetype == SHADER_STAGE_TEX){ if (stage->stageflag & (SHADER_EYELINMAP | SHADER_OBJLINMAP) && !stage->texgen){ stage->stageflag &= ~(SHADER_EYELINMAP | SHADER_OBJLINMAP); stage->texgen = NULL; lprintf("WARNING shdload: no texgenplanes defined,%s\n",shader->resinfo.name); } if (stage->texgen){ uchar legalcombos[] = { LUX_TRUE,LUX_TRUE,LUX_FALSE,LUX_FALSE, // XY LUX_TRUE,LUX_TRUE,LUX_TRUE,LUX_FALSE, // XYZ LUX_TRUE,LUX_TRUE,LUX_FALSE,LUX_TRUE, // XYW LUX_TRUE,LUX_TRUE,LUX_TRUE,LUX_TRUE}; // XYZW enum32 legalmodes[] = { VID_TEXCOORD_TEXGEN_ST, VID_TEXCOORD_TEXGEN_STR, VID_TEXCOORD_TEXGEN_STQ, VID_TEXCOORD_TEXGEN_STRQ}; uint *pIn = (uint*)legalcombos; uint *pCur = (uint*)stage->texgen->enabledaxis; int c; for (c = 0; c < 4; c++,pIn++){ if (*pIn == *pCur){ stage->texgen->texgenmode = legalmodes[c]; break; } } if (!stage->texgen){ stage->texgen = NULL; stage->stageflag &= ~(SHADER_EYELINMAP | SHADER_OBJLINMAP); lprintf("WARNING shdload: illegal combination of texgenplanes defined,%s\n",shader->resinfo.name); } } } n++; } } if (needsworldinv) shader->shaderflag |= SHADER_NEEDINVMATRIX; // check if textured if (l_SHDData.stagesTexInBuffer) shader->shaderflag |= SHADER_TEXTURED; // nicer to work with, if first stage = color replace & second stage = tex modulate, we "encode" the modulate via vcolor flag if ( l_SHDData.stagesColorInBuffer && l_SHDData.stagesColor->blendmode == VID_REPLACE && l_SHDData.stagesTexInBuffer) for (i = 0; i < shader->numStages; i++){ if (shader->stages[i]->stagetype == SHADER_STAGE_TEX ){ if (shader->stages[i]->blendmode == VID_MODULATE && !(isFlagSet(shader->stages[i]->stageflag,SHADER_VCOLOR))){ shader->stages[i]->blendmode = VID_REPLACE; shader->stages[i]->stageflag |= SHADER_VCOLOR | SHADER_VCOLOR_KEEP; } break; } } // if there is a bumpstage, we will remove lighting info from all other stages if (l_SHDData.bumpStage != -1){ shader->shaderflag |= SHADER_TANGENTS; for (i= 0; i < shader->numStages; i++) shader->stages[i]->stageflag &= ~(SHADER_VCOLOR | SHADER_VCOLOR_KEEP); } }
bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack) { char str[MAX_PATH+1],ch,*p; char tmp[MAX_PATH+1],tmp2[MAX_PATH+1]; char* fname; char* fmode; int mode; uint i,j,k,conf; long l,size,msgndx,posts,ex; long mailmsgs=0; ulong totalcdt,totaltime,lastmsg ,files,submsgs,msgs,netfiles=0,preqwk=0; ulong subs_scanned=0; float f; /* Sparky is responsible */ time_t start; node_t node; mail_t *mail; post_t *post; glob_t g; FILE *stream,*qwk,*personal,*ndx; DIR* dir; DIRENT* dirent; struct tm tm; smbmsg_t msg; ex=EX_OUTL|EX_OUTR; /* Need sh for wildcard expansion */ if(prepack) ex|=EX_OFFLINE; delfiles(cfg.temp_dir,ALLFILES); sprintf(str,"%sfile/%04u.qwk",cfg.data_dir,useron.number); if(fexistcase(str)) { for(k=0;k<cfg.total_fextrs;k++) if(!stricmp(cfg.fextr[k]->ext,useron.tmpext) && chk_ar(cfg.fextr[k]->ar,&useron)) break; if(k>=cfg.total_fextrs) k=0; p=cmdstr(cfg.fextr[k]->cmd,str,ALLFILES,NULL); if((i=external(p,ex))==0) preqwk=1; else errormsg(WHERE,ERR_EXEC,p,i); } if(useron.rest&FLAG('Q') && useron.qwk&QWK_RETCTLA) useron.qwk|=(QWK_NOINDEX|QWK_NOCTRL|QWK_VIA|QWK_TZ|QWK_MSGID); if(useron.qwk&QWK_EXPCTLA) mode=A_EXPAND; else if(useron.qwk&QWK_RETCTLA) mode=A_LEAVE; else mode=0; if(useron.qwk&QWK_TZ) mode|=QM_TZ; if(useron.qwk&QWK_VIA) mode|=QM_VIA; if(useron.qwk&QWK_MSGID) mode|=QM_MSGID; (*msgcnt)=0L; if(/* !prepack && */ !(useron.qwk&QWK_NOCTRL)) { /***************************/ /* Create CONTROL.DAT file */ /***************************/ sprintf(str,"%sCONTROL.DAT",cfg.temp_dir); if((stream=fopen(str,"wb"))==NULL) { errormsg(WHERE,ERR_OPEN,str,0); return(false); } now=time(NULL); if(localtime_r(&now,&tm)==NULL) return(false); fprintf(stream,"%s\r\n%s\r\n%s\r\n%s, Sysop\r\n0000,%s\r\n" "%02u-%02u-%u,%02u:%02u:%02u\r\n" ,cfg.sys_name ,cfg.sys_location ,cfg.node_phone ,cfg.sys_op ,cfg.sys_id ,tm.tm_mon+1,tm.tm_mday,tm.tm_year+1900 ,tm.tm_hour,tm.tm_min,tm.tm_sec); k=0; for(i=0;i<usrgrps;i++) for(j=0;j<usrsubs[i];j++) k++; /* k is how many subs */ fprintf(stream,"%s\r\n\r\n0\r\n0\r\n%u\r\n",useron.alias,k); fprintf(stream,"0\r\nE-mail\r\n"); /* first conference is e-mail */ char confname[256]; for(i=0;i<usrgrps;i++) for(j=0;j<usrsubs[i];j++) { if(useron.qwk&QWK_EXT) /* 255 char max */ sprintf(confname,"%s %s" ,cfg.grp[cfg.sub[usrsub[i][j]]->grp]->sname ,cfg.sub[usrsub[i][j]]->lname); else /* 10 char max */ strcpy(confname,cfg.sub[usrsub[i][j]]->qwkname); fprintf(stream,"%u\r\n%s\r\n" ,cfg.sub[usrsub[i][j]]->qwkconf ? cfg.sub[usrsub[i][j]]->qwkconf : ((i+1)*1000)+j+1,confname); } fprintf(stream,"HELLO\r\nBBSNEWS\r\nGOODBYE\r\n"); fclose(stream); /***********************/ /* Create DOOR.ID File */ /***********************/ sprintf(str,"%sDOOR.ID",cfg.temp_dir); if((stream=fopen(str,"wb"))==NULL) { errormsg(WHERE,ERR_OPEN,str,0); return(false); } p="CONTROLTYPE = "; fprintf(stream,"DOOR = %.10s\r\nVERSION = %s%c\r\n" "SYSTEM = %s\r\n" "CONTROLNAME = SBBS\r\n" "%sADD\r\n" "%sDROP\r\n" "%sYOURS\r\n" "%sRESET\r\n" "%sRESETALL\r\n" "%sFILES\r\n" "%sATTACH\r\n" "%sOWN\r\n" "%smail\r\n" "%sDELMAIL\r\n" "%sCTRL-A\r\n" "%sFREQ\r\n" "%sNDX\r\n" "%sTZ\r\n" "%sVIA\r\n" "%sCONTROL\r\n" "MIXEDCASE = YES\r\n" ,VERSION_NOTICE ,VERSION,REVISION ,VERSION_NOTICE ,p,p,p,p ,p,p,p,p ,p,p,p,p ,p,p,p,p ); fclose(stream); if(useron.rest&FLAG('Q')) { /***********************/ /* Create NETFLAGS.DAT */ /***********************/ sprintf(str,"%sNETFLAGS.DAT",cfg.temp_dir); if((stream=fopen(str,"wb"))==NULL) { errormsg(WHERE,ERR_CREATE,str,0); return(false); } ch=1; /* Net enabled */ if(usrgrps) for(i=0;i<(usrgrps*1000)+usrsubs[usrgrps-1];i++) fputc(ch,stream); fclose(stream); } } /****************************************************/ /* Create MESSAGES.DAT, write header and leave open */ /****************************************************/ sprintf(str,"%sMESSAGES.DAT",cfg.temp_dir); if(fexistcase(str)) fmode="r+b"; else fmode="w+b"; if((qwk=fopen(str,fmode))==NULL) { errormsg(WHERE,ERR_OPEN,str,0); return(false); } l=filelength(fileno(qwk)); if(l<1) { fprintf(qwk,"%-128.128s","Produced by " VERSION_NOTICE " " COPYRIGHT_NOTICE); msgndx=1; } else { msgndx=l/QWK_BLOCK_LEN; fseek(qwk,0,SEEK_END); } sprintf(str,"%sNEWFILES.DAT",cfg.temp_dir); remove(str); if(!(useron.rest&FLAG('T')) && useron.qwk&QWK_FILES) files=create_filelist("NEWFILES.DAT",FL_ULTIME); else files=0; start=time(NULL); if(useron.rest&FLAG('Q')) useron.qwk|=(QWK_EMAIL|QWK_ALLMAIL|QWK_DELMAIL); if(!(useron.qwk&QWK_NOINDEX)) { sprintf(str,"%sPERSONAL.NDX",cfg.temp_dir); if((personal=fopen(str,"ab"))==NULL) { fclose(qwk); errormsg(WHERE,ERR_OPEN,str,0); return(false); } } else personal=NULL; if(useron.qwk&(QWK_EMAIL|QWK_ALLMAIL) /* && !prepack */) { sprintf(smb.file,"%smail",cfg.data_dir); smb.retry_time=cfg.smb_retry_time; smb.subnum=INVALID_SUB; if((i=smb_open(&smb))!=0) { fclose(qwk); if(personal) fclose(personal); errormsg(WHERE,ERR_OPEN,smb.file,i,smb.last_error); return(false); } /***********************/ /* Pack E-mail, if any */ /***********************/ qwkmail_last=0; mail=loadmail(&smb,&mailmsgs,useron.number,0,useron.qwk&QWK_ALLMAIL ? 0 : LM_UNREAD); if(mailmsgs && !(sys_status&SS_ABORT)) { bputs(text[QWKPackingEmail]); if(!(useron.qwk&QWK_NOINDEX)) { sprintf(str,"%s000.NDX",cfg.temp_dir); if((ndx=fopen(str,"ab"))==NULL) { fclose(qwk); if(personal) fclose(personal); smb_close(&smb); errormsg(WHERE,ERR_OPEN,str,0); free(mail); return(false); } } else ndx=NULL; if(useron.rest&FLAG('Q')) mode|=QM_TO_QNET; else mode&=~QM_TO_QNET; for(l=0;l<mailmsgs;l++) { bprintf("\b\b\b\b\b\b\b\b\b\b\b\b%4lu of %-4lu" ,l+1,mailmsgs); memset(&msg,0,sizeof(msg)); msg.idx=mail[l]; if(msg.idx.number>qwkmail_last) qwkmail_last=msg.idx.number; if(!loadmsg(&msg,mail[l].number)) continue; if(msg.hdr.auxattr&MSG_FILEATTACH && useron.qwk&QWK_ATTACH) { sprintf(str,"%sfile/%04u.in/%s" ,cfg.data_dir,useron.number,msg.subj); sprintf(tmp,"%s%s",cfg.temp_dir,msg.subj); if(fexistcase(str) && !fexistcase(tmp)) mv(str,tmp,1); } size=msgtoqwk(&msg,qwk,mode,INVALID_SUB,0); smb_unlockmsghdr(&smb,&msg); smb_freemsgmem(&msg); if(ndx) { msgndx++; f=ltomsbin(msgndx); /* Record number */ ch=0; /* Sub number, not used */ if(personal) { fwrite(&f,4,1,personal); fwrite(&ch,1,1,personal); } fwrite(&f,4,1,ndx); fwrite(&ch,1,1,ndx); msgndx+=size/QWK_BLOCK_LEN; } YIELD(); /* yield */ } bprintf(text[QWKPackedEmail],mailmsgs); if(ndx) fclose(ndx); } smb_close(&smb); /* Close the e-mail */ if(mailmsgs) free(mail); } /*********************/ /* Pack new messages */ /*********************/ for(i=0;i<usrgrps;i++) { for(j=0;j<usrsubs[i] && !msgabort();j++) { if(subscan[usrsub[i][j]].cfg&SUB_CFG_NSCAN || (!(useron.rest&FLAG('Q')) && cfg.sub[usrsub[i][j]]->misc&SUB_FORCED)) { if(!chk_ar(cfg.sub[usrsub[i][j]]->read_ar,&useron)) continue; lncntr=0; /* defeat pause */ if(useron.rest&FLAG('Q') && !(cfg.sub[usrsub[i][j]]->misc&SUB_QNET)) continue; /* QWK Net Node and not QWK networked, so skip */ subs_scanned++; msgs=getlastmsg(usrsub[i][j],&lastmsg,0); if(!msgs || lastmsg<=subscan[usrsub[i][j]].ptr) { /* no msgs */ if(subscan[usrsub[i][j]].ptr>lastmsg) { /* corrupted ptr */ outchar('*'); subscan[usrsub[i][j]].ptr=lastmsg; /* so fix automatically */ subscan[usrsub[i][j]].last=lastmsg; } bprintf(text[NScanStatusFmt] ,cfg.grp[cfg.sub[usrsub[i][j]]->grp]->sname ,cfg.sub[usrsub[i][j]]->lname,0L,msgs); continue; } sprintf(smb.file,"%s%s" ,cfg.sub[usrsub[i][j]]->data_dir,cfg.sub[usrsub[i][j]]->code); smb.retry_time=cfg.smb_retry_time; smb.subnum=usrsub[i][j]; if((k=smb_open(&smb))!=0) { errormsg(WHERE,ERR_OPEN,smb.file,k,smb.last_error); continue; } k=0; if(useron.qwk&QWK_BYSELF) k|=LP_BYSELF; if(useron.rest&FLAG('Q') || !(subscan[usrsub[i][j]].cfg&SUB_CFG_YSCAN)) k|=LP_OTHERS; post=loadposts(&posts,usrsub[i][j],subscan[usrsub[i][j]].ptr,k); bprintf(text[NScanStatusFmt] ,cfg.grp[cfg.sub[usrsub[i][j]]->grp]->sname ,cfg.sub[usrsub[i][j]]->lname,posts,msgs); if(!posts) { /* no new messages */ smb_close(&smb); continue; } bputs(text[QWKPackingSubboard]); submsgs=0; conf=cfg.sub[usrsub[i][j]]->qwkconf; if(!conf) conf=((i+1)*1000)+j+1; if(!(useron.qwk&QWK_NOINDEX)) { sprintf(str,"%s%u.NDX",cfg.temp_dir,conf); if((ndx=fopen(str,"ab"))==NULL) { fclose(qwk); if(personal) fclose(personal); smb_close(&smb); errormsg(WHERE,ERR_OPEN,str,0); free(post); return(false); } } else ndx=NULL; for(l=0;l<posts && !msgabort();l++) { bprintf("\b\b\b\b\b%-5lu",l+1); subscan[usrsub[i][j]].ptr=post[l].number; /* set ptr */ subscan[usrsub[i][j]].last=post[l].number; /* set last read */ memset(&msg,0,sizeof(msg)); msg.idx=post[l]; if(!loadmsg(&msg,post[l].number)) continue; if(useron.rest&FLAG('Q')) { if(msg.from_net.type && msg.from_net.type!=NET_QWK && !(cfg.sub[usrsub[i][j]]->misc&SUB_GATE)) { /* From other */ smb_freemsgmem(&msg); /* net, don't gate */ smb_unlockmsghdr(&smb,&msg); continue; } mode|=(QM_TO_QNET|QM_TAGLINE); if(msg.from_net.type==NET_QWK) { mode&=~QM_TAGLINE; if(route_circ((char *)msg.from_net.addr,useron.alias) || !strnicmp(msg.subj,"NE:",3)) { smb_freemsgmem(&msg); smb_unlockmsghdr(&smb,&msg); continue; } } } else mode&=~(QM_TAGLINE|QM_TO_QNET); size=msgtoqwk(&msg,qwk,mode,usrsub[i][j],conf); smb_unlockmsghdr(&smb,&msg); if(ndx) { msgndx++; f=ltomsbin(msgndx); /* Record number */ ch=0; /* Sub number, not used */ if(personal && (!stricmp(msg.to,useron.alias) || !stricmp(msg.to,useron.name))) { fwrite(&f,4,1,personal); fwrite(&ch,1,1,personal); } fwrite(&f,4,1,ndx); fwrite(&ch,1,1,ndx); msgndx+=size/QWK_BLOCK_LEN; } smb_freemsgmem(&msg); (*msgcnt)++; submsgs++; if(cfg.max_qwkmsgs && !(useron.exempt&FLAG('O')) && (*msgcnt)>=cfg.max_qwkmsgs) { bputs(text[QWKmsgLimitReached]); break; } if(!(l%50)) YIELD(); /* yield */ } if(!(sys_status&SS_ABORT)) bprintf(text[QWKPackedSubboard],submsgs,(*msgcnt)); if(ndx) { fclose(ndx); sprintf(str,"%s%u.NDX",cfg.temp_dir,conf); if(!flength(str)) remove(str); } smb_close(&smb); free(post); if(l<posts) break; YIELD(); /* yield */ } } if(j<usrsubs[i]) /* if sub aborted, abort all */ break; } if(online==ON_LOCAL) /* event */ eprintf(LOG_INFO,"%s scanned %lu sub-boards for new messages" ,useron.alias,subs_scanned); else lprintf(LOG_INFO,"Node %d %s scanned %lu sub-boards for new messages" ,cfg.node_num,useron.alias,subs_scanned); if((*msgcnt)+mailmsgs && time(NULL)-start) { bprintf("\r\n\r\n\1n\1hPacked %lu messages (%lu bytes) in %lu seconds " "(%lu messages/second)." ,(*msgcnt)+mailmsgs ,ftell(qwk) ,time(NULL)-start ,((*msgcnt)+mailmsgs)/(time(NULL)-start)); sprintf(str,"Packed %lu messages (%lu bytes) in %lu seconds (%lu msgs/sec)" ,(*msgcnt)+mailmsgs ,ftell(qwk) ,(ulong)(time(NULL)-start) ,((*msgcnt)+mailmsgs)/(time(NULL)-start)); if(online==ON_LOCAL) /* event */ eprintf(LOG_INFO,"%s",str); else lprintf(LOG_INFO,"%s",str); } fclose(qwk); /* close MESSAGE.DAT */ if(personal) { fclose(personal); /* close PERSONAL.NDX */ sprintf(str,"%sPERSONAL.NDX",cfg.temp_dir); if(!flength(str)) remove(str); } CRLF; if(!prepack && (sys_status&SS_ABORT || !online)) return(false); if(/*!prepack && */ useron.rest&FLAG('Q')) { /* If QWK Net node, check for files */ sprintf(str,"%sqnet/%s.out/",cfg.data_dir,useron.alias); dir=opendir(str); while(dir!=NULL && (dirent=readdir(dir))!=NULL) { /* Move files into temp dir */ sprintf(str,"%sqnet/%s.out/%s",cfg.data_dir,useron.alias,dirent->d_name); if(isdir(str)) continue; sprintf(tmp2,"%s%s",cfg.temp_dir,dirent->d_name); lncntr=0; /* Default pause */ if(online==ON_LOCAL) eprintf(LOG_INFO,"Including %s in packet",str); else lprintf(LOG_INFO,"Including %s in packet",str); bprintf(text[RetrievingFile],str); if(!mv(str,tmp2,1)) netfiles++; } if(dir!=NULL) closedir(dir); if(netfiles) CRLF; } if(batdn_total) { for(i=0,totalcdt=0;i<batdn_total;i++) if(!is_download_free(&cfg,batdn_dir[i],&useron)) totalcdt+=batdn_cdt[i]; if(totalcdt>useron.cdt+useron.freecdt) { bprintf(text[YouOnlyHaveNCredits] ,ultoac(useron.cdt+useron.freecdt,tmp)); } else { for(i=0,totaltime=0;i<batdn_total;i++) { if(!(cfg.dir[batdn_dir[i]]->misc&DIR_TFREE) && cur_cps) totaltime+=batdn_size[i]/(ulong)cur_cps; } if(!(useron.exempt&FLAG('T')) && !SYSOP && totaltime>timeleft) bputs(text[NotEnoughTimeToDl]); else { for(i=0;i<batdn_total;i++) { lncntr=0; unpadfname(batdn_name[i],tmp); sprintf(tmp2,"%s%s",cfg.temp_dir,tmp); if(!fexistcase(tmp2)) { seqwait(cfg.dir[batdn_dir[i]]->seqdev); bprintf(text[RetrievingFile],tmp); sprintf(str,"%s%s" ,batdn_alt[i]>0 && batdn_alt[i]<=cfg.altpaths ? cfg.altpath[batdn_alt[i]-1] : cfg.dir[batdn_dir[i]]->path ,tmp); mv(str,tmp2,1); /* copy the file to temp dir */ getnodedat(cfg.node_num,&thisnode,1); thisnode.aux=0xfe; putnodedat(cfg.node_num,&thisnode); CRLF; } } } } } if(!(*msgcnt) && !mailmsgs && !files && !netfiles && !batdn_total && (prepack || !preqwk)) { bputs(text[QWKNoNewMessages]); return(false); } if(!(useron.rest&FLAG('Q'))) { /* Don't include in network */ /***********************/ /* packets */ /* Copy QWK Text files */ /***********************/ sprintf(str,"%sQWK/HELLO",cfg.text_dir); if(fexistcase(str)) { sprintf(tmp2,"%sHELLO",cfg.temp_dir); mv(str,tmp2,1); } sprintf(str,"%sQWK/BBSNEWS",cfg.text_dir); if(fexistcase(str)) { sprintf(tmp2,"%sBBSNEWS",cfg.temp_dir); mv(str,tmp2,1); } sprintf(str,"%sQWK/GOODBYE",cfg.text_dir); if(fexistcase(str)) { sprintf(tmp2,"%sGOODBYE",cfg.temp_dir); mv(str,tmp2,1); } sprintf(str,"%sQWK/BLT-*",cfg.text_dir); glob(str,0,NULL,&g); for(i=0;i<(uint)g.gl_pathc;i++) { /* Copy BLT-*.* files */ fname=getfname(g.gl_pathv[i]); padfname(fname,str); if(isdigit(str[4]) && isdigit(str[9])) { sprintf(str,"%sQWK/%s",cfg.text_dir,fname); sprintf(tmp2,"%s%s",cfg.temp_dir,fname); mv(str,tmp2,1); } } globfree(&g); } if(prepack) { for(i=1;i<=cfg.sys_nodes;i++) { getnodedat(i,&node,0); if((node.status==NODE_INUSE || node.status==NODE_QUIET || node.status==NODE_LOGON) && node.useron==useron.number) break; } if(i<=cfg.sys_nodes) /* Don't pre-pack with user online */ return(false); } /*******************/ /* Compress Packet */ /*******************/ sprintf(tmp2,"%s%s",cfg.temp_dir,ALLFILES); i=external(cmdstr(temp_cmd(),packet,tmp2,NULL) ,ex|EX_WILDCARD); if(!fexist(packet)) { bputs(text[QWKCompressionFailed]); if(i) errormsg(WHERE,ERR_EXEC,cmdstr(temp_cmd(),packet,tmp2,NULL),i); else errorlog("Couldn't compress QWK packet"); return(false); } if(prepack) /* Early return if pre-packing */ return(true); l=flength(packet); sprintf(str,"%s.qwk",cfg.sys_id); bprintf(text[FiFilename],str); bprintf(text[FiFileSize],ultoac(l,tmp)); if(l>0L && cur_cps) i=l/(ulong)cur_cps; else i=0; bprintf(text[FiTransferTime],sectostr(i,tmp)); CRLF; if(!(useron.exempt&FLAG('T')) && i>timeleft) { bputs(text[NotEnoughTimeToDl]); return(false); } if(useron.rest&FLAG('Q')) { sprintf(str,"%s.qwk",cfg.sys_id); dir=opendir(cfg.temp_dir); while(dir!=NULL && (dirent=readdir(dir))!=NULL) { if(!stricmp(str,dirent->d_name)) /* QWK packet */ continue; sprintf(tmp,"%s%s",cfg.temp_dir,dirent->d_name); if(!isdir(tmp)) remove(tmp); } if(dir!=NULL) closedir(dir); } return(true); }
int nfs_proc_writev(struct nfs_fh *fhandle, int offset, int count, struct ae_recv *r, struct nfs_fattr *fattr) { int *p; int status; int ruid = 0; struct generic_server *server = fhandle->server; char *tmp_data; int i; int wsize; /* to be used with new prpc */ int remaining_count = count; struct p_rpc *prpc; struct p_rpc_rec *rw; DPRINTF(CLUHELP_LEVEL,("NFS call write %p %d @ %d\n", r, count, offset)); wsize = server->wsize; if (!(prpc = p_overhead_rpc_alloc(wsize, count))) return -EIO; demand(count <= wsize, we only handle up to 8K for now); tmp_data = NULL; // data; for (i = 0; i < prpc->n ; i++) { static char overflow[4]; rw = &prpc->rw[i]; rw->start = nfs_rpc_header(rw->ptr, NFSPROC_WRITE, ruid); rw->start = xdr_encode_fhandle(rw->start, fhandle); *rw->start++ = htonl(offset + i*wsize); /* offset */ *rw->start++ = htonl(offset + i*wsize); /* offset */ rw->count = (remaining_count >= wsize) ? wsize : remaining_count; *rw->start++ = htonl(rw->count); /* count */ *rw->start++ = htonl(rw->count); /* data len */ rw->end = rw->start; rw->r.n = 1; rw->r = *r; if ((rw->count % 4) != 0) { rw->r.r[r->n].data = overflow; rw->r.r[r->n].sz = 4 - (rw->count % 4); rw->r.n++; } pr_ae_recv(&rw->r); tmp_data += rw->count; remaining_count -= rw->count; rw->xid = rw->ptr[0]; rw->done = 0; /* print_rpc2(prpc->rw[i].ptr,128); */ } /* pr_p_rpc(prpc); */ lprintf("p_generic_rpc_call start\n"); if ((status = p_generic_rpc_call(server,prpc)) < 0) { p_overhead_rpc_free(prpc); return status; } lprintf("p_generic_rpc_call done\n"); DPRINTF(CLUHELP_LEVEL,("P_GENERIC_RPC_CALL: %d\n",status)); for (i = 0; i < prpc->n ; i++) { rw = &prpc->rw[i]; if (!(p = generic_rpc_verify(rw->ptr))) { status = NFSERR_IO; break; } else if ((status = ntohl(*p++)) == NFS_OK) { p = xdr_decode_fattr(p, fattr); DPRINTF(CLUHELP_LEVEL,("NFS reply write xid: %d, count %d\n", rw->xid,rw->count)); } } DPRINTF(CLUHELP_LEVEL,("status: %d\n",status)); p_overhead_rpc_free(prpc); return nfs_stat_to_errno(status); }
rtsp_t *rtsp_connect(xine_stream_t *stream, const char *mrl, const char *user_agent) { rtsp_t *s = malloc(sizeof(rtsp_t)); char *mrl_ptr=strdup(mrl); char *slash, *colon, *amp; int hostend, i; size_t pathbegin; if (strncmp(mrl,"rtsp://",7)) { xprintf(stream->xine, XINE_VERBOSITY_LOG, _("rtsp: bad mrl: %s\n"), mrl); free(s); return NULL; } mrl_ptr+=7; for (i=0; i<MAX_FIELDS; i++) { s->answers[i]=NULL; s->scheduled[i]=NULL; } s->stream=stream; s->host=NULL; s->port=554; /* rtsp standard port */ s->path=NULL; s->mrl=NULL; s->mrl=strdup(mrl); s->server=NULL; s->server_state=0; s->server_caps=0; s->cseq=0; s->session=NULL; if (user_agent) s->user_agent=strdup(user_agent); else s->user_agent=strdup("User-Agent: RealMedia Player Version 6.0.9.1235 (linux-2.0-libc6-i386-gcc2.95)"); amp =strchr(mrl_ptr,'@'); slash=strchr(mrl_ptr,'/'); colon=strchr(mrl_ptr,':'); if (amp && (!slash || amp < slash)) { char *username = NULL, *password = NULL; /* xxx@host:port/ */ if (colon && colon < amp) { /* xxx:yyy@host:port/ */ username = strndup(mrl_ptr, colon - mrl_ptr); password = strndup(colon + 1, amp - colon - 1); } else { username = strndup(mrl_ptr, amp - mrl_ptr); } mrl_ptr = amp + 1; slash = strchr(mrl_ptr, '/'); colon = strchr(mrl_ptr, ':'); if (username) { char *auth; rtsp_basicauth(username, password, &auth); s->auth = _x_asprintf("Authorization: Basic %s", auth); free(auth); } free(username); free(password); } if(!slash) slash=mrl_ptr+strlen(mrl_ptr)+1; if(!colon) colon=slash; if(colon > slash) colon=slash; pathbegin=slash-mrl_ptr; hostend=colon-mrl_ptr; s->host = strndup(mrl_ptr, hostend); if (pathbegin < strlen(mrl_ptr)) s->path=strdup(mrl_ptr+pathbegin+1); if (colon != slash) { char buffer[pathbegin-hostend]; strncpy(buffer,mrl_ptr+hostend+1, pathbegin-hostend-1); buffer[pathbegin-hostend-1]=0; s->port=atoi(buffer); if (s->port < 0 || s->port > 65535) s->port = 554; /* rtsp standard port */ } lprintf("got mrl: %s %i %s\n",s->host,s->port,s->path); s->s = _x_io_tcp_connect (stream, s->host, s->port); if (s->s < 0) { xprintf (stream->xine, XINE_VERBOSITY_LOG, _("rtsp: failed to connect to '%s'\n"), s->host); rtsp_close(s); return NULL; } s->server_state=RTSP_CONNECTED; /* now lets send an options request. */ rtsp_schedule_field(s, "CSeq: 1"); rtsp_schedule_field(s, s->user_agent); rtsp_schedule_field(s, "ClientChallenge: 9e26d33f2984236010ef6253fb1887f7"); rtsp_schedule_field(s, "PlayerStarttime: [28/03/2003:22:50:23 00:00]"); rtsp_schedule_field(s, "CompanyID: KnKV4M4I/B2FjJ1TToLycw=="); rtsp_schedule_field(s, "GUID: 00000000-0000-0000-0000-000000000000"); rtsp_schedule_field(s, "RegionData: 0"); rtsp_schedule_field(s, "ClientID: Linux_2.4_6.0.9.1235_play32_RN01_EN_586"); /*rtsp_schedule_field(s, "Pragma: initiate-session");*/ rtsp_request_options(s, NULL); return s; }
static void update_task(void *param) { conn_t *conn = (conn_t *) FROM_VOID_PARAM(param); bool force_check = (conn && conn->update_check == FORCE_CHECK); bool force_build = (conn && conn->update_check == FORCE_BUILD); bool ver_changed, update_install; lprintf("UPDATE: checking for updates\n"); // Run curl in a Linux child process otherwise this thread will block and cause trouble // if the check is invoked from the admin page while there are active user connections. int status = child_task("kiwi.upd", POLL_MSEC(1000), curl_makefile_ctask, NULL); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { lprintf("UPDATE: curl Makefile error, no Internet access? status=0x%08x WIFEXITED=%d WEXITSTATUS=%d\n", status, WIFEXITED(status), WEXITSTATUS(status)); if (force_check) report_result(conn); goto common_return; } FILE *fp; scallz("fopen Makefile.1", (fp = fopen("/root/" REPO_NAME "/Makefile.1", "r"))); int n1, n2; n1 = fscanf(fp, "VERSION_MAJ = %d\n", &pending_maj); n2 = fscanf(fp, "VERSION_MIN = %d\n", &pending_min); fclose(fp); ver_changed = (n1 == 1 && n2 == 1 && (pending_maj > version_maj || (pending_maj == version_maj && pending_min > version_min))); update_install = (admcfg_bool("update_install", NULL, CFG_REQUIRED) == true); if (force_check) { if (ver_changed) lprintf("UPDATE: version changed (current %d.%d, new %d.%d), but check only\n", version_maj, version_min, pending_maj, pending_min); else lprintf("UPDATE: running most current version\n"); report_result(conn); goto common_return; } else if (ver_changed && !update_install && !force_build) { lprintf("UPDATE: version changed (current %d.%d, new %d.%d), but update install not enabled\n", version_maj, version_min, pending_maj, pending_min); } else if (ver_changed || force_build) { lprintf("UPDATE: version changed%s, current %d.%d, new %d.%d\n", force_build? " (forced)":"", version_maj, version_min, pending_maj, pending_min); lprintf("UPDATE: building new version..\n"); update_in_progress = true; rx_server_user_kick(-1); // kick everyone off to speed up build sleep(5); // Run build in a Linux child process so the server can continue to respond to connection requests // and display a "software update in progress" message. // This is because the calls to system() in update_build_ctask() block for the duration of the build. u4_t build_time = timer_sec(); status = child_task("kiwi.bld", POLL_MSEC(1000), update_build_ctask, TO_VOID_PARAM(force_build)); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { lprintf("UPDATE: build error, no Internet access? status=0x%08x WIFEXITED=%d WEXITSTATUS=%d\n", status, WIFEXITED(status), WEXITSTATUS(status)); goto common_return; } lprintf("UPDATE: build took %d secs\n", timer_sec() - build_time); lprintf("UPDATE: switching to new version %d.%d\n", pending_maj, pending_min); if (admcfg_int("update_restart", NULL, CFG_REQUIRED) == 0) { xit(0); } else { lprintf("UPDATE: rebooting Beagle..\n"); system("sleep 3; reboot"); } } else { lprintf("UPDATE: version %d.%d is current\n", version_maj, version_min); } if (daily_restart) { lprintf("UPDATE: daily restart..\n"); xit(0); } common_return: if (conn) conn->update_check = WAIT_UNTIL_NO_USERS; // restore default update_pending = update_task_running = update_in_progress = false; }
void TrackThree::generateTable(TrackInfo *trackInfoLeft, TrackInfo *trackInfoRight, int trackStartX, int trackStartY) { int i,j; int x,y; TrackInfo *currentTrackInfo; int turnAngle,numBlocks,roadWidth; int count; //Forcing contigous memory allocation cellArray = new char*[numCellsY]; //cellArray[0] = new int[numCellsX * numCellsY]; for (i = 0; i < numCellsY; i++) { cellArray[i] = new char[numCellsX];//cellArray[0] + i * numCellsY; } guardRail = new GuardRailCell[numCellsY]; //left side currentTrackInfo = trackInfoLeft; leftSideBarrier = new LineClass[numTurns + 1]; count = numCellsY - 1; x = trackStartX; y = trackStartY; for (i = numTurns; i >= 0; i--) { currentTrackInfo[i].startTurnY = y; numBlocks = currentTrackInfo[i].numCells; turnAngle = currentTrackInfo[i].curve; roadWidth = currentTrackInfo[i].roadWidth; lprintf("Index = %d, TurnAngle = %d, NumBlocks = %d\n",i,turnAngle,numBlocks); leftSideBarrier[i].setP1(x + 1 ,y); for(j = 0;j < numBlocks;j++) { if(j % 2 == 0) { switch(turnAngle) { case NONE: break; case NORMAL_LEFT: x -= 1; break; case NORMAL_RIGHT: x += 1; break; case STEEP_LEFT: x -= 2; break; case STEEP_RIGHT: x += 2; break; default: assert(0); break; } } if(count < 0) { lprintf("total count of numcells in trackInfoLeft are inconsistent with count\n"); assert(0); } else { guardRail[count].left.setX(x); guardRail[count].left.setY(y); } y += BOUNDARY_CELL_SIZE; count--; } currentTrackInfo[i].endTurnY = y; leftSideBarrier[i].setP2(x + 1, y); } //right side currentTrackInfo = trackInfoRight; rightSideBarrier = new LineClass[numTurns + 1]; count = numCellsY - 1; x = trackStartX + 69; y = trackStartY; for (i = numTurns; i >= 0; i--) { numBlocks = currentTrackInfo[i].numCells; turnAngle = currentTrackInfo[i].curve; roadWidth = currentTrackInfo[i].roadWidth; lprintf("Index = %d, TurnAngle = %d, NumBlocks = %d\n",i,turnAngle,numBlocks); rightSideBarrier[i].setP1(x - 1 ,y); for(j = 0;j < numBlocks;j++) { switch(turnAngle) { case NONE: break; case NORMAL_LEFT: x -= 1; break; case NORMAL_RIGHT: x += 1; break; case STEEP_LEFT: x -= 2; break; case STEEP_RIGHT: x += 2; break; default: assert(0); break; } if(count < 0) { lprintf("total count of numcells in trackInfoRight are inconsistent with count\n"); assert(0); } else { guardRail[count].right.setX(x); guardRail[count].right.setY(y); } guardRail[count].roadWidth = (guardRail[count].right.getX() - guardRail[count].left.getX()) / BOUNDARY_CELL_SIZE; //don't show road strip while on turns if(numBlocks < 30) { guardRail[count].showRoadStrip = no; } y += BOUNDARY_CELL_SIZE; count--; } rightSideBarrier[i].setP2(x - 1, y); } }
int BoardID(int crateNum, uint32_t slotMask, int updateLocation) { lprintf("*** Starting Board ID ******************\n"); XL3Packet packet; BoardIDReadArgs *args = (BoardIDReadArgs *) packet.payload; BoardIDReadResults *results = (BoardIDReadResults *) packet.payload; uint16_t ids[16*6]; int crates[16*6]; int slots[16*6]; int positions[16*6]; int boardcount = 0; try{ lprintf("SLOT ID: MB DB1 DB2 DB3 DB4 HVC\n"); for (int i=0;i<16;i++){ if ((0x1<<i) & slotMask){ lprintf("%d ",i); for (int j=1;j<7;j++){ packet.header.packetType = BOARD_ID_READ_ID; args->slot = i; args->chip = j; args->reg = 15; SwapLongBlock(packet.payload,sizeof(BoardIDReadArgs)/sizeof(uint32_t)); xl3s[crateNum]->SendCommand(&packet); SwapLongBlock(packet.payload,sizeof(BoardIDReadResults)/sizeof(uint32_t)); lprintf("0x%04x ",results->id); int pass = 1; if (j==1){ //fec if (((results->id & 0xF000) != 0xF000) || results->id == 0xFFFF) pass = 0; }else if (j<6){//db if ( (results->id & 0xF000) != 0xD000) pass = 0; }else{//pmtic if ((results->id & 0xF000) != 0xE000) pass = 0; } if (pass && updateLocation){ ids[boardcount] = results->id; crates[boardcount] = crateNum; slots[boardcount] = i; positions[boardcount] = j-1; boardcount++; } } lprintf("\n"); } } if (updateLocation){ lprintf("Updating location...\n"); UpdateLocation(ids,crates,slots,positions,boardcount); } } catch(const char* s){ lprintf("BoardID: %s\n",s); } lprintf("****************************************\n"); return 0; }
/* Copy a monochrome bitmap. */ static int x_copy_mono(gx_device * dev, const byte * base, int sourcex, int raster, gx_bitmap_id id, int x, int y, int w, int h, gx_color_index zero, gx_color_index one) /* * X doesn't directly support the simple operation of writing a color * through a mask specified by an image. The plot is the following: * If neither color is gx_no_color_index ("transparent"), * use XPutImage with the "copy" function as usual. * If the color either bitwise-includes or is bitwise-included-in * every color written to date * (a special optimization for writing black/white on color displays), * use XPutImage with an appropriate Boolean function. * Otherwise, do the following complicated stuff: * Create pixmap of depth 1 if necessary. * If foreground color is "transparent" then * invert the raster data. * Use XPutImage to copy the raster image to the newly * created Pixmap. * Install the Pixmap as the clip_mask in the X GC and * tweak the clip origin. * Do an XFillRectangle, fill style=solid, specifying a * rectangle the same size as the original raster data. * De-install the clip_mask. */ { gx_device_X *xdev = (gx_device_X *) dev; int function = GXcopy; unsigned long lzero = zero, lone = one; x_pixel bc = lzero, fc = lone; fit_copy(dev, base, sourcex, raster, id, x, y, w, h); flush_text(xdev); xdev->image.width = sourcex + w; xdev->image.height = h; xdev->image.data = (char *)base; xdev->image.bytes_per_line = raster; X_SET_FILL_STYLE(xdev, FillSolid); /* Check for null, easy 1-color, hard 1-color, and 2-color cases. */ if (zero != gx_no_color_index) { if (one != gx_no_color_index) { /* 2-color case. */ /* Simply replace existing bits with what's in the image. */ } else if (!(~xdev->colors_and & bc)) { function = GXand; fc = ~(x_pixel) 0; } else if (!(~bc & xdev->colors_or)) { function = GXor; fc = 0; } else { goto hard; } } else { if (one == gx_no_color_index) { /* no-op */ return 0; } else if (!(~xdev->colors_and & fc)) { function = GXand; bc = ~(x_pixel) 0; } else if (!(~fc & xdev->colors_or)) { function = GXor; bc = 0; } else { goto hard; } } xdev->image.format = XYBitmap; X_SET_FUNCTION(xdev, function); if (bc != xdev->back_color) { XSetBackground(xdev->dpy, xdev->gc, (xdev->back_color = bc)); } if (fc != xdev->fore_color) { XSetForeground(xdev->dpy, xdev->gc, (xdev->fore_color = fc)); } if (zero != gx_no_color_index) NOTE_COLOR(xdev, lzero); if (one != gx_no_color_index) NOTE_COLOR(xdev, lone); put_image(xdev->dpy, xdev->dest, xdev->gc, &xdev->image, sourcex, 0, x, y, w, h); goto out; hard: /* Handle the hard 1-color case. */ if (raster > xdev->cp.raster || h > xdev->cp.height) { /* Must allocate a new pixmap and GC. */ /* Release the old ones first. */ free_cp(dev); /* Create the clipping pixmap, depth must be 1. */ xdev->cp.pixmap = XCreatePixmap(xdev->dpy, xdev->win, raster << 3, h, 1); if (xdev->cp.pixmap == (Pixmap) 0) { lprintf("x_copy_mono: can't allocate pixmap\n"); return_error(gs_error_VMerror); } xdev->cp.gc = XCreateGC(xdev->dpy, xdev->cp.pixmap, 0, 0); if (xdev->cp.gc == (GC) 0) { lprintf("x_copy_mono: can't allocate GC\n"); return_error(gs_error_VMerror); } xdev->cp.raster = raster; xdev->cp.height = h; } /* Initialize static mask image params */ xdev->image.format = XYBitmap; X_SET_FUNCTION(xdev, GXcopy); /* Select polarity based on fg/bg transparency. */ if (one == gx_no_color_index) { /* invert */ XSetBackground(xdev->dpy, xdev->cp.gc, (x_pixel) 1); XSetForeground(xdev->dpy, xdev->cp.gc, (x_pixel) 0); X_SET_FORE_COLOR(xdev, lzero); } else { XSetBackground(xdev->dpy, xdev->cp.gc, (x_pixel) 0); XSetForeground(xdev->dpy, xdev->cp.gc, (x_pixel) 1); X_SET_FORE_COLOR(xdev, lone); } put_image(xdev->dpy, xdev->cp.pixmap, xdev->cp.gc, &xdev->image, sourcex, 0, 0, 0, w, h); /* Install as clipmask. */ XSetClipMask(xdev->dpy, xdev->gc, xdev->cp.pixmap); XSetClipOrigin(xdev->dpy, xdev->gc, x, y); /* * Draw a solid rectangle through the raster clip mask. * Note fill style is guaranteed to be solid from above. */ XFillRectangle(xdev->dpy, xdev->dest, xdev->gc, x, y, w, h); /* Tidy up. Free the pixmap if it's big. */ XSetClipMask(xdev->dpy, xdev->gc, None); if (raster * h > xdev->MaxTempPixmap) free_cp(dev); out:if (xdev->bpixmap != (Pixmap) 0) { /* We wrote to the pixmap, so update the display now. */ x_update_add(xdev, x, y, w, h); } return 0; }
int main(int argc, char **argv) { CONFIG cfg; WT_CONNECTION *conn; const char *user_cconfig, *user_tconfig; const char *opts = "C:I:P:R:U:T:c:d:eh:i:k:l:r:s:t:u:v:SML"; char *cc_buf, *tc_buf; int ch, checkpoint_created, ret, stat_created; pthread_t checkpoint, stat; uint64_t req_len; /* Setup the default configuration values. */ memcpy(&cfg, &default_cfg, sizeof(cfg)); cc_buf = tc_buf = NULL; user_cconfig = user_tconfig = NULL; conn = NULL; checkpoint_created = stat_created = 0; /* * First parse different config structures - other options override * fields within the structure. */ while ((ch = getopt(argc, argv, opts)) != EOF) switch (ch) { case 'S': memcpy(&cfg, &small_cfg, sizeof(cfg)); break; case 'M': memcpy(&cfg, &med_cfg, sizeof(cfg)); break; case 'L': memcpy(&cfg, &large_cfg, sizeof(cfg)); break; default: /* Validation is provided on the next parse. */ break; } /* Parse other options */ optind = 1; while ((ch = getopt(argc, argv, opts)) != EOF) switch (ch) { case 'd': cfg.data_sz = (uint32_t)atoi(optarg); break; case 'c': cfg.checkpoint_interval = (uint32_t)atoi(optarg); break; case 'e': cfg.create = 0; break; case 'h': cfg.home = optarg; break; case 'i': cfg.icount = (uint32_t)atoi(optarg); break; case 'k': cfg.key_sz = (uint32_t)atoi(optarg); break; case 'l': cfg.stat_interval = (uint32_t)atoi(optarg); break; case 'r': cfg.run_time = (uint32_t)atoi(optarg); break; case 's': cfg.rand_seed = (uint32_t)atoi(optarg); break; case 't': cfg.report_interval = (uint32_t)atoi(optarg); break; case 'u': cfg.uri = optarg; break; case 'v': cfg.verbose = (uint32_t)atoi(optarg); break; case 'C': user_cconfig = optarg; break; case 'I': cfg.insert_threads = (uint32_t)atoi(optarg); break; case 'P': cfg.populate_threads = (uint32_t)atoi(optarg); break; case 'R': cfg.read_threads = (uint32_t)atoi(optarg); break; case 'U': cfg.update_threads = (uint32_t)atoi(optarg); break; case 'T': user_tconfig = optarg; break; case 'L': case 'M': case 'S': break; case '?': default: fprintf(stderr, "Invalid option\n"); usage(); return (EINVAL); } if ((ret = setup_log_file(&cfg)) != 0) goto err; /* Make stdout line buffered, so verbose output appears quickly. */ (void)setvbuf(stdout, NULL, _IOLBF, 0); /* Concatenate non-default configuration strings. */ if (cfg.verbose > 1 || user_cconfig != NULL) { req_len = strlen(cfg.conn_config) + strlen(debug_cconfig) + 3; if (user_cconfig != NULL) req_len += strlen(user_cconfig); cc_buf = calloc(req_len, 1); if (cc_buf == NULL) { ret = ENOMEM; goto err; } snprintf(cc_buf, req_len, "%s%s%s%s%s", cfg.conn_config, cfg.verbose > 1 ? "," : "", cfg.verbose > 1 ? debug_cconfig : "", user_cconfig ? "," : "", user_cconfig ? user_cconfig : ""); cfg.conn_config = cc_buf; } if (cfg.verbose > 1 || user_tconfig != NULL) { req_len = strlen(cfg.table_config) + strlen(debug_tconfig) + 3; if (user_tconfig != NULL) req_len += strlen(user_tconfig); tc_buf = calloc(req_len, 1); if (tc_buf == NULL) { ret = ENOMEM; goto err; } snprintf(tc_buf, req_len, "%s%s%s%s%s", cfg.table_config, cfg.verbose > 1 ? "," : "", cfg.verbose > 1 ? debug_tconfig : "", user_tconfig ? "," : "", user_tconfig ? user_tconfig : ""); cfg.table_config = tc_buf; } srand(cfg.rand_seed); if (cfg.verbose > 1) print_config(&cfg); /* Open a connection to the database, creating it if necessary. */ if ((ret = wiredtiger_open( cfg.home, NULL, cfg.conn_config, &conn)) != 0) { lprintf(&cfg, ret, 0, "Error connecting to %s", cfg.home); goto err; } cfg.conn = conn; g_util_running = 1; if (cfg.stat_interval != 0) { if ((ret = pthread_create( &stat, NULL, stat_worker, &cfg)) != 0) { lprintf(&cfg, ret, 0, "Error creating statistics thread."); goto err; } stat_created = 1; } if (cfg.checkpoint_interval != 0) { if ((ret = pthread_create( &checkpoint, NULL, checkpoint_worker, &cfg)) != 0) { lprintf(&cfg, ret, 0, "Error creating checkpoint thread."); goto err; } checkpoint_created = 1; } if (cfg.create != 0 && execute_populate(&cfg) != 0) goto err; /* If we aren't populating, set the insert count. */ if (cfg.create == 0 && find_table_count(&cfg) != 0) goto err; if (cfg.run_time != 0 && cfg.read_threads + cfg.insert_threads + cfg.update_threads != 0 && (ret = execute_workload(&cfg)) != 0) goto err; lprintf(&cfg, 0, 1, "Ran performance test example with %d read threads, %d insert" " threads and %d update threads for %d seconds.", cfg.read_threads, cfg.insert_threads, cfg.update_threads, cfg.run_time); if (cfg.read_threads != 0) lprintf(&cfg, 0, 1, "Executed %" PRIu64 " read operations", g_nread_ops); if (cfg.insert_threads != 0) lprintf(&cfg, 0, 1, "Executed %" PRIu64 " insert operations", g_nins_ops); if (cfg.update_threads != 0) lprintf(&cfg, 0, 1, "Executed %" PRIu64 " update operations", g_nupdate_ops); err: g_util_running = 0; if (checkpoint_created != 0 && (ret = pthread_join(checkpoint, NULL)) != 0) lprintf(&cfg, ret, 0, "Error joining checkpoint thread."); if (stat_created != 0 && (ret = pthread_join(stat, NULL)) != 0) lprintf(&cfg, ret, 0, "Error joining stat thread."); if (conn != NULL && (ret = conn->close(conn, NULL)) != 0) lprintf(&cfg, ret, 0, "Error closing connection to %s", cfg.home); if (cc_buf != NULL) free(cc_buf); if (tc_buf != NULL) free(tc_buf); if (cfg.logf != NULL) { fflush(cfg.logf); fclose(cfg.logf); } return (ret); }
LOCAL void logTask( void ) { LOG_MSG logMsg; char *tName; int newMsgsLost; /* Initialize locals */ newMsgsLost = oldMsgsLost; /* Endless loop */ while (1) { /* If failed to get message */ if (msgQReceive(logMsgQId, &logMsg, sizeof(logMsg), WAIT_FOREVER) != sizeof(logMsg)) { /* Error */ lprintf( "logTask: error reading log messages.\n", (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0 ); } else { if (logMsg.id == -1) { lprintf( "interrupt: ", (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0 ); } else { /* Get name from task */ tName = taskName(logMsg.id); if (tName == NULL) { lprintf( "%#x (): task dead", (ARG) logMsg.id, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0 ); } else { lprintf( "%#x (%s): ", (ARG) logMsg.id, (ARG) tName, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0 ); } } /* If message format null */ if (logMsg.fmt == NULL) { lprintf( "<null \"fmt\" parameter>\n", (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0 ); } else { lprintf( logMsg.fmt, logMsg.arg[0], logMsg.arg[1], logMsg.arg[2], logMsg.arg[3], logMsg.arg[4], logMsg.arg[5] ); } } /* If lost messages changed */ if (newMsgsLost != oldMsgsLost) { lprintf( "logTask: %d log messages lost.\n", (ARG) newMsgsLost - oldMsgsLost, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0 ); oldMsgsLost = newMsgsLost; } } }
void SetupDevice() { // Query how many devices are present in the system uint32_t deviceCount = 0; VkResult result; if( !vl.instance ) SetupInstance(); result = vkEnumeratePhysicalDevices( vl.instance, &deviceCount, NULL ); if( result != VK_SUCCESS ) { fprintf( stderr, "Failed to query the number of physical devices present: %d", result ); abort(); } // There has to be at least one device present if( deviceCount == 0 ) { fprintf( stderr, "Couldn't detect any device present with Vulkan support: %d", result ); abort(); } // Get the physical devices vl.physicalDevices = NewArray( VkPhysicalDevice, deviceCount ); result = vkEnumeratePhysicalDevices( vl.instance, &deviceCount, vl.physicalDevices ); if( result != VK_SUCCESS ) { fprintf( stderr, "Faied to enumerate physical devices present: %d", result ); abort(); } { // Enumerate all physical devices VkPhysicalDeviceProperties deviceProperties; uint32_t i; for( i = 0; i < deviceCount; i++ ) { memset( &deviceProperties, 0, sizeof deviceProperties ); vkGetPhysicalDeviceProperties( vl.physicalDevices[i], &deviceProperties ); lprintf( "Driver Version: %d", deviceProperties.driverVersion ); lprintf( "Device Name: %s", deviceProperties.deviceName ); lprintf( "Device Type: %d", deviceProperties.deviceType ); lprintf( "API Version: %d.%d.%d" // See note below regarding this: , VK_VERSION_MAJOR( deviceProperties.apiVersion ) , VK_VERSION_MINOR( deviceProperties.apiVersion ) , VK_VERSION_PATCH( deviceProperties.apiVersion ) ); { uint32_t queueFamilyCount = 0; uint32_t i , j; VkQueueFamilyProperties *familyProperties; vkGetPhysicalDeviceQueueFamilyProperties( vl.physicalDevices[i], &queueFamilyCount, NULL ); familyProperties = NewArray( VkQueueFamilyProperties, (queueFamilyCount) ); vkGetPhysicalDeviceQueueFamilyProperties( vl.physicalDevices[i], &queueFamilyCount, familyProperties ); // Print the families for( i = 0; i < deviceCount; i++ ) { for( j = 0; j < queueFamilyCount; j++ ) { printf( "Count of Queues: %d", familyProperties[j].queueCount ); printf( "Supported operationg on this queue:" ); if( familyProperties[j].queueFlags & VK_QUEUE_GRAPHICS_BIT ) lprintf( "\t\t Graphics" ); if( familyProperties[j].queueFlags & VK_QUEUE_COMPUTE_BIT ) lprintf( "\t\t Compute" ); if( familyProperties[j].queueFlags & VK_QUEUE_TRANSFER_BIT ) lprintf( "\t\t Transfer" ); if( familyProperties[j].queueFlags & VK_QUEUE_SPARSE_BINDING_BIT ) lprintf( "\t\t Sparse Binding" ); } } } } } }
/* * mmove(x,y,xd,yd) Function to actually perform the monster movement * int x,y,xd,yd; * * Enter with the from coordinates in (x,y) and the destination coordinates * in (xd,yd). */ static void mmove(int aa, int bb, int cc, int dd) { int tmp,i,flag; char *who = ""; char *p = ""; flag=0; /* set to 1 if monster hit by arrow trap */ if ((cc==playerx) && (dd==playery)) { hitplayer(aa,bb); return; } i=item[cc][dd]; if ((i==OPIT) || (i==OTRAPDOOR)) switch(mitem[aa][bb]) { case BAT: case EYE: case SPIRITNAGA: case PLATINUMDRAGON: case WRAITH: case VAMPIRE: case SILVERDRAGON: case POLTERGEIST: case DEMONLORD: case DEMONLORD+1: case DEMONLORD+2: case DEMONLORD+3: case DEMONLORD+4: case DEMONLORD+5: case DEMONLORD+6: case DEMONPRINCE: break; default: mitem[aa][bb]=0; /* fell in a pit or trapdoor */ }; tmp = mitem[aa][bb]; mitem[cc][dd] = tmp; if (i==OANNIHILATION) { if (tmp>=DEMONLORD+3) /* demons dispel spheres */ { cursors(); lprintf("\nThe %s dispels the sphere!",monster[tmp].name); rmsphere(cc,dd); /* delete the sphere */ } else mitem[cc][dd]=i=tmp=0; } stealth[cc][dd]=1; if ((hitp[cc][dd] = hitp[aa][bb]) < 0) hitp[cc][dd]=1; mitem[aa][bb] = 0; if (tmp == LEPRECHAUN) switch(i) { case OGOLDPILE: case OMAXGOLD: case OKGOLD: case ODGOLD: case ODIAMOND: case ORUBY: case OEMERALD: case OSAPPHIRE: item[cc][dd] = 0; /* leprechaun takes gold */ }; if (tmp == TROLL) /* if a troll regenerate him */ if ((gtime & 1) == 0) if (monster[tmp].hitpoints > hitp[cc][dd]) hitp[cc][dd]++; if (i==OTRAPARROW) /* arrow hits monster */ { who = "An arrow"; if ((hitp[cc][dd] -= rnd(10)+level) <= 0) { mitem[cc][dd]=0; flag=2; } else flag=1; } if (i==ODARTRAP) /* dart hits monster */ { who = "A dart"; if ((hitp[cc][dd] -= rnd(6)) <= 0) { mitem[cc][dd]=0; flag=2; } else flag=1; } if (i==OTELEPORTER) /* monster hits teleport trap */ { flag=3; fillmonst(mitem[cc][dd]); mitem[cc][dd]=0; } if (cdesc[BLINDCOUNT]) return; /* if blind don't show where monsters are */ if (know[cc][dd] & HAVESEEN) { p=0; if (flag) cursors(); switch(flag) { case 1: p="\n%s hits the %s"; break; case 2: p="\n%s hits and kills the %s"; break; case 3: p="\nThe %s%s gets teleported"; who=""; break; }; if (p) { lprintf(p,who,monster[tmp].name); } } /* if (yrepcount>1) { know[aa][bb] &= 2; know[cc][dd] &= 2; return; } */ if (know[aa][bb] & HAVESEEN) show1cell(aa,bb); if (know[cc][dd] & HAVESEEN) show1cell(cc,dd); }
void SetupInstance() { int n = 5; //for( n = 0; n < 100; n++ ) { // Filling out application description: // sType is mandatory vl.applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; // pNext is mandatory vl.applicationInfo.pNext = NULL; // The name of our application vl.applicationInfo.pApplicationName = GetProgramName(); // The name of the engine (e.g: Game engine name) vl.applicationInfo.pEngineName = "SACK Core"; // The version of the engine vl.applicationInfo.engineVersion = 1; // The version of Vulkan we're using for this application vl.applicationInfo.apiVersion = VK_API_VERSION_1_0 | n; // Filling out instance description: // sType is mandatory vl.instanceInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; // pNext is mandatory vl.instanceInfo.pNext = NULL; // flags is mandatory vl.instanceInfo.flags = 0; // The application info structure is then passed through the instance vl.instanceInfo.pApplicationInfo = &vl.applicationInfo; // Don't enable and layer vl.instanceInfo.enabledLayerCount = 0; vl.instanceInfo.ppEnabledLayerNames = NULL; // Don't enable any extensions vl.instanceInfo.enabledExtensionCount = 0; vl.instanceInfo.ppEnabledExtensionNames = NULL; // open an actual output device... { PLIST enabledExtensions = NULL; AddLink( &enabledExtensions, VK_KHR_SURFACE_EXTENSION_NAME ); #if defined(_WIN32) AddLink( &enabledExtensions, VK_KHR_WIN32_SURFACE_EXTENSION_NAME ); #else AddLink( &enabledExtensions, VK_KHR_XCB_SURFACE_EXTENSION_NAME ); #endif vl.instanceInfo.enabledExtensionCount = GetLinkCount( enabledExtensions ); vl.instanceInfo.ppEnabledExtensionNames = (const char*const*)GetLinkAddress( &enabledExtensions, 0 ); } { // Now create the desired instance VkResult result = vkCreateInstance( &vl.instanceInfo, NULL, &vl.instance ); if( result != VK_SUCCESS ) { lprintf( "Failed to create instance: %d", result ); //exit( 0 ); } else lprintf( "Success!" ); } } // To Come Later // ... // ... }
void loadTex(void * target,char * command, char* rest) { char buffer[1024]; int bufferpos=0,restpos=0; ShaderStage_t *stage = l_SHDData.stage; int tex = 0; int attribute = 0; if (strcmp(command,"alphamode")==0 || strcmp(command,"blendmode")==0 || strcmp(command,"blendinvertalpha")==0){ loadBlend(target,command,rest); return; } if (strcmp(command,"TEXALPHA")==0 || strcmp(command,"VTEXALPHA")==0) tex = TEX_ALPHA; else if (strcmp(command,"TEXCUBE")==0 || strcmp(command,"VTEXCUBE")==0){ tex = TEX_COLOR; attribute |= TEX_ATTR_CUBE; } else if (strcmp(command,"TEXPROJ")==0 || strcmp(command,"VTEXPROJ")==0){ tex = TEX_COLOR; attribute |= TEX_ATTR_PROJ; } else if (strcmp(command,"TEXDOTZ")==0 || strcmp(command,"VTEXDOTZ")==0){ tex = TEX_COLOR; attribute |= TEX_ATTR_DOTZ; } else if (strcmp(command,"TEX")==0 || strcmp(command,"VTEX")==0) tex = TEX_COLOR; if (tex) { char name[256]; lxStrReadInQuotes(rest, name, 255); stage->srcType = tex; stage->srcAttributes |= attribute; if (strstr(name,"Texture:")){ if (sscanf(name,"Texture:%i",&stage->id)){ stage->id += MATERIAL_TEX0; stage->colorid = stage->id; } } else{ resnewstrcpy(stage->srcName,name); } if (strcmp(command,"VTEX")==0 || strcmp(command,"VTEXALPHA")==0 || strcmp(command,"VTEXPROJ")==0 || strcmp(command,"VTEXCUBE")==0 || strcmp(command,"VTEXDOTZ")==0) stage->stageflag |= SHADER_VCOLOR | SHADER_VCOLOR_KEEP; return; } if (strcmp(command,"ATTENUATE3D")==0){ stage->srcType = TEX_3D_ATTENUATE; stage->stageflag |= SHADER_SPECIAL; return; } if (strcmp(command,"NORMALIZE")==0){ stage->srcType = TEX_CUBE_NORMALIZE; stage->stageflag |= SHADER_SPECIAL; return; } if (strcmp(command,"SKYBOX")==0){ stage->srcType = TEX_CUBE_SKYBOX; stage->stageflag |= SHADER_SPECIAL; return; } if (strcmp(command,"DUMMY")==0){ stage->srcType = TEX_DUMMY; stage->stageflag |= SHADER_SPECIAL; return; } if (strcmp(command,"SPECULAR")==0){ stage->srcType = TEX_CUBE_SPECULAR; stage->stageflag |= SHADER_SPECIAL; return; } if (strcmp(command,"DIFFUSE")==0){ stage->srcType = TEX_CUBE_DIFFUSE; stage->stageflag |= SHADER_SPECIAL; return; } if (strcmp(command,"LIGHTMAP")==0){ stage->srcType = TEX_2D_LIGHTMAP; stage->stageflag |= SHADER_SPECIAL; stage->texchannel = VID_TEXCOORD_LIGHTMAP; return; } if (strcmp(command,"vertexcolored")==0) { stage->stageflag |= SHADER_VCOLOR | SHADER_VCOLOR_KEEP; return; } if (strcmp(command,"spheremap")==0) { stage->stageflag |= SHADER_SPHEREMAP; stage->stageflag |= SHADER_TEXGEN; return; } if (strcmp(command,"screenmap")==0) { stage->stageflag |= SHADER_SCREENMAP; stage->stageflag |= SHADER_TEXGEN; return; } if (strcmp(command,"reflectmap")==0) { stage->stageflag |= SHADER_REFLECTMAP; stage->stageflag |= SHADER_TEXGEN; return; } if (strcmp(command,"skyreflectmap")==0) { stage->stageflag |= SHADER_SKYMAP; stage->stageflag |= SHADER_TEXGEN; return; } if (strstr(command,"lightnormalmap")){ stage->stageflag |= SHADER_SUNREFMAP; stage->stageflag |= SHADER_TEXGEN; stage->stageparam = command[14]-'0'; stage->stageparam %= 4; return; } if (strstr(command,"lightreflectmap")){ stage->stageflag |= SHADER_SUNREFMAP; stage->stageflag |= SHADER_TEXGEN; stage->stageparam = command[15]-'0'; stage->stageparam %= 4; return; } if (strcmp(command,"sunreflectmap")==0) { stage->stageflag |= SHADER_SUNREFMAP; stage->stageflag |= SHADER_TEXGEN; //l_SHDData.shader->shaderflag |= SHADER_NEEDINVMATRIX; stage->stageparam = 0; return; } if (strcmp(command,"sunnormalmap")==0) { stage->stageflag |= SHADER_SUNNORMALMAP; stage->stageflag |= SHADER_TEXGEN; //l_SHDData.shader->shaderflag |= SHADER_NEEDINVMATRIX; stage->stageparam = 0; return; } if (strcmp(command,"worldlinmap")==0 || strcmp(command,"eyelinmap")==0) { // backwards compatibility stage->stageflag |= SHADER_EYELINMAP; stage->stageflag |= SHADER_TEXGEN; return; } if (strcmp(command,"normalmap")==0) { stage->stageflag |= SHADER_NORMALMAP; stage->stageflag |= SHADER_TEXGEN; return; } if (strcmp(command,"depthcompare")==0) { stage->stageflag |= SHADER_DEPTHCOMPARE; return; } if (strcmp(command,"depthvalue")==0) { stage->stageflag |= SHADER_DEPTHNOCOMPARE; return; } if (strcmp(command,"texcoord")==0) { sscanf(rest,"%i",&stage->texchannel); if (stage->texchannel >= VID_TEXCOORD_CHANNELS){ lprintf("WARNING shdload: illegal texcoord channel\n"); stage->texchannel = 0; } return; } if (strcmp(command,"texclamp")==0) { int states[3]; while (rest[restpos]!=0 && rest[restpos]!=';') buffer[bufferpos++]=rest[restpos++]; buffer[bufferpos]=0; if (3==sscanf(buffer,"(%d,%d,%d)",&states[0],&states[1],&states[2])){ int i; for (i = 0; i < 3; i++) if (states[i]) stage->texclamp |= 1<<i; } return; } if (strcmp(command,"texgenplane")==0){ int axis; lxVector4 plane; float *vec4; while (rest[restpos]!=0 && rest[restpos]!=';') buffer[bufferpos++]=rest[restpos++]; buffer[bufferpos]=0; if (stage->stagetype == SHADER_STAGE_TEX && 5==sscanf(buffer,"%d (%f,%f,%f,%f)",&axis,&plane[0],&plane[1],&plane[2],&plane[3])){ if (!stage->texgen) stage->texgen = reszalloc(sizeof(ShaderTexGen_t)); axis = LUX_MAX(axis,0); axis %= 4; stage->texgen->enabledaxis[axis] = LUX_TRUE; vec4 = &stage->texgen->texgenmatrix[4*axis]; lxVector4Copy(vec4,plane); } } if (strcmp(command,"rgbscale2")==0) { stage->rgbscale = 1; return; } if (strcmp(command,"rgbscale4")==0) { stage->rgbscale = 2; return; } if (strcmp(command,"alphascale2")==0) { stage->alphascale = 1; return; } if (strcmp(command,"alphascale4")==0) { stage->alphascale = 2; return; } if (strcmp(command,"lightmapscale")==0) { stage->stageflag |= SHADER_LMRGBSCALE; return; } if (strcmp(command,"nomipmap")==0) { stage->srcAttributes &= ~TEX_ATTR_MIPMAP; return; } if (strcmp(command,"param")==0) { parseShaderParam(buffer,rest); return; } }
/** * Main function * * This is the traditional C main(). */ int main(void) { #if USE_PROGRAM_STARTUP program_startup(); #else char s[64]; /* sprintf string */ unsigned long why; /* Why did we get reset? Why? */ prvSetupHardware(); init_logger(); #if PART == LM3S8962 RIT128x96x4Init(1000000); #endif /* * \todo maybe this needs to be earlier or later in the code. * Enable fault handlers in addition to FaultIsr() */ NVIC_SYS_HND_CTRL_R |= NVIC_SYS_HND_CTRL_USAGE |NVIC_SYS_HND_CTRL_BUS |NVIC_SYS_HND_CTRL_MEM; #if (PART != LM3S2110) /* * Allow the following to erase the permanent configuration flash page: * * make PROTECT_PERMCFG="-D PROTECT_PERMCFG=0" \ * ERASE_PERMCFG="-D ERASE_PERMCFG=1" * * The program will continue to erase the permanent configuration structure * at every powerup, so the program must be recompiled without the * ERASE_PERMCFG=1 part and reloaded to allow a permanent configuration * record to persist through power cycles. */ #if ERASE_PERMCFG #if !PROTECT_PERMCFG if (permcfg_erase()) { #if (PART == LM3S8962) RIT128x96x4StringDraw("permcfg Blank", 0, RITLINE(10), 15); #endif } else { #if (PART == LM3S8962) RIT128x96x4StringDraw("permcfg Not Blank", 0, RITLINE(10), 15); #endif } #endif #endif config_init(); #endif /** * \req \req_id The \program \shall identify: * - The program version. * - A copyright string. * - The board identification. * - The assembly identification. * - Network configuration information. * * \todo Issue #1175 Add software build time, git hash, software * version to build. */ lstr("\r\nCRI Quickstart\r\n"); #if (PART == LM3S2110) lstr("LM3S2110 Eval Board\r\n"); #elif (PART == LM3S8962) lstr("LM3S8962 Eval Board\r\n"); #elif (PART == LM3S9B96) lstr("LM3S9B96 Eval Board\r\n"); #endif lstr("Copyright (C) 2011 Consolidated Resource Imaging\r\n"); lprintf(" Software Build Date: %s\n", buildDate); #if (PART != LM3S2110) lprintf(" Assembly Part Number: %s\n", usercfg.assy_pn); lprintf("Assembly Serial Number: %s\n", usercfg.assy_sn); lprintf(" Board Part Number: %s\n", permcfg.bd_pn); lprintf(" Board Serial Number: %s\n", permcfg.bd_sn); lprintf("Notes:\r\n %s\r\n", usercfg.notes); #endif #if (PART == LM3S8962) /* * Display our configuration on the OLED display. */ RIT128x96x4StringDraw("CRI Quickstart", 0, RITLINE(0), 15); RIT128x96x4StringDraw("LM3S8962", 0, RITLINE(1), 15); /* * Split date * 0123456789012345678901234567890 * Sun, 08 May 2011 19:05:42 -0400 * * into: * 0123456789012345678901234567890 * Sun, 08 May 2011 * * and * * 0123456789012345678901234567890 * 19:05:42 -0400 */ strcpy(s,buildDate); s[16]=0; RIT128x96x4StringDraw(s, 0, RITLINE(2), 15); RIT128x96x4StringDraw(&s[17], 0, RITLINE(3), 15); #endif /** * \req \req_id The \program \shall identify: * - The reason for the reset. */ why = SysCtlResetCauseGet(); if (why != 0) { SysCtlResetCauseClear(why); lprintf("Reset reason: "); if (why & SYSCTL_CAUSE_LDO) lprintf("LDO "); if (why & SYSCTL_CAUSE_SW) lprintf("SW "); if (why & SYSCTL_CAUSE_WDOG) lprintf("WDOG "); if (why & SYSCTL_CAUSE_BOR) lprintf("Brown-out "); if (why & SYSCTL_CAUSE_POR) lprintf("Power-on "); if (why & SYSCTL_CAUSE_EXT) lprintf("External "); lprintf("\r\n"); } io_init(); #endif util_init(); /** * \req \req_tcpip The \program \shall support TCP/IP communications. * * Create the LWIP task if running on a processor that includes a MAC * and PHY. */ #if QUICK_ETHERNET if( SysCtlPeripheralPresent( SYSCTL_PERIPH_ETH ) ) { xTaskCreate(ethernetThread, (signed char *)"eth-init", DEFAULT_STACK_SIZE, NULL, ETH_INIT_PRIORITY, NULL); } #endif /* * Enable interrupts... */ IntMasterEnable(); vSetupHighFrequencyTimer(); vTaskStartScheduler(); DPRINTF(0,"Idle Task Create Failed."); /* * Will only get here if there was insufficient memory to create the * idle task. */ for( ;; ); return 0; }
void M_LoadDefaults (void) { int i; int len; FILE* f; char def[80]; char strparm[100]; char* newstring = NULL; // killough int parm; boolean isstring; // set everything to base values numdefaults = sizeof(defaults)/sizeof(defaults[0]); for (i = 0 ; i < numdefaults ; i++) { if (defaults[i].location.ppsz) *defaults[i].location.ppsz = strdup(defaults[i].defaultvalue.psz); if (defaults[i].location.pi) *defaults[i].location.pi = defaults[i].defaultvalue.i; } // check for a custom default file i = M_CheckParm ("-config"); if (i && i < myargc-1) defaultfile = myargv[i+1]; else { const char* exedir = I_DoomExeDir(); defaultfile = malloc(PATH_MAX+1); /* get config file from same directory as executable */ #ifdef HAVE_SNPRINTF snprintf((char *)defaultfile, PATH_MAX, #else sprintf ((char *)defaultfile, #endif "%s%s%sboom.cfg", exedir, HasTrailingSlash(exedir) ? "" : "/", #if ((defined GL_DOOM) && (defined _MSC_VER)) "gl"); #else "pr"); #endif } lprintf (LO_CONFIRM, " default file: %s\n",defaultfile); // read the file in, overriding any set defaults f = fopen (defaultfile, "r"); if (f) { while (!feof(f)) { isstring = false; if (fscanf (f, "%79s %[^\n]\n", def, strparm) == 2) { //jff 3/3/98 skip lines not starting with an alphanum if (!isalnum(def[0])) continue; if (strparm[0] == '"') { // get a string default isstring = true; len = strlen(strparm); newstring = (char *) malloc(len); strparm[len-1] = 0; // clears trailing double-quote mark strcpy(newstring, strparm+1); // clears leading double-quote mark } else if ((strparm[0] == '0') && (strparm[1] == 'x')) { // CPhipps - allow ints to be specified in hex sscanf(strparm+2, "%x", &parm); } else { sscanf(strparm, "%i", &parm); // Keycode hack removed } for (i = 0 ; i < numdefaults ; i++) if ((defaults[i].type != def_none) && !strcmp(def, defaults[i].name)) { // CPhipps - safety check if (isstring != IS_STRING(defaults[i])) { lprintf(LO_WARN, "M_LoadDefaults: Type mismatch reading %s\n", defaults[i].name); continue; } if (!isstring) { //jff 3/4/98 range check numeric parameters if ((defaults[i].minvalue==UL || defaults[i].minvalue<=parm) && (defaults[i].maxvalue==UL || defaults[i].maxvalue>=parm)) *(defaults[i].location.pi) = parm; } else { free((char*)*(defaults[i].location.ppsz)); /* phares 4/13/98 */ *(defaults[i].location.ppsz) = newstring; } break; } } } fclose (f); } //jff 3/4/98 redundant range checks for hud deleted here /* proff 2001/7/1 - added prboom.wad as last entry so it's always loaded and doesn't overlap with the cfg settings */ wad_files[MAXLOADFILES-1]="prboom.wad"; }
void ethernetThread(void *pParams) { IP_CONFIG ipconfig; unsigned char hwaddr[6] = {0, 0, 0, 0, 0, 0}; char s[64]; /* sprintf string */ ETHServiceTaskInit(0); ETHServiceTaskFlush(0,ETH_FLUSH_RX | ETH_FLUSH_TX); /* * Allow make SET_IP_ADR="-D SET_IP_ADR=\"(192<<24|168<<16|98<<8|29)\"" * to build application with a recovery IP address. */ #ifndef SET_IP_ADR #define SET_IP_ADR 0 #endif if (SET_IP_ADR) { ipconfig.IPMode = IPADDR_USE_STATIC; ipconfig.IPAddr = SET_IP_ADR; #ifndef SET_NET_MASK #define SET_NET_MASK 0xffffff00 #endif ipconfig.NetMask = SET_NET_MASK; #ifndef SET_GW_ADR #define SET_GW_ADR (((SET_IP_ADR)&(SET_NET_MASK))|0x00000001) #endif ipconfig.GWAddr = SET_GW_ADR; } else { ipconfig.IPMode = usercfg.IPMode; ipconfig.IPAddr = IP2LONG(usercfg.ip[0], usercfg.ip[1], usercfg.ip[2], usercfg.ip[3]); ipconfig.NetMask = IP2LONG(usercfg.netmask[0], usercfg.netmask[1], usercfg.netmask[2], usercfg.netmask[3]); ipconfig.GWAddr= IP2LONG(usercfg.gateway[0], usercfg.gateway[1], usercfg.gateway[2], usercfg.gateway[3]); } LWIPServiceTaskInit(&ipconfig); /* * Get actual MAC and IP address programmed */ EthernetMACAddrGet(ETH_BASE, &hwaddr[0]); LWIPServiceTaskIPConfigGet(&lwip_netif, &ipconfig); /* * Print Ethernet configuration to serial */ lprintf("\r\n"); lprintf("MAC: %02X:%02X:%02X:%02X:%02X:%02X\r\n", hwaddr[0], hwaddr[1], hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]); lprintf(" IP: %d.%d.%d.%d\r\n", ipconfig.IPAddr>>0 & 0xff, ipconfig.IPAddr>>8 & 0xff, ipconfig.IPAddr>>16 & 0xff, ipconfig.IPAddr>>24 & 0xff ); lprintf("\r\n"); #if (PART == LM3S8962) /* * Print Ethernet configuration to OLED screen */ sprintf(s, "MAC %02X:%02X:%02X:%02X:%02X:%02X", hwaddr[0], hwaddr[1], hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]); RIT128x96x4StringDraw(s, 0, RITLINE(5), 15); sprintf(s, "IP %d.%d.%d.%d", ipconfig.IPAddr>>0 & 0xff, ipconfig.IPAddr>>8 & 0xff, ipconfig.IPAddr>>16 & 0xff, ipconfig.IPAddr>>24 & 0xff ); RIT128x96x4StringDraw(s, 0, RITLINE(6), 15); #endif syslogInit(); syslog(facility_local0 , level_err, "A message from QuickStart" ); /* Nothing else to do. No point hanging around. */ vTaskDelete( NULL); /* We should not get here. */ return; }
static void print_command(char *data, int len) { #ifdef DEBUG int i; int dir = LE_32 (data + 36) >> 16; int comm = LE_32 (data + 36) & 0xFFFF; lprintf ("----------------------------------------------\n"); if (dir == 3) { lprintf ("send command 0x%02x, %d bytes\n", comm, len); } else { lprintf ("receive command 0x%02x, %d bytes\n", comm, len); } lprintf (" start sequence %08x\n", LE_32 (data + 0)); lprintf (" command id %08x\n", LE_32 (data + 4)); lprintf (" length %8x \n", LE_32 (data + 8)); lprintf (" protocol %08x\n", LE_32 (data + 12)); lprintf (" len8 %8x \n", LE_32 (data + 16)); lprintf (" sequence # %08x\n", LE_32 (data + 20)); lprintf (" len8 (II) %8x \n", LE_32 (data + 32)); lprintf (" dir | comm %08x\n", LE_32 (data + 36)); if (len >= 4) lprintf (" prefix1 %08x\n", LE_32 (data + 40)); if (len >= 8) lprintf (" prefix2 %08x\n", LE_32 (data + 44)); for (i = (CMD_HEADER_LEN + CMD_PREFIX_LEN); i < (CMD_HEADER_LEN + CMD_PREFIX_LEN + len); i += 1) { unsigned char c = data[i]; if ((c >= 32) && (c < 128)) lprintf ("%c", c); else lprintf (" %02x ", c); } if (len > CMD_HEADER_LEN) lprintf ("\n"); lprintf ("----------------------------------------------\n"); #endif }
int main( int argc, char *argv[] ) { sigset_t newmask; char c; extern char *optarg; extern int optind, opterr, optopt; char *cfgfile = HTUN_DEFAULT_CFGFILE; char *tunfile = NULL; char *logfile = NULL; unsigned short port=0; int foreground = 0; int dont_route = 0; int config_test_only = 0; int debug = 0; unsigned int logflags = 0; dropprivs(""); while( (c=getopt(argc, argv, "rdfc:vht:l:p:o")) != -1 ) { switch(c) { case 'r': dont_route = 1; break; /* #ifdef _DEBUG */ case 'd': debug = 1; break; /* #endif */ case 'o': debug = 1; config_test_only = 1; break; case 'f': foreground = 1; break; case 'c': cfgfile = optarg; break; case 'v': fprintf( stderr, "HTun " VERSION "\n" "(c) 2002 Moshe Jacobson <*****@*****.**>\n" " and Ola Nordstrom <*****@*****.**>\n" "This program is distributed under the GNU General Public License.\n" "for details, see the LICENSE file packaged with htun.\n"); return EXIT_SUCCESS; case 't': tunfile = optarg; break; case 'l': logfile = optarg; break; case 'p': port = htons((unsigned short)strtoul(optarg,NULL,0)); if(!port) { fprintf( stderr, "Invalid port specified: %s.\n", argv[optind] ); return EXIT_FAILURE; } break; case 'h': usage(); return EXIT_SUCCESS; default: usage(); return EXIT_FAILURE; } } /* Read the config */ if( (config=read_config(cfgfile)) == NULL ) { fprintf( stderr, "Fatal: Reading cfgfile \"%s\": %s\n", cfgfile, strerror(errno) ); return EXIT_FAILURE; } if( config_test_only == 1 ) { log = log_open("-", LOG_STDERR|LOG_NODATE|LOG_DEBUG|LOG_NOLVL|LOG_FUNC); print_config(config); log_close(log); return EXIT_SUCCESS; } /* Now override config values with cmdline values */ strcpy(config->cfgfile,cfgfile); if( tunfile ) strncpy(config->tunfile,tunfile,PATH_MAX); if( logfile ) strncpy(config->logfile,logfile,PATH_MAX); if( port ) { if( config->is_server ) config->u.s.server_ports[0] = htons(port); else config->u.c.proxy_port = (port); } if( dont_route ) config->u.c.do_routing = 0; if( debug ) config->debug = 1; /* Open the log file */ if( config->debug ) logflags |= LOG_DEBUG; logflags |= LOG_FUNC; getprivs("opening logfile"); if( !(log=log_open( config->logfile, logflags )) ) { fprintf( stderr, "Warning: Could not open logfile %s: %s\n", config->logfile, strerror(errno) ); } dropprivs("logfile opened"); /* Daemonize unless -f or -l - have been specified */ if( !foreground && strcmp(config->logfile,"-") ) daemonize(); lprintf( log, INFO, "HTun " VERSION " started." ); init_signames(); /* Ignore SIGPIPE. We will use errno=EPIPE instead. */ signal(SIGPIPE,SIG_IGN); signal(SIGWINCH,SIG_IGN); /* Mask TERM, HUP, INT, and USR1 */ sigemptyset(&newmask); sigaddset(&newmask, SIGINT); sigaddset(&newmask, SIGHUP); sigaddset(&newmask, SIGTERM); sigaddset(&newmask, SIGUSR1); sigaddset(&newmask, SIGUSR2); sigaddset(&newmask, SIGALRM); sigaddset(&newmask, SIGCONT); sigaddset(&newmask, SIGTSTP); sigaddset(&newmask, SIGWINCH); sigprocmask( SIG_BLOCK, &newmask, NULL ); return config->is_server ? server_main() : client_main(); }
static int Lucent_set_compression (int *compression, int *speed, int *bits) { char buffer[VOICE_BUF_LEN]; reset_watchdog(); if (*compression == 0) *compression = 4; if (*speed == 0) *speed = 8000; switch (*compression) { case 1: *bits = 8; if ( (*speed != 7200) && (*speed != 8000) && (*speed != 11025) ) { lprintf(L_WARN, "%s: Illegal sample rate (%d)", voice_modem_name, *speed); return(FAIL); } sprintf(buffer, "AT+VSM=128,%d", *speed); if (voice_command(buffer, "OK") != VMA_USER_1) return(FAIL); break; case 2: *bits = 16; if ( (*speed != 7200) && (*speed != 8000) && (*speed != 11025) ) { lprintf(L_WARN, "%s: Illegal sample rate (%d)", voice_modem_name, *speed); return(FAIL); } sprintf(buffer, "AT+VSM=129,%d", *speed); if (voice_command(buffer, "OK") != VMA_USER_1) return(FAIL); break; case 3: *bits = 8; if ( *speed != 8000 ) { lprintf(L_WARN, "%s: Illegal sample rate (%d)", voice_modem_name, *speed); return(FAIL); } sprintf(buffer, "AT+VSM=130,%d", *speed); if (voice_command(buffer, "OK") != VMA_USER_1) return(FAIL); break; case 4: *bits = 8; if ( *speed != 8000 ) { lprintf(L_WARN, "%s: Illegal sample rate (%d)", voice_modem_name, *speed); return(FAIL); } sprintf(buffer, "AT+VSM=131,%d", *speed); if (voice_command(buffer, "OK") != VMA_USER_1) return(FAIL); break; case 5: *bits = 4; if ((*speed != 8000) && (*speed != 7200) && (*speed != 11025)) { lprintf(L_WARN, "%s: Illegal sample rate (%d)", voice_modem_name, *speed); return(FAIL); } sprintf(buffer, "AT+VSM=132,%d", *speed); if (voice_command(buffer, "OK") != VMA_USER_1) return(FAIL); break; default: lprintf(L_WARN, "%s: Illegal voice compression method (%d)", voice_modem_name, *compression); return(FAIL); }; return(OK); }
char* I_FindFileInternal(const char* wfname, const char* ext, dboolean isStatic) { // lookup table of directories to search static const struct { const char *dir; // directory const char *sub; // subdirectory const char *env; // environment variable const char *(*func)(void); // for I_DoomExeDir } search[] = { {NULL, NULL, NULL, I_DoomExeDir}, // config directory {NULL}, // current working directory {NULL, NULL, "DOOMWADDIR"}, // run-time $DOOMWADDIR {DOOMWADDIR}, // build-time configured DOOMWADDIR {NULL, "doom", "HOME"}, // ~/doom {NULL, NULL, "HOME"}, // ~ {"/usr/local/share/games/doom"}, {"/usr/share/games/doom"}, {"/usr/local/share/doom"}, {"/usr/share/doom"}, }; size_t i; size_t pl; static char static_p[PATH_MAX]; char * dinamic_p = NULL; char *p = (isStatic ? static_p : dinamic_p); if (!wfname) return NULL; /* Precalculate a length we will need in the loop */ pl = strlen(wfname) + (ext ? strlen(ext) : 0) + 4; for (i = 0; i < sizeof(search)/sizeof(*search); i++) { const char * d = NULL; const char * s = NULL; /* Each entry in the switch sets d to the directory to look in, * and optionally s to a subdirectory of d */ // switch replaced with lookup table if (search[i].env) { if (!(d = getenv(search[i].env))) continue; } else if (search[i].func) d = search[i].func(); else d = search[i].dir; s = search[i].sub; if (!isStatic) p = malloc((d ? strlen(d) : 0) + (s ? strlen(s) : 0) + pl); sprintf(p, "%s%s%s%s%s", d ? d : "", (d && !HasTrailingSlash(d)) ? "/" : "", s ? s : "", (s && !HasTrailingSlash(s)) ? "/" : "", wfname); if (ext && access(p,F_OK)) strcat(p, ext); if (!access(p,F_OK)) { if (!isStatic) lprintf(LO_INFO, " found %s\n", p); return p; } if (!isStatic) free(p); } return NULL; }
void file_unpackc(unsigned char *buf_dest,unsigned char *buf_src) { int size; unsigned char value; unsigned char maskvalue; unsigned char andvalue; unsigned int offset; int nb; lprintf("file_unpackc\n"); buf_src+=4; // Skipp LZ77 heqder size=8000; //8000; buf_src+=4; // Skipp the size andvalue=0; while (size>0) { // // Reload encoding type mask // if (!andvalue) { andvalue=1; value=*buf_src++; lprintf("Reload mask: %x (%d)\n",value,value); maskvalue=value; } if (maskvalue & andvalue) { // // Copy 1 unsigned char // /* if (buf_dest==((unsigned char*)0xb3e7)) { *(unsigned char*)(0xbfdf)=17; } */ value=*buf_src++; lprintf("New: byte=%x (%d) from %x to %x)\n",value,value,buf_src,buf_dest); *buf_dest++=value; size--; } else { // // Copy with offset // // At this point, the source pointer points to a two byte // value that actually contains a 4 bits counter, and a // 12 bit offset to point back into the depacked stream. // The counter is in the 4 high order bits. // // Original offset = buf_src[0]; // Read 16 bits non alligned datas... offset|=((unsigned int)(buf_src[1]&0x0F))<<8; offset+=1; nb =(buf_src[1]>>4)+3; lprintf("Copy: size=%d offset=%d ",nb,offset); lprintf("(from %x-%x to %x-%x) ",buf_dest-offset,buf_dest-offset+nb-1,buf_dest,buf_dest+nb-1); buf_src+=2; size-=nb; while (nb>0) { /* if (buf_dest==((unsigned char*)0xb3e7)) { *(unsigned char*)(0xbfdf)=18; } */ value=*(buf_dest-offset); lprintf("%x,",value); *buf_dest=value; buf_dest++; nb--; } lprintf("\n"); } andvalue<<=1; } *(unsigned char*)(0xbfde)=18; }
void OS::allocate_failed(const char* what) { lprintf("\n**** could not allocate space for %s\n", what); lprintf("Out of virtual memory - please add swap space to your system.\n"); fatal("out of memory"); }
static void jpeg_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { jpeg_decoder_t *this = (jpeg_decoder_t *) this_gen; if (!this->video_open) { lprintf("opening video\n"); (this->stream->video_out->open) (this->stream->video_out, this->stream); this->video_open = 1; } xine_buffer_copyin(this->image, this->index, buf->mem, buf->size); this->index += buf->size; if (buf->decoder_flags & BUF_FLAG_FRAME_END && this->index > 0) { struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; JSAMPARRAY buffer; int i, linesize; int width, height; vo_frame_t *img; int max_width, max_height; uint8_t *slice_start[1] = {NULL}; int slice_line = 0; /* query max. image size vo can handle */ max_width = this->stream->video_out->get_property( this->stream->video_out, VO_PROP_MAX_VIDEO_WIDTH); max_height = this->stream->video_out->get_property( this->stream->video_out, VO_PROP_MAX_VIDEO_HEIGHT); /* init and parse header */ cinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&cinfo); jpeg_memory_src(&cinfo, this->image, this->index); jpeg_read_header(&cinfo, TRUE); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, cinfo.image_width); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, cinfo.image_height); lprintf("header parsed\n"); /* set decoding parameters */ cinfo.out_color_space = JCS_YCbCr; /* request scaling when image is too large for vo */ if (this->cls->enable_downscaling) { cinfo.output_width = cinfo.image_width; cinfo.output_height = cinfo.image_height; cinfo.scale_num = 1; cinfo.scale_denom = 1; while ((max_width > 0 && cinfo.output_width > max_width) || (max_height > 0 && cinfo.output_height > max_height)) { cinfo.scale_denom <<= 1; cinfo.output_width >>= 1; cinfo.output_height >>= 1; } if (cinfo.scale_denom > 1) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": downscaling image by 1:%d to %dx%d\n", cinfo.scale_denom, cinfo.output_width, cinfo.output_height); } } /* start decompress */ jpeg_start_decompress(&cinfo); width = cinfo.output_width; height = cinfo.output_height; /* crop when image is too large for vo */ if (max_width > 0 && cinfo.output_width > max_width) width = max_width; if (max_height > 0 && cinfo.output_height > max_height) height = max_height; img = this->stream->video_out->get_frame (this->stream->video_out, width, height, (double)width/(double)height, XINE_IMGFMT_YUY2, VO_BOTH_FIELDS); linesize = cinfo.output_width * cinfo.output_components; buffer = (cinfo.mem->alloc_sarray)((void*)&cinfo, JPOOL_IMAGE, linesize, 1); if (img->proc_slice && !(img->height & 0xf)) { slice_start[0] = img->base[0]; } /* cut to frame width */ if (cinfo.output_width > img->width) { lprintf("cut right border %d pixels\n", cinfo.output_width - img->width); linesize = img->width * 3; } /* YUV444->YUV422 simple */ while (cinfo.output_scanline < cinfo.output_height) { uint8_t *dst = img->base[0] + img->pitches[0] * cinfo.output_scanline; jpeg_read_scanlines(&cinfo, buffer, 1); /* cut to frame height */ if (cinfo.output_scanline > img->height) { lprintf("cut bottom scanline %d\n", cinfo.output_scanline - 1); continue; } for (i = 0; i < linesize; i += 3) { *dst++ = buffer[0][i]; if (i & 1) { *dst++ = buffer[0][i + 2]; } else { *dst++ = buffer[0][i + 1]; } } if (slice_start[0]) { slice_line++; if (slice_line == 16) { img->proc_slice(img, slice_start); slice_start[0] += 16 * img->pitches[0]; slice_line = 0; } } } /* final slice */ if (slice_start[0] && slice_line) { img->proc_slice(img, slice_start); } jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); img->pts = buf->pts; img->duration = 3600; img->bad_frame = 0; _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, img->duration); img->draw(img, this->stream); img->free(img); this->index = 0; }
int execute_populate(CONFIG *cfg) { WT_CONNECTION *conn; WT_SESSION *session; pthread_t *threads; double secs; int ret; uint64_t elapsed, last_ops; struct timeval e; conn = cfg->conn; cfg->phase = WT_PERF_POP; lprintf(cfg, 0, 1, "Starting populate threads"); /* First create the table. */ if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) { lprintf(cfg, ret, 0, "Error opening a session on %s", cfg->home); return (ret); } if ((ret = session->create( session, cfg->uri, cfg->table_config)) != 0) { lprintf(cfg, ret, 0, "Error creating table %s", cfg->uri); session->close(session, NULL); return (ret); } session->close(session, NULL); if ((ret = start_threads( cfg, cfg->populate_threads, &threads, populate_thread)) != 0) return (ret); gettimeofday(&cfg->phase_start_time, NULL); for (cfg->elapsed_time = 0, elapsed = last_ops = 0; g_npop_ops < cfg->icount && g_threads_quit < cfg->populate_threads;) { /* * Sleep for 100th of a second, report_interval is in second * granularity, so adjust accordingly. */ usleep(10000); elapsed += 1; if (elapsed % 100 == 0 && (elapsed / 100) % cfg->report_interval == 0) { lprintf(cfg, 0, 1, "%" PRIu64 " ops in %d secs", g_npop_ops - last_ops, cfg->report_interval); last_ops = g_npop_ops; } } if (g_threads_quit == cfg->populate_threads) { lprintf(cfg, WT_ERROR, 0, "Populate threads exited without finishing."); return (WT_ERROR); } gettimeofday(&e, NULL); if ((ret = stop_threads(cfg, cfg->populate_threads, threads)) != 0) return (ret); lprintf(cfg, 0, 1, "Finished load of %d items", cfg->icount); secs = e.tv_sec + e.tv_usec / 1000000.0; secs -= (cfg->phase_start_time.tv_sec + cfg->phase_start_time.tv_usec / 1000000.0); if (secs == 0) ++secs; lprintf(cfg, 0, 1, "Load time: %.2f\n" "load ops/sec: %.2f", secs, cfg->icount / secs); return (0); }