static HRESULT WINAPI domattr_insertBefore( IXMLDOMAttribute *iface, IXMLDOMNode* newNode, VARIANT refChild, IXMLDOMNode** old_node) { domattr *This = impl_from_IXMLDOMAttribute( iface ); DOMNodeType type; HRESULT hr; FIXME("(%p)->(%p %s %p) needs test\n", This, newNode, debugstr_variant(&refChild), old_node); if (!newNode) return E_INVALIDARG; hr = IXMLDOMNode_get_nodeType(newNode, &type); if (hr != S_OK) return hr; TRACE("new node type %d\n", type); switch (type) { case NODE_ATTRIBUTE: case NODE_CDATA_SECTION: case NODE_COMMENT: case NODE_ELEMENT: case NODE_PROCESSING_INSTRUCTION: if (old_node) *old_node = NULL; return E_FAIL; default: return node_insert_before(&This->node, newNode, &refChild, old_node); } }
void network_client_expects_response(Client *client, Packet *request) { PendingRequest *pending_request; char packet_signature[PACKET_MAX_SIGNATURE_LENGTH]; if (client->pending_request_count >= CLIENT_MAX_PENDING_REQUESTS) { log_warn("Pending requests list for client ("CLIENT_SIGNATURE_FORMAT") is full, dropping %d pending request(s)", client_expand_signature(client), client->pending_request_count - CLIENT_MAX_PENDING_REQUESTS + 1); while (client->pending_request_count >= CLIENT_MAX_PENDING_REQUESTS) { pending_request = containerof(client->pending_request_sentinel.next, PendingRequest, client_node); pending_request_remove_and_free(pending_request); } } pending_request = calloc(1, sizeof(PendingRequest)); if (pending_request == NULL) { log_error("Could not allocate pending request: %s (%d)", get_errno_name(ENOMEM), ENOMEM); return; } node_reset(&pending_request->global_node); node_insert_before(&_pending_request_sentinel, &pending_request->global_node); node_reset(&pending_request->client_node); node_insert_before(&client->pending_request_sentinel, &pending_request->client_node); ++client->pending_request_count; pending_request->client = client; pending_request->zombie = NULL; memcpy(&pending_request->header, &request->header, sizeof(PacketHeader)); #ifdef BRICKD_WITH_PROFILING pending_request->arrival_time = microseconds(); #endif log_packet_debug("Added pending request (%s) for client ("CLIENT_SIGNATURE_FORMAT")", packet_get_request_signature(packet_signature, request), client_expand_signature(client)); }
static HRESULT WINAPI domtext_insertBefore( IXMLDOMText *iface, IXMLDOMNode* newNode, VARIANT refChild, IXMLDOMNode** outOldNode) { domtext *This = impl_from_IXMLDOMText( iface ); FIXME("(%p)->(%p %s %p) needs test\n", This, newNode, debugstr_variant(&refChild), outOldNode); return node_insert_before(&This->node, newNode, &refChild, outOldNode); }
static HRESULT WINAPI dom_pi_insertBefore( IXMLDOMProcessingInstruction *iface, IXMLDOMNode* newNode, VARIANT refChild, IXMLDOMNode** outOldNode) { dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface ); FIXME("(%p)->(%p x%d %p) needs test\n", This, newNode, V_VT(&refChild), outOldNode); return node_insert_before(&This->node, newNode, &refChild, outOldNode); }
static HRESULT WINAPI entityref_insertBefore( IXMLDOMEntityReference *iface, IXMLDOMNode* newNode, VARIANT refChild, IXMLDOMNode** outOldNode) { entityref *This = impl_from_IXMLDOMEntityReference( iface ); FIXME("(%p)->(%p %s %p) needs test\n", This, newNode, debugstr_variant(&refChild), outOldNode); return node_insert_before(&This->node, newNode, &refChild, outOldNode); }
static HRESULT WINAPI unknode_insertBefore( IXMLDOMNode *iface, IXMLDOMNode* newNode, VARIANT refChild, IXMLDOMNode** outOldNode) { unknode *This = unknode_from_IXMLDOMNode( iface ); FIXME("(%p)->(%p x%d %p)\n", This, newNode, V_VT(&refChild), outOldNode); return node_insert_before(&This->node, newNode, &refChild, outOldNode); }
static HRESULT WINAPI domcomment_insertBefore( IXMLDOMComment *iface, IXMLDOMNode* newNode, VARIANT refChild, IXMLDOMNode** outOldNode) { domcomment *This = impl_from_IXMLDOMComment( iface ); FIXME("(%p)->(%p x%d %p) needs test\n", This, newNode, V_VT(&refChild), outOldNode); return node_insert_before(&This->node, newNode, &refChild, outOldNode); }
static HRESULT WINAPI domfrag_insertBefore( IXMLDOMDocumentFragment *iface, IXMLDOMNode* newNode, VARIANT refChild, IXMLDOMNode** outOldNode) { domfrag *This = impl_from_IXMLDOMDocumentFragment( iface ); TRACE("(%p)->(%p %s %p)\n", This, newNode, debugstr_variant(&refChild), outOldNode); /* TODO: test */ return node_insert_before(&This->node, newNode, &refChild, outOldNode); }
int main() { struct node* head = head_init(); int i; for(i=0; i<5; i++) { node_add(head, i); } printf_list(head); node_del(head, 3); printf_list(head); node_insert_after(head,2,6); printf_list(head); node_insert_before(&head,0,5); printf_list(head); node_insert_before(&head,6,8); printf_list(head); node_reverse(&head); printf_list(head); node_reverse_by_test(&head); printf_list(head); struct node* p = search_mid_node(head); printf("mid=%d\n", p->data); /* delete head emlement */ Remove_head(&head); printf_list(head); for(i=7; i<10; i++) { node_add(head, i); } printf_list(head); p = search_mid_node(head); printf("mid=%d\n", p->data); return 0; }
int libusb_submit_transfer(struct libusb_transfer *transfer) { usbi_transfer *itransfer = (usbi_transfer *)transfer; libusb_device_handle *dev_handle = transfer->dev_handle; libusb_context *ctx = dev_handle->dev->ctx; usbfs_urb *urb = &itransfer->urb; int rc; if (transfer->type != LIBUSB_TRANSFER_TYPE_BULK || transfer->timeout != 0 || transfer->callback == NULL) { return LIBUSB_ERROR_INVALID_PARAM; } if (itransfer->submitted) { return LIBUSB_ERROR_BUSY; } libusb_ref_device(dev_handle->dev); itransfer->submitted = true; urb->status = INT32_MIN; urb->endpoint = transfer->endpoint; urb->buffer = transfer->buffer; urb->buffer_length = transfer->length; rc = ioctl(dev_handle->pollfd.fd, IOCTL_USBFS_SUBMITURB, urb); if (rc < 0) { if (errno == ENODEV) { rc = LIBUSB_ERROR_NO_DEVICE; } else { rc = LIBUSB_ERROR_IO; } itransfer->submitted = false; libusb_unref_device(dev_handle->dev); usbi_log_error(ctx, "Could not submit %s transfer %p (length: %d): %s (%d)", (LIBUSB_ENDPOINT_IN & transfer->endpoint) != 0 ? "read" : "write", transfer, transfer->length, get_errno_name(errno), errno); return rc; } node_insert_before(&dev_handle->itransfer_sentinel, &itransfer->node); return LIBUSB_SUCCESS; }
int libusb_open(libusb_device *dev, libusb_device_handle **dev_handle_ptr) { libusb_context *ctx = dev->ctx; libusb_device_handle *dev_handle; jmethodID open_device_mid; int fd; dev_handle = calloc(1, sizeof(libusb_device_handle)); if (dev_handle == NULL) { usbi_log_error(ctx, "Could not allocate device handle"); return LIBUSB_ERROR_NO_MEM; } open_device_mid = (*android_env)->GetMethodID(android_env, (*android_env)->GetObjectClass(android_env, android_service), "openDevice", "(Landroid/hardware/usb/UsbDevice;)I"); // FIXME: check result fd = (*android_env)->CallIntMethod(android_env, android_service, open_device_mid, dev->device); // FIXME: check result if (fd < 0) { free(dev_handle); return LIBUSB_ERROR_NO_DEVICE; } dev_handle->dev = libusb_ref_device(dev); dev_handle->pollfd.fd = fd; dev_handle->pollfd.events = POLLOUT; dev_handle->disconnected = false; node_reset(&dev_handle->itransfer_sentinel); node_insert_before(&ctx->dev_handle_sentinel, &dev_handle->node); ++ctx->dev_handle_count; *dev_handle_ptr = dev_handle; usbi_log_debug(ctx, "Opened device %p (context: %p, name: %s, fd: %d)", dev, ctx, dev->name, dev_handle->pollfd.fd); if (ctx->pollfd_added_callback != NULL) { ctx->pollfd_added_callback(dev_handle->pollfd.fd, dev_handle->pollfd.events, ctx->pollfd_user_data); } return LIBUSB_SUCCESS; }
static int usbi_get_device_list(libusb_context *ctx, Node *sentinel) { int rc; jmethodID get_device_list_mid; jobjectArray device_infos; int device_infos_length; int i; jobject device_info; int vendor_id; int product_id; libusb_device *dev; int length = 0; get_device_list_mid = (*android_env)->GetMethodID(android_env, (*android_env)->GetObjectClass(android_env, android_service), "getDeviceList", "()[Lcom/tinkerforge/brickd/USBDeviceInfo;"); // FIXME: check result device_infos = (jobjectArray)(*android_env)->CallObjectMethod(android_env, android_service, get_device_list_mid); device_infos_length = (*android_env)->GetArrayLength(android_env, device_infos); for (i = 0; i < device_infos_length; ++i) { device_info = (*android_env)->GetObjectArrayElement(android_env, device_infos, i); usbi_get_int_field(device_info, "vendorID", &vendor_id); // FIXME: check result usbi_get_int_field(device_info, "productID", &product_id); // FIXME: check result if (vendor_id == 0x16D0 && (product_id == 0x063D || product_id == 0x09E5)) { rc = usbi_create_device(ctx, device_info, &dev); if (rc < 0) { return rc; } node_insert_before(sentinel, &dev->node); ++length; } } return length; }
void list_insert_back (linked_list_t list, node_t node) { node_insert_before (list->data, node); list->count++; }
static void node_insert_after(struct bnode_s *node, int pos, struct bnode_s *nnode) { node_insert_before(node, pos+1, nnode); }