static void load_script(const char *name) { struct stat st; int rc; updatecontext(); if (!name) return; if (stat(name, &st) < 0) { myruby_loaded = -1; outerror(OUTERROR_TYPE_WARN_LOUD, "cannot access '%s', ignoring: %s", name, strerror(errno)); return; } ruby_script(name); myruby_time = st.st_mtime; rb_load_protect(rb_str_new(name, strlen(name)), 0, &rc); if (rc != 0) { outerror(OUTERROR_TYPE_WARN_LOUD, "ruby_exec failed with %d: %s", rc, strerror(errno)); myruby_loaded = 1; return; } myruby_loaded = 1; oIrofferEvent = rb_class_new_instance(0, NULL, cIrofferEvent); rb_define_variable("objIrofferEvent", &oIrofferEvent); /* NOTRANSLATE */ }
/* search the DDC transfer a user wants to resume */ unsigned int t_find_resume(const char *nick, const char *filename, const char *localport, const char *bytes, char *token) { char *sendnamestr; transfer *guess; transfer *tr; off_t len; guess = NULL; for (tr = irlist_get_head(&gdata.trans); tr; tr = irlist_get_next(tr)) { if ((tr->tr_status != TRANSFER_STATUS_LISTENING) && (tr->tr_status != TRANSFER_STATUS_RESUME)) continue; if (strcasecmp(tr->caps_nick, nick)) continue; /* the filename can be converted */ if (guess == NULL) guess = tr; if (strcasestr(tr->xpack->file, filename)) break; if (tr->con.localport == (unsigned)atoi(localport)) break; } if (tr == NULL) { if (guess != NULL) { outerror(OUTERROR_TYPE_WARN, "Guessed transfer that %s on %s tried to resume!", nick, gnetwork->name); outerror(OUTERROR_TYPE_WARN, "resume trying %s, %s, %d", nick, filename, atoi(localport)); tr = guess; } else { t_find_debug(nick, filename, localport); return 1; } } len = atoull(bytes); if (len >= tr->xpack->st_size) { notice(nick, "You can't resume the transfer at a point greater than the size of the file"); ioutput(OUT_S|OUT_L|OUT_D, COLOR_YELLOW, "XDCC [%02i:%s on %s]: Resume attempted beyond end of file ( %" LLPRINTFMT "d >= %" LLPRINTFMT "d )", tr->id, tr->nick, gnetwork->name, len, tr->xpack->st_size); return 1; } t_setresume(tr, bytes); sendnamestr = getsendname(filename); if ((tr->tr_status == TRANSFER_STATUS_RESUME) && (token != NULL)) { privmsg_fast(nick, IRC_CTCP "DCC ACCEPT %s %s %s %s" IRC_CTCP, sendnamestr, localport, bytes, token); /* NOTRANSLATE */ } else { privmsg_fast(nick, IRC_CTCP "DCC ACCEPT %s %s %s" IRC_CTCP, sendnamestr, localport, bytes); /* NOTRANSLATE */ } mydelete(sendnamestr); ioutput(OUT_S|OUT_L|OUT_D, COLOR_YELLOW, "XDCC [%02i:%s on %s]: Resumed at %" LLPRINTFMT "dK", tr->id, tr->nick, gnetwork->name, tr->startresume/1024); return 0; }
/* rename file after upload */ static void fetch_rename(fetch_curl_t *ft, const char *effective_url) { char *name; char *destname; int rc; int fd; if (strncasecmp(ft->name, "AUTO", 4) != 0) /* NOTRANSLATE */ return; name = fetch_get_filename(ft, effective_url); if (name == NULL) return; destname = mystrjoin(ft->uploaddir, name, '/'); fd = open(destname, O_RDONLY | ADDED_OPEN_FLAGS); if (fd >= 0) { close(fd); outerror(OUTERROR_TYPE_WARN_LOUD, "File %s could not be moved to %s: %s", ft->name, name, strerror(EEXIST)); } else { rc = rename(ft->fullname, destname); if (rc < 0) { outerror(OUTERROR_TYPE_WARN_LOUD, "File %s could not be moved to %s: %s", ft->name, name, strerror(errno)); } else { a_respond(&(ft->u), "fetched: '%s'", destname); } } mydelete(destname); mydelete(name); }
static void t_find_debug(const char *nick, const char *filename, const char *remoteport) { transfer *tr; outerror(OUTERROR_TYPE_WARN, "Couldn't find transfer that %s on %s tried to resume!", nick, gnetwork->name); outerror(OUTERROR_TYPE_WARN, "resume trying %s, %s, %d", nick, filename, atoi(remoteport)); if (gdata.debug == 0) return; for (tr = irlist_get_head(&gdata.trans); tr; tr = irlist_get_next(tr)) { ioutput(OUT_S, COLOR_NO_COLOR, "transfer %u: %s on %s, %s, %d\n", tr->tr_status, tr->caps_nick, gdata.networks[tr->net].name, tr->xpack->file, tr->con.localport); } }
void wheresyntax(int &lexpos, int &lineno) { int index1, index2, icond; f_int cond; lexmovenext(lexpos); if (outArray[lexpos] == id) { index1 = idnosyn++; lexmovenext(lexpos); if (IsCon(lexpos)) { icond = outArray[lexpos]; F77_NAME(decode_cond_code, DECODE_COND_CODE)(keywords[icond], &cond); lexmovenext(lexpos); if (outArray[lexpos] == id) { index2 = idnosyn++; lexmovenext(lexpos); Instruct.insert(where, index1, index2, cond); } else outerror(lineno, "Second operand of WHERE must be an index"); } else outerror(lineno, "Invalid conditional in WHERE"); } else outerror(lineno, "First operand in WHERE must be an index"); moveoverreturn(lexpos, lineno); }
void in_syntax_check(int &lexpos, int &lineno, int subindex_idnosyn) { int superindex, subindex_varid; lexmovenext(lexpos); // eat the "in" keyword if (outArray[lexpos] == id) // next element must be the superindex { /* Check to make sure the index is the superindex of this subindex. */ superindex = Variable.getidnumber(idnosyn); subindex_varid = Variable.getidnumber(subindex_idnosyn); /* The superindex is stored in the range1 field of the variable table entry of the subindex. It should match the superindex declared in this pardo. */ if (Variable.getrange1(subindex_varid) != superindex) outerror(lineno, "subindex and superindex do not correspond."); } else { outerror(lineno, "subindex missing superindex"); } /* Done with the "in" syntax check. Move to next index on pardo. */ idnosyn++; lexmovenext(lexpos); if (outArray[lexpos] == comma) lexmovenext(lexpos); }
/* set all options for a transfer connection */ void ir_setsockopt(int clientsocket) { #if !defined(CANT_SET_TOS) int tempc; #endif int nodelay = 1; int rc; updatecontext(); if (gdata.tcp_buffer_size > 0) { ir_setsockopt2(clientsocket, SO_SNDBUF, "SO_SNDBUF", gdata.tcp_buffer_size); /* NOTRANSLATE */ ir_setsockopt2(clientsocket, SO_RCVBUF, "SO_RCVBUF", gdata.tcp_buffer_size); /* NOTRANSLATE */ } #if !defined(CANT_SET_TOS) /* Set TOS socket option to max throughput */ tempc = 0x8; /* IPTOS_THROUGHPUT */ setsockopt(clientsocket, IPPROTO_IP, IP_TOS, &tempc, sizeof(int)); #endif if (gdata.tcp_nodelay != 0) { rc = setsockopt(clientsocket, IPPROTO_TCP, TCP_NODELAY, &nodelay, sizeof(nodelay)); if (rc < 0) outerror(OUTERROR_TYPE_WARN, "Couldn't Set TCP_NODELAY"); } if (set_socket_nonblocking(clientsocket, 1) < 0 ) outerror(OUTERROR_TYPE_WARN, "Couldn't Set Non-Blocking"); }
/* call a ruby script as CGI via HTTP */ unsigned int http_ruby_script(const char *name, const char *output) { struct stat st; char *tempstr; int rc; updatecontext(); if (!name) return 1; if (stat(name, &st) < 0) { outerror(OUTERROR_TYPE_WARN_LOUD, "cannot access '%s', ignoring: %s", name, strerror(errno)); return 1; } ruby_script(name); tempstr = mymalloc(maxtextlength); snprintf(tempstr, maxtextlength, "$stdout = File.new(\"%s\", \"w+\")", output); /* NOTRANSLATE */ rb_eval_string_protect(tempstr, &rc); mydelete(tempstr); rb_load_protect(rb_str_new(name, strlen(name)), 0, &rc); if (rc != 0) { outerror(OUTERROR_TYPE_WARN_LOUD, "ruby_exec failed with %d: %s", rc, strerror(errno)); iroffer_ruby_errro(rc); } rb_eval_string_protect("$stdout.close", &rc); /* NOTRANSLATE */ if (rc != 0) return 1; return 0; }
/*==================================== The function functionsyntax anylyzes the token array stored in outArray. variable lexpos keeps tracking the position of the outArray. string temp is the char array of lexical meanings. ====================================*/ void functionsyntax(int &lexpos, int& lineno) { int sialnameno=0; if (outArray[lexpos]!=sial) outerror(lineno, "Data type is missing."); else { if(!lexmovenext(lexpos)) return; } if (id!=outArray[lexpos]) //id outerror(lineno, "<---Identifier missing."); else { sialnameno=idnosyn++; if(!lexmovenext(lexpos)) return; } moveoverreturn(lexpos, lineno); while (IsDeclaration (lexpos) && !endofoutArray) //declaration { declarationsyntax(lexpos, lineno); } while (IsProc (lexpos)&& !endofoutArray) //proc { procsyntax(lexpos, lineno); } Instruct.insert(start, 0); while(!endofoutArray &&endsial!=outArray[lexpos]) { while(IsInstruction (lexpos) && !endofoutArray ) //instruction { instructionsyntax(lexpos, lineno); } if (!endofoutArray&&endsial!=outArray[lexpos]) moveoverreturn(lexpos, lineno); } if (endsial!=outArray[lexpos]) //endsial { outerror(lineno, "not instructions. endsial is missing."); return; } else lexmovenext(lexpos); if (idname[sialnameno]!=idname[idnosyn]) { outerror(lineno, "endsial name does not match."); } else { idnosyn++; lexmovenext(lexpos); } }
static void iroffer_ruby_errro(int error) { VALUE lasterr; VALUE inclass; VALUE message; VALUE ary; long c; if (error == 0) return; lasterr = rb_gv_get("$!"); /* NOTRANSLATE */ inclass = rb_class_path(CLASS_OF(lasterr)); message = rb_obj_as_string(lasterr); outerror(OUTERROR_TYPE_WARN_LOUD, "error ruby_script: class=%s, message=%s", RSTRING_PTR(inclass), RSTRING_PTR(message)); if (!NIL_P(rb_errinfo())) { ary = rb_funcall(rb_errinfo(), rb_intern("backtrace"), 0); for (c=0; c<RARRAY_LEN(ary); ++c) { outerror(OUTERROR_TYPE_WARN_LOUD, "backtrace from %s", RSTRING_PTR(RARRAY_PTR(ary)[c])); } } }
void QCArrayClass::insert(int type, int idno, int nindex, int*indexarray) { int i, j; int variableid; int found; if (Variable.getidnumber(idno)!=-1) { outerror(glno, "id exist."); return; } i=getidnumber(idno); if (i!=-1) { outerror(glno, "id exist."); return; } i=0; if (nvars<maxidnumber) { found=1; while(i<nindex&&found) { variableid=Variable.getidnumber(indexarray[i]); if(variableid==-1) found=0; else { arrayindex[nvars][i]=variableid; i++; } } if (!found) { outerror(glno, "index not defined."); printf("%s, \n",idname[indexarray[i]].c_str()); return; } /*add 0 to meet the ll needs*/ for (j=i; j<mx_array_dim; j++) arrayindex[nvars][j]=0; vararray[nvars]=idname[idno]; arraynindex[nvars]=nindex; arraytype[nvars]=type; nvars++; } else { outerror(glno, "More id than id container can hold, please contact writer.\n"); } }
void executesyntax(int &lexpos, int &lineno) { int arraynameid, nindex; int indexarray[mx_array_dim]; int fnnameid=0; int idno=0; int idno1=0; lexmovenext(lexpos); if (id!=outArray[lexpos]) outerror(lineno, "function name is missing."); else { fnnameid=idnosyn++; lexmovenext(lexpos); if (id != outArray[lexpos]) { Instruct.insert(execute, fnnameid, -1); moveoverreturn(lexpos, lineno); return; } } if (id ==outArray[lexpos] && lparen ==outArray[lexpos+1]) { if(!commonarraysyntax(lexpos, lineno, arraynameid, nindex, indexarray)) { outerror(lineno, "Array name is missing."); return; } Instruct.insert(execute, fnnameid, arraynameid, nindex, indexarray); } else if (id==outArray[lexpos]) { idno=idnosyn++; lexmovenext(lexpos); if (id==outArray[lexpos]) { idno1=idnosyn++; lexmovenext(lexpos); /*insert 2 arguements*/ Instruct.insert(execute, fnnameid, idno, idno1); } else if (fconst==outArray[lexpos]) { scalarsyntax(lexpos, idno1); Instruct.insert(execute, fnnameid, idno, idno1); } else /*insert one argument*/ Instruct.insert(execute, fnnameid, idno); } moveoverreturn(lexpos, lineno); }
/* check that the given text is an IP address or hostname and store it as external DCC IP */ void update_natip(const char *var) { struct hostent *hp; struct in_addr old; struct in_addr in; ir_uint32 oldip; char *oldtxt; updatecontext(); if (var == NULL) return; gnetwork->usenatip = 1; if (gnetwork->myip.sa.sa_family != AF_INET) return; if (gnetwork->r_ourip != 0) return; bzero((char *)&in, sizeof(in)); if (inet_aton(var, &in) == 0) { hp = gethostbyname(var); if (hp == NULL) { outerror(OUTERROR_TYPE_WARN_LOUD, "Invalid NAT Host, Ignoring: %s", hstrerror(h_errno)); return; } if ((unsigned)hp->h_length > sizeof(in) || hp->h_length < 0) { outerror(OUTERROR_TYPE_WARN_LOUD, "Invalid DNS response, Ignoring: %s", hstrerror(h_errno)); return; } memcpy(&in, hp->h_addr_list[0], sizeof(in)); } old.s_addr = htonl(gnetwork->ourip); if (old.s_addr == in.s_addr) return; oldip = gnetwork->ourip; gnetwork->ourip = ntohl(in.s_addr); if (oldip != gnetwork->ourip) { oldtxt = mystrdup(inet_ntoa(old)); ioutput(OUT_S|OUT_L|OUT_D, COLOR_YELLOW, "DCC IP changed from %s to %s on %s", oldtxt, inet_ntoa(in), gnetwork->name); mydelete(oldtxt); update_getip_net(gnetwork->net, gnetwork->ourip); } if (gdata.debug > 0) ioutput(OUT_S|OUT_L, COLOR_YELLOW, "ip=%s\n", inet_ntoa(in)); /* check for 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 */ if (((gnetwork->ourip & 0xFF000000U) == 0x0A000000U) || ((gnetwork->ourip & 0xFFF00000U) == 0xAC100000U) || ((gnetwork->ourip & 0xFFFF0000U) == 0xC0A80000U)) { outerror(OUTERROR_TYPE_WARN_LOUD, "usenatip of %s looks wrong, this is probably not what you want to do", inet_ntoa(in)); } }
int QCArrayClass::CheckTensor(int nindex1, int indexarray1[], int nindex2, int indexarray2[], int nindex3, int indexarray3[], int &nindexr, int indexarrayr[]) const { int i, i2, i3; nindexr=0; int sortindexarray1[mx_array_dim], sortindexarray2[mx_array_dim], sortindexarray3[mx_array_dim]; int contractionarray[2*mx_array_dim], contractnindex; selectionSort(indexarray1, sortindexarray1, nindex1); selectionSort(indexarray2, sortindexarray2, nindex2); selectionSort(indexarray3, sortindexarray3, nindex3); /*check tensor index of array*/ /*merge two arrays*/ i2=i3=0; contractnindex=0; while (i2<nindex2 && i3<nindex3) { if (sortindexarray2[i2]>sortindexarray3[i3]) contractionarray[contractnindex++]=sortindexarray3[i3++]; else if (sortindexarray2[i2]<sortindexarray3[i3]) contractionarray[contractnindex++]=sortindexarray2[i2++]; else /*==*/ { indexarrayr[nindexr++]=sortindexarray2[i2]; i2++; i3++; } } while (i2<nindex2) contractionarray[contractnindex++]=sortindexarray2[i2++]; while (i3<nindex3) contractionarray[contractnindex++]=sortindexarray3[i3++]; /*compare array1 and calculated contraction array*/ if (nindex1!=contractnindex) { outerror(glno, "error in tensor index."); return -2; } for (i=0; i<nindex1; i++) { if (contractionarray[i]!=sortindexarray1[i]) { outerror(glno, "tensor array doesn't match."); return -1; } } return 0; }
/* complete the connection to the IRC server */ static unsigned int connectirc2(res_addrinfo_t *remote) { int retval; int family; if (remote->ai_reset) gnetwork->serv_resolv.next = 0; family = remote->ai_addr.sa_family; gnetwork->ircserver = socket(family, remote->ai_socktype, remote->ai_protocol); if (gnetwork->ircserver < 0) { outerror(OUTERROR_TYPE_WARN_LOUD, "Socket Error: %s", strerror(errno)); return 1; } if (gdata.debug > 0) { char *msg; msg = mymalloc(maxtextlength); my_getnameinfo(msg, maxtextlength -1, &(remote->ai_addr)); ioutput(OUT_S, COLOR_YELLOW, "Connecting to %s", msg); mydelete(msg); } if (bind_irc_vhost(family, gnetwork->ircserver) != 0) { outerror(OUTERROR_TYPE_WARN_LOUD, "Couldn't Bind To Virtual Host"); event_close(gnetwork->ircserver); return 1; } if (set_socket_nonblocking(gnetwork->ircserver, 1) < 0 ) outerror(OUTERROR_TYPE_WARN, "Couldn't Set Non-Blocking"); alarm(CTIMEOUT); retval = connect(gnetwork->ircserver, &(remote->ai_addr), remote->ai_addrlen); if ( (retval < 0) && !((errno == EINPROGRESS) || (errno == EAGAIN)) ) { outerror(OUTERROR_TYPE_WARN_LOUD, "Connection to Server Failed: %s", strerror(errno)); alarm(0); event_close(gnetwork->ircserver); return 1; } alarm(0); if (gdata.debug > 0) { ioutput(OUT_S, COLOR_YELLOW, "ircserver socket = %d", gnetwork->ircserver); } gnetwork->lastservercontact=gdata.curtime; /* good */ gnetwork->serverstatus = SERVERSTATUS_TRYING; return 0; }
/* open file on disk for upload */ int l_setup_file(upload * const l, struct stat *stp) { char *fullfile; int retval; updatecontext(); if (l->uploaddir == NULL) { l_closeconn(l, "No uploaddir defined.", 0); return 1; } /* local file already exists? */ fullfile = mystrjoin(l->uploaddir, l->file, '/'); l->filedescriptor = open(fullfile, O_WRONLY | O_CREAT | O_EXCL | ADDED_OPEN_FLAGS, CREAT_PERMISSIONS ); if ((l->filedescriptor < 0) && (errno == EEXIST)) { retval = stat(fullfile, stp); if (retval < 0) { outerror(OUTERROR_TYPE_WARN_LOUD, "Cant Stat Upload File '%s': %s", fullfile, strerror(errno)); l_closeconn(l, "File Error, File couldn't be opened for writing", errno); mydelete(fullfile); return 1; } if (!S_ISREG(stp->st_mode) || (stp->st_size >= l->totalsize)) { l_closeconn(l, "File Error, That filename already exists", 0); mydelete(fullfile); return 1; } l->filedescriptor = open(fullfile, O_WRONLY | O_APPEND | ADDED_OPEN_FLAGS); if (l->filedescriptor >= 0) { l->resumesize = l->bytesgot = stp->st_size; if (l->resumed <= 0) { close(l->filedescriptor); mydelete(fullfile); return 2; /* RESUME */ } } } if (l->filedescriptor < 0) { outerror(OUTERROR_TYPE_WARN_LOUD, "Cant Access Upload File '%s': %s", fullfile, strerror(errno)); l_closeconn(l, "File Error, File couldn't be opened for writing", errno); mydelete(fullfile); return 1; } mydelete(fullfile); return 0; }
void exitcyclesyntax(int &lexpos, int &lineno) { if (docount==0) outerror(lineno, "exit or cycle not allowed outside do loop."); if (exitt==outArray[lexpos]||cycle==outArray[lexpos]) Instruct.insert(outArray[lexpos], 0); else outerror(lineno, "unknow error in exitcyclesyntax."); lexmovenext(lexpos); moveoverreturn(lexpos, lineno); }
void procsyntax(int &lexpos, int &lineno) { int variableno=0; returncount=0; lexmovenext(lexpos); //proc if (id!=outArray[lexpos]) outerror(lineno, "id is missing."); else { variableno=idnosyn; Instruct.insert(proc, variableno); idnosyn++; lexmovenext(lexpos); } moveoverreturn(lexpos, lineno); while(!endofoutArray&&(IsInstruction(lexpos) )) { instructionsyntax(lexpos, lineno); } /* while(!endofoutArray&&(IsInstruction(lexpos) ))//||returnsil==outArray[lexpos])) { while(IsInstruction(lexpos) && !endofoutArray) { instructionsyntax(lexpos, lineno); } if (returnsil==outArray[lexpos]) { Instruct.insert (endproc, variableno); lexmovenext(lexpos); moveoverreturn(lexpos, lineno); } } */ if (endproc!=outArray[lexpos]) outerror(lineno, "endproc is missing."); else lexmovenext(lexpos); if (idname[variableno]!=idname[idnosyn]) outerror(lineno, "proc name does not match."); else { Instruct.insert (endproc, variableno); idnosyn++; lexmovenext(lexpos); } returncount=-1; moveoverreturn(lexpos, lineno); }
void subindex_syntax(int &lexpos, int &lineno) { int indexnameno=0; int indextype=outArray[lexpos]; //ao, moindex, index int superindex = 0; /* Syntax of the subindex declaration is: subindex ii of i where ii is the name of the subindex i is the name of the superindex. */ lexmovenext(lexpos); if (id!=outArray[lexpos]) { outerror(lineno, "idname is missing."); indexnameno=0; } else { indexnameno=idnosyn++; // subindex name. lexmovenext(lexpos); } /* Next element is the "of" keyword. */ if (outArray[lexpos] != of_kwd) outerror(lineno, "subindex syntax error: of is missing."); else lexmovenext(lexpos); // move pointer past "of". /* Check next element. It must be an index of any type except subindex. */ if (id!=outArray[lexpos]) { outerror(lineno, "superindex idname is missing."); } else { superindex=Variable.getidnumber(idnosyn); // superindex number. if (superindex == -1) { outerror(lineno, "superindex must be a previously declared index."); } idnosyn++; lexmovenext(lexpos); } Variable.insert(indextype, indexnameno, superindex, 0); moveoverreturn(lexpos, lineno); }
void scalardecsyntax(int &lexpos, int &lineno) { int indexnameno=0; double value1=0; int negtive=0; lexmovenext(lexpos); if (id!=outArray[lexpos]) outerror(lineno, "idname is missing."); else { indexnameno=idnosyn++; lexmovenext(lexpos); } if (assign==outArray[lexpos]) { lexmovenext(lexpos); if (sub==outArray[lexpos]) { negtive=1; lexmovenext(lexpos); } if (fconst==outArray[lexpos]) { value1=floatconst[floatnosyn]; if (negtive) value1=-value1; floatnosyn++; lexmovenext(lexpos); } else if (iconst==outArray[lexpos]) { lexmovenext(lexpos); value1=double(intconst[intnosyn]); if (negtive) value1=-value1; intnosyn++; } else outerror(lineno, "value is missing."); } QCArray.insertscalar(indexnameno, value1); moveoverreturn (lexpos, lineno); }
void pardoline(int &lexpos, int &lineno, int &nindex, int indexarray[], int in_flag[]) { int i; nindex=0; for (i = 0; i < mx_array_dim; i++) in_flag[i] = 0; while (!endofoutArray&& id==outArray[lexpos]) { if (nindex<mx_array_dim) indexarray[nindex]=idnosyn; nindex++; idnosyn++; lexmovenext(lexpos); if (comma==outArray[lexpos]) lexmovenext(lexpos); else if (outArray[lexpos] == in_kwd) // "pardo ... ii in i" syntax. { in_syntax_check(lexpos, lineno, indexarray[nindex-1]); in_flag[nindex-1] = 1; } else break; } if (nindex>mx_array_dim) { outerror(lineno, "Warning: Too many indices detected."); printf("Only the first %d are used.\n",mx_array_dim); printf("%d=nindex\n", nindex); printf("All the indices are: "); for (int ii=indexarray[0]; ii<idnosyn; ii++) printf("%s, ", idname[ii].c_str()); printf("\n"); nindex=mx_array_dim; } if (nindex==0) outerror(lineno, "id is missing."); Instruct.insert(pardo, nindex, indexarray, in_flag); moveoverreturn(lexpos, lineno); }
/* process successful connection */ static void t_connected(transfer *tr) { int callval_i; int connect_error; SIGNEDSOCK int connect_error_len = sizeof(connect_error); tr->con.connecttime = gdata.curtime; FD_CLR(tr->con.clientsocket, &gdata.writeset); callval_i = getsockopt(tr->con.clientsocket, SOL_SOCKET, SO_ERROR, &connect_error, &connect_error_len); if (callval_i < 0) { outerror(OUTERROR_TYPE_WARN, "Couldn't determine upload connection status on %s: %s", gnetwork->name, strerror(errno)); t_closeconn(tr, "Download Connection Failed status:", errno); return; } if (connect_error) { t_closeconn(tr, "Download Connection Failed", connect_error); return; } ioutput(OUT_S|OUT_L|OUT_D, COLOR_MAGENTA, "Download Connection Established on %s", gnetwork->name); t_setup_send(tr); return; }
/* limit connection to the configured interface */ unsigned int bind_irc_vhost(int family, int clientsocket) { const char *vhost; ir_sockaddr_union_t localaddr; SIGNEDSOCK int addrlen; int e; vhost = get_local_vhost(); if (!vhost) return 0; bzero((char*)&localaddr, sizeof(ir_sockaddr_union_t)); if (family == AF_INET ) { addrlen = sizeof(struct sockaddr_in); localaddr.sin.sin_family = AF_INET; localaddr.sin.sin_port = 0; e = inet_pton(family, vhost, &(localaddr.sin.sin_addr)); } else { addrlen = sizeof(struct sockaddr_in6); localaddr.sin6.sin6_family = AF_INET6; localaddr.sin6.sin6_port = 0; e = inet_pton(family, vhost, &(localaddr.sin6.sin6_addr)); } if (e != 1) { outerror(OUTERROR_TYPE_WARN_LOUD, "Invalid IP: %s", vhost); return 1; } if (bind(clientsocket, &(localaddr.sa), addrlen) < 0) return 1; return 0; }
void returnsilsyntax(int &lexpos, int &lineno) { int variableno=0; if (returncount==-1) outerror(lineno, "return cannot be used in the main part of sial."); if (returnsil==outArray[lexpos]) { Instruct.insert (endproc, variableno); lexmovenext(lexpos); moveoverreturn(lexpos, lineno); } else outerror(lineno, "unknown error in returnsilsyntax."); }
static void my_get_upnp_data(const struct sockaddr *sa) { #if !defined(NO_GETADDRINFO) char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; socklen_t salen; salen = (sa->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6); if (getnameinfo(sa, salen, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) { outerror(OUTERROR_TYPE_WARN_LOUD, "Invalid IP: %s", "upnp_router"); return; } #else /* NO_GETADDRINFO */ const struct sockaddr_in *remoteaddr = (const struct sockaddr_in *)sa; ir_uint32 to_ip; char hbuf[maxtextlengthshort], sbuf[maxtextlengthshort]; to_ip = ntohl(remoteaddr->sin_addr.s_addr); snprintf(hbuf, sizeof(hbuf), IPV4_PRINT_FMT, IPV4_PRINT_DATA(to_ip)); snprintf(sbuf, sizeof(sbuf), "%d", ntohs(remoteaddr->sin_port)); /* NOTRANSLATE */ #endif /* NO_GETADDRINFO */ if (sa->sa_family != AF_INET) return; updatecontext(); upnp_add_redir(hbuf, sbuf); }
/* cancel a running fetch command */ unsigned int fetch_cancel(unsigned int num) { fetch_curl_t *ft; CURLMcode cms; updatecontext(); ft = irlist_get_head(&fetch_trans); while (ft) { if (num > 0) { if (ft->id != num) { ft = irlist_get_next(ft); continue; } } a_respond(&(ft->u), "fetch '%s' canceled", ft->name); cms = curl_multi_remove_handle(cm, ft->curlhandle); if ( cms != 0 ) { outerror(OUTERROR_TYPE_WARN_LOUD, "curl_multi_remove_handle() = %d", cms); } --fetch_started; ft = clean_fetch(ft); start_qupload(); return 0; } return 1; }
int conditionsyntax(int &lexpos, int &lineno) { int op=0; int stackno1, stackno2; int datatype=iconst; int datatype2=iconst; stackno1=expsyntax(lexpos, datatype, lineno); if (IsCon(lexpos)) //==, >=,<=, !=, >,< { op = outArray[lexpos]; lexmovenext(lexpos); stackno2=expsyntax(lexpos, datatype2, lineno); if (datatype!=datatype2) outerror(lineno, "data type does not match."); } else { if (datatype==iconst) stackno2=Instruct.inserts(iconst, 0, 0, 0); else stackno2=Instruct.inserts(fconst, 0, 0, 0); op=ne; } if (datatype==iconst) Instruct.inserts(op, stackno1, stackno1, stackno2); else Instruct.inserts(gtf-gt+op, stackno1, stackno1, stackno2); return stackno1; }
void QCArrayClass::outputll() { int type=0; int isize=0; int i; f_int f_nvars = nvars; F77_NAME(create_array_table, CREATE_ARRAY_TABLE)(&f_nvars); for(i=0; i<nvars; i++) { if (served==arraytype[i]) type=201; else if (staticc==arraytype[i]) type=202; else if (distributed==arraytype[i]) type=203; else if (temp==arraytype[i]) type=204; else if (scalar==arraytype[i]) type=205; else if (local==arraytype[i]) type=206; else outerror(glno, "error in create_array_table"); add_array_table_c (arraynindex[i], type, isize, &arrayindex[i][0], fvalue[i]); } }
void moveoverreturn (int &lexpos, int &lineno) { if (outArray[lexpos]!=returnn && lexpos <outarray_size) { outerror(lineno, "@@@ unexpected char, ignored till end of line."); printf("Unexpected char: %s\n" , keywords[outArray[lexpos]]); if (outArray[lexpos]==id) printf(" '%s' ### unexpected char", idname[idnosyn].c_str()); else printf(" '%s' $$$ unexpected char", keywords[outArray[lexpos]]); while (outArray[lexpos]!=returnn && !endofoutArray) { if (outArray[lexpos]==id) idnosyn++; lexmovenext(lexpos); } } while (outArray[lexpos]==returnn && !endofoutArray) { lineno++; glno=lineno; lexmovenext(lexpos); } if (lexpos>=outarray_size) endofoutArray=1; }
static statefile_hdr_t* read_statefile_item(ir_uint32 **buffer, ir_uint32 *buffer_len) { statefile_hdr_t *all; if (*buffer_len < sizeof(statefile_hdr_t)) { return NULL; } all = (statefile_hdr_t*)*buffer; all->tag = ntohl(all->tag); all->length = ntohl(all->length); if (*buffer_len < all->length) { outerror(OUTERROR_TYPE_WARN_LOUD, "Bad Header From State File (%u < %u)", *buffer_len, all->length); return NULL; } *buffer += ceiling(all->length, 4) / sizeof(ir_uint32); *buffer_len -= ceiling(all->length, 4); return all; }