static void all_data_read(Protocol *protocol) { protocol->flags |= FLAG_ALL_DATA_READ; report_data(protocol); report_result(protocol, S_OK); }
/* Begin: leyihua modify ioctl for sensor report, 2011/12/11 */ static long sensor_daemon_misc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; switch (cmd) { case SENSOR_IOCTL_SEND_DATA: #ifdef CONFIG_HAS_EARLYSUSPEND if(sensor_report_dev_alive_status) { #endif if (copy_from_user(&sensor_data, argp, sizeof(sensor_data))) { return -EFAULT; } report_data(sensor_data); #ifdef CONFIG_HAS_EARLYSUSPEND } #endif break; default: return -EINVAL; } return 0; }
static int forward_msg_tcp(struct silly_socket *ss, struct socket *s) { ssize_t sz; ssize_t presize = s->presize; uint8_t *buff = (uint8_t *)silly_malloc(presize); sz = readn(s->fd, buff, presize); //half close socket need no data if (sz > 0 && s->type != STYPE_HALFCLOSE) { report_data(ss, s, SILLY_SDATA, buff, sz); //to predict the pakcet size if (sz == presize) { s->presize *= 2; } else if (presize > MIN_READBUFF_LEN) { //s->presize at leatest is 2 * MIN_READBUFF_LEN int half = presize / 2; if (sz < half) s->presize = half; } } else { silly_free(buff); if (sz < 0) { report_close(ss, s, errno); delsocket(ss, s); return -1; } return 0; } return sz; }
static HRESULT WINAPI BPInternetProtocolSink_ReportData(IInternetProtocolSink *iface, DWORD grfBSCF, ULONG ulProgress, ULONG ulProgressMax) { BindProtocol *This = PROTSINK_THIS(iface); TRACE("(%p)->(%d %u %u)\n", This, grfBSCF, ulProgress, ulProgressMax); if(!This->protocol_sink) return S_OK; if(!do_direct_notif(This)) { report_data_task_t *task; task = heap_alloc(sizeof(report_data_task_t)); if(!task) return E_OUTOFMEMORY; task->bscf = grfBSCF; task->progress = ulProgress; task->progress_max = ulProgressMax; push_task(This, &task->header, report_data_proc); return S_OK; } return report_data(This, grfBSCF, ulProgress, ulProgressMax); }
static void report_data_proc(BindProtocol *This, task_header_t *t) { report_data_task_t *task = (report_data_task_t*)t; report_data(This, task->bscf, task->progress, task->progress_max); heap_free(task); }
// Calls report and captures user input for options selection. int report_main_menu() { int selection = 0; int error = NO_ERROR; // Exits when the user enters 2. while (selection != EXIT_REPORT) { clear_screen(); selection = report_menu(); switch (selection) { case REPORT_DISPLAY: { error = report_data(); if (error) printf("File error: Check name\n"); press_enter(); break; } } } clear_screen(); return error; }
static HRESULT WINAPI InternetProtocolSink_ReportData(IInternetProtocolSink *iface, DWORD grfBSCF, ULONG ulProgress, ULONG ulProgressMax) { Binding *This = PROTSINK_THIS(iface); TRACE("(%p)->(%d %u %u)\n", This, grfBSCF, ulProgress, ulProgressMax); report_data(This, grfBSCF, ulProgress, ulProgressMax); return S_OK; }
static HRESULT start_binding(IMoniker *mon, Binding *binding_ctx, IUri *uri, IBindCtx *pbc, BOOL to_obj, REFIID riid, Binding **ret) { Binding *binding = NULL; HRESULT hres; MSG msg; hres = Binding_Create(mon, binding_ctx, uri, pbc, to_obj, riid, &binding); if(FAILED(hres)) return hres; hres = IBindStatusCallback_OnStartBinding(binding->callback, 0, &binding->IBinding_iface); if(FAILED(hres)) { WARN("OnStartBinding failed: %08x\n", hres); stop_binding(binding, INET_E_DOWNLOAD_FAILURE, NULL); IBinding_Release(&binding->IBinding_iface); return hres; } if(binding_ctx) { set_binding_sink(binding->protocol, &binding->IInternetProtocolSink_iface, &binding->IInternetBindInfo_iface); if(binding_ctx->redirect_url) IBindStatusCallback_OnProgress(binding->callback, 0, 0, BINDSTATUS_REDIRECTING, binding_ctx->redirect_url); report_data(binding, BSCF_FIRSTDATANOTIFICATION | (binding_ctx->download_state == END_DOWNLOAD ? BSCF_LASTDATANOTIFICATION : 0), 0, 0); }else { hres = IInternetProtocolEx_StartEx(&binding->protocol->IInternetProtocolEx_iface, uri, &binding->IInternetProtocolSink_iface, &binding->IInternetBindInfo_iface, PI_APARTMENTTHREADED|PI_MIMEVERIFICATION, 0); TRACE("start ret %08x\n", hres); if(FAILED(hres) && hres != E_PENDING) { stop_binding(binding, hres, NULL); IBinding_Release(&binding->IBinding_iface); return hres; } } while(!(binding->bindf & BINDF_ASYNCHRONOUS) && !(binding->state & BINDING_STOPPED)) { MsgWaitForMultipleObjects(0, NULL, FALSE, 5000, QS_POSTMESSAGE); while (PeekMessageW(&msg, binding->notif_hwnd, WM_USER, WM_USER+117, PM_REMOVE|PM_NOYIELD)) { TranslateMessage(&msg); DispatchMessageW(&msg); } } *ret = binding; return S_OK; }
static int forward_msg_udp(struct silly_socket *ss, struct socket *s) { ssize_t n; uint8_t *data; struct sockaddr addr; socklen_t len = sizeof(addr); n = readudp(s->fd, ss->udpbuff, MAX_UDP_PACKET, &addr, &len); if (n < 0) return 0; data = (uint8_t *)silly_malloc(n + sizeof(addr)); memcpy(data, ss->udpbuff, n); memcpy(data + n, &addr, sizeof(addr)); report_data(ss, s, SILLY_SUDP, data, n); return n; }
static inline HRESULT handle_xml_load(BindStatusCallback *This) { static const WCHAR selectW[] = {'p','r','o','c','e','s','s','i','n','g','-', 'i','n','s','t','r','u','c','t','i','o','n','(','\'','x','m','l', '-','s','t','y','l','e','s','h','e','e','t','\'',')',0}; static const WCHAR hrefW[] = {'h','r','e','f','=',0}; IXMLDOMDocument3 *xml = NULL, *xsl = NULL; IXMLDOMNode *stylesheet; IBindCtx *pbc; IMoniker *mon; LPOLESTR xsl_url; LARGE_INTEGER off; VARIANT_BOOL succ; VARIANT var; WCHAR *href = NULL, *p; BSTR bstr; HRESULT hres; off.QuadPart = 0; hres = IStream_Seek(This->stream, off, STREAM_SEEK_SET, NULL); if(FAILED(hres)) return display_error_page(This); hres = DOMDocument_create(MSXML_DEFAULT, NULL, (void**)&xml); if(FAILED(hres)) return display_error_page(This); V_VT(&var) = VT_UNKNOWN; V_UNKNOWN(&var) = (IUnknown*)This->stream; hres = IXMLDOMDocument3_load(xml, var, &succ); if(FAILED(hres) || !succ) { IXMLDOMDocument3_Release(xml); return display_error_page(This); } V_VT(&var) = VT_EMPTY; bstr = SysAllocString(selectW); hres = IXMLDOMDocument3_selectSingleNode(xml, bstr, &stylesheet); SysFreeString(bstr); if(hres != S_OK) { IXMLDOMDocument3_Release(xml); return display_error_page(This); } hres = IXMLDOMNode_get_nodeValue(stylesheet, &var); IXMLDOMNode_Release(stylesheet); if(SUCCEEDED(hres) && V_VT(&var)!=VT_BSTR) { FIXME("Variant type %d not supported\n", V_VT(&var)); VariantClear(&var); hres = E_FAIL; } if(FAILED(hres)) { IXMLDOMDocument3_Release(xml); return display_error_page(This); } /* TODO: fix parsing processing instruction value */ if((p = strstrW(V_BSTR(&var), hrefW))) { p += sizeof(hrefW)/sizeof(WCHAR)-1; if(*p!='\'' && *p!='\"') p = NULL; else { href = p+1; p = strchrW(href, *p); } } if(p) { *p = 0; } else { VariantClear(&var); IXMLDOMDocument3_Release(xml); return display_error_page(This); } hres = CreateURLMonikerEx(This->mon, href, &mon, 0); VariantClear(&var); if(FAILED(hres)) { IXMLDOMDocument3_Release(xml); return display_error_page(This); } hres = CreateBindCtx(0, &pbc); if(SUCCEEDED(hres)) { hres = IMoniker_GetDisplayName(mon, pbc, NULL, &xsl_url); IMoniker_Release(mon); IBindCtx_Release(pbc); } if(FAILED(hres)) { IXMLDOMDocument3_Release(xml); return display_error_page(This); } V_VT(&var) = VT_BSTR; V_BSTR(&var) = SysAllocString(xsl_url); CoTaskMemFree(xsl_url); if(!V_BSTR(&var)) { IXMLDOMDocument3_Release(xml); return display_error_page(This); } hres = DOMDocument_create(MSXML_DEFAULT, NULL, (void**)&xsl); if(FAILED(hres)) { VariantClear(&var); IXMLDOMDocument3_Release(xml); return display_error_page(This); } /* TODO: do the binding asynchronously */ hres = IXMLDOMDocument3_load(xsl, var, &succ); VariantClear(&var); if(FAILED(hres) || !succ) { IXMLDOMDocument3_Release(xsl); IXMLDOMDocument3_Release(xml); return display_error_page(This); } hres = IXMLDOMDocument3_transformNode(xml, (IXMLDOMNode*)xsl, &bstr); IXMLDOMDocument3_Release(xsl); IXMLDOMDocument3_Release(xml); if(FAILED(hres)) return display_error_page(This); hres = IStream_Seek(This->stream, off, STREAM_SEEK_SET, NULL); if(FAILED(hres)) { SysFreeString(bstr); return display_error_page(This); } hres = IStream_Write(This->stream, (BYTE*)bstr, SysStringLen(bstr)*sizeof(WCHAR), NULL); SysFreeString(bstr); if(FAILED(hres)) return display_error_page(This); return report_data(This); }
static inline HRESULT display_error_page(BindStatusCallback *This) { FIXME("Error page not implemented yet.\n"); return report_data(This); }
HRESULT protocol_continue(Protocol *protocol, PROTOCOLDATA *data) { BOOL is_start; HRESULT hres; is_start = !data || data->pData == UlongToPtr(BINDSTATUS_DOWNLOADINGDATA); if(!protocol->request) { WARN("Expected request to be non-NULL\n"); return S_OK; } if(!protocol->protocol_sink) { WARN("Expected IInternetProtocolSink pointer to be non-NULL\n"); return S_OK; } if(protocol->flags & FLAG_ERROR) { protocol->flags &= ~FLAG_ERROR; protocol->vtbl->on_error(protocol, PtrToUlong(data->pData)); return S_OK; } if(protocol->post_stream) return write_post_stream(protocol); if(is_start) { hres = start_downloading(protocol); if(FAILED(hres)) return S_OK; } if(!data || data->pData >= UlongToPtr(BINDSTATUS_DOWNLOADINGDATA)) { if(!protocol->available_bytes) { if(protocol->query_available) { protocol->available_bytes = protocol->query_available; }else { BOOL res; /* InternetQueryDataAvailable may immediately fork and perform its asynchronous * read, so clear the flag _before_ calling so it does not incorrectly get cleared * after the status callback is called */ protocol->flags &= ~FLAG_REQUEST_COMPLETE; res = InternetQueryDataAvailable(protocol->request, &protocol->query_available, 0, 0); if(res) { TRACE("available %u bytes\n", protocol->query_available); if(!protocol->query_available) { if(is_start) { TRACE("empty file\n"); all_data_read(protocol); }else { WARN("unexpected end of file?\n"); report_result(protocol, INET_E_DOWNLOAD_FAILURE); } return S_OK; } protocol->available_bytes = protocol->query_available; }else if(GetLastError() != ERROR_IO_PENDING) { protocol->flags |= FLAG_REQUEST_COMPLETE; WARN("InternetQueryDataAvailable failed: %d\n", GetLastError()); report_result(protocol, INET_E_DATA_NOT_AVAILABLE); return S_OK; } } protocol->flags |= FLAG_REQUEST_COMPLETE; } report_data(protocol); } return S_OK; }
HRESULT protocol_continue(Protocol *protocol, PROTOCOLDATA *data) { HRESULT hres; if (!data) { WARN("Expected pProtocolData to be non-NULL\n"); return S_OK; } if(!protocol->request) { WARN("Expected request to be non-NULL\n"); return S_OK; } if(!protocol->protocol_sink) { WARN("Expected IInternetProtocolSink pointer to be non-NULL\n"); return S_OK; } if(protocol->flags & FLAG_ERROR) { protocol->flags &= ~FLAG_ERROR; protocol->vtbl->on_error(protocol, (DWORD)data->pData); return S_OK; } if(protocol->post_stream) return write_post_stream(protocol); if(data->pData == (LPVOID)BINDSTATUS_DOWNLOADINGDATA) { hres = protocol->vtbl->start_downloading(protocol); if(FAILED(hres)) { protocol_close_connection(protocol); report_result(protocol, hres); return S_OK; } if(protocol->bindf & BINDF_NEEDFILE) { WCHAR cache_file[MAX_PATH]; DWORD buflen = sizeof(cache_file); if(InternetQueryOptionW(protocol->request, INTERNET_OPTION_DATAFILE_NAME, cache_file, &buflen)) { report_progress(protocol, BINDSTATUS_CACHEFILENAMEAVAILABLE, cache_file); }else { FIXME("Could not get cache file\n"); } } protocol->flags |= FLAG_FIRST_CONTINUE_COMPLETE; } if(data->pData >= (LPVOID)BINDSTATUS_DOWNLOADINGDATA) { BOOL res; /* InternetQueryDataAvailable may immediately fork and perform its asynchronous * read, so clear the flag _before_ calling so it does not incorrectly get cleared * after the status callback is called */ protocol->flags &= ~FLAG_REQUEST_COMPLETE; res = InternetQueryDataAvailable(protocol->request, &protocol->available_bytes, 0, 0); if(res) { protocol->flags |= FLAG_REQUEST_COMPLETE; report_data(protocol); }else if(GetLastError() != ERROR_IO_PENDING) { protocol->flags |= FLAG_REQUEST_COMPLETE; WARN("InternetQueryDataAvailable failed: %d\n", GetLastError()); report_result(protocol, INET_E_DATA_NOT_AVAILABLE); } } return S_OK; }
static void read_all_data(DATA **data, DATA *valdata, int n_vars) { int i; DATA *area; init_data_minmax(); area = get_data_area(); for (i = 0; i < n_vars; i++) { if (get_mode() == STRATIFY) printlog("stratum # %d:\n", i + strata_min); printlog("data(%s): ", name_identifier(i)); if (data[i]->id < 0) { message("data(%s) was not specified\n", name_identifier(i)); ErrMsg(ER_SYNTAX, "data specification error"); } read_gstat_data(data[i]); report_data(data[i]); } /* for i */ /* * what to do when area is specified, but no masks or data()? * default prediction to `area'. Create a valdata with one point at * centre of area (for select()); and centre area at (0,0,0) */ if (area && get_n_masks() <= 0 && valdata->id == -1) { valdata->id = ID_OF_VALDATA; valdata->centre = area->centre = 1; } /* * read data() data: */ if (valdata->id > -1) { setup_valdata_X(valdata); if (! valdata->centre) valdata = read_gstat_data(valdata); } /* * read area, if existed */ if (area != NULL && get_method() != POLY) { read_gstat_data(area); /* now, before centring area: */ if (valdata->centre) valdata = get_area_centre(area, valdata); if (area->centre) centre_area(area); printlog("area:%s\n", area->centre ? " (centred around 0)" : ""); report_data(area); if (DEBUG_DATA) print_data_list(area); } /* * read edges, if existed */ if (get_n_edges() > 0) { read_edges(); report_edges(); /* setup_visibility_graph(); */ /*setup_planar_subdivisions();*/ } /* * setup and report data */ if (valdata->id > -1) { printlog("data():%s ", valdata->centre ? " [at area centre]" : ""); report_data(valdata); } for (i = 0; i < n_vars; i++) setup_data_minmax(data[i]); if (valdata->id > -1) setup_data_minmax(valdata); for (i = 0; i < n_vars; i++) calc_polynomials(data[i]); if (valdata->id > -1) calc_polynomials(valdata); if (DEBUG_DATA) { for (i = 0; i < n_vars; i++) print_data_list(data[i]); if (valdata->id > -1) print_data_list(valdata); } }
static void st1232_ts_irq_worker(struct work_struct *work) { u8 buf[8],buf1[16]; u32 x_st1,y_st1,x_st2,y_st2; int ret,rc,press1=0, press2=0; if(tp_version==1) { buf1[0]=0x0; rc=i2c_master_send(st1232_ts->client, buf1,1); if(rc!=1) printk("[Bing]st1232 i2c_master_send error\r\n"); rc= i2c_master_recv(st1232_ts->client, buf1,16); if(rc!=16) printk("[Bing]st1232 i2c_master_recv error\r\n"); printk("[Bing]st1232 probe:buf[0]=%d\r\n", buf1[0]); printk("[Bing]st1232 probe:buf[1]=%d\r\n", buf1[1]); printk("[Bing]st1232 probe:buf[2]=%d\r\n", buf1[2]); printk("[Bing]st1232 probe:buf[3]=%d\r\n", buf1[3]); printk("[Bing]st1232 probe:buf[4]=%d\r\n", buf1[4]); printk("[Bing]st1232 probe:buf[5]=%d\r\n", buf1[5]); printk("[Bing]st1232 probe:buf[6]=%d\r\n", buf1[6]); printk("[Bing]st1232 probe:buf[7]=%d\r\n", buf1[7]); printk("[Bing]st1232 probe:buf[8]=%d\r\n", buf1[8]); printk("[Bing]st1232 probe:buf[9]=%d\r\n", buf1[9]); printk("[Bing]st1232 probe:buf[10]=%d\r\n", buf1[10]); printk("[Bing]st1232 probe:buf[11]=%d\r\n", buf1[11]); printk("[Bing]st1232 probe:buf[12]=%d\r\n", buf1[12]); printk("[Bing]st1232 probe:buf[13]=%d\r\n", buf1[13]); printk("[Bing]st1232 probe:buf[14]=%d\r\n", buf1[14]); printk("[Bing]st1232 probe:buf[15]=%d\r\n", buf1[15]); tpversion=buf1[0]; buf[0]=0x10; rc = i2c_master_send(st1232_ts->client, buf,1); if(rc!=1) printk("[Bing]st1232 i2c_master_send error\r\n"); tp_version=0; } buf[0]=0x10; rc = i2c_master_send(st1232_ts->client, buf,1); if(rc!=1) printk("[Bing]st1232 i2c_master_send error\r\n"); ret = i2c_master_recv(st1232_ts->client, buf, 8); if (BKL_EN==1) { if( (buf[2]&0x80) && (buf[5]&0x80)) { press1 = 1; press2 = 1; } else if( (buf[2]&0x80)) press1 = 1; else if( (buf[5]&0x80)) press2 = 1; x_st1 = ((buf[2]&0x70)<<4)|buf[3]; y_st1 = (((buf[2]&0x07)<<8)|buf[4]); x_st2 = ((buf[5]&0x70)<<4)|buf[6]; y_st2 = (((buf[5]&0x07)<<8)|buf[7]); // printk("[bing]press1=%d press2=%d x_st1=%d y_st1=%d\r\n",press1,press2,x_st1,y_st1); if(press1 && press2) { last_x = x_st1; last_y = y_st1; if(y_st1<=480) { //finger 1 is in touch area report_data(st1232_ts, x_st1, y_st1, 1 ); if(y_st2<=480){ report_data(st1232_ts, x_st2, y_st2, 1 ); st1232_ts->prev_touches = 2; } else st1232_ts->prev_touches = 1; input_sync(st1232_ts->input_dev); } else { // buttom 4... st1232_ts_update_pen_state(st1232_ts,x_st1, y_st1, 1 ); } } else if(press1) { if(y_st1<=480) { //finger 1 is in touch area report_data(st1232_ts, x_st1, y_st1, 1 ); if(st1232_ts->prev_touches == 2){ input_report_abs(st1232_ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); input_report_abs(st1232_ts->input_dev, ABS_MT_WIDTH_MAJOR, 0); input_mt_sync(st1232_ts->input_dev); } st1232_ts->prev_touches = 1; touchedge=1; input_sync(st1232_ts->input_dev); } else if(tpversion==0) { //printk("[bing]touchedge=%d y_st1=%d\r\n",touchedge,y_st1); if(y_st1>480) { if(touchedge==1) { report_data(st1232_ts, x_st1, y_st1, 0 ); st1232_ts_update_pen_state(st1232_ts, last_x, last_y, 0); printk("[bing]trigger edge=%d\r\n",touchedge); touchedge=0; } else st1232_ts_update_pen_state(st1232_ts,x_st1, y_st1, 1 ); } } last_x = x_st1; last_y = y_st1; //printk("[bing]x_st1,y_st1=(%d %d) trigger edge=%d\r\n",x_st1,y_st1,touchedge); } else if(press2) { last_x = x_st2; last_y = y_st2; if(y_st2<=480) { //finger 1 is in touch area report_data(st1232_ts, x_st2, y_st2, 1 ); if(st1232_ts->prev_touches == 2) { input_report_abs(st1232_ts->input_dev, ABS_MT_TOUCH_MAJOR, 0); input_report_abs(st1232_ts->input_dev, ABS_MT_WIDTH_MAJOR, 0); input_mt_sync(st1232_ts->input_dev); } st1232_ts->prev_touches = 1; input_sync(st1232_ts->input_dev); } else st1232_ts_update_pen_state(st1232_ts,x_st2, y_st2, 1 ); } else { if(tpversion>=1) //Herman { keypress=buf[1]; if(keypress!=0) keyregister=keypress; if(keypress!=0) { //printk("[Bing]keyregister=%d \r\n",buf[1]); x_st1=y_st1=-1; st1232_ts_update_pen_state(st1232_ts,x_st1,y_st1, 1); } } } // int mod_timer(struct timer_list *timer, unsigned long expires) mod_timer(&st1232_ts->timer,jiffies + msecs_to_jiffies(TS_PENUP_TIMEOUT_MS)); } /* kick pen up timer - to make sure it expires again(!) */ enable_irq(st1232_ts->irq); atomic_inc(&st1232_ts->irq_disable); }