t_l *listtr(t_l **file, char *str, char *path) { t_arg stmp; stmp.file = (*file); stmp.path = listadd(str); /* ft_putstr("\n list tr ------ "); ft_putstr(path); ft_putstr(" list tr ------ \n"); */ stmp.npath = getpath(path, str); while (stmp.file != NULL) { stmp.lpath = getpath(path, stmp.file->str); if (stat(stmp.npath, &stmp.fs) < 0 || stat(stmp.lpath, &stmp.sf) < 0) return (0); if (stmp.fs.st_mtime < stmp.sf.st_mtime) return (cond1(&stmp, file)); if (stmp.file->next == NULL) { stmp.file->next = stmp.path; stmp.path->back = stmp.file; return (freeret(&stmp.lpath, &stmp.npath, *(file))); } ft_memdel((void **)&stmp.lpath); stmp.file = stmp.file->next; } return ((*file)); }
static int array(rconlexer* lexer, rconnode** nodep) { rconnode* subnode = NULL; struct rconlist list = {NULL,0,0}; rconnode* node = NULL; ENTER(_array); node = createrconnode(lexer,rcon_array); for(;;) { int token = nexttoken(lexer); if(token == EOF) FAIL(lexer,"unclosed array"); if(token == RBRACK) goto done; if(token == COMMA || token == SEMICOLON) continue; pushtoken(lexer); if(!value(lexer,&subnode)) goto fail; if(!listadd(&list,subnode)) goto fail; } done: node->list.values = list.contents; node->list.nvalues = list.len; if(nodep) *nodep = node; LEAVE(_array,1); return 1; fail: listclear(&list); if(subnode != NULL) rconnodefree(subnode); if(node != NULL) rconnodefree(node); LEAVE(_array,0); return 0; }
Node * createlist(FILE * fd){ /* getting the stats of the file to be opened*/ /* calculating the size of the file*/ Node * head; head = NULL; char temp[12]; /*loop for the individual raeding of the integers from the file*/ while (fgets(temp, sizeof(temp), fd)) { int temp1 = atoi(temp); head = listadd(head, temp1); } /*closing the file*/ /* returns EOF if there is an error, in which case the program is exitted*/ if(fclose(fd)==EOF){ printf("error closing file - aborting\n"); exit(1); } /*the head node is returned*/ /* it is null if there was an error during adding into the linked list*/ return head; }
static listnode* findMaxima(const imImage* hough_points, int *line_count, const imImage* hough) { int x, y, xsize, ysize, rhomax, offset, rho_delta = 0; listnode* maxima = NULL, *cur_node = NULL; point pt; imbyte *map = (imbyte*)hough_points->data[0]; int *hough_map = NULL; xsize = hough_points->width; /* X = theta */ ysize = hough_points->height; /* Y = rho */ rhomax = ysize/2; if (hough) { hough_map = (int*)hough->data[0]; rho_delta = (int)(rhomax*tan(THETA_DELTA1)); } for (y=0; y < ysize; y++) { for (x=0; x < xsize; x++) { offset = y*xsize + x; if (map[offset]) { pt.theta = x; pt.rho = y-rhomax; if (!maxima) { cur_node = maxima = listnew(&pt); (*line_count)++; } else { if (hough_map) { listnode* old_node = cur_node; pt.count = hough_map[offset]; cur_node = listadd_filtered(maxima, cur_node, &pt, rho_delta); if (cur_node != old_node) (*line_count)++; } else { cur_node = listadd(cur_node, &pt); (*line_count)++; } } } } } return maxima; }
SYMBOL *mkanyvar(SYMBOL * var, SYMBOL * any) { var->type = var->itype = st_any; var->name = var->v.p; var->v.p = any->v.p; any->v.p = NULL; symtab = (SYMBOL *) listadd((LIST *) symtab, (LIST *) var, cmpsymsym); /* can't show any */ return var; }
t_l *initlist(t_l **file, char *str, char *flag, char *path) { if (!*file) return (listadd(str)); if (isflag(flag, "tr")) return (listtr(file, str, path)); if (isflag(flag, "t")) return (listt(file, str, path)); if (isflag(flag, "r")) return (listr(file, str)); return (alphalistsort(file, str)); }
void receiver(String *path) { char *sender, *rcpt; if(rejectcheck()) return; if(him == 0 || *him == 0){ rejectcount++; reply("503 Start by saying HELO, please\r\n"); return; } if(senders.last) sender = s_to_c(senders.last->p); else sender = "<unknown>"; if(!recipok(s_to_c(path))){ rejectcount++; syslog(0, "smtpd", "Disallowed %s (%s/%s) to blocked, unknown or invalid name %s", sender, him, nci->rsys, s_to_c(path)); reply("550 5.1.1 %s ... user unknown\r\n", s_to_c(path)); return; } rcpt = s_to_c(path); if (!senderok(rcpt)) { rejectcount++; syslog(0, "smtpd", "Disallowed sending IP of %s (%s/%s) to %s", sender, him, nci->rsys, rcpt); reply("550 5.7.1 %s ... sending system not allowed\r\n", rcpt); return; } logged = 0; /* forwarding() can modify 'path' on loopback request */ if(filterstate == ACCEPT && fflag && !authenticated && forwarding(path)) { syslog(0, "smtpd", "Bad Forward %s (%s/%s) (%s)", senders.last && senders.last->p? s_to_c(senders.last->p): sender, him, nci->rsys, path? s_to_c(path): rcpt); rejectcount++; reply("550 5.7.1 we don't relay. send to your-path@[] for " "loopback.\r\n"); return; } listadd(&rcvers, path); reply("250 2.0.0 receiver is %s\r\n", s_to_c(path)); }
SYMBOL *mkmapvar(SYMBOL * var, SYMBOL * map) { var->type = var->itype = st_map; var->name = var->v.p; var->v.p = map->v.p; map->v.p = NULL; freesym(map); symtab = (SYMBOL *) listadd((LIST *) symtab, (LIST *) var, cmpsymsym); printmap(var); return var; }
Node * createlist(FILE *fp){ Node * head = NULL; char line[256]; int buffer; while(fgets(line, sizeof(line), fp)){ buffer = atoi(line); head = listadd(head, buffer); } if (feof(fp) == 0){ fprintf(stderr, "fgets failed\n"); exit(1); } return head; }
//create_node Node* create_node(int nl, Node_type t, char* lexeme, Node* child0, ...) { if(t < nodo_programa && t > nodo_coringa) _error(OWIDTH); Node * child, * n = (Node*) malloc(sizeof(Node)); n->num_line = nl; n->lexeme = lexeme; n->type = t; n->children = NULL; va_list ap; va_start(ap, child0); for (child = child0; child != NULL; child = va_arg(ap, Node*)) listadd(&n->children, child); va_end(ap); return n; }
int ralloc(ident_t id, int regmask){ int reg = 0, i; if(((store_t)(id->extra))->cur_reg) return ((store_t)(id->extra))->cur_reg; if(((store_t)(id->extra))->wanted_reg){ reg = ((store_t)(id->extra))->wanted_reg; }else{ for(i = R_EAX; i < R_END; i<<=1) if((i & regmask) && rstate(i)){ reg = i; break; } if(!reg)reg = listoldest(regmask); } if(!rstate(reg)){ rfree(reg); } rlock(reg); ((store_t)(id->extra))->cur_reg=reg; listadd(id); return reg; }
static int map(rconlexer* lexer, rconnode** nodep, int optional) { rconnode* node = NULL; rconnode* subnode = NULL; struct rconlist list = {NULL,0,0}; int token; ENTER(_map); node = createrconnode(lexer,rcon_map); for(;;) { token = nexttoken(lexer); if(optional && token == RBRACE) FAIL(lexer,"brace mismatch"); else if(optional && token == EOF) goto done; else if(!optional && token == EOF) FAIL(lexer,"unclosed map"); else if(!optional && token == RBRACE) goto done; if(token == COMMA || token == SEMICOLON) continue; pushtoken(lexer); if(!pair(lexer,&subnode)) goto fail; if(!listadd(&list,subnode)) goto fail; } done: node->list.values = list.contents; node->list.nvalues = list.len; if(nodep) *nodep = node; LEAVE(_map,1); return 1; fail: listclear(&list); if(subnode != NULL) rconnodefree(subnode); if(node != NULL) rconnodefree(node); LEAVE(_map,0); return 0; }
void sender(String *path) { String *s; static char *lastsender; if(rejectcheck()) return; if (authenticate && !authenticated) { rejectcount++; reply("530 5.7.0 Authentication required\r\n"); return; } if(him == 0 || *him == 0){ rejectcount++; reply("503 Start by saying HELO, please.\r\n", s_to_c(path)); return; } /* don't add the domain onto black holes or we will loop */ if(strchr(s_to_c(path), '!') == 0 && strcmp(s_to_c(path), "/dev/null") != 0){ s = s_new(); s_append(s, him); s_append(s, "!"); s_append(s, s_to_c(path)); s_terminate(s); s_free(path); path = s; } if(shellchars(s_to_c(path))){ rejectcount++; reply("501 5.1.3 Bad character in sender address %s.\r\n", s_to_c(path)); return; } /* * if the last sender address resulted in a rejection because the sending * domain didn't exist and this sender has the same domain, reject * immediately. */ if(lastsender){ if (strncmp(lastsender, s_to_c(path), strlen(lastsender)) == 0){ filterstate = REFUSED; rejectcount++; reply("554 5.1.8 Sender domain must exist: %s\r\n", s_to_c(path)); return; } free(lastsender); /* different sender domain */ lastsender = 0; } /* * see if this ip address, domain name, user name or account is blocked */ logged = 0; filterstate = blocked(path); /* * permanently reject what we can before trying smtp ping, which * often leads to merely temporary rejections. */ switch (filterstate){ case DENIED: syslog(0, "smtpd", "Denied %s (%s/%s)", s_to_c(path), him, nci->rsys); rejectcount++; logged++; reply("554-5.7.1 We don't accept mail from %s.\r\n", s_to_c(path)); reply("554 5.7.1 Contact postmaster@%s for more information.\r\n", dom); return; case REFUSED: syslog(0, "smtpd", "Refused %s (%s/%s)", s_to_c(path), him, nci->rsys); rejectcount++; logged++; reply("554 5.7.1 Sender domain must exist: %s\r\n", s_to_c(path)); return; } listadd(&senders, path); reply("250 2.0.0 sender is %s\r\n", s_to_c(path)); }
/*eject*/ pboslist() { /* * Process the BLDOUTSC List */ register OUTSECT *osptr; register INSECT *insptr; register INFILE *inflptr; #if !ONEPROC ACTITEM a; #endif OUTSECT *dfn_scn_grp(); long check_sect(); /* * Process the list of output sections. Output sections can be * defined in two places: * * 1. PASS 1: user-supplied; bldcnt will be > 0, and the bldoutsc * list head will be NULL * 2. PASS 2: default-generation; bldcnt will be 0, and the * bldoutsc list will describe the output * sections * * These two uses are mutually exclusive */ #if DEBUG if( dflag > 2 ) fprintf( stderr, "\nBLDOSCN data structures:" ); #endif #if !ONEPROC while( bldcnt-- ) { fread( &a, 1, sizeof(ACTITEM), trnfdes ); a.dfnscn.aiinflnm = (char *) ((int) a.dfnscn.aiinflnm + (int) strbase); if (a.dfnscn.aibndadr != NULL) a.dfnscn.aibndadr = ldlimb( ); if (a.dfnscn.aialign != NULL) a.dfnscn.aialign = ldlimb( ); osptr = dfn_scn_grp(&a, 0); copy(osptr->oshdr.s_name, a.dfnscn.ainame, 8); #if TRVEC /* * User can define attributes of TV in two ways: * (1) using TV { } directive * (2) using SECTIONS { .tv : {} } directive * so force them to agree */ if ( equal(a.dfnscn.ainame, _TV, 8) ) { /* defining .tv */ if ( tvspec.tvbndadr == -1L ) { lineno = a.dfnscn.aiinlnno; curfilnm = a.dfnscn.aiinflnm; tvspec.tvbndadr = eval( a.dfnscn.aibndadr) ; } else a.dfnscn.aibndadr = cnstnode( tvspec.tvbndadr ); } #endif if( a.dfnscn.aitype == AIDFNSCN ) numoutsc++; osptr->oshdr.s_paddr = -1L; listadd(l_OS, &outsclst, osptr); } #endif /* * We now know everything there is to know about the * transfer vector: * At the end of ploadfil(), we knew how big it * had to be. * Here we know whether it was defined by ld or * whether it is defined by .tv input sections * together with a .tv SECTION directive * Go check everything and complete tvspec definition. */ #if TRVEC if ( tvflag ) tvupdat(); /* update definition of tv */ #endif if( bldoutsc.head ) { register ACTITEM *aptr, *a2ptr; aptr = (ACTITEM *) bldoutsc.head; while( aptr ) { osptr = dfn_scn_grp(aptr, 1); copy(osptr->oshdr.s_name, aptr->dfnscn.ainame, 8); if( aptr->dfnscn.aitype == AIDFNSCN ) numoutsc++; osptr->oshdr.s_paddr = -1L; listadd(l_OS, &outsclst, osptr); a2ptr = aptr; aptr = aptr->dfnscn.ainext; free( (char *) a2ptr); } } /* * Make sure all input sections are allocated * into some output section. */ for( inflptr = (INFILE *) infilist.head; inflptr; inflptr = inflptr->flnext ) { for( insptr = inflptr->flishead; insptr; insptr=insptr->isnext ) { if (insptr->isoutsec == 0) { if ((osptr = fndoutsec(insptr->ishdr.s_name)) != NULL) inscadd(insptr,osptr); else { osptr = (OUTSECT *) mycalloc( sizeof( OUTSECT )); numoutsc++; copy(osptr->oshdr.s_name, insptr->ishdr.s_name, 8); osptr->osfill = globfill; osptr->oshdr.s_paddr = -1l; osptr->osnlnno = 1; osptr->osnflnm = "*default*"; listadd(l_OS,&outsclst,osptr); inscadd(insptr,osptr); } } } } /* * for each output section, check the flags, and for a group, * check the size. */ for( osptr = (OUTSECT *) outsclst.head; osptr; osptr = osptr->osnext ) { #if PAGING ACTITEM *aptr; ADDRESS textbegin, textsize; textbegin = hflag + FILHSZ + SCNHSZ * numoutsc + memorg; #endif if (osptr->oshdr.s_flags & STYP_GROUP) { OUTSECT *op; for( op = ((OUTSECT *) osptr->osinclhd); op; op = op->osnext ) { #if PAGING if (bond_t_d && !Nflag && equal(op->oshdr.s_name,_DATA,8)) { osptr->osalign = NULL; aptr = (ACTITEM *) mycalloc(sizeof(ACTITEM)); aptr->bond.aitype = AIBOND; aptr->bond.aiinflnm = "*default.bond.file*"; aptr->bond.aiinlnno = 3; aptr->bond.aioutsec = osptr; aptr->bond.aiadrbnd = cnstnode(((textsize + textbegin) / BOUNDARY + 1) * BOUNDARY + (textsize + textbegin) % K8); listadd(l_AI,&bondlist,aptr); } #endif osptr->oshdr.s_size += check_sect( op ); } if (osptr->oshdr.s_size > MAXSCNSIZE) lderror(1,0,NULL, "GROUP containing section %.8s is too big", osptr->osinclhd->ishdr.s_name); } else { #if PAGING if (bond_t_d && !Nflag && equal(osptr->oshdr.s_name,_TEXT,8)) { textsize = osptr->oshdr.s_size; aptr = (ACTITEM *) mycalloc(sizeof(ACTITEM)); aptr->bond.aitype = AIBOND; aptr->bond.aiinflnm = "*default.bond.file*"; aptr->bond.aiinlnno = 2; aptr->bond.aioutsec = osptr; aptr->bond.aiadrbnd = cnstnode( textbegin ); listadd(l_AI,&bondlist,aptr); } #endif check_sect( osptr ); } } /* * If .tv is user-defined, we now know the true size of * the section ( the sum of the sizes of the input * sections) which we didn't know before. Now call the * the final update routine to insure .tv symtab entry * is correct */ #if TRVEC if ( tvflag ) tvupdt2(); /* final update of tvrange and tvlength */ #endif #if DEBUG if (dflag) dmp_outsects(); #endif }
int add5(LIST *cell) { cell->data = (void*)cell; listadd(& glob, (void*)add5); }