static void print_kdump_flat_header(struct df_kdump_flat_hdr *hdr) { STDERR("diskdump main header\n"); STDERR(" signature : %s\n", hdr->signature); STDERR(" version : %lld\n", hdr->version); STDERR(" type : %lld\n", hdr->type); }
/* * Print info about dump tool */ void dt_info_print(void) { STDERR("Dump device info:\n"); STDERR(" Dump tool.........: %s\n", l.dt->desc); STDERR(" Version...........: %d\n", l.version); STDERR(" Architecture......: %s\n", dfi_arch_str(l.arch)); if (l.attr.dasd_type) STDERR(" DASD type.........: %s\n", l.attr.dasd_type); if (l.attr.mem_limit) { if (*l.attr.mem_limit != U64_MAX) STDERR(" Dump size limit...: %lld MB\n", TO_MIB(*l.attr.mem_limit)); else STDERR(" Dump size limit...: none\n"); } if (l.attr.force) { if (*l.attr.force == 0) STDERR(" Force specified...: no\n"); else STDERR(" Force specified...: yes\n"); } if (l.dt->info) { STDERR("\n"); l.dt->info(); } }
/************************************************************************ * * * This routine will notify the appropriate user function when the * * message has arrived. This routine is shielded from the user. * * * * In RPC term, SERVER has received a message. Process it. * * */ static void ipgwin_priv_msg_receive( struct svc_req *rqstp, /* Request info */ SVCXPRT *transp) /* transport info */ { Svcmsg *current; /* traversal pointer */ char buf[IPG_MAX_BYTES]; /* message string buffer */ Ipgmsg msg; /* IPG message */ /* Return if no request */ if (rqstp->rq_proc == NULLPROC) return; /* Check for the same UID */ if (((struct authunix_parms *)rqstp->rq_clntcred)->aup_uid != uid) { STDERR("Sorry ! CLIENT doesn't have the same UID as SERVER"); return; } /* Check for all user register transport and find the correct */ /* program number and version number. */ for (current=svchead; current; current=current->next) { if ((current->prognum == rqstp->rq_prog) && (current->versnum == rqstp->rq_vers)) { msg.msgbuf = buf; #ifdef SOLARIS if (!svc_getargs(transp, (xdrproc_t)xdr_ipgmsg, (caddr_t)(&msg)) ) #elif LINUX if (!svc_getargs(transp, (xdrproc_t)xdr_ipgmsg, (caddr_t)(&msg)) ) #else if (!svc_getargs(transp, xdr_ipgmsg, &msg)) #endif { STDERR("ipgwin_priv_msg_receive:can't decode arguments"); return; } /* Make sure that the request procedure number is the same as */ /* major ID. */ if (rqstp->rq_proc != msg.major_id) { STDERR("ipgwin_priv_msg_receive:Undefined major ID:"); STDERR_2(" major ID should be %d, but it receives %d", msg.major_id, rqstp->rq_proc); return; } /* Call the user function */ current->msgfunc(rqstp->rq_proc, &msg); return; } } /* ERROR if the code passes here */ STDERR("ipgwin_priv_msg_receive:No receiver for this message"); }
void storeNuiImage(void) { NUI_IMAGE_FRAME imageFrame; if(WAIT_OBJECT_0 != WaitForSingleObject(hNextColorFrameEvent, 0)) return; HRESULT hr = pNuiSensor->NuiImageStreamGetNextFrame( pVideoStreamHandle, 0, &imageFrame ); if( FAILED( hr ) ){ return; } if(imageFrame.eImageType != NUI_IMAGE_TYPE_COLOR) STDERR("Image type is not match with the color\r\n"); INuiFrameTexture *pTexture = imageFrame.pFrameTexture; NUI_LOCKED_RECT LockedRect; pTexture->LockRect( 0, &LockedRect, NULL, 0 ); if( LockedRect.Pitch != 0 ){ byte * pBuffer = (byte *)LockedRect.pBits; #if defined(USE_FACETRACKER) setColorImage(LockedRect.pBits, LockedRect.size); #endif NUI_SURFACE_DESC pDesc; pTexture->GetLevelDesc(0, &pDesc); //printf("w: %d, h: %d, byte/pixel: %d\r\n", pDesc.Width, pDesc.Height, LockedRect.Pitch/pDesc.Width); typedef struct t_RGBA{ byte r; byte g; byte b; byte a; }; t_RGBA *p = (t_RGBA *)pBuffer; for(int i=0;i<pTexture->BufferLen()/4;i++){ byte b = p->b; p->b = p->r; p->r = b; p->a = (byte)255; p++; } glBindTexture(GL_TEXTURE_2D, bg_texture[IMAGE_TEXTURE]); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pDesc.Width, pDesc.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pBuffer); pTexture->UnlockRect(0); }else{ STDERR("Buffer length of received texture is bogus\r\n"); } pNuiSensor->NuiImageStreamReleaseFrame( pVideoStreamHandle, &imageFrame ); }
void initFaceTracker(void) { HRESULT hr; pFaceTracker = FTCreateFaceTracker(NULL); // We don't use any options. if(!pFaceTracker) { STDERR("Could not create the face tracker.\r\n"); return; } FT_CAMERA_CONFIG videoConfig; videoConfig.Width = 640; videoConfig.Height = 480; videoConfig.FocalLength = NUI_CAMERA_COLOR_NOMINAL_FOCAL_LENGTH_IN_PIXELS; // 640x480 //videoConfig.FocalLength = NUI_CAMERA_COLOR_NOMINAL_FOCAL_LENGTH_IN_PIXELS * 2.f; // 1280x960 FT_CAMERA_CONFIG depthConfig; depthConfig.Width = 320; depthConfig.Height = 240; //depthConfig.FocalLength = NUI_CAMERA_DEPTH_NOMINAL_FOCAL_LENGTH_IN_PIXELS / 4.f; // 80x 60 depthConfig.FocalLength = NUI_CAMERA_DEPTH_NOMINAL_FOCAL_LENGTH_IN_PIXELS; // 320x240 //depthConfig.FocalLength = NUI_CAMERA_DEPTH_NOMINAL_FOCAL_LENGTH_IN_PIXELS * 2.f; // 640x480 hr = pFaceTracker->Initialize(&videoConfig, &depthConfig, NULL, NULL); if(!pFaceTracker) { STDERR("Could not initialize the face tracker.\r\n"); return; } hr = pFaceTracker->CreateFTResult(&pFTResult); if (FAILED(hr) || !pFTResult) { STDERR("Could not initialize the face tracker result.\r\n"); return; } iftColorImage = FTCreateImage(); if (!iftColorImage || FAILED(hr = iftColorImage->Allocate(videoConfig.Width, videoConfig.Height, FTIMAGEFORMAT_UINT8_B8G8R8X8))) { STDERR("Could not create the color image.\r\n"); return; } iftDepthImage = FTCreateImage(); if (!iftDepthImage || FAILED(hr = iftDepthImage->Allocate(320, 240, FTIMAGEFORMAT_UINT16_D13P3))) { STDERR("Could not create the depth image.\r\n"); return; } lastTrackSucceeded = false; faceScale = 0; }
void storeNuiDepth(void) { NUI_IMAGE_FRAME depthFrame; if(WAIT_OBJECT_0 != WaitForSingleObject(hNextDepthFrameEvent, 0)) return; HRESULT hr = pNuiSensor->NuiImageStreamGetNextFrame( pDepthStreamHandle, 0, &depthFrame ); if( FAILED( hr ) ){ return; } if(depthFrame.eImageType != NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX) STDERR("Depth type is not match with the depth and players\r\n"); INuiFrameTexture *pTexture = depthFrame.pFrameTexture; NUI_LOCKED_RECT LockedRect; pTexture->LockRect( 0, &LockedRect, NULL, 0 ); if( LockedRect.Pitch != 0 ){ unsigned short *pBuffer = (unsigned short *)LockedRect.pBits; memcpy(depth, LockedRect.pBits, pTexture->BufferLen()); #if defined(USE_FACETRACKER) setDepthImage(LockedRect.pBits, LockedRect.size); #endif NUI_SURFACE_DESC pDesc; pTexture->GetLevelDesc(0, &pDesc); //printf("w: %d, h: %d, byte/pixel: %d\r\n", pDesc.Width, pDesc.Height, LockedRect.Pitch/pDesc.Width); unsigned short *p = (unsigned short *)pBuffer; for(int i=0;i<pTexture->BufferLen()/2;i++){ //*p = (unsigned short)((*p & 0xff00)>>8) | ((*p & 0x00ff)<<8); // for test //*p = (unsigned short)((*p & 0xfff8)>>3); *p = (unsigned short)(NuiDepthPixelToDepth(*pBuffer)); p++; } glBindTexture(GL_TEXTURE_2D, bg_texture[DEPTH_TEXTURE]); glPixelStorei(GL_UNPACK_ALIGNMENT, 2); glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, pDesc.Width, pDesc.Height, 0, GL_LUMINANCE, GL_UNSIGNED_SHORT, pBuffer); pTexture->UnlockRect(0); } else{ STDERR("Buffer length of received texture is bogus\r\n"); } pNuiSensor->NuiImageStreamReleaseFrame( pDepthStreamHandle, &depthFrame ); }
void g_short_to_pixel(short *indata, /* pointer to input data */ char *outdata, /* pointer to output pixel data */ int points_per_line, /* # data points per scan line (width)*/ int scan_lines, /* scan lines (height of) data */ int x_offset, /* x offset in data to start at */ int y_offset, /* y offset in data to start at */ int src_width, /* width of data to use */ int src_height, /* height of data to use */ int pix_width, /* (resulting) image width in pixels */ int pix_height, /* (resulting) image height in pixels */ float vs, /* vertical scale to apply */ int pixel_offset, /* pixel offset */ int num_pixel_level, /* number of pixel level */ Orientation direction) /* indata orientation */ { if ((indata == NULL) || (outdata == NULL)) { STDERR("g_short_to_pixel: passed NULL data pointer"); return; } /* initialize the line-fill routine */ raw_line_fill_init(pix_width, src_width, pixel_offset, num_pixel_level, vs); raw_flag = TRUE; /* scale and convert data to pixel data */ convert_short_data(indata, outdata, points_per_line, scan_lines, x_offset, y_offset, src_width, src_height, pix_width, pix_height, direction); raw_flag = FALSE; } /* end of function g_short_to_pixel */
/************************************************************************ * * * Create macro display window. It actually creates it when the first * message is displayed. * */ void msgmacro_win_create(Frame owner, int x, int y, int wd, int ht) { if (wmacromsg) { STDERR("msgmacro_win_create:Window has been created"); return; } if ((wmacromsg = (Wmsgprt *)malloc(sizeof(Wmsgprt))) == NULL) { PERROR("msgmacro_win_create:Cannot malloc"); return; } wmacromsg->owner = owner; wmacromsg->popup = NULL; wmacromsg->textsw = NULL; wmacromsg->x = x; wmacromsg->y = y; wmacromsg->wd = wd; wmacromsg->ht = ht; /* Since there is a BUG in Xview, we cannot wait to create a window. */ /* Until the bug is fixed, we create a window at start-up time (NOW). */ msgprt_win_create(wmacromsg); xv_set(wmacromsg->popup, FRAME_LABEL, "Macro Edit", NULL); xv_set(wmacromsg->textsw, TEXTSW_BROWSING, FALSE, WIN_KBD_FOCUS, TRUE, NULL); }
/* * Signal handler for exiting zgetdump (the atexit handler will do the work) */ static void sig_exit(int sig) { (void) sig; STDERR("\n"); /* E.g. to get newline after '^C' */ ERR_EXIT("Got signal %i, exiting...", sig); }
/************************************************************************ * * * Create error message window. It actually creates it when the first * * message is displayed. * */ void msgerr_win_create(Frame owner, int x, int y, int wd, int ht) { if (werrmsg) { STDERR("msgerr_win_create:Window has been created"); return; } if ((werrmsg = (Wmsgprt *)malloc(sizeof(Wmsgprt))) == NULL) { PERROR("msgerr_win_create:Cannot malloc"); return; } werrmsg->owner = owner; werrmsg->popup = NULL; werrmsg->textsw = NULL; werrmsg->x = x; werrmsg->y = y; werrmsg->wd = wd; werrmsg->ht = ht; /* Since there is a BUG in Xview, we cannot wait to create a window. */ /* Until the bug is fixed, we create a window at start-up time (NOW). */ msgprt_win_create(werrmsg); xv_set(werrmsg->popup, FRAME_LABEL, "Error Messages", NULL); }
/************************************************************************ * * * This routine is used to send a message to the server. In order to * * send a message, the user should have registered sender ID. * * * * In RPC term, CLIENT sends a message to server. * * * * Return OK or NOT_OK. * * */ int ipgwin_send(u_long send_id, /* sender ID */ Ipgmsg *msg) /* message */ { Cltmsg *ptr; /* pointer to find the corrent sender ID */ struct timeval timeout; /* timeout to wait for reply */ int clnt_status; /* return status from clnt_call */ /* No waiting for reply */ timeout.tv_sec = 0; timeout.tv_usec = 0; /* Finf the correct sender ID which have been registered */ for (ptr=clthead; ptr; ptr=ptr->next) { if (ptr->client_id == send_id) { #ifdef SOLARIS if ( (clnt_status = clnt_call(ptr->client, msg->major_id, (xdrproc_t)xdr_ipgmsg, (caddr_t)msg, (xdrproc_t)xdr_void, NULL, timeout) ) != RPC_SUCCESS) #elif LINUX if ( (clnt_status = clnt_call(ptr->client, msg->major_id, (xdrproc_t)xdr_ipgmsg, (caddr_t)msg, (xdrproc_t)xdr_void, NULL, timeout) ) != RPC_SUCCESS) #else if ( (clnt_status = clnt_call(ptr->client, msg->major_id, xdr_ipgmsg, msg, xdr_void, NULL, timeout) ) != RPC_SUCCESS) #endif { /* Ignore error due to timeout */ if (clnt_status != (int)RPC_TIMEDOUT) { STDERR("ipgwin_send:clnt_call"); clnt_perror(ptr->client, "clnt_call"); return(NOT_OK); } } return(OK); } } STDERR_1("ipgwin_send: No such sender ID (%d) registered", send_id); return(NOT_OK); }
AFFEND AFFDEF(arc_stderr) { AVAR(fd); AFBEGIN; STDERR(fd); ARETURN(AV(fd)); AFEND; }
/* * Run "--info" action */ static int do_dump_info(void) { if (dfi_init() != 0) { dfi_info_print(); STDERR("\nERROR: Dump is not complete\n"); zg_exit(1); } kdump_select_check(); dfi_info_print(); dfi_exit(); return 0; }
void storeNuiDepth(bool waitflag) { NUI_IMAGE_FRAME depthFrame; if(waitflag) WaitForSingleObject(hNextDepthFrameEvent, INFINITE); else if(WAIT_OBJECT_0 != WaitForSingleObject(hNextDepthFrameEvent, 0)) return; HRESULT hr = pNuiSensor->NuiImageStreamGetNextFrame( pDepthStreamHandle, 0, &depthFrame ); if( FAILED( hr ) ){ return; } if(depthFrame.eImageType != NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX) STDERR("Depth type is not match with the depth and players\r\n"); INuiFrameTexture *pTexture = depthFrame.pFrameTexture; NUI_LOCKED_RECT LockedRect; pTexture->LockRect( 0, &LockedRect, NULL, 0 ); D3DLOCKED_RECT LPdest; DepthTex->LockRect(0,&LPdest,NULL, 0); if( LockedRect.Pitch != 0 ){ unsigned short *pBuffer = (unsigned short *)LockedRect.pBits; unsigned char *pDestImage=(unsigned char*)LPdest.pBits; NUI_SURFACE_DESC pDesc; pTexture->GetLevelDesc(0, &pDesc); unsigned short *p = (unsigned short *)pBuffer; for(int y=0;y<60;y++){ for(int x=0;x<80;x++){ unsigned char depth = (unsigned char)((*pBuffer & 0xff00)>>8); unsigned short playerID = NuiDepthPixelToPlayerIndex(*pBuffer); *pDestImage = (unsigned char)(Colors[playerID][0] * depth); pDestImage++; *pDestImage = (unsigned char)(Colors[playerID][1] * depth); pDestImage++; *pDestImage = (unsigned char)(Colors[playerID][2] * depth); pDestImage++; *pDestImage = 255; pDestImage++; pBuffer++; } pDestImage += (128-80)*4; } DepthTex->UnlockRect(0); pTexture->UnlockRect(0); }
static void print_sub_header(void) { STDERR("kdump sub header\n"); STDERR(" phys_base : 0x%lx\n", l.shdr.phys_base); STDERR(" dump_level : %d\n", l.shdr.dump_level); STDERR(" split : %d\n", l.shdr.split); STDERR(" start_pfn : 0x%lx\n", l.shdr.start_pfn); STDERR(" end_pfn : 0x%lx\n", l.shdr.end_pfn); }
static int reset_textsw (Textsw msg_textsw, Textsw_index beg_index, int text_len) { /******************************************************************** LOCAL VARIABLES: p_text Pointer to space allocated for saving the text to be restored after the reset. ret_val Contains the result of the operation: TRUE or FALSE. *********************************************************************/ char *p_text; int ret_val = TRUE; /* allocate sufficient memory to store the text currently in the window */ if ( (p_text = (char *)malloc (text_len + 1)) == NULL) { STDERR ("reset_text_window: malloc error"); return (FALSE); } /* get the text from the window; the extra character in the length insures that the string will be NULL-terminated */ xv_get (msg_textsw, TEXTSW_CONTENTS, beg_index, p_text, text_len+1); /* reset the text sub-window, which clears the edit log buffer */ textsw_reset (msg_textsw, 0, 0); /* restore the message text */ if (textsw_insert (msg_textsw, p_text, text_len) != text_len) ret_val = FALSE; /* free the memory allocated */ free (p_text); return (ret_val); }
/************************************************************************ * * * Create info print-message window. * * */ static void msgprt_win_create(Wmsgprt *wmsg) { if (wmsg->owner == NULL) { STDERR("msgprt_win_create:Need a parent for this window"); return; } if (wmsg->wd == 0) wmsg->wd = 300; if (wmsg->ht == 0) wmsg->ht = 100; wmsg->popup = xv_create(wmsg->owner, FRAME_CMD, FRAME_LABEL, "Message-Window", XV_X, wmsg->x, XV_Y, wmsg->y, XV_WIDTH, wmsg->wd, XV_HEIGHT, wmsg->ht, FRAME_SHOW_RESIZE_CORNER, TRUE, NULL); /* Destroy the default created panel */ // (This causes an Xview warning when we set XV_SHOW) //xv_destroy_safe(xv_get(wmsg->popup,FRAME_CMD_PANEL)); wmsg->textsw = xv_create (wmsg->popup, TEXTSW, TEXTSW_INSERT_MAKES_VISIBLE, TEXTSW_ALWAYS, TEXTSW_DISABLE_LOAD, TRUE, TEXTSW_DISABLE_CD, TRUE, TEXTSW_BROWSING, TRUE, TEXTSW_MEMORY_MAXIMUM,1000000, /*TEXTSW_AGAIN_RECORDING, FALSE,*/ TEXTSW_IGNORE_LIMIT, TEXTSW_INFINITY, WIN_X, 0, WIN_Y, 0, WIN_WIDTH, WIN_EXTEND_TO_EDGE, WIN_HEIGHT, WIN_EXTEND_TO_EDGE, WIN_KBD_FOCUS, FALSE, /*WIN_IGNORE_KBD_EVENT, WIN_NO_EVENTS,*/ 0); }
/************************************************************************ * * * Get the current directory for a given filelist. * Returns the address of a newly malloced string, which must be * freed by the caller. * */ char * get_filelist_dir(long id) /* which filelist */ { /* Find the requested ID */ Fileinfo *newcurfinfo; /* new current curfinfo */ for (newcurfinfo=finfoheader; newcurfinfo; newcurfinfo=newcurfinfo->next){ if (newcurfinfo->id == id){ break; } } if (newcurfinfo == NULL){ STDERR_1("get_filelist_dir: No such ID registered: %d", id); return NULL; } if (newcurfinfo->dirpath == NULL){ STDERR("get_filelist_dir: No default directory"); return NULL; } return strdup(newcurfinfo->dirpath); }
void* DLLEXPORT SpectrumAnalyzer_Init ( ViSession hParentInstrumentHandle , ViRsrc szRsrcAddress , ViSession *vhInstrumentHandle , int *InstrumentConnectStatus , int *InstrumentChannelsQuantity ) { STD_ERROR StdError = {0}; if ( hParentInstrumentHandle == 0 ) { STDERR( hp8563e_init ( szRsrcAddress , VI_FALSE , VI_FALSE , vhInstrumentHandle )); IF (( IS_NOT_OK ) , "Spectrum Analyzer Initializing Error." ); } if ( InstrumentConnectStatus ) *InstrumentConnectStatus = 1; if ( InstrumentChannelsQuantity ) *InstrumentChannelsQuantity = 1; Error: RETURN_STDERR_POINTER; }
/************************************************************************ * * * Create file list handler. Note that it doesn't create its window * * until it is necessary. * * Return OK or NOT_OK. * * */ int filelist_win_create(Frame owner, int x, int y, /* window position */ int filename_wd, /* filename width */ int filelist_num) /* number of listing files */ { if (fhdl){ STDERR("filelist_win_create:filelist window has already been created"); return (NOT_OK); } if ((fhdl = (Filelist_hdl *) malloc(sizeof(Filelist_hdl))) == NULL){ PERROR("filelist_win_create:malloc"); return (NOT_OK); } fhdl->owner = owner; fhdl->x = x; fhdl->y = y; fhdl->filename_wd = filename_wd; fhdl->filename_num = filelist_num; fhdl->popup = NULL; fhdl->filename = NULL; return (OK); }
static void line_expand (short *indata, char *outdata) { /************************************************************************** LOCAL VARIABLES: p_in A fast pointer to the data being loaded into the image line. p_out A fast pointer to the start of the image line. max_gray A fast variable to hold the maximum gray-level value. min_gray A fast variable to hold the minimum gray-level value. dv The decision variable (see Foley & van Dam). cmindex A fast variable for testing the converted gray-level value. i A counter for the length of the image line. */ register short *p_in = indata; register char *p_out = outdata; register short max_gray = g_max_gray; register short min_gray = g_min_gray; register int dv; register int cmindex; register int i; /* check the imput and output buffer pointers */ if (indata = (short *) NULL) { STDERR("line_expand: passed NULL indata pointer"); return; } if (outdata = (char *) NULL) { STDERR("line_expand: passed NULL outdata pointer"); return; } /* set the starting value of the decision variable */ dv = D1 - line_size; /* convert a data value to a colormap index, and test against limits */ if ((cmindex = (int) (vs * (*p_in) + min_gray)) > max_gray) cmindex = max_gray; if (raw_flag) { for (i = line_size; i > 0; --i, ++p_out) { /* load the data value into the output buffer */ *p_out = (u_char) cmindex; /* adjust the decision variable */ if (dv < 0) dv += D1; else { dv += D2; /* move to the next input point */ ++p_in; /* convert a data value to a colormap index, */ /* and test against limits */ if ((cmindex = (int) (vs * (*p_in) + min_gray)) > max_gray) cmindex = max_gray; } } } else { for (i = line_size; i > 0; --i, ++p_out) { /* load the data value into the output buffer */ *p_out = (u_char) x_color[cmindex]; /* adjust the decision variable */ if (dv < 0) dv += D1; else { dv += D2; /* move to the next input point */ ++p_in; /* convert a data value to a colormap index, */ /* and test against limits */ if ((cmindex = (int) (vs * (*p_in) + min_gray)) > max_gray) cmindex = max_gray; } } } } /* end of function "line_expand" */
/************************************************************************ * * * This routine is used to register a message for sending. After * * registering, the user will refer to "send_id" when sending a * * message. * * The message can be sent to any host by specifying the hostname. If * * hostname is NULL, this routine will unregister the message. * * * * Return program number for success and 0 for failure. * * * * In RPC term, CLIENT registers program and version numbers. The * * server should have already registered these numbers. * * */ u_long ipgwin_register_msg_send( u_long send_id, /* user sender ID */ u_long prognum, /* program ID */ u_long versnum, /* program version */ char *hostname) /* hostname where the message delivers to */ { struct hostent *hp; /* database information for hostname */ struct sockaddr_in svc_addr; /* server spcket address */ CLIENT *client; /* Client info */ Cltmsg *current, *prev; /* ptrs used for message item */ Cltmsg *newitem; /* new item */ int sock = RPC_ANYSOCK; /* any socket */ /* Check if the sender ID has been registered. */ for (current=prev=clthead; current; prev=current, current=current->next) { if (current->client_id == send_id) /* Found */ { auth_destroy(current->client->cl_auth); clnt_destroy(current->client); (void)free(current->hostname); if (current == prev) /* Only one item on the list */ svchead = NULL; else prev->next = current->next; (void)free((char *)current); if (hostname == NULL) return(prognum); else break; } } /* Get hostname info */ if ((hp = gethostbyname(hostname)) == NULL) { STDERR_1("ipgwin_register_msg_send:Can't get address for %s", hostname); return(0); } /* Set socket address */ memcpy( (caddr_t)&svc_addr.sin_addr, hp->h_addr_list[0], hp->h_length); svc_addr.sin_family = AF_INET; svc_addr.sin_port = 0; /* Create RPC client using TCP */ if ((client = clnttcp_create(&svc_addr, prognum, versnum, &sock, IPG_MAX_BYTES, IPG_MAX_BYTES)) == NULL) { STDERR("ipgwin_register_msg_send:clnttcp_create"); clnt_pcreateerror("clnttcp_create"); return(0); } /* Create Authentication. Server will check the UID everytime */ /* it receives a message. */ client->cl_auth = authunix_create_default(); /* Create new item */ if ((newitem = (Cltmsg *)malloc(sizeof(Cltmsg))) == NULL) { PERROR("ipgwin_register_msg_send:malloc:Message is not registered"); return(0); } newitem->client = client; newitem->client_id = send_id; newitem->prognum = prognum; newitem->versnum = versnum; newitem->hostname = strdup(hostname); newitem->next = NULL; /* Add a new item at the front of the list */ newitem->next = clthead; clthead = newitem; return(prognum); }
/************************************************************************ * * * This routine is used to register a specific function which will be * * called when there is a message. * * User function to be called can be NULL, indicating unregistering * * message, or user-func address, which takes a form of * * func(u_long proc_id, where proc_id is ID number. * * Ipgmsg *msg) where msg is a message. * * * * Return program number for success and 0 for failure. * * * * In RPC term, SERVER registers/unregisters program and version number * * */ u_long ipgwin_register_msg_receive( u_long prognum, /* program ID */ u_long versnum, /* program version */ void (*userfunc)(u_long, Ipgmsg*)) { Svcmsg *current, *prev; /* ptrs used for message item */ Svcmsg *newitem; /* new created item */ SVCXPRT *transp; /* transport info */ int protocol; /* protocol */ /* Check if the msgid has been registered or not. If the message */ /* has been registered, only change the user function. If the user */ /* function is NULL, delete the message item from the list. If the */ /* message has not been registered, add the new message item at the */ /* first of the list. */ for (current=prev=svchead; current; prev=current, current=current->next) { if ((current->prognum == prognum) && (current->versnum == versnum)) /* Found */ { svc_unregister(current->prognum, current->versnum); svc_destroy(current->xprt); if (current == prev) /* Only one item on the list */ svchead = NULL; else prev->next = current->next; (void)free((char *)current); if (userfunc == NULL) return(prognum) ; else break; } } /* Create an RPC with TCP socket */ if ((transp = svctcp_create(RPC_ANYSOCK, 0, 0)) == NULL) { STDERR("Can't create RPC"); return(0); } /* Get the "transient" program number if prognum is zero */ if (prognum == 0) { /* The "transient" program number starts at 0x40000000 */ /* Get the unused number. */ prognum = 0x40000000; while (!pmap_set(prognum, versnum, IPPROTO_TCP, transp->xp_port)) prognum++; /* We don't need to register it at svc_register since pmap_set */ /* has done it. */ protocol = 0; } else { /* Erase the pormapper's table */ pmap_unset(prognum, versnum); protocol = IPPROTO_TCP; } /* Register the portmapper. */ /* Note that Sun suggests that the program number ranges from */ /* 0x20000000 to 0x5fffffff. However, our routine doesn't */ /* check for this limit. */ #ifdef SOLARIS if (!svc_register(transp, prognum, versnum, ipgwin_priv_msg_receive, protocol)) #elif LINUX if (!svc_register(transp, prognum, versnum, ipgwin_priv_msg_receive, protocol)) #else if (!svc_register(transp, prognum, versnum, (void (*)(DOTDOTDOT))ipgwin_priv_msg_receive, protocol)) #endif { STDERR("ipgwin_register_msg_receive:Can't register RPC"); svc_destroy(transp); return(0); } /* Create new item */ if ((newitem = (Svcmsg *)malloc(sizeof(Svcmsg))) == NULL) { PERROR("ipgwin_register_message_receive:malloc:Message is not registered"); return(0); } newitem->xprt = transp; newitem->prognum = prognum; newitem->versnum = versnum; newitem->msgfunc = userfunc; /* Add a new item at the front of the list */ newitem->next = svchead; svchead = newitem; return(prognum); }
static int convert_short_data ( short *indata, char *outdata, int x_data, int y_data, int x_offset, int y_offset, int width, int height, int x_image, int y_image, Orientation direction) { /************************************************************************** LOCAL VARIABLES: sub_msg The name of this function, for error messages. trace A counter for the trace read from the data. max_val A pointer to a buffer used for generating the max data values for traces that will be removed during image compression. dv, d1, d2 The decision variable and delta's (see Foley & van Dam). p_in A fast pointer to the input buffer. p_out A fast pointer to the output buffer; register is desired since the pointer is changed during image filling. i, j Counters used for image filling and expansion/compression. trace_ptr Points to the trace being currently processed */ static char sub_msg[] = "convert_short_data:"; int trace; short *max_val; int dv, d1, d2; register char *p_out; int i; register short *trace_ptr; WARNING_OFF(width); /* set a fast pointer to the output buffer */ p_out = outdata; /* Build an image from the data: there are 3 possibilities: the data traces exactly fit the number of display lines */ if (height == y_image) { if (direction == TOP) { /* top down direction */ for (trace = y_offset; trace < y_offset + height; trace++) { if ( (trace_ptr = gettrace (indata, x_data, x_offset, trace)) == (short *) NULL) return (NOT_OK); (*LineFill)(trace_ptr, p_out); p_out += x_image; } } else if (direction == BOTTOM) /* Vnmr data starts at bottom scan line and comes up */ { for (trace = y_data-1 - y_offset; trace > y_data-1 - y_offset - height; trace--) { if ( (trace_ptr = gettrace (indata, x_data, x_offset, trace)) == (short *) NULL) return (NOT_OK); (*LineFill)(trace_ptr, p_out); p_out += x_image; } } } /* expand (repeat some of) the data traces to fill out the display lines */ else if (height < y_image) { /* set the adjustment values for the decision variable */ d1 = 2 * height; d2 = d1 - (2 * y_image); /* set the starting value of the decision variable */ dv = d1 - y_image; if (direction == TOP) { /* top down direction */ trace_ptr = NULL; for (i = 0, trace = y_offset; i < y_image; i++, p_out += x_image) { /* adjust the decision variable */ if (dv < 0) { dv += d1; if (trace_ptr) { (void)memcpy(p_out, p_out-x_image, x_image * sizeof(*p_out)); } else { /* Only get executed once (at the most)*/ if ( (trace_ptr = gettrace (indata, x_data, x_offset, trace)) == (short *)NULL) return (NOT_OK); /* load the data trace into the output buffer */ (*LineFill)(trace_ptr, p_out); } } else { dv += d2; if ( (trace_ptr = gettrace (indata, x_data, x_offset, trace++)) == (short *) NULL) return (NOT_OK); /* load the data trace into the output buffer */ (*LineFill)(trace_ptr, p_out); } } /* end of for all image scan lines */ } else if (direction == BOTTOM) /* Vnmr data starts at bottom scan line and comes up */ { /* starting with the last data trace, load the display lines */ trace_ptr = NULL; for (i = y_image, trace = y_data - y_offset; i > 0; --i, p_out += x_image) { /* adjust the decision variable */ if (dv < 0) { dv += d1; if (trace_ptr) { (void)memcpy(p_out, p_out-x_image, x_image * sizeof(*p_out)); } else { /* Only get executed once (at the most)*/ if ( (trace_ptr = gettrace (indata, x_data, x_offset, trace-1)) == (short *)NULL) return (NOT_OK); /* load the data trace into the output buffer */ (*LineFill)(trace_ptr, p_out); } } else { dv += d2; /* decrement the data trace counter */ --trace; if ( (trace_ptr = gettrace (indata, x_data, x_offset, trace)) == (short *) NULL) return (NOT_OK); /* load the data trace into the output buffer */ (*LineFill)(trace_ptr, p_out); } } /* end of for all display scan lines */ } /* end of if display inverted data set */ } /* end of if expand scan lines */ /* compress (delete some of) the data traces to fit into the display lines */ else { /* allocate a maximum buffer */ if ((max_val=(short *)calloc((uint)x_data,sizeof(short))) == (short *)NULL) { STDERR("convert_short_data: can't allocate memory"); return (NOT_OK); } /* set the adjustment values for the decision variable */ d1 = 2*y_image; d2 = d1 - 2 * height; /* set the starting value of the decision variable */ dv = d1 - height; if (direction == TOP) { /* starting with the first data trace, load the display lines */ for (trace = y_offset; trace < y_offset + height; trace++) { if ( (trace_ptr = gettrace (indata, x_data, x_offset, trace)) == (short *)NULL) return (NOT_OK); /* load this trace into the maximum buffer */ for (i = 1; i <= x_data; ++i) if (*(trace_ptr+i) > *(max_val+i)) *(max_val+i) = *(trace_ptr+i); /* adjust the decision variable */ if (dv < 0) dv += d1; else { dv += d2; /* load the maximum buffer into the output buffer */ (*LineFill)(max_val, p_out); p_out += x_image; /* clear the maximum buffer */ (void)memset ((char *)max_val, '\0', x_data * sizeof(short)); } } /* end of for all traces */ } else if (direction == BOTTOM) /* Vnmr data starts at bottom scan line and comes up */ { /* starting with the last data trace, load the display lines */ for (trace = y_data-1 - y_offset; trace > y_data-1 - y_offset - height; trace--) { if ( (trace_ptr = gettrace (indata, x_data, x_offset, trace)) == (short *)NULL) return (NOT_OK); /* load this trace into the maximum buffer */ for (i = 1; i <= x_data; ++i) if (*(trace_ptr+i) > *(max_val+i)) *(max_val+i) = *(trace_ptr+i); /* adjust the decision variable */ if (dv < 0) dv += d1; else { dv += d2; /* load the maximum buffer into the output buffer */ (*LineFill)(max_val, p_out); p_out += x_image; /* clear the maximum buffer */ (void)memset ((char *)max_val, '\0', x_data * sizeof(short)); } } /* end of for all traces */ } /* end of if display inverted data */ free ((char *)max_val); } return (OK); } /* end of function "convert_short_data" */
void g_display_short_image(Gdev *gdev, /* pointer to graphics device */ Siscms_type cms_index, /* index of siscms Colormap to use */ short *data, /* pointer to data points */ int points_per_line, /* data points per scan line */ int scan_lines, /* # of scan lines in data */ int src_x, /* x offset into source data */ int src_y, /* y offset into source data */ int src_width, /* width in data set, must be */ /* <= points_per_line */ int src_height, /* height to draw in data set */ int dest_x, /* x destination on canvas */ int dest_y, /* y destination on canvas */ int pix_width, /* pixel width */ int pix_height, /* pixel height */ Orientation direction, /* end from which data encoding */ /* starts in data set */ float vs) /* vertical scaling of data */ { char *pix_data; int prev_op; /* X-lib op to store while drawing */ XImage *ximage; int smooth_x, smooth_y ; short *new_data ; /* Do some checking on function inputs */ if (gdev == (Gdev *) NULL) { WARNING_OFF(Sid); STDERR("g_display_image2: passed NULL gdev pointer"); return; } if (data == (short *) NULL) { STDERR("g_display_image2: passed NULL data pointer"); return; } /* check the direction value */ if ((direction == LEFT) || (direction == RIGHT)) { STDERR("g_display_image2: LEFT or RIGHT orientation not supported"); return; } /* malloc space for pixel data */ if ((pix_data = (char *) malloc(pix_width * pix_height)) == NULL) { STDERR("g_display_short_image: pix_data malloc failed"); return; } if (smooth_flag) { if ((new_data = (short *)malloc(pix_width * pix_height * 2)) == NULL) { STDERR("g_display_short_image: new_data malloc failed"); return; } g_short_to_short (data, new_data, points_per_line, scan_lines, src_x, src_y, src_width, src_height, pix_width, pix_height); points_per_line = pix_width ; scan_lines = pix_height ; src_x = 0 ; src_y = 0 ; src_width = pix_width ; src_height = pix_height ; /* smooth top and bottom lines */ for (smooth_x = 1 ; smooth_x < pix_width - 1 ; smooth_x++) { new_data [smooth_x] = ( new_data [smooth_x + 1] + new_data [smooth_x - 1] ) / 2 ; new_data [((pix_height-1) * pix_width) + smooth_x ] = ( new_data [((pix_height-1) * pix_width) + smooth_x + 1] + new_data [((pix_height-1) * pix_width) + smooth_x - 1] ) / 2 ; } /* smooth leftmost and rightmost lines */ for (smooth_y = 1 ; smooth_y < pix_height -1; smooth_y++) { new_data [ (smooth_y * pix_width) ] = ( new_data [ ( (smooth_y-1) * pix_width ) ] + new_data [ ( (smooth_y+1) * pix_width ) ] ) / 2 ; new_data [ (smooth_y * pix_width) + (pix_width-1) ] = ( new_data [ ( (smooth_y-1) * pix_width ) + (pix_width-1) ] + new_data [ ( (smooth_y+1) * pix_width ) + (pix_width-1) ] ) / 2 ; } /* smooth the rest */ for (smooth_y = 1 ; smooth_y < pix_height - 1 ; smooth_y++) for (smooth_x = 1 ; smooth_x < pix_width - 1 ; smooth_x++) { new_data [ (smooth_y * pix_width) + smooth_x ] = ( new_data [ ( smooth_y * pix_width ) + smooth_x + 1 ] + new_data [ ( smooth_y * pix_width ) + smooth_x - 1 ] ) / 2 ; new_data [ (smooth_y * pix_width) + smooth_x ] = ( new_data [ ( (smooth_y-1) * pix_width ) + smooth_x ] + new_data [ ( (smooth_y+1) * pix_width ) + smooth_x ] ) / 2 ; } /* initialize the line-fill routine*/ line_fill_init (pix_width, src_width, gdev, cms_index, vs); /* scale and convert data to pixel data */ convert_short_data(new_data, pix_data, points_per_line, scan_lines, src_x, src_y, src_width, src_height, pix_width, pix_height, direction); free ((char *) new_data) ; } else { /* initialize the line-fill routine */ line_fill_init (pix_width, src_width, gdev, cms_index, vs); /* scale and convert data to pixel data */ convert_short_data(data, pix_data, points_per_line, scan_lines, src_x, src_y, src_width, src_height, pix_width, pix_height, direction); } /* create the X-Windows image */ ximage = XCreateImage(gdev->xdpy, DefaultVisual(gdev->xdpy, DefaultScreen(gdev->xdpy)), DefaultDepth(gdev->xdpy, DefaultScreen(gdev->xdpy)), ZPixmap, 0, pix_data, pix_width, pix_height, 8, 0); if (ximage == (XImage *) NULL) { STDERR("g_display_image2:XCreateImage returned NULL pointer"); /* you have to release malloc'ed memory if you are not going to call */ /* XDestroyImage() later. */ free(pix_data); return; } /* store the current type of draw operation */ prev_op = G_Get_Op(gdev); /* set the type of draw operation */ G_Set_Op(gdev, GXcopy); /* draw the X-Windows image */ XPutImage(gdev->xdpy, gdev->xid, gdev->xgc, ximage, 0, 0, dest_x, dest_y, pix_width, pix_height); /* restore the original X draw operation */ G_Set_Op(gdev, prev_op); /* destroy the X-Windows image */ XDestroyImage(ximage); } /* end of g_display_image2() */
/* * @brief A general Nui initialization function. Sets all of the initial parameters. */ void initNui(void) // We call this right after Nui functions called. { HRESULT hr; hr = NuiCreateSensorByIndex(0, &pNuiSensor); if(FAILED(hr)) STDERR("Cannot connect with kinect0.\r\n"); hr = pNuiSensor->NuiInitialize( //NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX | NUI_INITIALIZE_FLAG_USES_COLOR | NUI_INITIALIZE_FLAG_USES_SKELETON ); if ( E_NUI_SKELETAL_ENGINE_BUSY == hr ){ hr = pNuiSensor->NuiInitialize( NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_USES_COLOR ); } if(FAILED(hr)){ STDERR("Cannot initialize kinect.\r\n"); } hNextColorFrameEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); hNextDepthFrameEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); hNextSkeletonEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); if(HasSkeletalEngine(pNuiSensor)){ hr = pNuiSensor->NuiSkeletonTrackingEnable( hNextSkeletonEvent, //NUI_SKELETON_TRACKING_FLAG_TITLE_SETS_TRACKED_SKELETONS | //NUI_SKELETON_TRACKING_FLAG_ENABLE_SEATED_SUPPORT 0 ); if(FAILED(hr)) STDERR("Cannot track skeletons\r\n"); } hr = pNuiSensor->NuiImageStreamOpen( NUI_IMAGE_TYPE_COLOR, NUI_IMAGE_RESOLUTION_640x480, 0, 2, hNextColorFrameEvent, &pVideoStreamHandle ); if(FAILED(hr)){ STDERR("Cannot open image stream\r\n"); } hr = pNuiSensor->NuiImageStreamOpen( HasSkeletalEngine(pNuiSensor) ? NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX : NUI_IMAGE_TYPE_DEPTH, NUI_IMAGE_RESOLUTION_320x240, 0, 2, hNextDepthFrameEvent, &pDepthStreamHandle ); if(FAILED(hr)){ STDERR("Cannot open depth and player stream\r\n"); } /* hr = pNuiSensor->NuiImageStreamOpen( NUI_IMAGE_TYPE_DEPTH, NUI_IMAGE_RESOLUTION_640x480, 0, 2, hNextDepthFrameEvent, &pDepthStreamHandle ); if(FAILED(hr)){ STDERR("Cannot open depth stream\r\n"); } */ #if defined(USE_FACETRACKER) initFaceTracker(); #endif }
/************************************************************************ * * * Create filelist window. * * */ static void file_create_win(void) { int x_pos, y_pos; char *envhome; if (fhdl == NULL){ STDERR("file_create_win:filelist handler has not been created"); return; } (void) getcwd(dirname,MAXPATHLEN); /* Get the parent directory of user's home directory. Note that */ /* it is a complete path name including the file-mount name. */ /* The way we do this is to change directory to the login directory */ /* get the full-path name, and change it back to the current working */ /* directory. */ if (envhome = getenv("HOME")){ int i; char temp[MAXPATHLEN]; strcpy(temp, getenv("HOME")); /* Get rid of the login name. Hence we have parent directory */ /* of home directory. */ i = strlen(temp); while (temp[i] != '/'){ i--; } temp[i] = 0; parent_login = strdup(temp); }else{ parent_login = (char *)malloc(1); /* allocate 1 memory */ parent_login[0] = 0; } /* Set the default values */ if (fhdl->filename_wd == 0){ fhdl->filename_wd = 380; } if (fhdl->filename_num == 0){ fhdl->filename_num = 10; } if ((fhdl->font = xv_find(fhdl->owner, FONT, FONT_FAMILY, FONT_FAMILY_LUCIDA, FONT_STYLE, FONT_STYLE_BOLD, NULL)) == NULL) { STDERR("file_create_win: FONT_FAMILY_LUCIDA"); } /* Create pop-up frame */ fhdl->popup = xv_create(fhdl->owner, FRAME_CMD, FRAME_LABEL, "File Browser", XV_X, fhdl->x, XV_Y, fhdl->y, XV_FONT, fhdl->font, FRAME_SHOW_RESIZE_CORNER, TRUE, NULL); /* Get a panel from pop-up frame */ fhdl->panel = xv_get(fhdl->popup, FRAME_CMD_PANEL); /* Set the panel font */ xv_set(fhdl->panel, XV_FONT, fhdl->font, NULL); x_pos = 12; y_pos = 6; fhdl->filemsg = xv_create(fhdl->panel, PANEL_MESSAGE, XV_X, x_pos, XV_Y, y_pos, PANEL_LABEL_STRING, LOAD_FILE_MSG, NULL); fhdl->load_but = xv_create(fhdl->panel, PANEL_BUTTON, XV_X, x_pos + fhdl->filename_wd - 40, XV_Y, y_pos, PANEL_LABEL_STRING, "Load", PANEL_CLIENT_DATA, FILELIST_LOAD, PANEL_NOTIFY_PROC, file_action_proc, NULL); fhdl->save_but = xv_create(fhdl->panel, PANEL_BUTTON, XV_X, x_pos + fhdl->filename_wd - 40, XV_Y, y_pos, PANEL_LABEL_STRING, "Save", PANEL_CLIENT_DATA, FILELIST_SAVE, PANEL_NOTIFY_PROC, file_action_proc, NULL); y_pos += (int) xv_get(fhdl->filemsg, XV_HEIGHT) + 8; fhdl->load_all_but = xv_create(fhdl->panel, PANEL_BUTTON, XV_X, x_pos + fhdl->filename_wd - 40, XV_Y, y_pos, PANEL_LABEL_STRING, "Load All", PANEL_CLIENT_DATA, FILELIST_LOAD_ALL, PANEL_NOTIFY_PROC, file_action_proc, NULL); y_pos += (int) xv_get(fhdl->filemsg, XV_HEIGHT) + 8; fhdl->filename = xv_create(fhdl->panel, PANEL_TEXT, XV_X, x_pos, XV_Y, y_pos, PANEL_VALUE, "", PANEL_VALUE_DISPLAY_LENGTH, (int) (fhdl->filename_wd / 10), PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED, PANEL_NOTIFY_STRING, "\t\r\t\033", PANEL_NOTIFY_PROC, file_enter_proc, NULL); y_pos += (int) xv_get(fhdl->filename, XV_HEIGHT) + 14; fhdl->dirmsg = xv_create(fhdl->panel, PANEL_MESSAGE, XV_X, x_pos, XV_Y, y_pos, PANEL_LABEL_STRING, "", NULL); show_dir_path(short_path(dirname)); y_pos += (int) xv_get(fhdl->dirmsg, XV_HEIGHT) + 8; fhdl->filename_xpos = x_pos; fhdl->filename_ypos = y_pos; fhdl->dirlist = xv_create(fhdl->panel, PANEL_LIST, XV_X, x_pos, XV_Y, y_pos, PANEL_LIST_WIDTH, fhdl->filename_wd, PANEL_LIST_DISPLAY_ROWS, fhdl->filename_num, PANEL_NOTIFY_PROC, file_select_proc, NULL); y_pos += (int) xv_get(fhdl->dirlist, XV_HEIGHT) + 8; fhdl->msg = xv_create(fhdl->panel, PANEL_MESSAGE, PANEL_LABEL_STRING, "Message", XV_X, x_pos, XV_Y, y_pos, NULL); y_pos += (int) xv_get(fhdl->msg, XV_HEIGHT) + 8; fhdl->errmsg = xv_create(fhdl->panel, PANEL_MESSAGE, PANEL_LABEL_STRING, "Error Message", XV_X, x_pos, XV_Y, y_pos, NULL); window_fit(fhdl->panel); window_fit(fhdl->popup); }
static void print_header(void) { STDERR("diskdump main header\n"); STDERR(" signature : %s\n", l.hdr.signature); STDERR(" header_version : %d\n", l.hdr.header_version); STDERR(" status : %d\n", l.hdr.status); STDERR(" block_size : %d\n", l.hdr.block_size); STDERR(" sub_hdr_size : %d\n", l.hdr.sub_hdr_size); STDERR(" bitmap_blocks : %d\n", l.hdr.bitmap_blocks); STDERR(" max_mapnr : 0x%x\n", l.hdr.max_mapnr); STDERR(" total_ram_blocks : %d\n", l.hdr.total_ram_blocks); STDERR(" device_blocks : %d\n", l.hdr.device_blocks); STDERR(" written_blocks : %d\n", l.hdr.written_blocks); STDERR(" current_cpu : %d\n", l.hdr.current_cpu); STDERR(" nr_cpus : %d\n", l.hdr.nr_cpus); }
/************************************************************************ * * * Register user functions to call when the "Load" or "Save" button is * * selected. * * */ void filelist_notify_func(long id, Flist_type ftype, long addr_loadfunc, long addr_savefunc, long addr_loadallfunc) { Fileinfo *ptr, *prev; /* Fileinfo pointers */ char curdir[MAXPATHLEN]; /* buffer for current directory name */ if (fhdl == NULL){ STDERR("filelist_notify_func:File browser window has NOT been created"); return; } for (prev = ptr = finfoheader; ptr; prev = ptr, ptr = ptr->next){ /* Only allow to change callback function if */ /* ftype != FILELIST_NEW */ if (ptr->id == id){ if (ftype == FILELIST_CHANGE){ ptr->loadfunc = (int (*) (char *, char *)) addr_loadfunc; ptr->loadallfunc = (int (*) (char *, char *)) addr_loadallfunc; ptr->savefunc = (int (*) (char *, char *)) addr_savefunc; }else if (ftype == FILELIST_DELETE){ if (ptr == finfoheader) finfoheader = ptr->next; else prev->next = ptr->next; if (ptr == curfinfo){ /* We should close the file-browser if we delete its */ /* item from the finfoheader list. */ xv_set(fhdl->popup, FRAME_CMD_PUSHPIN_IN, FALSE, XV_SHOW, FALSE, NULL); curfinfo = NULL; } if (ptr->dirpath) free(ptr->dirpath); free((char *) ptr); }else err_msg("Id %d exists", id); return; } } /* Cannot find the ID */ if (ftype != FILELIST_NEW){ STDERR_1("filelist_notify_func:No such registered ID: %d", id); return; } /* === Now we know that ftype is FILELIST_NEW ==== */ /* Allocate memory for a new fileinfo */ if ((ptr = (Fileinfo *) malloc(sizeof(Fileinfo))) == NULL){ PERROR("filelist_notify_func:malloc"); exit(1); } ptr->id = id; getcwd(curdir,MAXPATHLEN); ptr->dirpath = strdup(curdir); ptr->loadfunc = (int (*) (char *, char *)) addr_loadfunc; ptr->loadallfunc = (int (*) (char *, char *)) addr_loadallfunc; ptr->savefunc = (int (*) (char *, char *)) addr_savefunc; ptr->next = NULL; /* Link it into a list at the last position */ if (prev){ prev->next = ptr; }else{ finfoheader = ptr; } }
/************************************************************************ * * * Creator of window. * * */ Win_movie::Win_movie(void) { int xitempos; // current panel item position int yitempos; // current panel item position Panel_item item; // Panel item int xpos, ypos; // window position int name_width; // width of filename (in pixel) int num_names; // number of filenames showed at one time char initname[128]; // init file low_frame = 0 ; high_frame = 0 ; Win_movie::get_the_frame(); (void)init_get_win_filename(initname); // Get the position of the control panel if (init_get_val(initname, "WINPRO_MOVIE", "dd", &xpos, &ypos) == NOT_OK) { xpos = 400; ypos = 20; } frame = xv_create(NULL, FRAME, NULL); popup = xv_create(frame, FRAME_CMD, XV_X, xpos, XV_Y, ypos, FRAME_LABEL, "Movie Control", FRAME_DONE_PROC, &Win_movie::done_proc, FRAME_CMD_PUSHPIN_IN, TRUE, NULL); panel = (Panel)xv_get(popup, FRAME_CMD_PANEL); xitempos = 150; yitempos = 10; item = xv_create(panel, PANEL_BUTTON, XV_X, xitempos, XV_Y, yitempos, PANEL_LABEL_STRING, "Load Frames ...", PANEL_NOTIFY_PROC, &Win_movie::movie_load, NULL); xitempos = 20; yitempos += (int)(DEFAULT_VERT_GAP * 1.17); start_stop_item = xv_create(panel, PANEL_CHOICE, XV_X, xitempos, XV_Y, yitempos, PANEL_CHOICE_STRINGS, "REVERSE", "STOP", "FORWARD", NULL, PANEL_NOTIFY_PROC, (&Win_movie::start_stop), PANEL_VALUE, 1, XV_SHOW, FALSE, NULL); xitempos = 10; yitempos += (int)(DEFAULT_VERT_GAP * 1.17); delay_item = xv_create(panel, PANEL_TEXT, XV_X, xitempos, XV_Y, yitempos, PANEL_LABEL_STRING, "Frames/sec", PANEL_NOTIFY_PROC, NULL, PANEL_VALUE, "10", PANEL_VALUE_DISPLAY_LENGTH, 5, NULL); //xitempos = 60; xitempos = 10; yitempos += DEFAULT_VERT_GAP; movie_speedometer = xv_create(panel, PANEL_GAUGE, XV_X, xitempos, XV_Y, yitempos, PANEL_LABEL_STRING, "Speed (%) ", PANEL_MIN_VALUE, 0, PANEL_MAX_VALUE, 100, PANEL_TICKS, 3, PANEL_GAUGE_WIDTH, 100, PANEL_VALUE, 0, NULL); /* yitempos += DEFAULT_VERT_GAP; xitempos += 20; item = xv_create(panel, PANEL_MESSAGE, XV_X, xitempos, XV_Y, yitempos, PANEL_LABEL_STRING, "Movie speed (%)", NULL); */ xitempos = 10; yitempos += (int)(DEFAULT_VERT_GAP * 1.17); item = xv_create(panel, PANEL_MESSAGE, XV_X, xitempos, XV_Y, yitempos, PANEL_LABEL_STRING, "Display frames:", NULL); xitempos += 100; low_frame_item = xv_create(panel, /*PANEL_TEXT,*/ PANEL_NUMERIC_TEXT, XV_X, xitempos, XV_Y, yitempos, PANEL_LABEL_STRING, "First", //PANEL_NOTIFY_LEVEL, PANEL_ALL, PANEL_NOTIFY_PROC, Win_movie::low_frame_set, PANEL_VALUE_DISPLAY_LENGTH, 4, PANEL_MIN_VALUE, 1, PANEL_MAX_VALUE, 1, PANEL_VALUE, 1, NULL); xitempos += 2; yitempos += DEFAULT_VERT_GAP; high_frame_item = xv_create(panel, /*PANEL_TEXT,*/ PANEL_NUMERIC_TEXT, XV_X, xitempos, XV_Y, yitempos, PANEL_LABEL_STRING, "Last", //PANEL_NOTIFY_LEVEL, PANEL_ALL, PANEL_NOTIFY_PROC, Win_movie::high_frame_set, PANEL_VALUE_DISPLAY_LENGTH, 4, PANEL_MIN_VALUE, 1, PANEL_MAX_VALUE, 1, PANEL_VALUE, 1, NULL); xitempos += -25; yitempos += DEFAULT_VERT_GAP; frame_slider = xv_create(panel, PANEL_NUMERIC_TEXT, //PANEL_SLIDER, XV_X, xitempos, XV_Y, yitempos, PANEL_LABEL_STRING, "Current", PANEL_MIN_VALUE, 1, PANEL_MAX_VALUE, 1, //PANEL_SLIDER_WIDTH, 150, //PANEL_TICKS, 2, PANEL_VALUE_DISPLAY_LENGTH, 3, PANEL_NOTIFY_PROC, &Win_movie::slider_slid, XV_SHOW, FALSE, NULL); window_fit(panel); window_fit(popup); window_fit(frame); xv_set(popup, XV_SHOW, TRUE, NULL); (void)init_get_win_filename(initname); // Get the initialized file-browser window position and its size if (init_get_val(initname, "FILE_BROWSER", "dddd", &xpos, &ypos, &name_width, &num_names) == NOT_OK) { // Default xpos = ypos = 0; name_width = 0; num_names = 0; } // Create frame-browser if (framelist_win_create(frame, xpos, ypos, name_width, num_names) == NOT_OK) { STDERR("window_create_frame_browser:framelist_win_create"); exit(1); } framelist_notify_func ((long)&Win_movie::get_name); }