/* looks alot like acpi_bus_walk doesnt it */ NTSTATUS ACPIEnumerateDevices(PFDO_DEVICE_DATA DeviceExtension) { ULONG Count = 0; struct acpi_device *Device = acpi_root; while(Device) { if (Device->status.present && Device->status.enabled && Device->flags.hardware_id) { Bus_PlugInDevice(Device, DeviceExtension); Count++; } if (HAS_CHILDREN(Device)) { Device = NODE_TO_DEVICE(Device->children.next); continue; } if (HAS_SIBLINGS(Device)) { Device = NODE_TO_DEVICE(Device->node.next); continue; } while ((Device = Device->parent)) { if (HAS_SIBLINGS(Device)) { Device = NODE_TO_DEVICE(Device->node.next); break; } } } DPRINT("acpi device count: %d\n", Count); return STATUS_SUCCESS; }
static void move_family(struct Window * w, int dx, int dy) { struct Window * _w = w->firstchild; while (_w) { _w->LeftEdge += dx, _w->TopEdge += dy; if (HAS_CHILDREN(_w)) move_family(_w,dx,dy); _w=_w->nextchild; } }
/*===========================================================================* * do_create * *===========================================================================*/ PUBLIC int do_create() { /* Create a new file. */ char path[PATH_MAX], name[NAME_MAX+1]; struct inode *parent, *ino; struct hgfs_attr attr; hgfs_file_t handle; int r; /* We cannot create files on a read-only file system. */ if (state.read_only) return EROFS; /* Get path, name, parent inode and possibly inode for the given path. */ if ((r = get_name(m_in.REQ_GRANT, m_in.REQ_PATH_LEN, name)) != OK) return r; if (!strcmp(name, ".") || !strcmp(name, "..")) return EEXIST; if ((parent = find_inode(m_in.REQ_INODE_NR)) == NULL) return EINVAL; if ((r = verify_dentry(parent, name, path, &ino)) != OK) return r; /* Are we going to need a new inode upon success? * Then make sure there is one available before trying anything. */ if (ino == NULL || ino->i_ref > 1 || HAS_CHILDREN(ino)) { if (!have_free_inode()) { if (ino != NULL) put_inode(ino); return ENFILE; } } /* Perform the actual create call. */ r = hgfs_open(path, O_CREAT | O_EXCL | O_RDWR, m_in.REQ_MODE, &handle); if (r != OK) { /* Let's not try to be too clever with error codes here. If something * is wrong with the directory, we'll find out later anyway. */ if (ino != NULL) put_inode(ino); return r; } /* Get the created file's attributes. */ attr.a_mask = HGFS_ATTR_MODE | HGFS_ATTR_SIZE; r = hgfs_getattr(path, &attr); /* If this fails, or returns a directory, we have a problem. This * scenario is in fact possible with race conditions. * Simulate a close and return a somewhat appropriate error. */ if (r != OK || S_ISDIR(attr.a_mode)) { printf("HGFS: lost file after creation!\n"); hgfs_close(handle); if (ino != NULL) { del_dentry(ino); put_inode(ino); } return (r == OK) ? EEXIST : r; } /* We do assume that the HGFS open(O_CREAT|O_EXCL) did its job. * If we previousy found an inode, get rid of it now. It's old. */ if (ino != NULL) { del_dentry(ino); put_inode(ino); } /* Associate the open file handle with an inode, and reply with its details. */ ino = get_free_inode(); assert(ino != NULL); /* we checked before whether we had a free one */ ino->i_file = handle; ino->i_flags = I_HANDLE; add_dentry(parent, name, ino); m_out.RES_INODE_NR = INODE_NR(ino); m_out.RES_MODE = get_mode(ino, attr.a_mode); m_out.RES_FILE_SIZE_HI = ex64hi(attr.a_size); m_out.RES_FILE_SIZE_LO = ex64lo(attr.a_size); m_out.RES_UID = opt.uid; m_out.RES_GID = opt.gid; m_out.RES_DEV = NO_DEV; return OK; }
void DoMoveSizeWindow(struct Window *targetwindow, LONG NewLeftEdge, LONG NewTopEdge, LONG NewWidth, LONG NewHeight, BOOL send_newsize, struct IntuitionBase *IntuitionBase) { struct IIHData *iihdata = (struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data; //struct IntWindow *w = (struct IntWindow *)targetwindow; struct Layer *targetlayer = WLAYER(targetwindow)/*, *L*/; struct Requester *req; struct InputEvent *ie; LONG OldLeftEdge = targetwindow->LeftEdge; LONG OldTopEdge = targetwindow->TopEdge; LONG OldWidth = targetwindow->Width; LONG OldHeight = targetwindow->Height; LONG pos_dx, pos_dy, size_dx, size_dy; /* correct new window coords if necessary */ FixWindowCoords(targetwindow, &NewLeftEdge, &NewTopEdge, &NewWidth, &NewHeight,IntuitionBase); D(bug("DoMoveSizeWindow to %d,%d %d x %d\n", NewLeftEdge, NewTopEdge, NewWidth, NewHeight)); pos_dx = NewLeftEdge - OldLeftEdge; pos_dy = NewTopEdge - OldTopEdge; size_dx = NewWidth - OldWidth; size_dy = NewHeight - OldHeight; LOCK_REFRESH(targetwindow->WScreen); /* jDc: intuition 68k doesn't care about that */ // if (pos_dx || pos_dy || size_dx || size_dy) // { if (size_dx || size_dy) { WindowSizeWillChange(targetwindow, size_dx, size_dy, IntuitionBase); } targetwindow->LeftEdge += pos_dx; targetwindow->TopEdge += pos_dy; #ifndef __MORPHOS__ targetwindow->RelLeftEdge += pos_dx; targetwindow->RelTopEdge += pos_dy; #endif targetwindow->Width = NewWidth; targetwindow->Height = NewHeight; targetwindow->GZZWidth = targetwindow->Width - targetwindow->BorderLeft - targetwindow->BorderRight; targetwindow->GZZHeight = targetwindow->Height - targetwindow->BorderTop - targetwindow->BorderBottom; /* check for GZZ window */ if (BLAYER(targetwindow)) { /* move outer window first */ MoveSizeLayer(BLAYER(targetwindow), pos_dx, pos_dy, size_dx, size_dy); } MoveSizeLayer(targetlayer, pos_dx, pos_dy, size_dx, size_dy); for (req = targetwindow->FirstRequest; req; req = req->OlderRequest) { struct Layer *layer = req->ReqLayer; if (layer) { int dx, dy, dw, dh; int left, top, right, bottom; left = NewLeftEdge + req->LeftEdge; top = NewTopEdge + req->TopEdge; right = left + req->Width - 1; bottom = top + req->Height - 1; if (left > NewLeftEdge + NewWidth - 1) left = NewLeftEdge + NewWidth - 1; if (top > NewTopEdge + NewHeight - 1) top = NewTopEdge + NewHeight - 1; if (right > NewLeftEdge + NewWidth - 1) right = NewLeftEdge + NewWidth - 1; if (bottom > NewTopEdge + NewHeight - 1) bottom = NewTopEdge + NewHeight - 1; dx = left - layer->bounds.MinX; dy = top - layer->bounds.MinY; dw = right - left - layer->bounds.MaxX + layer->bounds.MinX; dh = bottom - top - layer->bounds.MaxY + layer->bounds.MinY; MoveSizeLayer(layer, dx, dy, dw, dh); } } #if 0 if (w->ZipLeftEdge != ~0) w->ZipLeftEdge = OldLeftEdge; if (w->ZipTopEdge != ~0) w->ZipTopEdge = OldTopEdge; if (w->ZipWidth != ~0) w->ZipWidth = OldWidth; if (w->ZipHeight != ~0) w->ZipHeight = OldHeight; #endif if (pos_dx || pos_dy) { UpdateMouseCoords(targetwindow); #ifndef __MORPHOS__ if (HAS_CHILDREN(targetwindow)) move_family(targetwindow, pos_dx, pos_dy); #endif } // } /* if (pos_dx || pos_dy || size_dx || size_dy) */ if (size_dx || size_dy) { WindowSizeHasChanged(targetwindow, size_dx, size_dy, FALSE, IntuitionBase); } ih_fire_intuimessage(targetwindow, IDCMP_CHANGEWINDOW, CWCODE_MOVESIZE, targetwindow, IntuitionBase); if (send_newsize) { /* Send IDCMP_NEWSIZE and IDCMP_CHANGEWINDOW to resized window, even if there was no resizing/position change at all. BGUI for example relies on this! */ ih_fire_intuimessage(targetwindow, IDCMP_NEWSIZE, 0, targetwindow, IntuitionBase); if ((ie = AllocInputEvent(iihdata))) { ie->ie_Class = IECLASS_EVENT; ie->ie_Code = IECODE_NEWSIZE; ie->ie_EventAddress = targetwindow; CurrentTime(&ie->ie_TimeStamp.tv_secs, &ie->ie_TimeStamp.tv_micro); } } // jDc: CheckLayers calls LOCK_REFRESH, so there's no reason to UNLOCK here! // UNLOCK_REFRESH(targetwindow->WScreen); CheckLayers(targetwindow->WScreen, IntuitionBase); UNLOCK_REFRESH(targetwindow->WScreen); #if 0 if (size_dx || size_dy) { if (!(((struct IntWindow *)targetwindow)->CustomShape)) { struct wdpWindowShape shapemsg; struct Region *shape; shapemsg.MethodID = WDM_WINDOWSHAPE; shapemsg.wdp_Width = targetwindow->Width; shapemsg.wdp_Height = targetwindow->Height; shapemsg.wdp_Window = targetwindow; shapemsg.wdp_TrueColor = (((struct IntScreen *)targetwindow->WScreen)->DInfo.dri.dri_Flags & DRIF_DIRECTCOLOR); shapemsg.wdp_UserBuffer = ((struct IntWindow *)targetwindow)->DecorUserBuffer; shape = DoMethodA(((struct IntScreen *)(targetwindow->WScreen))->WinDecorObj, (Msg)&shapemsg); if (((struct IntWindow *)targetwindow)->OutlineShape) DisposeRegion(((struct IntWindow *)targetwindow)->OutlineShape); ((struct IntWindow *)targetwindow)->OutlineShape = shape; ChangeWindowShape(targetwindow, shape, NULL); ((struct IntWindow *)targetwindow)->CustomShape = FALSE; } } #endif }
pTree *tree_remove(struct pqNode *p, pTree *head) { _DA_ fprintf(err, "remove() [id=%i]\n", ID(p)); /**/ assert (p->node != NULL); /**/ assert (p->node->cell.list != NULL); pTree *node = p->node; struct pqNode *list = node->cell.list; struct pqNode *item, *temp; /*======================================================================== * Find the particle in the list. item will point to the correct place on * exit. Notice that there is no check for loop termination other than the * assert. It is a serious error if the particle is not in the list. *======================================================================*/ for (item = temp = list; item != p; temp = item, item = item->neighbor) assert(item != NULL); if (item == list) node->cell.list = list->neighbor; /* first item in list */ else temp->neighbor = item->neighbor; node->cell.count--; /**/ assert(node->cell.count >= 0); #if 0 for (; node != NULL; node = node->pParent) { node->cell.fMass -= MASS(p); /**/ assert(node->cell.fMass >= -1e-3); } #endif node = p->node; pTree *parent = node->pParent; /*======================================================================== * If we are not at the root node then examine the sibling to see if we * can merge the children it back into the parent. *======================================================================*/ if (parent != NULL) { /**/ assert(parent->cell.count == 0); /**/ assert(HAS_CHILDREN(parent)); pTree *sibling = (parent->pLeft == node) ? parent->pRight : parent->pLeft; /* node doesn't have children because p is in node */ assert(NO_CHILDREN(node)); if (NO_CHILDREN(sibling)) { if (node->cell.count + sibling->cell.count <= MAX_PIC) { _DA_ fprintf(err, "Merging children [id=%i]\n", ID(p)); //parent->cell.fMass = sibling->cell.fMass + node->cell.fMass; parent->cell.count = sibling->cell.count + node->cell.count; parent->cell.list = join_lists(sibling->cell.list, node->cell.list); int c=0; for (temp = parent->cell.list; temp != NULL; temp = temp->neighbor) { temp->node = parent; c++; } /**/ assert(c == node->cell.count + sibling->cell.count); parent->pLeft = NULL; parent->pRight = NULL; if (head == node) head = parent; free_node(sibling); sibling = NULL; free_node(node); node = NULL; } } } p->node = NULL; free(item); return head; }