//--------------------------------------------------------------------------- void __fastcall CWave::SetSoundID(int &rxID, int &txID) { BOOL fList = FALSE; int d; if( sscanf(sys.m_SoundIDRX.c_str(), "%d", &d ) == 1 ){ rxID = d; } else { rxID = -2; GetDeviceList(); fList = TRUE; for( int i = 0; i < m_InDevs; i++ ){ if( !strcmp(m_tInDevName[i].c_str(), sys.m_SoundIDRX.c_str()) ){ rxID = i; break; } } if( rxID == -2 ){ sys.m_SoundMMW = sys.m_SoundIDRX; } } if( sscanf(sys.m_SoundIDTX.c_str(), "%d", &d ) == 1 ){ txID = d; } else { txID = -1; if( !fList ) GetDeviceList(); for( int i = 0; i < m_OutDevs; i++ ){ if( !strcmp(m_tOutDevName[i].c_str(), sys.m_SoundIDTX.c_str()) ){ txID = i; break; } } } }
static GDHandle click_in_device_area( GDSpecPtr device_spec, Rect *frame, Point mouse) { Point offset; GDHandle device, intersected_device= (GDHandle) NULL; get_device_area_offset(frame, &offset); for (device= GetDeviceList(); device; device= GetNextDevice(device)) { if (TestDeviceAttribute(device, screenDevice) && TestDeviceAttribute(device, screenActive)) { GDSpec spec; Rect bounds; BuildExplicitGDSpec(&spec, device, device_spec->flags, device_spec->bit_depth, 0, 0); if (HasDepthGDSpec(&spec)) { get_device_area_frame(device, &bounds, offset); if (PtInRect(mouse, &bounds)) { intersected_device= device; break; } } } } return intersected_device; }
int main(int *argc,char *argv) { GetDeviceList(); system("pause"); return 0; }
int fileXio_GetDeviceList_RPC(struct fileXioDevice* ee_devices, int eecount) { int device_count = 0; iop_device_t **devices = GetDeviceList(); struct fileXioDevice local_devices[FILEXIO_MAX_DEVICES]; while (devices[device_count] && device_count < eecount) { iop_device_t *device = devices[device_count]; strncpy(local_devices[device_count].name, device->name, 128); local_devices[device_count].name[127] = '\0'; local_devices[device_count].type = device->type; local_devices[device_count].version = device->version; strncpy(local_devices[device_count].desc, device->desc, 128); local_devices[device_count].desc[127] = '\0'; ++device_count; } if (device_count) { struct t_SifDmaTransfer dmaStruct; int intStatus; // interrupt status - for dis/en-abling interrupts dmaStruct.src = local_devices; dmaStruct.dest = ee_devices; dmaStruct.size = sizeof(struct fileXioDevice) * device_count; dmaStruct.attr = 0; // Do the DMA transfer CpuSuspendIntr(&intStatus); SifSetDma(&dmaStruct, 1); CpuResumeIntr(intStatus); } return device_count; }
static void DrawSend(int ds, char *token) { nPageGroups= 0; if (token && strcmp(token, "to")==0) { /* draw to or send to merely resets outDraw or outSend list */ int i, n= 0; int *outDS= ds? outSend : outDraw; if (GetDeviceList(0, dsName[ds])) return; for (i=0 ; i<8 ; i++) if ((outDS[i]= outMark[i])) n++; if (!n) for (i=0 ; i<8 ; i++) outDS[i]= outEngines[i]? (ds? outTypes[i]<2 : outTypes[i]==2) : 0; return; } else if (token) { do { if (GetPageGroup(token)) return; } while ((token= strtok(0, " \t\n"))); } else { nPage[0]= mPage[0]= CGMRelative(0); sPage[0]= 1; nPageGroups= 1; } ReadCGM(mPage, nPage, sPage, nPageGroups); }
//--------------------------------------------------------------------------- // サウンドカードの問い合わせ void __fastcall CWave::GetInDevName(AnsiString &as) { int id = m_SoundID; if( id == -2 ){ as = sys.m_SoundMMW + " (MM Custom sound)"; return; } GetDeviceList(); if( (id < 0) || (id >= AN(m_tInDevName)) ) id = 0; as = m_tInDevName[id]; }
bool LoadXMLDoc(LPCWSTR file, BDADEVICES& d) { IXMLDOMDocumentPtr Document; HRESULT hr; d.reset(); hr = Document.CreateInstance(CLSID_DOMDocument30); if(hr==S_OK) { VARIANT_BOOL success; hr = Document->load(_variant_t(file),&success); if(hr==S_OK&&success==VARIANT_TRUE) { IXMLDOMElementPtr root; IXMLDOMElementPtr bda_source; IXMLDOMElementPtr bda_reciever; IXMLDOMNodePtr bda_source_node; IXMLDOMNodePtr bda_reciever_node; hr = Document->get_documentElement(&root); hr = root->selectSingleNode(_bstr_t(L"kscategory_bda_network_tuner"),&bda_source_node); hr = root->selectSingleNode(_bstr_t(L"kscategory_bda_receiver_component"),&bda_reciever_node); bda_source = bda_source_node; bda_reciever = bda_reciever_node; GetDeviceList(bda_source,d.bda_source); GetDeviceList(bda_reciever,d.bda_reciever); } else { return false; } } else { return false; } return false; }
int main(int argc, char *argv[]) { int err = 0; if(argc < 2) return 0; if(strstr(argv[1], "list") != NULL) { err = GetDeviceList(); if(err < 0) { fprintf(stderr, "GetDeviceList error:%d\n", err); } return 0; } else if(strstr(argv[1], "download") != NULL) { if(argc < 3) return 0; err = DownfwDevice(argv[2], argv[3]); if(err < 0) fprintf(stderr, "DownfwDevice error:%d\n", err); return 0; } else if(strstr(argv[1], "format") != NULL) { err = FormatDevice(argv[2]); if(err < 0) fprintf(stderr, "format error:%d\n", err); return 0; } else if(strstr(argv[1], "activate") != NULL) { if (argc < 5){ printf("argc not is 5\n"); return 0; } int slot = (argv[3][0]) - 48; int action = (argv[4][0]) - 48; err = ActivateDevice(argv[2], slot, action); if(err < 0) fprintf(stderr, "activate error:%d\n", err); return 0; } else { printf("args error\n"); } return 0; }
bool SSDPExtension::ProcessRequest( HTTPRequest *pRequest ) { if (pRequest) { if ( pRequest->m_sBaseUrl != "/") return( false ); switch( GetMethod( pRequest->m_sMethod )) { case SSDPM_GetDeviceDesc: GetDeviceDesc( pRequest ); return( true ); case SSDPM_GetDeviceList: GetDeviceList( pRequest ); return( true ); default: break; } } return( false ); }
static void draw_device_area( GDSpecPtr device_spec, GDHandle selected_device, Rect *frame) { Point offset; GDHandle device; get_device_area_offset(frame, &offset); EraseRect(frame); FrameRect(frame); for (device= GetDeviceList(); device; device= GetNextDevice(device)) { if (TestDeviceAttribute(device, screenDevice) && TestDeviceAttribute(device, screenActive)) { GDSpec spec; Rect bounds; BuildExplicitGDSpec(&spec, device, device_spec->flags, device_spec->bit_depth, 0, 0); get_device_area_frame(device, &bounds, offset); RGBForeColor(HasDepthGDSpec(&spec) ? &rgb_dark_gray : &rgb_white); PaintRect(&bounds); RGBForeColor(&rgb_black); if (device==selected_device) PenSize(2, 2); FrameRect(&bounds); PenSize(1, 1); if (device==GetMainDevice()) { bounds.bottom= bounds.top + DEVICE_AREA_MENU_BAR_HEIGHT; EraseRect(&bounds); FrameRect(&bounds); } } } return; }
// New doMyDeviceLoop, now works with multiple monitors void doMyDeviceLoop() { int depth; Rect gDeviceRect; Rect intersectingRect; GDHandle gDevice; //WindowRecord *windowRec = (WindowRecord *)gWindow; WindowPtr windowRec = gWindow; Rect windowRect; //= (**windowRec->contRgn).rgnBBox; RgnHandle rgnHandle = NewRgn(); GetWindowRegion(windowRec, kWindowContentRgn, rgnHandle); GetRegionBounds(rgnHandle, &windowRect); // Get the handle to the first device in the list. gDevice = GetDeviceList(); // Loop through all the devices in the list. while (gDevice != nil) { // Get the device's gdRect */ gDeviceRect = (**gDevice).gdRect; depth = (**(**gDevice).gdPMap).pixelSize; // Check if the app's window rect intersects the device's, and if it // does, set the clip region's rect to the intersection, then DRAW! if (SectRect( &windowRect, &gDeviceRect, &intersectingRect )) { // The intersectingRect is in global coords. Convert to local GlobalToLocal((Point *)&intersectingRect.top); GlobalToLocal((Point *)&intersectingRect.bottom); ClipRect( &intersectingRect ); doDraw( depth, &intersectingRect ); } // Get the next device in the list. gDevice = GetNextDevice( gDevice ); } DisposeRgn(rgnHandle); }
Boolean CanUserPickMonitor (void) { GDHandle dev = GetDeviceList(); OSErr err = noErr; int numMonitors; // build the list of monitors numMonitors = 0; while (dev && numMonitors < kMaxMonitors) { if (TestDeviceAttribute(dev, screenDevice) && TestDeviceAttribute(dev, screenActive)) { numMonitors++; } dev = GetNextDevice(dev); } if (numMonitors > 1) return true; else return false; }
int printRendererInfo(void) { GLenum err; GDHandle device; GLuint dnum = 0; device = GetDeviceList(); while(device) { DPRINTF(3,(fp,"\nDevice : %d\n", dnum)); CheckGetRendererInfo(device); device = GetNextDevice(device); dnum++; } err = aglGetError(); if(err != AGL_NO_ERROR) DPRINTF(3,(fp,"aglGetError - %s\n", aglErrorString(err))); return 1; }
BOOL AFXAPI AfxCheckMonochrome(const RECT* pRect) { long versionQD; if (Gestalt(gestaltQuickdrawVersion, &versionQD) != noErr || versionQD < gestalt8BitQD) return TRUE; // We draw all toolbars in monochrome if the main monitor is monochrome // because the main monitor is what determines the button face color // and button shadow color, and if those aren't grays, we won't get // reasonable output no matter how deep a monitor we're drawing on. if (GetSysColor(COLOR_BTNFACE) == RGB(255, 255, 255)) return TRUE; Rect rectMacClient; rectMacClient.top = (short)pRect->top; rectMacClient.left = (short)pRect->left; rectMacClient.bottom = (short)pRect->bottom; rectMacClient.right = (short)pRect->right; for (GDHandle hgd = GetDeviceList(); hgd != NULL; hgd = GetNextDevice(hgd)) { if (!TestDeviceAttribute(hgd, screenDevice) || !TestDeviceAttribute(hgd, screenActive)) continue; // ignore devices that the toolbar isn't drawn on Rect rect; if (!SectRect(&rectMacClient, &(*hgd)->gdRect, &rect)) continue; // we require 2-bit grayscale or 4-bit color to draw in color int pixelSize = (*(*hgd)->gdPMap)->pixelSize; if (pixelSize == 1 || (pixelSize == 2 && TestDeviceAttribute(hgd, gdDevType))) return TRUE; } return FALSE; }
static int FreeAny(int help) { int i; if (help) { p_stderr("gist: free command syntax:\n free [device# ...]\n"); p_stderr(" Finish and close the device#(s). If none given,\n"); p_stderr(" frees all send devices,\n"); p_stderr(" (Use the info command to describe current device numbers.)\n"); return 0; } if (GetDeviceList(1, "free")) return 0; for (i=0 ; i<8 ; i++) { if (outMark[i]) { GpKillEngine(outEngines[i]); outEngines[i]= 0; } } return 0; }
GDHandle AFXAPI _AfxFindDevice(int x, int y) { long lResult; Point pt; GDHandle hgd; if (Gestalt(gestaltQuickdrawVersion, &lResult) != noErr || lResult < gestalt8BitQD) return NULL; pt.h = (short) x; pt.v = (short) y; hgd = GetDeviceList(); while (hgd != NULL) { if (MacPtInRect(pt, &(*hgd)->gdRect)) return hgd; hgd = GetNextDevice(hgd); } return NULL; }
void myHideMenuBar( GDHandle ignoredDev) { RgnHandle gray,rect; GDHandle dev; (void)ignoredDev; if (savedgray) return; gray=GetGrayRgn(); savedgray=NewRgn(); rect=NewRgn(); CopyRgn(gray,savedgray); for (dev=GetDeviceList(); dev; dev=GetNextDevice(dev)) { if (!TestDeviceAttribute(dev,screenDevice) || !TestDeviceAttribute(dev,screenActive)) continue; RectRgn(rect,&(*dev)->gdRect); UnionRgn(gray,rect,gray); } DisposeRgn(rect); savedmbh=LMGetMBarHeight(); LMSetMBarHeight(0); }
OSErr SetupPickMonitorPane(ControlRef inPane, DisplayIDType inDefaultMonitor) { GDHandle dev = GetDeviceList(); OSErr err = noErr; // make the default monitor the selected device if (inDefaultMonitor) DMGetGDeviceByDisplayID(inDefaultMonitor, &sSelectedDevice, true); else sSelectedDevice = GetMainDevice(); // build the list of monitors sNumMonitors = 0; while (dev && sNumMonitors < kMaxMonitors) { if (TestDeviceAttribute(dev, screenDevice) && TestDeviceAttribute(dev, screenActive)) { sMonitors[sNumMonitors].device = dev; sMonitors[sNumMonitors].origRect = (**dev).gdRect; sMonitors[sNumMonitors].isMain = (dev == GetMainDevice()); sNumMonitors++; } dev = GetNextDevice(dev); } // calculate scaled rects if (sNumMonitors) { Rect origPaneRect, paneRect; Rect origGrayRect, grayRect, scaledGrayRect; float srcAspect, dstAspect, scale; int i; GetControlBounds(inPane, &origPaneRect); paneRect = origPaneRect; OffsetRect(&paneRect, -paneRect.left, -paneRect.top); GetRegionBounds(GetGrayRgn(), &origGrayRect); grayRect = origGrayRect; OffsetRect(&grayRect, -grayRect.left, -grayRect.top); srcAspect = (float)grayRect.right / (float)grayRect.bottom; dstAspect = (float)paneRect.right / (float)paneRect.bottom; scaledGrayRect = paneRect; if (srcAspect < dstAspect) { scaledGrayRect.right = (float)paneRect.bottom * srcAspect; scale = (float)scaledGrayRect.right / grayRect.right; } else { scaledGrayRect.bottom = (float)paneRect.right / srcAspect; scale = (float)scaledGrayRect.bottom / grayRect.bottom; } for (i = 0; i < sNumMonitors; i++) { Rect r = sMonitors[i].origRect; Rect r2 = r; // normalize rect and scale OffsetRect(&r, -r.left, -r.top); r.bottom = (float)r.bottom * scale; r.right = (float)r.right * scale; // offset rect wrt gray region OffsetRect(&r, (float)(r2.left - origGrayRect.left) * scale, (float)(r2.top - origGrayRect.top) * scale); sMonitors[i].scaledRect = r; } // center scaledGrayRect in the pane OffsetRect(&scaledGrayRect, (paneRect.right - scaledGrayRect.right) / 2, (paneRect.bottom - scaledGrayRect.bottom) / 2); // offset monitors to match for (i = 0; i < sNumMonitors; i++) OffsetRect(&sMonitors[i].scaledRect, scaledGrayRect.left, scaledGrayRect.top); } else return paramErr; // setup the procs for the pick monitor user pane err = SetupUserPaneProcs(inPane, drawProc, hitTestProc, trackingProc); return err; }
/*
static void ROM_HideMenuBar(_THIS) { #if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */ RgnHandle drawRgn = nil; RgnHandle tempRgn = nil; RgnHandle grayRgn = nil; WindowPtr window = nil; GDHandle gd = nil; GrafPtr savePort; long response; short height; EventRecord theEvent; height = GetMBarHeight(); if ( height > 0 ) { tempRgn = NewRgn(); drawRgn = NewRgn(); gSaveGrayRgn = NewRgn(); if ( ! tempRgn || ! drawRgn || ! gSaveGrayRgn ) { goto CLEANUP; } grayRgn = GetGrayRgn(); /* No need to check for this */ GetPort(&savePort); /* Hide the control strip if it's present, and record its previous position into the dirty region for redrawing. This isn't necessary, but may help catch stray bits. */ CopyRgn(grayRgn, tempRgn); if (!Gestalt(gestaltControlStripAttr, &response) && (response & (1L << gestaltControlStripExists))) { gSaveCSVis = SBIsControlStripVisible(); if (gSaveCSVis) SBShowHideControlStrip(false); } DiffRgn(grayRgn, tempRgn, drawRgn); /* Save the gray region once the control strip is hidden*/ CopyRgn(grayRgn, gSaveGrayRgn); /* Change the menu height in lowmem */ gSaveMenuBar = height; LMSetMBarHeight(0); /* Walk the monitor rectangles, and combine any pieces that aren't in GrayRgn: menubar, round corners, fake floaters. */ for(gd = GetDeviceList(); gd; gd = GetNextDevice(gd)) { if (!TestDeviceAttribute(gd, screenDevice)) continue; if (!TestDeviceAttribute(gd, screenActive)) continue; RectRgn(tempRgn, &(*gd)->gdRect); /* Get the whole screen */ DiffRgn(tempRgn, grayRgn, tempRgn); /* Subtract out GrayRgn */ UnionRgn(tempRgn, drawRgn, drawRgn);/* Combine all the bits */ } /* Add the bits into the GrayRgn */ UnionRgn(drawRgn, grayRgn, grayRgn); /* Modify the vis regions of exposed windows */ window = (FrontWindow()) ? FrontWindow() : (WindowPtr) -1L; PaintBehind(window, drawRgn); CalcVisBehind(window, drawRgn); SetPort(savePort); /* Yield time so that floaters can catch up */ EventAvail(0, &theEvent); EventAvail(0, &theEvent); EventAvail(0, &theEvent); EventAvail(0, &theEvent); } CLEANUP: if (tempRgn) DisposeRgn(tempRgn); if (drawRgn) DisposeRgn(drawRgn); #endif /* !TARGET_API_MAC_CARBON */ }
void *client_thread(void *arg) { cJSON *root = NULL; char buffer[512] = {0}; dev_tt dev; DEV_ADD_RETURN ret_add_dev = DEV_ADD_OK; BOOL ret = FALSE; char cityid[20] = {0}; fd_set pending_data; struct timeval block_time; if (arg == NULL) { return NULL; } int *fd = arg; FD_ZERO(&pending_data); FD_SET(*fd,&pending_data); block_time.tv_sec = 5; block_time.tv_usec = 0; /*if client connect and not send message in 5 seconds,we will close the connection*/ if (select((*fd) + 1, &pending_data, NULL, NULL, &block_time) > 0) { if (FD_ISSET(*fd, &pending_data)) { if (read(*fd, buffer, sizeof(buffer)) < 0) { close(*fd); return NULL; } } } led_flash(LED_FOR_NETWORK, 1, 3); DEBUG_MSG("Network receive:%s\n", buffer); root = cJSON_Parse(buffer);//parse json if (root == NULL) { return NULL; } memset(&dev, 0, sizeof(dev_tt)); char *who = cJSON_GetObjectItem(root, "param0")->valuestring; dev.user_action = cJSON_GetObjectItem(root, "param1")->valuestring; dev.basic_info.mac = cJSON_GetObjectItem(root, "param2")->valuestring; dev.basic_info.name = cJSON_GetObjectItem(root, "param3")->valuestring; dev.type = cJSON_GetObjectItem(root, "param4")->valuestring; dev.dev_cmd = cJSON_GetObjectItem(root, "param5")->valuestring; dev.basic_info.groupname = cJSON_GetObjectItem(root, "param6")->valuestring; char *param1 = cJSON_GetObjectItem(root, "param7")->valuestring; char *param2 = cJSON_GetObjectItem(root, "param8")->valuestring; if (who == NULL || dev.user_action == NULL || dev.basic_info.mac==NULL ||dev.basic_info.name== NULL||dev.dev_cmd==NULL||dev.basic_info.groupname==NULL) { close(*fd); return NULL; } USER_ACTION user_action_type = (USER_ACTION)atoi(dev.user_action); switch (user_action_type) { case ACTION_DEV_ADD: dev.basic_info.name = strtok(dev.basic_info.name,":");//contains unicode dev.basic_info.unicode = strtok(NULL,":"); dev.type = param2; if (dev.basic_info.name == NULL ||dev.basic_info.unicode == NULL) { break; } DEBUG_MSG("ADD:name= %s,unicode= %s\n",dev.basic_info.name,dev.basic_info.unicode); ret_add_dev = AddDevToStaticTable(dev.basic_info.mac,dev.basic_info.name,dev.basic_info.unicode,dev.basic_info.groupname,atoi(param1),atoi(dev.type)); if (ret_add_dev==DEV_ADD_OK) { write(*fd, SOCKET_RESPONSE_YES, strlen(SOCKET_RESPONSE_YES)); send_broadcast(who, user_action_type, dev.basic_info.name); } else if (ret_add_dev == DEV_MAC_EXIST) { write(*fd,SOCKET_RESPONSE_MAC_EXIST, strlen(SOCKET_RESPONSE_MAC_EXIST)); } else if (ret_add_dev == DEV_NAME_EXIST) { write(*fd,SOCKET_RESPONSE_NAME_EXIST, strlen(SOCKET_RESPONSE_NAME_EXIST)); } break; case ACTION_DEV_REMOVE: ret = RemoveDevFromStaticTable(dev.basic_info.mac,dev.basic_info.name); if (ret) { send_broadcast(who,user_action_type,dev.basic_info.name); } goto response_client; break; case ACTION_DEV_ADD_GROUP: ret = AddDevGroupName(dev.basic_info.groupname); goto response_client; break; case ACTION_DEV_EDIT: { char *oldname = param1; dev.basic_info.name = strtok(dev.basic_info.name,":"); dev.basic_info.unicode = strtok(NULL,":"); if (dev.basic_info.name == NULL ||dev.basic_info.unicode == NULL||oldname==NULL) { break; } DEBUG_MSG("UPDATE:oldname = %s newname= %s,unicode= %s\n",oldname,dev.basic_info.name,dev.basic_info.unicode); ret = UpdateDevDisplayName(dev.basic_info.mac, oldname,dev.basic_info.name,dev.basic_info.unicode); if (ret) { send_broadcast(who,user_action_type,dev.basic_info.name); } goto response_client; } break; case ACTION_GET_ALARM_LIST: GetAlarmAllList(); write(*fd,get_alarm_alllist(),strlen(get_alarm_alllist())); break; case ACTION_GET_DEV_LIST: GetDeviceList(); write(*fd,get_dev_list(),strlen(get_dev_list())); break; case ACTION_GET_CITY_ID: //char *name = dev.basic_info.name; memset(cityid,0,sizeof(cityid)); if (GetCityIDByName(dev.basic_info.name, cityid)) { write(*fd,cityid,strlen(cityid)); } else { write(*fd,SOCKET_RESPONSE_NO,strlen(SOCKET_RESPONSE_NO)); } break; case ACTION_DEV_CONTROL: if (app_status.is_uart_ok) { ret = ForwardControlToUart(dev.basic_info.mac,dev.basic_info.name,(DEV_TYPE_INDEX)(atoi(dev.type)),atoi(dev.dev_cmd),atoi(param1)); } else { ret = FALSE; } goto response_client; break; case ACTION_SEND_MSG: if (app_status.is_sms_ok) { ret = sms.send(dev.basic_info.mac,dev.basic_info.name); } else { ret = FALSE; } goto response_client; break; case ACTION_ALARM_ADD: //mac as the value(email or mobile value) ret = AddAlarmItem((ALARM_TYPE)(atoi(dev.type)), dev.basic_info.mac); goto response_client; break; case ACTION_ALARM_LOCK: ret = ChangeAlarmItemToState(ALARM_LOCK,(ALARM_TYPE)(atoi(dev.type)), dev.basic_info.mac); goto response_client; break; case ACTION_ALARM_UNLOCK: ret = ChangeAlarmItemToState(ALARM_UNLOCK,(ALARM_TYPE)(atoi(dev.type)), dev.basic_info.mac); goto response_client; break; case ACTION_ALARM_DELETE: ret = DeleteFromAlarmTable((ALARM_TYPE)(atoi(dev.type)), dev.basic_info.mac); goto response_client; break; case ACTION_GET_ALL_GROUP_NAME: GetAllGroupName(); write(*fd , get_group_list(), strlen(get_group_list())); break; case ACTION_UPDATE_DEV_GROUP: ret = UpdateDevGroupName(dev.basic_info.mac,dev.basic_info.name,dev.basic_info.groupname); goto response_client; break; case ACTION_SET_GROUP_ID: { groupInfo_t group_info; memset(&group_info,0,sizeof(&group_info)); strcpy(group_info.group_id,dev.basic_info.mac); strcpy(group_info.group_name,dev.basic_info.name); ret = SetFamilyGroupInfo(group_info); goto response_client; } break; case ACTION_GET_GROUP_ID: { groupInfo_t group_info; memset(&group_info,0,sizeof(&group_info)); if (GetFamilyGroupInfo(&group_info)) { char buf[1024] = {0}; sprintf(buf,"%s,%s,",group_info.group_id,group_info.group_name); write(*fd,buf,strlen(buf)); } else { write(*fd,"_FAIL_",strlen("_FAIL_")); } } break; case ACTION_ADD_TIMERTASK: { timertask_item_t item; DEBUG_MSG("add timertask!\n"); memset(&item,0,sizeof(&item)); strcpy(item.dev_mac,dev.basic_info.mac); strcpy(item.dev_name,dev.basic_info.name); strcpy(item.happen_time ,param1); item.period = atoi(dev.type); item.action = atoi(dev.dev_cmd); item.tipinfo = atoi(dev.basic_info.groupname); item.howlong = atoi(param2); DEBUG_MSG("action = %d, howlong = hour:%2d,minute:%2d\n",item.action,(item.howlong)/100,(item.howlong)%100); ret = AddOneTimerTask(item); if (ret && item.howlong > 0) { TimeAdd(item.happen_time,item.howlong/100, item.howlong%100, item.happen_time); if (item.action == CMD_SW_OPEN) { item.action = CMD_SW_CLOSE; } else { item.action = CMD_SW_OPEN; } item.howlong = 0;//avoid repeat ret = AddOneTimerTask(item); } goto response_client; } break; case ACTION_DELETE_TIMERTASK: { int timertask_id = 0; ret = DeleteOneTimerTaskByID(timertask_id); goto response_client; } break; case ACTION_GET_TIMERTASK_INFO: GetAllTimerTaskInfo(); write(*fd,g_timertask_info,strlen(g_timertask_info)); break; case ACTION_SW_GET_STATE: { char buffer[10] = {0}; enum control_cmd state = SWGetCurrentState(dev.basic_info.mac,dev.basic_info.name,atoi(param1)); sprintf(buffer,"%d", state); write(*fd,buffer,strlen(buffer)); } break; case ACTION_QUIT: close(*fd); return NULL; default: break; } close(*fd); return NULL; response_client: if (ret) { write(*fd, SOCKET_RESPONSE_YES, strlen(SOCKET_RESPONSE_YES)); } else { write(*fd, SOCKET_RESPONSE_NO, strlen(SOCKET_RESPONSE_NO)); } close(*fd); return NULL; }
void CheckOpenGLCaps (CGDisplayCount maxDspys, GLCaps dCaps[], CGDisplayCount * dCnt) { CGLContextObj curr_ctx = 0; CGDirectDisplayID dspys[32]; CGDisplayErr err; unsigned short i; short size = sizeof (GLCaps); // no devices *dCnt = 0; if (maxDspys == 0) { // find number of displays *dCnt = 0; err = CGGetActiveDisplayList (32, dspys, dCnt); if (err) // err getting list *dCnt = 0; // 0 displays since can't correctly find any // zero list to ensure the routines are used correctly memset (dspys, 0, sizeof (CGDirectDisplayID) * *dCnt); return; // return dCnt } if (NULL == dCaps) return; err = CGGetActiveDisplayList(maxDspys, dspys, dCnt); if (err) return; // err getting list if (0 == *dCnt) return; // no displays memset (dCaps, 0, size * *dCnt); // zero memory for (i = 0; i < *dCnt; i++) { // get device ids dCaps[i].cgDisplayID = dspys[i]; dCaps[i].cglDisplayMask = CGDisplayIDToOpenGLDisplayMask(dspys[i]); { // get current geometry CGRect displayRect = CGDisplayBounds (dspys[i]); // get mode dictionary CFDictionaryRef dispMode = CGDisplayCurrentMode (dspys[i]); dCaps[i].deviceWidth = (long) displayRect.size.width; dCaps[i].deviceHeight = (long) displayRect.size.height; dCaps[i].deviceOriginX = (long) displayRect.origin.x; dCaps[i].deviceOriginY = (long) displayRect.origin.y; dCaps[i].deviceDepth = (short) _getDictLong (dispMode, kCGDisplayBitsPerPixel); dCaps[i].deviceRefresh = (short) (_getDictDouble (dispMode, kCGDisplayRefreshRate) + 0.5); } { // find gDevice device by bounds GDHandle hGD; for (hGD = GetDeviceList (); hGD; hGD = GetNextDevice (hGD)) { if (!TestDeviceAttribute (hGD, screenDevice) || !TestDeviceAttribute (hGD, screenActive)) continue; // if postion and sizes match if (((*hGD)->gdRect.top == dCaps[i].deviceOriginY) && ((*hGD)->gdRect.left == dCaps[i].deviceOriginX) && (((*hGD)->gdRect.bottom - (*hGD)->gdRect.top) == dCaps[i].deviceHeight) && (((*hGD)->gdRect.right - (*hGD)->gdRect.left) == dCaps[i].deviceWidth)) { dCaps[i].hGDevice = hGD; break; } } if (dCaps[i].hGDevice == NULL) return; // err if (noErr != DMGetDisplayIDByGDevice (dCaps[i].hGDevice, &dCaps[i].displayID, false)) dCaps[i].displayID = 0; // err getting display ID } { // get renderer info based on gDevice CGLRendererInfoObj info; long j, numRenderers = 0, rv = 0; err = (CGLError)0; err = CGLQueryRendererInfo (dCaps[i].cglDisplayMask, &info, &numRenderers); if (0 == err) { CGLDescribeRenderer (info, 0, kCGLRPRendererCount, &numRenderers); for (j = 0; j < numRenderers; j++) { // find accelerated renderer (assume only one) CGLDescribeRenderer (info, j, kCGLRPAccelerated, &rv); if (true == rv) { // if accelerated // what is the renderer ID CGLDescribeRenderer (info, j, kCGLRPRendererID, (long *)&dCaps[i].rendererID); // can we do full screen? CGLDescribeRenderer (info, j, kCGLRPFullScreen, &rv); dCaps[i].fullScreenCapable = (bool) rv; // what is the VRAM? CGLDescribeRenderer (info, j, kCGLRPVideoMemory, &dCaps[i].deviceVRAM); // what is the current texture memory? CGLDescribeRenderer (info, j, kCGLRPTextureMemory, &dCaps[i].deviceTextureRAM); break; // done } } } CGLDestroyRendererInfo (info); } { // build context and context specific info CGLPixelFormatAttribute attribs[] = { (CGLPixelFormatAttribute)kCGLPFADisplayMask, (CGLPixelFormatAttribute)dCaps[i].cglDisplayMask, (CGLPixelFormatAttribute)NULL }; CGLPixelFormatObj pixelFormat = NULL; long numPixelFormats = 0; CGLContextObj cglContext; curr_ctx = CGLGetCurrentContext (); // get current CGL context CGLChoosePixelFormat (attribs, &pixelFormat, &numPixelFormats); if (pixelFormat) { CGLCreateContext(pixelFormat, NULL, &cglContext); CGLDestroyPixelFormat (pixelFormat); CGLSetCurrentContext (cglContext); if (cglContext) { const GLubyte * strExt; const GLubyte * strRend; const GLubyte * strVers; const GLubyte * strVend; // get renderer strings strRend = glGetString (GL_RENDERER); strncpy (dCaps[i].strRendererName, (const char*)strRend, 255); strVend = glGetString (GL_VENDOR); strncpy (dCaps[i].strRendererVendor, (const char*)strVend, 255); strVers = glGetString (GL_VERSION); strncpy (dCaps[i].strRendererVersion, (const char*)strVers, 255); { // get BCD version short j = 0; short shiftVal = 8; while (((strVers[j] <= '9') && (strVers[j] >= '0')) || (strVers[j] == '.')) { // get only basic version info (until first non-digit or non-.) if ((strVers[j] <= '9') && (strVers[j] >= '0')) { dCaps[i].glVersion += (strVers[j] - '0') << shiftVal; shiftVal -= 4; } j++; } } strExt = glGetString (GL_EXTENSIONS); // get caps glGetIntegerv (GL_MAX_TEXTURE_UNITS, &dCaps[i].textureUnits); glGetIntegerv (GL_MAX_TEXTURE_SIZE, &dCaps[i].maxTextureSize); glGetIntegerv (GL_MAX_3D_TEXTURE_SIZE, &dCaps[i].max3DTextureSize); glGetIntegerv (GL_MAX_CUBE_MAP_TEXTURE_SIZE, &dCaps[i].maxCubeMapTextureSize); // get functionality info dCaps[i].fSpecularVector = gluCheckExtension ((const GLubyte*)"GL_APPLE_specular_vector", strExt); dCaps[i].fTransformHint = gluCheckExtension ((const GLubyte*)"GL_APPLE_transform_hint", strExt); dCaps[i].fPackedPixels = gluCheckExtension ((const GLubyte*)"GL_APPLE_packed_pixels", strExt) || gluCheckExtension ((const GLubyte*)"GL_APPLE_packed_pixel", strExt) || (dCaps[i].glVersion >= 0x0120); dCaps[i].fClientStorage = gluCheckExtension ((const GLubyte*)"GL_APPLE_client_storage", strExt); dCaps[i].fYCbCr = gluCheckExtension ((const GLubyte*)"GL_APPLE_ycbcr_422", strExt); dCaps[i].fTextureRange = gluCheckExtension ((const GLubyte*)"GL_APPLE_texture_range", strExt); dCaps[i].fFence = gluCheckExtension ((const GLubyte*)"GL_APPLE_fence", strExt); dCaps[i].fVAR = gluCheckExtension ((const GLubyte*)"GL_APPLE_vertex_array_range", strExt); dCaps[i].fVAO = gluCheckExtension ((const GLubyte*)"GL_APPLE_vertex_array_object", strExt); dCaps[i].fElementArray = gluCheckExtension ((const GLubyte*)"GL_APPLE_element_array", strExt); dCaps[i].fVPEvals = gluCheckExtension((const GLubyte*)"GL_APPLE_vertex_program_evaluators",strExt); dCaps[i].fFloatPixels = gluCheckExtension ((const GLubyte*)"GL_APPLE_float_pixels", strExt); dCaps[i].fFlushRenderer = gluCheckExtension ((const GLubyte*)"GL_APPLE_flush_render", strExt); dCaps[i].fPixelBuffer = gluCheckExtension ((const GLubyte*)"GL_APPLE_pixel_buffer", strExt); dCaps[i].fImaging = gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt); dCaps[i].fTransposeMatrix = gluCheckExtension ((const GLubyte*)"GL_ARB_transpose_matrix", strExt) || (dCaps[i].glVersion >= 0x0130); dCaps[i].fMultitexture = gluCheckExtension ((const GLubyte*)"GL_ARB_multitexture", strExt) || (dCaps[i].glVersion >= 0x0130); dCaps[i].fTexEnvAdd = gluCheckExtension ((const GLubyte*)"GL_ARB_texture_env_add", strExt) || gluCheckExtension ((const GLubyte*)"GL_EXT_texture_env_add", strExt) || (dCaps[i].glVersion >= 0x0130); dCaps[i].fTexEnvCombine = gluCheckExtension ((const GLubyte*)"GL_ARB_texture_env_combine", strExt) || (dCaps[i].glVersion >= 0x0130); dCaps[i].fTexEnvDot3 = gluCheckExtension ((const GLubyte*)"GL_ARB_texture_env_dot3", strExt) || (dCaps[i].glVersion >= 0x0130); dCaps[i].fTexEnvCrossbar = gluCheckExtension ((const GLubyte*)"GL_ARB_texture_env_crossbar", strExt) || (dCaps[i].glVersion >= 0x0140); dCaps[i].fTexCubeMap = gluCheckExtension ((const GLubyte*)"GL_ARB_texture_cube_map", strExt) || (dCaps[i].glVersion >= 0x0130); dCaps[i].fTexCompress = gluCheckExtension ((const GLubyte*)"GL_ARB_texture_compression", strExt) || (dCaps[i].glVersion >= 0x0130); dCaps[i].fMultisample = gluCheckExtension ((const GLubyte*)"GL_ARB_multisample", strExt) || (dCaps[i].glVersion >= 0x0130); dCaps[i].fTexBorderClamp = gluCheckExtension ((const GLubyte*)"GL_ARB_texture_border_clamp", strExt) || (dCaps[i].glVersion >= 0x0130); dCaps[i].fPointParam = gluCheckExtension ((const GLubyte*)"GL_ARB_point_parameters", strExt) || (dCaps[i].glVersion >= 0x0140); dCaps[i].fVertexProg = gluCheckExtension ((const GLubyte*)"GL_ARB_vertex_program", strExt); dCaps[i].fFragmentProg = gluCheckExtension ((const GLubyte*)"GL_ARB_fragment_program", strExt); dCaps[i].fTexMirrorRepeat = gluCheckExtension ((const GLubyte*)"GL_ARB_texture_mirrored_repeat", strExt) || (dCaps[i].glVersion >= 0x0140); dCaps[i].fDepthTex = gluCheckExtension ((const GLubyte*)"GL_ARB_depth_texture", strExt) || (dCaps[i].glVersion >= 0x0140); dCaps[i].fShadow = gluCheckExtension ((const GLubyte*)"GL_ARB_shadow", strExt) || (dCaps[i].glVersion >= 0x0140); dCaps[i].fShadowAmbient = gluCheckExtension ((const GLubyte*)"GL_ARB_shadow_ambient", strExt); dCaps[i].fVertexBlend = gluCheckExtension ((const GLubyte*)"GL_ARB_vertex_blend", strExt); dCaps[i].fWindowPos = gluCheckExtension ((const GLubyte*)"GL_ARB_window_pos", strExt) || (dCaps[i].glVersion >= 0x0140); dCaps[i].fTex3D = gluCheckExtension ((const GLubyte*)"GL_EXT_texture3D", strExt) || (dCaps[i].glVersion >= 0x0120); dCaps[i].fClipVolHint = gluCheckExtension ((const GLubyte*)"GL_EXT_clip_volume_hint", strExt); dCaps[i].fRescaleNorm = gluCheckExtension ((const GLubyte*)"GL_EXT_rescale_normal", strExt) || (dCaps[i].glVersion >= 0x0120); dCaps[i].fBlendColor = gluCheckExtension ((const GLubyte*)"GL_EXT_blend_color", strExt) || gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt); dCaps[i].fBlendMinMax = gluCheckExtension ((const GLubyte*)"GL_EXT_blend_minmax", strExt) || gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt); dCaps[i].fBlendSub = gluCheckExtension ((const GLubyte*)"GL_EXT_blend_subtract", strExt) || gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt); dCaps[i].fCVA = gluCheckExtension ((const GLubyte*)"GL_EXT_compiled_vertex_array", strExt); dCaps[i].fTexLODBias = gluCheckExtension ((const GLubyte*)"GL_EXT_texture_lod_bias", strExt) || (dCaps[i].glVersion >= 0x0140); dCaps[i].fABGR = gluCheckExtension ((const GLubyte*)"GL_EXT_abgr", strExt); dCaps[i].fBGRA = gluCheckExtension ((const GLubyte*)"GL_EXT_bgra", strExt) || (dCaps[i].glVersion >= 0x0120); dCaps[i].fTexFilterAniso = gluCheckExtension ((const GLubyte*)"GL_EXT_texture_filter_anisotropic",strExt); dCaps[i].fPaletteTex = gluCheckExtension ((const GLubyte*)"GL_EXT_paletted_texture", strExt); dCaps[i].fShareTexPalette = gluCheckExtension ((const GLubyte*)"GL_EXT_shared_texture_palette", strExt); dCaps[i].fSecColor = gluCheckExtension ((const GLubyte*)"GL_EXT_secondary_color", strExt) || (dCaps[i].glVersion >= 0x0140); dCaps[i].fTexCompressS3TC = gluCheckExtension ((const GLubyte*)"GL_EXT_texture_compression_s3tc", strExt); dCaps[i].fTexRect = gluCheckExtension ((const GLubyte*)"GL_EXT_texture_rectangle", strExt); dCaps[i].fFogCoord = gluCheckExtension ((const GLubyte*)"GL_EXT_fog_coord", strExt); dCaps[i].fDrawRangeElements = gluCheckExtension ((const GLubyte*)"GL_EXT_draw_range_elements", strExt); dCaps[i].fStencilWrap = gluCheckExtension ((const GLubyte*)"GL_EXT_stencil_wrap", strExt) || (dCaps[i].glVersion >= 0x0140); dCaps[i].fBlendFuncSep = gluCheckExtension ((const GLubyte*)"GL_EXT_blend_func_separate", strExt) || (dCaps[i].glVersion >= 0x0140); dCaps[i].fMultiDrawArrays = gluCheckExtension ((const GLubyte*)"GL_EXT_multi_draw_arrays", strExt) || (dCaps[i].glVersion >= 0x0140); dCaps[i].fShadowFunc = gluCheckExtension ((const GLubyte*)"GL_EXT_shadow_funcs", strExt); dCaps[i].fStencil2Side = gluCheckExtension ((const GLubyte*)"GL_EXT_stencil_two_side", strExt) || (dCaps[i].glVersion >= 0x0140); dCaps[i].fColorSubtable = gluCheckExtension ((const GLubyte*)"GL_EXT_color_subtable", strExt) || gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt); dCaps[i].fConvolution = gluCheckExtension ((const GLubyte*)"GL_EXT_convolution", strExt) || gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt); dCaps[i].fHistogram = gluCheckExtension ((const GLubyte*)"GL_EXT_histogram", strExt) || gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt); dCaps[i].fColorTable = gluCheckExtension ((const GLubyte*)"GL_SGI_color_table", strExt) || gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt); dCaps[i].fColorMatrix = gluCheckExtension ((const GLubyte*)"GL_SGI_color_matrix", strExt) || gluCheckExtension ((const GLubyte*)"GL_ARB_imaging", strExt); dCaps[i].fTexEdgeClamp = gluCheckExtension ((const GLubyte*)"GL_SGIS_texture_edge_clamp", strExt) || (dCaps[i].glVersion >= 0x0120); dCaps[i].fGenMipmap = gluCheckExtension ((const GLubyte*)"GL_SGIS_generate_mipmap", strExt); dCaps[i].fTexLOD = gluCheckExtension ((const GLubyte*)"GL_SGIS_texture_lod", strExt) || (dCaps[i].glVersion >= 0x0120); dCaps[i].fPointCull = gluCheckExtension ((const GLubyte*)"GL_ATI_point_cull_mode", strExt); dCaps[i].fTexMirrorOnce = gluCheckExtension ((const GLubyte*)"GL_ATI_texture_mirror_once", strExt); dCaps[i].fPNtriangles = gluCheckExtension ((const GLubyte*)"GL_ATI_pn_triangles", strExt) || gluCheckExtension ((const GLubyte*)"GL_ATIX_pn_triangles", strExt); dCaps[i].fTextFragShader = gluCheckExtension ((const GLubyte*)"GL_ATI_text_fragment_shader", strExt); dCaps[i].fBlendEqSep = gluCheckExtension ((const GLubyte*)"GL_ATI_blend_equation_separate", strExt); dCaps[i].fBlendWeightMinMax = gluCheckExtension ((const GLubyte*)"GL_ATI_blend_weighted_minmax", strExt); dCaps[i].fCombine3 = gluCheckExtension ((const GLubyte*)"GL_ATI_texture_env_combine3", strExt); dCaps[i].fSepStencil = gluCheckExtension ((const GLubyte*)"GL_ATI_separate_stencil", strExt); dCaps[i].fArrayRevComps4Byte = gluCheckExtension ((const GLubyte*)"GL_ATI_array_rev_comps_in_4_bytes",strExt); dCaps[i].fPointSprite = gluCheckExtension ((const GLubyte*)"GL_NV_point_sprite", strExt); dCaps[i].fRegCombiners = gluCheckExtension ((const GLubyte*)"GL_NV_register_combiners", strExt); dCaps[i].fRegCombiners2 = gluCheckExtension ((const GLubyte*)"GL_NV_register_combiners2", strExt); dCaps[i].fTexEnvCombine4 = gluCheckExtension ((const GLubyte*)"GL_NV_texture_env_combine4", strExt); dCaps[i].fBlendSquare = gluCheckExtension ((const GLubyte*)"GL_NV_blend_square", strExt) || (dCaps[i].glVersion >= 0x0140); dCaps[i].fFogDist = gluCheckExtension ((const GLubyte*)"GL_NV_fog_distance", strExt); dCaps[i].fMultisampleFilterHint = gluCheckExtension ((const GLubyte*)"GL_NV_multisample_filter_hint", strExt); dCaps[i].fTexGenReflect = gluCheckExtension ((const GLubyte*)"GL_NV_texgen_reflection", strExt); dCaps[i].fTexShader = gluCheckExtension ((const GLubyte*)"GL_NV_texture_shader", strExt); dCaps[i].fTexShader2 = gluCheckExtension ((const GLubyte*)"GL_NV_texture_shader2", strExt); dCaps[i].fTexShader3 = gluCheckExtension ((const GLubyte*)"GL_NV_texture_shader3", strExt); dCaps[i].fDepthClamp = gluCheckExtension ((const GLubyte*)"GL_NV_depth_clamp", strExt); dCaps[i].fLightMaxExp = gluCheckExtension ((const GLubyte*)"GL_NV_light_max_exponent", strExt); dCaps[i].fRasterPosClip = gluCheckExtension ((const GLubyte*)"GL_IBM_rasterpos_clip", strExt); dCaps[i].fConvBorderModes = gluCheckExtension ((const GLubyte*)"GL_HP_convolution_border_modes", strExt) || gluCheckExtension ((const GLubyte*)(const GLubyte*)"GL_ARB_imaging", strExt); if (dCaps[i].fTexRect) // only check if extension supported glGetIntegerv (GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &dCaps[i].maxRectTextureSize); else dCaps[i].maxRectTextureSize = 0; CGLDestroyContext (cglContext); } } CGLSetCurrentContext (curr_ctx); // reset current CGL context } } }
uint4 MCScreenDC::getdisplays(MCDisplay const *& p_displays, bool p_effective) { if (s_monitor_count == 0) { bool error = false; uint4 t_display_count; t_display_count = 0; for(GDHandle t_device = GetDeviceList(); t_device != NULL; t_device = GetNextDevice(t_device)) if (TestDeviceAttribute(t_device, screenDevice) && TestDeviceAttribute(t_device, screenActive)) t_display_count += 1; error = t_display_count == 0; MCDisplay *t_displays = NULL; if (!error) error = (t_displays = new MCDisplay[t_display_count]) == NULL; if (!error) { uint4 t_current_index = 1; for(GDHandle t_device = GetDeviceList(); t_device != NULL; t_device = GetNextDevice(t_device)) if (TestDeviceAttribute(t_device, screenDevice) && TestDeviceAttribute(t_device, screenActive)) { uint4 t_index; HLock((Handle)t_device); if (TestDeviceAttribute(t_device, mainScreen)) t_index = 0; else t_index = t_current_index++; t_displays[t_index] . index = t_index; t_displays[t_index] . viewport . x = (*t_device) -> gdRect . left; t_displays[t_index] . viewport . y = (*t_device) -> gdRect . top; t_displays[t_index] . viewport . width = (*t_device) -> gdRect . right - (*t_device) -> gdRect . left; t_displays[t_index] . viewport . height = (*t_device) -> gdRect . bottom - (*t_device) -> gdRect . top; Rect t_workarea; GetAvailableWindowPositioningBounds(t_device, &t_workarea); t_displays[t_index] . workarea . x = t_workarea . left; t_displays[t_index] . workarea . y = t_workarea . top; t_displays[t_index] . workarea . width = t_workarea . right - t_workarea . left; t_displays[t_index] . workarea . height = t_workarea . bottom - t_workarea . top; HUnlock((Handle)t_device); } } if (error) delete[] t_displays; else { s_monitor_count = t_display_count; s_monitor_displays = t_displays; } } if (s_monitor_count == 0) { static MCDisplay t_display; Rect t_workarea; MCU_set_rect(t_display . viewport, 0, 0, getwidth(), getheight()); GetAvailableWindowPositioningBounds(GetMainDevice(), &t_workarea); t_display . index = 0; t_display . workarea . x = t_workarea . left; t_display . workarea . y = t_workarea . top; t_display . workarea . width = t_workarea . right - t_workarea . left; t_display . workarea . height = t_workarea . bottom - t_workarea . top; p_displays = &t_display; return 1; } p_displays = s_monitor_displays; return s_monitor_count; }
void slowPoll( void ) { RANDOM_STATE randomState; BYTE buffer[ RANDOM_BUFSIZE + 8 ]; ProcessSerialNumber psn; GDHandle deviceHandle; GrafPtr currPort; QElemPtr queuePtr; QHdrPtr queueHdr; static BOOLEAN addedFixedItems = FALSE; initRandomData( randomState, buffer, RANDOM_BUFSIZE ); /* Walk through the list of graphics devices adding information about a device (IM VI 21-21) */ deviceHandle = GetDeviceList(); while( deviceHandle != NULL ) { GDHandle currentHandle = deviceHandle; GDPtr devicePtr; HLock( ( Handle ) currentHandle ); devicePtr = *currentHandle; deviceHandle = devicePtr->gdNextGD; addRandomData( randomState, devicePtr, sizeof( GDevice ) ); HUnlock( ( Handle ) currentHandle ); } /* Walk through the list of processes adding information about each process, including the name and serial number of the process, file and resource information, memory usage information, the name of the launching process, launch time, and accumulated CPU time (IM VI 29-17) */ psn.highLongOfPSN = 0; psn.lowLongOfPSN = kNoProcess; while( !GetNextProcess( &psn ) ) { ProcessInfoRec infoRec; GetProcessInformation( &psn, &infoRec ); addRandomData( randomState, &infoRec, sizeof( ProcessInfoRec ) ); } /* Get the command type, trap address, and parameters for all commands in the file I/O queue. The parameters are quite complex and are listed on page 117 of IM IV, and include reference numbers, attributes, time stamps, length and file allocation information, finder info, and large amounts of other volume and filesystem-related data */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON if( ( queueHdr = GetFSQHdr() ) != NULL ) queuePtr = queueHdr->qHead; while( queuePtr != NULL ) { /* The queue entries are variant records of variable length so we need to adjust the length parameter depending on the record type */ addRandomData( randomState, queuePtr, 32 ); /* dunno how big.. */ queuePtr = queuePtr->qLink; } #endif /* The following are fixed for the lifetime of the process so we only add them once */ if( !addedFixedItems ) { Str255 appName, volName; GDHandle deviceHandle; Handle appHandle; DrvSts driveStatus; MachineLocation machineLocation; ProcessInfoRec processInfo; QHdrPtr vblQueue; SysEnvRec sysEnvirons; SysPPtr pramPtr; DefStartRec startupInfo; DefVideoRec videoInfo; DefOSRec osInfo; XPPParamBlock appleTalkParams; unsigned char *driverNames[] = { "\p.AIn", "\p.AOut", "\p.AppleCD", "\p.ATP", "\p.BIn", "\p.BOut", "\p.MPP", "\p.Print", "\p.Sony", "\p.Sound", "\p.XPP", NULL }; SInt16 count, dummy, i, node, net, vRefNum, script; SInt32 lcount, volume; /* Get the current font family ID, node ID of the local AppleMumble router, caret blink delay, CPU speed, double-click delay, sound volume, application and system heap zone, the number of resource types in the application, the number of sounds voices available, the FRef of the current resource file, volume of the sysbeep, primary line direction, computer SCSI disk mode ID, timeout before the screen is dimmed and before the computer is put to sleep, number of available threads in the thread pool, whether hard drive spin-down is disabled, the handle to the i18n resources, timeout time for the internal HDD, */ addRandomValue( randomState, GetAppFont() ); #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON addRandomValue( randomState, GetBridgeAddress() ); #endif addRandomValue( randomState, GetCaretTime() ); /* addRandomValue( randomState, GetCPUSpeed() ); */ addRandomValue( randomState, GetDblTime() ); GetSysBeepVolume( &volume ); addRandomValue( randomState, volume ); GetDefaultOutputVolume( &volume ); addRandomValue( randomState, volume ); #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON addRandomValue( randomState, ApplicationZone() ); addRandomValue( randomState, SystemZone() ); #endif addRandomValue( randomState, CountTypes() ); /* CountVoices( &count ); ** seems to crash addRandomValue( randomState, count ); */ addRandomValue( randomState, CurResFile() ); GetSysBeepVolume( &lcount ); addRandomValue( randomState, lcount ); addRandomValue( randomState, GetSysDirection() ); /* addRandomValue( randomState, GetSCSIDiskModeAddress() ); addRandomValue( randomState, GetDimmingTimeout() ); addRandomValue( randomState, GetSleepTimeout() ); */ GetFreeThreadCount( kCooperativeThread, &count ); addRandomValue( randomState, count ); /* addRandomValue( randomState, IsSpindownDisabled() ); */ addRandomValue( randomState, GetIntlResource( 0 ) ); #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON GetTimeout( &count ); addRandomValue( randomState, count ); #endif /* Get the number of documents/files which were selected when the app started and for each document get the vRefNum, name, type, and version -- OBSOLETE CountAppFiles( &dummy, &count ); addRandomValue( randomState, count ); while( count > 0 ) { AppFile theFile; GetAppFiles( count, &theFile ); addRandomData( randomState, &theFile, sizeof( AppFile ) ); count--; } */ /* Get the app's name, resource file reference number, and handle to the finder information -- OBSOLETE GetAppParams( appName, appHandle, &count ); addRandomData( randomState, appName, sizeof( Str255 ) ); addRandomValue( randomState, appHandle ); addRandomValue( randomState, count ); */ /* Get all sorts of statistics such as physical information, disk and write-protect present status, error status, and handler queue information, on floppy drives attached to the system. Also get the volume name, volume reference number and number of bytes free, for the volume in the drive */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON if( !DriveStatus( 1, &driveStatus ) ) addRandomData( randomState, &driveStatus, sizeof (DrvSts) ); #endif #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON if( !GetVInfo( 1, volName, &vRefNum, &lcount ) ) { addRandomData( randomState, volName, sizeof( Str255 ) ); addRandomValue( randomState, vRefNum ); addRandomValue( randomState, lcount ); } #endif #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON if( !DriveStatus( 2, &driveStatus ) ) addRandomData( randomState, &driveStatus, sizeof (DrvSts) ); #endif #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON if( !GetVInfo( 2, volName, &vRefNum, &lcount ) ) { addRandomData( randomState, volName, sizeof( Str255 ) ); addRandomValue( randomState, vRefNum ); addRandomValue( randomState, lcount ); } #endif /* Get information on the head and tail of the vertical retrace queue */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON if( ( vblQueue = GetVBLQHdr() ) != NULL ) addRandomData( randomState, vblQueue, sizeof( QHdr ) ); #endif /* Get the parameter RAM settings */ pramPtr = GetSysPPtr(); addRandomData( randomState, pramPtr, sizeof( SysParmType ) ); /* Get information about the machines geographic location */ ReadLocation( &machineLocation ); addRandomData( randomState, &machineLocation, sizeof( MachineLocation ) ); /* Get information on current graphics devices including device information such as dimensions and cursor information, and a number of handles to device-related data blocks and functions, and information about the dimentions and contents of the devices pixel image as well as the images resolution, storage format, depth, and colour usage */ deviceHandle = GetDeviceList(); do { GDPtr gdPtr; addRandomValue( randomState, deviceHandle ); HLock( ( Handle ) deviceHandle ); gdPtr = ( GDPtr ) *deviceHandle; addRandomData( randomState, gdPtr, sizeof( GDevice ) ); addRandomData( randomState, gdPtr->gdPMap, sizeof( PixMap ) ); HUnlock( ( Handle ) deviceHandle ); } while( ( deviceHandle = GetNextDevice( deviceHandle ) ) != NULL ); /* Get the current system environment, including the machine and system software type, the keyboard type, where there's a colour display attached, the AppleTalk driver version, and the VRefNum of the system folder */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON SysEnvirons( curSysEnvVers, &sysEnvirons ); addRandomData( randomState, &sysEnvirons, sizeof( SysEnvRec ) ); #endif /* Get the AppleTalk node ID and network number for this machine */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON if( GetNodeAddress( &node, &net ) ) { addRandomValue( randomState, node ); addRandomValue( randomState, net ); } #endif /* Get information on each device connected to the ADB including the device handler ID, the devices ADB address, and the address of the devices handler and storage area */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON count = CountADBs(); while( count-- > 0 ) { ADBDataBlock adbInfo; GetIndADB( &adbInfo, count ); addRandomData( randomState, &adbInfo, sizeof( ADBDataBlock ) ); } #endif /* Open the most common device types and get the general device status information and (if possible) device-specific status. The general device information contains the device handle and flags, I/O queue information, event information, and other driver-related details */ /* Try something like this again.. and ur a dead man, Peter ;-) -xmath */ /* for( count = 0; driverNames[ count ] != NULL; count++ ) { AuxDCEHandle dceHandle; short driverRefNum; ** Try and open the driver ** if( OpenDriver( driverNames[ count ], &driverRefNum ) ) continue; ** Get a handle to the driver control information (this could also be done with GetDCtlHandle()) ** Status( driverRefNum, 1, &dceHandle ); HLock( dceHandle ); addRandomData( randomState, *dceHandle, sizeof( AuxDCE ) ); HUnlock( dceHandle ); CloseDriver( driverRefNum ); } */ /* Get the name and volume reference number for the current volume */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON GetVol( volName, &vRefNum ); addRandomData( randomState, volName, sizeof( Str255 ) ); addRandomValue( randomState, vRefNum ); #endif /* Get the time information, attributes, directory information and bitmap, volume allocation information, volume and drive information, pointers to various pieces of volume-related information, and details on path and directory caches, for each volume */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON if( ( queueHdr = GetVCBQHdr() ) != NULL ) queuePtr = queueHdr->qHead; while ( queuePtr != NULL ) { addRandomData( randomState, queuePtr, sizeof( VCB ) ); queuePtr = queuePtr->qLink; } #endif /* Get the driver reference number, FS type, and media size for each drive */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON if( ( queueHdr = GetDrvQHdr() ) != NULL ) queuePtr = queueHdr->qHead; while ( queuePtr != NULL ) { addRandomData( randomState, queuePtr, sizeof( DrvQEl ) ); queuePtr = queuePtr->qLink; } #endif /* Get global script manager variables and vectors, including the globals changed count, font, script, and i18n flags, various script types, and cache information */ for( count = 0; count < 30; count++ ) addRandomValue( randomState, GetScriptManagerVariable( count ) ); /* Get the script code for the font script the i18n script, and for each one add the changed count, font, script, i18n, and display flags, resource ID's, and script file information */ script = FontScript(); addRandomValue( randomState, script ); for( count = 0; count < 30; count++ ) addRandomValue( randomState, GetScriptVariable( script, count ) ); script = IntlScript(); addRandomValue( randomState, script ); for( count = 0; count < 30; count++ ) addRandomValue( randomState, GetScriptVariable( script, count ) ); /* Get the device ID, partition, slot number, resource ID, and driver reference number for the default startup device */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON GetDefaultStartup( &startupInfo ); addRandomData( randomState, &startupInfo, sizeof( DefStartRec ) ); #endif /* Get the slot number and resource ID for the default video device */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON GetVideoDefault( &videoInfo ); addRandomData( randomState, &videoInfo, sizeof( DefVideoRec ) ); #endif /* Get the default OS type */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON GetOSDefault( &osInfo ); addRandomData( randomState, &osInfo, sizeof( DefOSRec ) ); #endif /* Get the AppleTalk command block and data size and number of sessions */ #if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON ASPGetParms( &appleTalkParams, FALSE ); addRandomData( randomState, &appleTalkParams, sizeof( XPPParamBlock ) ); #endif addedFixedItems = TRUE; } /* Flush any remaining data through */ endRandomData( randomState, 100 ); }