int flag_x(t_format f, va_list *ap) { unsigned long long int nb; char c; int left; int len; left = (ft_strchr(f.flags, '-') ? 0 : 1); nb = get_unsigned_arg(f.modifier, ap); get_out(&f, nb, &c); len = 0; if ((left ? c : ' ') != '0') f.out = add_prefix(&f, nb); else { if (ft_strchr(f.flags, '#') && nb != 0) len -= 2; } len += f.length - ft_strlen(f.out); f.out = add_string(&f, len, (left ? c : ' '), left); if ((left ? c : ' ') == '0') f.out = add_prefix(&f, nb); ft_putstr(f.out); len = ft_strlen(f.out); free(f.out); return (len); }
static void start_line(int verbose, int lineend) { char flg; if (flag_localtime || flag_utc) gettimeofday(&stamp, NULL); tino_buf_resetO(&prefix); add_prefix(""); if (flag_localtime) add_time(localtime); if (flag_utc) add_time(gmtime); flg = verbose ? '-' : lineend ? ' ' : '+'; if (flag_verbose && producer) add_prefix("[%ld]", (long)producer); if (flag_linecount) { if (!in_line) line_nr++; add_prefix((flag_linecount==1 ? "%5d%c" : flag_linecount==2 ? "%05d%c" : "%d%c"), line_nr, flg); } else if (flag_verbose) add_prefix("%c", flg); }
void Log :: produce_log(int event, const char * fmt, va_list args) { std::unique_ptr<char[]> tmp(new char[LOG_MAXLINE]); switch(event) { case LOG_DEBUG: add_prefix(tmp.get(), str_prefix[LOG_DEBUG]); break; case LOG_NOTICE: add_prefix(tmp.get(), str_prefix[LOG_NOTICE]); break; case LOG_WARN: add_prefix(tmp.get(), str_prefix[LOG_WARN]); break; case LOG_ERROR: add_prefix(tmp.get(), str_prefix[LOG_ERROR]); break; } char * valPtr = tmp.get(); ctime(&valPtr[9], 20); valPtr[23] = ' '; valPtr[24] = ' '; vsprintf(&valPtr[25], fmt, args); pthread_mutex_lock(&log_mutex); log_buffer.push(std::move(tmp)); if(log_buffer.size() == 1) pthread_cond_signal(&log_cond); else pthread_cond_broadcast(&log_cond); pthread_mutex_unlock(&log_mutex); }
static char * ext_help_generator(const char *text, int state) { static int len, junk, n, def, key; static char *TEXT; if (!state) { n = 0; def = key = 1; init_prefix(text, &len, &junk, &TEXT); } if (def) { char *s = default_generator(TEXT, state); if (s) return add_prefix(s, text, junk); def = 0; } if (key) { const char **L = gphelp_keyword_list(); for ( ; L[n]; n++) if (!strncmp(L[n],TEXT,len)) return add_prefix(L[n++], text, junk); key = 0; state = 0; } return command_generator(text, state); }
/* {{{ append_multiple_key_values * Internal function which is called from locale_compose * gets the multiple values for the key_name and appends to the loc_name * used for 'variant','extlang','private' * returns 1 if successful , -1 if not found , * 0 if array element is not a string , -2 if buffer-overflow */ static int append_multiple_key_values(smart_str* loc_name, HashTable* hash_arr, char* key_name) { zval *ele_value; int i = 0; int isFirstSubtag = 0; int max_value = 0; /* Variant/ Extlang/Private etc. */ if ((ele_value = zend_hash_str_find( hash_arr , key_name , strlen(key_name))) != NULL) { if( Z_TYPE_P(ele_value) == IS_STRING ){ add_prefix( loc_name , key_name); smart_str_appendl(loc_name, SEPARATOR , sizeof(SEPARATOR)-1); smart_str_appendl(loc_name, Z_STRVAL_P(ele_value) , Z_STRLEN_P(ele_value)); return SUCCESS; } else if(Z_TYPE_P(ele_value) == IS_ARRAY ) { HashTable *arr = HASH_OF(ele_value); zval *data; ZEND_HASH_FOREACH_VAL(arr, data) { if(Z_TYPE_P(data) != IS_STRING) { return FAILURE; } if (isFirstSubtag++ == 0){ add_prefix(loc_name , key_name); } smart_str_appendl(loc_name, SEPARATOR , sizeof(SEPARATOR)-1); smart_str_appendl(loc_name, Z_STRVAL_P(data) , Z_STRLEN_P(data)); } ZEND_HASH_FOREACH_END(); return SUCCESS; } else { return FAILURE;
// ============================================================================ // update the content of Data-On-Demand actions // ============================================================================ StatusCode DataOnDemandSvc::update () { if ( !m_updateRequired ) { return StatusCode::SUCCESS ; } /// convert obsolete "Nodes" into new "NodeMap" StatusCode sc = setupNodeHandlers() ; // convert "Nodes" new "NodeMap" if ( sc.isFailure() ) { stream() << MSG::ERROR << "Failed to setup old \"Nodes\"" << endmsg ; return sc ; } /// convert obsolete "Algorithms" into new "AlgMap" sc = setupAlgHandlers() ; // convert "Algorithms" into "AlgMap" if ( sc.isFailure() ) { stream() << MSG::ERROR << "Failed to setup old \"Algorithms\"" << endmsg ; return sc ; } /// add the default prefix add_prefix ( m_algMap , m_prefix ) ; /// add the default prefix add_prefix ( m_nodeMap , m_prefix ) ; /// get all directories typedef std::set<std::string> Set ; Set dirs ; if ( m_partialPath ){ get_dirs ( m_algMap , dirs ) ; } if ( m_partialPath ){ get_dirs ( m_nodeMap , dirs ) ; } // Set::iterator _e = dirs.find("/Event") ; if ( dirs.end() != _e ) { dirs.erase( _e ) ; } // add all directories as nodes for ( Set::const_iterator dir = dirs.begin() ; dirs.end() != dir ; ++dir ) { if ( m_algMap .end () != m_algMap .find ( *dir ) ) { continue ; } if ( m_nodeMap .end () != m_nodeMap .find ( *dir ) ) { continue ; } m_nodeMap [*dir] = "DataObject" ; } // m_algs .clear () ; m_nodes .clear () ; // /// setup algorithms for ( Map::const_iterator ialg = m_algMap.begin() ; m_algMap.end() != ialg ; ++ialg ) { if (i_setAlgHandler(ialg->first, ialg->second).isFailure()) return StatusCode::FAILURE; } /// setup nodes for ( Map::const_iterator inode = m_nodeMap.begin() ; m_nodeMap.end() != inode ; ++inode ) { i_setNodeHandler(inode->first, inode->second); } /// m_updateRequired = false ; // return StatusCode::SUCCESS ; }
static void add_time(struct tm *fn(const time_t *timep)) { struct tm *tm; tm = fn(&stamp.tv_sec); if (flag_micro) add_prefix("[%04d%02d%02d-%02d%02d%02d-%06ld]", 1900+tm->tm_year, 1+tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, stamp.tv_usec); else add_prefix("[%04d%02d%02d-%02d%02d%02d]", 1900+tm->tm_year, 1+tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); }
/* Generator function for member completion. STATE lets us know whether * to start from scratch; without any state (i.e. STATE == 0), then we * start at the top of the list. */ static char * member_generator(const char *text, int state) { static int hashpos, len, junk; static entree* ep; static char *TEXT; entree **hash=functions_hash; /* If this is a new word to complete, initialize now: * + indexes hashpos (GP hash list) and n (keywords specific to long help). * + file completion and keyword completion use different word boundaries, * have TEXT point to the keyword start. * + save the length of TEXT for efficiency. */ if (!state) { hashpos = 0; ep = hash[hashpos]; init_prefix(text, &len, &junk, &TEXT); } /* Return the next name which partially matches from the command list. */ for(;;) if (!ep) { if (++hashpos >= functions_tblsz) return NULL; /* no names matched */ ep = hash[hashpos]; } else if (ep->name[0]=='_' && ep->name[1]=='.' && !strncmp(ep->name+2,TEXT,len)) break; else ep = ep->next; current_ep = ep; ep = ep->next; return add_prefix(current_ep->name+2,text,junk); }
static int add_rule(rt_data_t *rdata, char *grplst, str *prefix, rt_info_t *rule) { long int t; char *tmp; char *ep; int n; tmp=grplst; n=0; /* parse the grplst */ while(tmp && (*tmp!=0)) { errno = 0; t = strtol(tmp, &ep, 10); if (ep == tmp) { LM_ERR("bad grp id '%c' (%d)[%s]\n", *ep, (int)(ep-grplst), grplst); goto error; } if ((!IS_SPACE(*ep)) && (*ep != SEP) && (*ep != SEP1) && (*ep!=0)) { LM_ERR("bad char %c (%d) [%s]\n", *ep, (int)(ep-grplst), grplst); goto error; } if (errno == ERANGE && (t== LONG_MAX || t== LONG_MIN)) { LM_ERR("out of bounds\n"); goto error; } n++; /* add rule -> has prefix? */ if (prefix->len) { /* add the routing rule */ if ( add_prefix(rdata->pt, prefix, rule, (unsigned int)t)!=0 ) { LM_ERR("failed to add prefix route\n"); goto error; } } else { if ( add_rt_info( &rdata->noprefix, rule, (unsigned int)t)!=0 ) { LM_ERR("failed to add prefixless route\n"); goto error; } } /* keep parsing */ if(IS_SPACE(*ep)) EAT_SPACE(ep); if(ep && (*ep == SEP || *ep == SEP1)) ep++; tmp = ep; } if(n==0) { LM_ERR("no id in grp list [%s]\n", grplst); goto error; } return 0; error: return -1; }
int *open(const char *pathname, int flags) { char filename[BUFSIZE] = "\0"; int *(*original_open)(const char *, int); original_open = dlsym(RTLD_NEXT, "open"); return (*original_open)(add_prefix(pathname, filename), flags); }
DIR *opendir(const char *name) { char filename[BUFSIZE] = "\0"; DIR *(*original_opendir)(const char *); original_opendir = dlsym(RTLD_NEXT, "opendir"); return (*original_opendir)(add_prefix(name, filename)); }
FILE *fopen(const char *path, const char *mode) { char filename[BUFSIZE] = "\0"; FILE *(*original_fopen)(const char *, const char *); original_fopen = dlsym(RTLD_NEXT, "fopen"); return (*original_fopen)(add_prefix(path, filename), mode); }
/** * Transform topics to regex expression. * * @param topic topic of subscription as provided by the subscriber * @param regex_topic client identification of the client */ static void get_regex (char *topic, char **regex_topic) { char *plus; char *hash; char *prefixed_topic; int i; int j; int k; int plus_counter = 0; int hash_exists = 0; plus = strchr(topic,'+'); while (plus != NULL) { plus_counter +=1; plus=strchr(plus+1,'+'); } hash = strchr(topic,'#'); if (hash != NULL) { hash_exists = 1; } add_prefix(topic, &prefixed_topic); *regex_topic = GNUNET_malloc (strlen(prefixed_topic) - plus_counter - hash_exists + plus_counter*strlen(plus_regex) + hash_exists*strlen(hash_regex)+1); j = 0; for (i = 0; prefixed_topic[i] != '\0'; i++) { if (prefixed_topic[i] == '+') { for (k = 0; k<strlen(plus_regex); k++) { (*regex_topic)[j] = plus_regex[k]; j++; } } else if (prefixed_topic[i] == '#') { j--; for (k = 0; k<strlen(hash_regex); k++) { (*regex_topic)[j] = hash_regex[k]; j++; } } else { (*regex_topic)[j] = prefixed_topic[i]; j++; } } (*regex_topic)[j] = '\0'; }
dict * getval ( int table_id , char *key ) { char * key_name = (char *) malloc(80 * sizeof(char)); key_name = add_prefix(table_id,key); int hsh = hash(key_name); dict *ptr; for (ptr = table[hsh]; ptr != (dict *) 0; ptr = (dict *)ptr->next) if (strcmp (ptr->name,key_name) == 0) return ptr; return (dict *) 0; }
static void build_ra(struct safe_buffer * sb, struct Interface const * iface) { add_ra_header(sb, &iface->ra_header_info, iface->state_info.cease_adv); if (iface->AdvPrefixList) { add_prefix(sb, iface->AdvPrefixList, iface->state_info.cease_adv); } if (iface->AdvRouteList) { add_route(sb, iface->AdvRouteList, iface->state_info.cease_adv); } if (iface->AdvRDNSSList) { add_rdnss(sb, iface->AdvRDNSSList, iface->state_info.cease_adv); } if (iface->AdvDNSSLList) { add_dnssl(sb, iface->AdvDNSSLList, iface->state_info.cease_adv); } if (iface->AdvPvdList) { add_pvd(sb, iface->AdvPvdList, iface->state_info.cease_adv); } if (iface->AdvLinkMTU != 0) { add_mtu(sb, iface->AdvLinkMTU); } if (iface->AdvSourceLLAddress && iface->sllao.if_hwaddr_len > 0) { add_sllao(sb, &iface->sllao); } if (iface->mipv6.AdvIntervalOpt) { add_mipv6_rtr_adv_interval(sb, iface->MaxRtrAdvInterval); } if (iface->mipv6.AdvHomeAgentInfo && (iface->mipv6.AdvMobRtrSupportFlag || iface->mipv6.HomeAgentPreference != 0 || iface->mipv6.HomeAgentLifetime != iface->ra_header_info.AdvDefaultLifetime)) { add_mipv6_home_agent_info(sb, &iface->mipv6); } if (iface->AdvLowpanCoList) { add_lowpanco(sb, iface->AdvLowpanCoList); } if (iface->AdvAbroList) { add_abro(sb, iface->AdvAbroList); } }
void putval ( int table_id , char *key,int sval ) { /* For inserting a key into the table with integer value */ char * key_name = (char *) malloc(80 * sizeof(char)); key_name = add_prefix(table_id,key); int hsh = hash(key_name); dict *ptr; ptr = (dict *) malloc (sizeof(dict)); ptr->name = (char *) malloc (strlen(key_name)+1); ptr->val = sval; strcpy (ptr->name,key_name); ptr->next = (struct dict *)table[hsh]; table[hsh] = ptr; }
static int parse_child_option(struct isl_arg *decl, char **arg, struct isl_prefixes *prefixes, void *opt) { void *child; int first, parsed; if (decl->offset == (size_t) -1) child = opt; else child = *(void **)(((char *)opt) + decl->offset); first = add_prefix(prefixes, decl->long_name); parsed = parse_option(decl->u.child.child->args, arg, prefixes, child); drop_prefix(prefixes, first); return parsed; }
UnitConverter::UnitConverter() { // add_prefix("P", 1E12f); // add_prefix("T", 1E9f); add_prefix("M", 1E6f); add_prefix("k", 1E3f); prefix_values_indexed.push_back(""); // add_prefix("c", 1E-2f); add_prefix("m", 1E-3f); add_prefix("\u03BC", 1E-6f); prefix_values["u"] = 1E-6f; add_prefix("n", 1E-9f); add_prefix("p", 1E-12f); // add_prefix("f", 1E-15f); }
void fn_prefix(char **args) { if (args == NULL) { /* emacs C-u */ return; } else if (args[0][1] == '\0') { if (isdigit(args[0][0])) add_prefix(args[0][0] - '0'); else if (args[0][0] == '-') negate_prefix(); } else { int p = atoi(args[0]); if (p || args[0][0] == '0') set_prefix(p); } }
void check_alias(gpointer alias) { char *alias_name = _get_real_name(alias); /* add to beans list or common prefix */ char * r = NULL; if (lp->params.s3.delimiter) r = g_strstr_len((!lp->params.s3.prefix) ? alias_name : alias_name + strlen(lp->params.s3.prefix), -1, lp->params.s3.delimiter); if (r) { GRID_DEBUG("Found common prefix : %.*s", ((int)( r - alias_name)) + 1, alias_name); add_prefix(g_strndup(alias_name, r + 1 - alias_name)); } else { _get_cb(obc, alias); } g_free(alias_name); }
void jsil_typecheckt::typecheck_type(typet &type) { if(type.id()==ID_code) { code_typet ¶meters=to_code_type(type); for(code_typet::parametert &p : parameters.parameters()) { // create new symbol parameter_symbolt new_symbol; new_symbol.base_name=p.get_identifier(); // append procedure name to parameters p.set_identifier(add_prefix(p.get_identifier())); new_symbol.name=p.get_identifier(); if(is_jsil_builtin_code_type(type)) new_symbol.type=jsil_value_or_empty_type(); else if(is_jsil_spec_code_type(type)) new_symbol.type=jsil_value_or_reference_type(); else new_symbol.type=jsil_value_type(); // User defined function new_symbol.mode="jsil"; // mark as already typechecked new_symbol.is_extern=true; if(symbol_table.add(new_symbol)) { error() << "failed to add parameter symbol `" << new_symbol.name << "' in the symbol table" << eom; throw 0; } } } }
void dag_network::potentially_lower_rank(rpl_node &peer, network_interface *iface, const struct nd_rpl_dio *dio, int dio_len) { unsigned int rank = ntohs(dio->rpl_dagrank); debug->verbose(" does peer '%s' have better rank? (%u < %u)\n", peer.node_name(), rank, mBestRank); this->mStats[PS_LOWER_RANK_CONSIDERED]++; if(rank > mBestRank) { this->mStats[PS_LOWER_RANK_REJECTED]++; return; } debug->verbose(" Yes, '%s' has best rank %u\n", peer.node_name(), rank); if(dag_bestparent == &peer || dag_parent == &peer) { debug->verbose(" But it is the same parent as before: ignored\n"); this->mStats[PS_SAME_PARENT_IGNORED]++; return; } /* XXX * this is actually quite a big deal (SEE rfc6550), setting my RANK. * just fake it for now by adding 1. */ if(mDTSN != INVALID_SEQUENCE && mDTSN >= dio->rpl_dtsn) { debug->verbose(" Same sequence number, ignore\n"); this->mStats[PS_SAME_SEQUENCE_IGNORED]++; return; } mDTSN = dio->rpl_dtsn; mBestRank = rank; /* XXX * this is actually quite a big deal (SEE rfc6550), setting my RANK. * just fake it for now by adding 1. */ mMyRank = rank + 1; // XXX mGrounded = RPL_DIO_GROUNDED(dio->rpl_mopprf); mInstanceid = dio->rpl_instanceid; mVersion = dio->rpl_version; mMode = RPL_DIO_MOP(dio->rpl_mopprf); dag_bestparentif = iface; dag_bestparent = &peer; /* now see if we have already an address on this new network */ /* * to do this, we have to crack open the DIO. UP to this point * we haven't taken the DIO apart, so do, keeping stuff on the stack. */ rpl_dio decoded_dio(peer, this, dio, dio_len); unsigned int optcount = 0; struct rpl_dio_destprefix *dp; while((dp = decoded_dio.destprefix()) != NULL) { unsigned char v6bytes[16]; int prefixbytes = ((dp->rpl_dio_prefixlen+7) / 8); ip_subnet prefix; prefix.maskbits = dp->rpl_dio_prefixlen; memset(v6bytes, 0, 16); memcpy(v6bytes, dp->rpl_dio_prefix, prefixbytes); initaddr(v6bytes, 16, AF_INET6, &prefix.addr); optcount++; add_prefix(peer, iface, prefix); } debug->verbose(" processed %u pio options\n", optcount); /* now schedule sending out packets */ if(dag_parent) { /* can only send DIOs once we are sure about our parent! */ maybe_schedule_dio(); } maybe_send_dao(); }
void jsil_typecheckt::typecheck_symbol_expr(symbol_exprt &symbol_expr) { irep_idt identifier=symbol_expr.get_identifier(); // if this is a built-in identifier, check if it exists in the // symbol table and retrieve it's type // TODO: add a flag for not needing to prefix internal symbols // that do not start with hash if(has_prefix(id2string(identifier), "#") || identifier=="eval" || identifier=="nan") { symbol_tablet::symbolst::const_iterator s_it= symbol_table.symbols.find(identifier); if(s_it==symbol_table.symbols.end()) throw "unexpected internal symbol: "+id2string(identifier); else { // symbol already exists const symbolt &symbol=s_it->second; // type the expression symbol_expr.type()=symbol.type; } } else { // if this is a variable, we need to check if we already // prefixed it and add to the symbol table if it is not there already irep_idt identifier_base = identifier; if(!has_prefix(id2string(identifier), id2string(proc_name))) { identifier = add_prefix(identifier); symbol_expr.set_identifier(identifier); } symbol_tablet::symbolst::const_iterator s_it= symbol_table.symbols.find(identifier); if(s_it==symbol_table.symbols.end()) { // create new symbol symbolt new_symbol; new_symbol.name=identifier; new_symbol.type=symbol_expr.type(); new_symbol.base_name=identifier_base; new_symbol.mode="jsil"; new_symbol.is_type=false; new_symbol.is_lvalue=new_symbol.type.id()!=ID_code; // mark as already typechecked new_symbol.is_extern=true; if(symbol_table.add(new_symbol)) { error() << "failed to add symbol `" << new_symbol.name << "' in the symbol table" << eom; throw 0; } } else { // symbol already exists assert(!s_it->second.is_type); const symbolt &symbol=s_it->second; // type the expression symbol_expr.type()=symbol.type; } } }
static void print_help(struct isl_arg *arg, struct isl_prefixes *prefixes, void *opt) { int i; int any = 0; for (i = 0; arg[i].type != isl_arg_end; ++i) { if (arg[i].flags & ISL_ARG_HIDDEN) continue; switch (arg[i].type) { case isl_arg_flags: print_flags_help(&arg[i], prefixes, opt); any = 1; break; case isl_arg_choice: print_choice_help(&arg[i], prefixes, opt); any = 1; break; case isl_arg_bool: print_bool_help(&arg[i], prefixes, opt); any = 1; break; case isl_arg_int: print_int_help(&arg[i], prefixes, opt); any = 1; break; case isl_arg_long: print_long_help(&arg[i], prefixes, opt); any = 1; break; case isl_arg_ulong: print_ulong_help(&arg[i], prefixes); any = 1; break; case isl_arg_str: print_str_help(&arg[i], prefixes, opt); any = 1; break; case isl_arg_str_list: print_str_list_help(&arg[i], prefixes); any = 1; break; case isl_arg_alias: case isl_arg_version: case isl_arg_arg: case isl_arg_footer: case isl_arg_child: case isl_arg_user: case isl_arg_end: break; } } for (i = 0; arg[i].type != isl_arg_end; ++i) { void *child; int first; if (arg[i].type != isl_arg_child) continue; if (arg[i].flags & ISL_ARG_HIDDEN) continue; if (any) printf("\n"); if (arg[i].help_msg) printf(" %s\n", arg[i].help_msg); if (arg[i].offset == (size_t) -1) child = opt; else child = *(void **)(((char *) opt) + arg[i].offset); first = add_prefix(prefixes, arg[i].long_name); print_help(arg[i].u.child.child->args, prefixes, child); drop_prefix(prefixes, first); any = 1; } }
static void add_pvd(struct safe_buffer * sb, struct AdvPvd const *pvd, int cease_adv) { while (pvd) { /* create a temporary buffer to write the encapsulated options to until we calculate the total length of the outer PVD_CO option */ size_t total_len = 0; struct safe_buffer pvd_sb = SAFE_BUFFER_INIT; struct AdvPrefix *prefix = pvd->AdvPrefixList; while (prefix) { char pfx_str[INET6_ADDRSTRLEN]; addrtostr(&prefix->Prefix, pfx_str, sizeof(pfx_str)); prefix = prefix->next; } struct nd_opt_pvd pvdinfo; memset(&pvdinfo, 0, sizeof(pvdinfo)); /* create PVD_CO container option */ pvdinfo.nd_opt_pvd_container_type = ND_OPT_PVD_CONTAINER; /* initial length of PVD_CO option without encapsulated options */ pvdinfo.nd_opt_pvd_container_len = 1; total_len += pvdinfo.nd_opt_pvd_container_len; pvdinfo.nd_opt_pvd_container_s = 0; pvdinfo.nd_opt_pvd_container_nametype = 0; /* add PVD_ID option */ pvdinfo.nd_opt_pvd_id_type = ND_OPT_PVD_ID; pvdinfo.nd_opt_pvd_id_len = 5; total_len += pvdinfo.nd_opt_pvd_id_len; pvdinfo.nd_opt_pvd_id_idtype = 4; pvdinfo.nd_opt_pvd_id_idlen = 36; memcpy(&pvdinfo.nd_opt_pvd_id_pvdid, pvd->pvdid, sizeof(pvdinfo.nd_opt_pvd_id_pvdid));; /* add encapsulated ND options if specified */ if (pvd->AdvPrefixList) { total_len += add_prefix(&pvd_sb, pvd->AdvPrefixList, cease_adv); } if (pvd->AdvRouteList) { total_len += add_route(&pvd_sb, pvd->AdvRouteList, cease_adv); } if (pvd->AdvRDNSSList) { total_len += add_rdnss(&pvd_sb, pvd->AdvRDNSSList, cease_adv); } if (pvd->AdvDNSSLList) { total_len += add_dnssl(&pvd_sb, pvd->AdvDNSSLList, cease_adv); } /* if (iface->AdvLinkMTU != 0) { add_mtu(sb, iface->AdvLinkMTU); } if (iface->AdvSourceLLAddress && iface->sllao.if_hwaddr_len > 0) { add_sllao(sb, &iface->sllao); } if (iface->mipv6.AdvIntervalOpt) { add_mipv6_rtr_adv_interval(sb, iface->MaxRtrAdvInterval); } if (iface->mipv6.AdvHomeAgentInfo && (iface->mipv6.AdvMobRtrSupportFlag || iface->mipv6.HomeAgentPreference != 0 || iface->mipv6.HomeAgentLifetime != iface->ra_header_info.AdvDefaultLifetime)) { add_mipv6_home_agent_info(sb, &iface->mipv6); } */ if (pvd->AdvLowpanCoList) { total_len += add_lowpanco(&pvd_sb, pvd->AdvLowpanCoList); } if (pvd->AdvAbroList) { total_len += add_abro(&pvd_sb, pvd->AdvAbroList); } /* write out PVD_CO container option + PVD_ID option */ pvdinfo.nd_opt_pvd_container_len = total_len; safe_buffer_append(sb, &pvdinfo, sizeof(pvdinfo)); /* write out encapsulated ND options */ safe_buffer_append(sb, pvd_sb.buffer, pvd_sb.used); /* destroy a temporary buffer */ safe_buffer_free(&pvd_sb); pvd = pvd->next; } }
void parse_routers() { xmlDoc *doc = NULL; xmlNode *root_element = NULL; xmlNode *current = NULL; char* c; /*parse the file and get the DOM */ doc = xmlReadFile(config_path, NULL, 0); /*Get the root element node */ root_element = xmlDocGetRootElement(doc); current = root_element->children; request ="/config_ndpmon/actions_low_pri/sendmail/text()"; xmlobject = xmlXPathEval ((xmlChar*)request, xpctxt); if ((xmlobject->nodesetval!=NULL) || (strcmp("1", (char*)xmlobject->nodesetval->nodeTab[0]->content)!=0)) action_low_pri.sendmail=0; else action_low_pri.sendmail=1; xmlXPathFreeObject (xmlobject); while(current != NULL) { if (current->type == XML_ELEMENT_NODE) { if( !STRCMP(current->name,"routers") ) { xmlNode *router = current->children; while(router != NULL) { if (router->type == XML_ELEMENT_NODE) { if( !STRCMP(router->name,"router") ) { struct ether_addr mac; struct in6_addr lla; uint8_t param_curhoplimit=0; uint8_t param_flags_reserved=0; uint16_t param_router_lifetime=0; uint32_t param_reachable_timer=0; uint32_t param_retrans_timer=0; xmlNode *param = router->children; while(param != NULL) { if (param->type == XML_ELEMENT_NODE) { if( !STRCMP(param->name,"mac") ) { memcpy(&mac,ether_aton((char *)XML_GET_CONTENT(param->children)),sizeof(struct ether_addr)); } else if( !STRCMP(param->name,"lla") ) { inet_pton(AF_INET6,(char *)XML_GET_CONTENT(param->children), &lla); } else if( !STRCMP(param->name,"param_curhoplimit") ) { char* text = (char*)XML_GET_CONTENT(param->children); param_curhoplimit = atoi(text!=NULL?text:"0"); } else if( !STRCMP(param->name,"param_flags_reserved") ) { char* text = (char*)XML_GET_CONTENT(param->children); param_flags_reserved = atoi(text!=NULL?text:"0"); } else if( !STRCMP(param->name,"param_router_lifetime") ) { char* text = (char*)XML_GET_CONTENT(param->children); param_router_lifetime = atoi(text!=NULL?text:"0"); } else if( !STRCMP(param->name,"param_reachable_timer") ) { char* text = (char*)XML_GET_CONTENT(param->children); param_reachable_timer = atoi(text!=NULL?text:"0"); } else if( !STRCMP(param->name,"param_retrans_timer") ) { char* text = (char*)XML_GET_CONTENT(param->children); param_retrans_timer = atoi(text!=NULL?text:"0"); add_router(&routers, &mac, &lla, param_curhoplimit, param_flags_reserved, param_router_lifetime, param_reachable_timer, param_retrans_timer); } else if( !STRCMP(param->name,"addresses") ) { xmlNode *address = param->children; while(address != NULL) { if (address->type == XML_ELEMENT_NODE) { if( !STRCMP(address->name,"address") ) { struct in6_addr addr; inet_pton(AF_INET6,(char *)XML_GET_CONTENT(address->children), &addr); add_router_address(&routers, mac, addr); } } address = address->next; } } else if( !STRCMP(param->name,"prefixes") ) { xmlNode *prefix = param->children; while(prefix != NULL) { if (prefix->type == XML_ELEMENT_NODE) { if( !STRCMP(prefix->name,"prefix") ) { struct in6_addr addr; int mask=0; char buffer[INET6_ADDRSTRLEN]; struct _xmlAttr *attr = prefix->properties; while(attr != NULL) { if (attr->type == XML_ATTRIBUTE_NODE) { if( !STRCMP(attr->name,"mask") ) { c=(char *)XML_GET_CONTENT(attr->children); mask = atoi(c); /* mask = atoi((char *)XML_GET_CONTENT(attr->children)); */ } } attr = attr->next; } c=(char *)XML_GET_CONTENT(prefix->children); strncpy(buffer,c, INET6_ADDRSTRLEN); /* strcpy(buffer,(char *)XML_GET_CONTENT(prefix->children)); */ inet_pton(AF_INET6,buffer, &addr); add_prefix(&routers, lla, mac, addr,mask); } } prefix = prefix->next; } } } param = param->next; } } } router = router->next; } } } current = current->next; } xmlFreeDoc(doc); return; }
int cmd_blame(int argc, const char **argv, const char *prefix) { struct rev_info revs; const char *path; struct blame_scoreboard sb; struct blame_origin *o; struct blame_entry *ent = NULL; long dashdash_pos, lno; struct progress_info pi = { NULL, 0 }; struct string_list range_list = STRING_LIST_INIT_NODUP; int output_option = 0, opt = 0; int show_stats = 0; const char *revs_file = NULL; const char *contents_from = NULL; const struct option options[] = { OPT_BOOL(0, "incremental", &incremental, N_("Show blame entries as we find them, incrementally")), OPT_BOOL('b', NULL, &blank_boundary, N_("Show blank SHA-1 for boundary commits (Default: off)")), OPT_BOOL(0, "root", &show_root, N_("Do not treat root commits as boundaries (Default: off)")), OPT_BOOL(0, "show-stats", &show_stats, N_("Show work cost statistics")), OPT_BOOL(0, "progress", &show_progress, N_("Force progress reporting")), OPT_BIT(0, "score-debug", &output_option, N_("Show output score for blame entries"), OUTPUT_SHOW_SCORE), OPT_BIT('f', "show-name", &output_option, N_("Show original filename (Default: auto)"), OUTPUT_SHOW_NAME), OPT_BIT('n', "show-number", &output_option, N_("Show original linenumber (Default: off)"), OUTPUT_SHOW_NUMBER), OPT_BIT('p', "porcelain", &output_option, N_("Show in a format designed for machine consumption"), OUTPUT_PORCELAIN), OPT_BIT(0, "line-porcelain", &output_option, N_("Show porcelain format with per-line commit information"), OUTPUT_PORCELAIN|OUTPUT_LINE_PORCELAIN), OPT_BIT('c', NULL, &output_option, N_("Use the same output mode as git-annotate (Default: off)"), OUTPUT_ANNOTATE_COMPAT), OPT_BIT('t', NULL, &output_option, N_("Show raw timestamp (Default: off)"), OUTPUT_RAW_TIMESTAMP), OPT_BIT('l', NULL, &output_option, N_("Show long commit SHA1 (Default: off)"), OUTPUT_LONG_OBJECT_NAME), OPT_BIT('s', NULL, &output_option, N_("Suppress author name and timestamp (Default: off)"), OUTPUT_NO_AUTHOR), OPT_BIT('e', "show-email", &output_option, N_("Show author email instead of name (Default: off)"), OUTPUT_SHOW_EMAIL), OPT_BIT('w', NULL, &xdl_opts, N_("Ignore whitespace differences"), XDF_IGNORE_WHITESPACE), /* * The following two options are parsed by parse_revision_opt() * and are only included here to get included in the "-h" * output: */ { OPTION_LOWLEVEL_CALLBACK, 0, "indent-heuristic", NULL, NULL, N_("Use an experimental heuristic to improve diffs"), PARSE_OPT_NOARG, parse_opt_unknown_cb }, OPT_BIT(0, "minimal", &xdl_opts, N_("Spend extra cycles to find better match"), XDF_NEED_MINIMAL), OPT_STRING('S', NULL, &revs_file, N_("file"), N_("Use revisions from <file> instead of calling git-rev-list")), OPT_STRING(0, "contents", &contents_from, N_("file"), N_("Use <file>'s contents as the final image")), { OPTION_CALLBACK, 'C', NULL, &opt, N_("score"), N_("Find line copies within and across files"), PARSE_OPT_OPTARG, blame_copy_callback }, { OPTION_CALLBACK, 'M', NULL, &opt, N_("score"), N_("Find line movements within and across files"), PARSE_OPT_OPTARG, blame_move_callback }, OPT_STRING_LIST('L', NULL, &range_list, N_("n,m"), N_("Process only line range n,m, counting from 1")), OPT__ABBREV(&abbrev), OPT_END() }; struct parse_opt_ctx_t ctx; int cmd_is_annotate = !strcmp(argv[0], "annotate"); struct range_set ranges; unsigned int range_i; long anchor; git_config(git_blame_config, &output_option); init_revisions(&revs, NULL); revs.date_mode = blame_date_mode; revs.diffopt.flags.allow_textconv = 1; revs.diffopt.flags.follow_renames = 1; save_commit_buffer = 0; dashdash_pos = 0; show_progress = -1; parse_options_start(&ctx, argc, argv, prefix, options, PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_ARGV0); for (;;) { switch (parse_options_step(&ctx, options, blame_opt_usage)) { case PARSE_OPT_HELP: exit(129); case PARSE_OPT_DONE: if (ctx.argv[0]) dashdash_pos = ctx.cpidx; goto parse_done; } if (!strcmp(ctx.argv[0], "--reverse")) { ctx.argv[0] = "--children"; reverse = 1; } parse_revision_opt(&revs, &ctx, options, blame_opt_usage); } parse_done: no_whole_file_rename = !revs.diffopt.flags.follow_renames; xdl_opts |= revs.diffopt.xdl_opts & XDF_INDENT_HEURISTIC; revs.diffopt.flags.follow_renames = 0; argc = parse_options_end(&ctx); if (incremental || (output_option & OUTPUT_PORCELAIN)) { if (show_progress > 0) die(_("--progress can't be used with --incremental or porcelain formats")); show_progress = 0; } else if (show_progress < 0) show_progress = isatty(2); if (0 < abbrev && abbrev < GIT_SHA1_HEXSZ) /* one more abbrev length is needed for the boundary commit */ abbrev++; else if (!abbrev) abbrev = GIT_SHA1_HEXSZ; if (revs_file && read_ancestry(revs_file)) die_errno("reading graft file '%s' failed", revs_file); if (cmd_is_annotate) { output_option |= OUTPUT_ANNOTATE_COMPAT; blame_date_mode.type = DATE_ISO8601; } else { blame_date_mode = revs.date_mode; } /* The maximum width used to show the dates */ switch (blame_date_mode.type) { case DATE_RFC2822: blame_date_width = sizeof("Thu, 19 Oct 2006 16:00:04 -0700"); break; case DATE_ISO8601_STRICT: blame_date_width = sizeof("2006-10-19T16:00:04-07:00"); break; case DATE_ISO8601: blame_date_width = sizeof("2006-10-19 16:00:04 -0700"); break; case DATE_RAW: blame_date_width = sizeof("1161298804 -0700"); break; case DATE_UNIX: blame_date_width = sizeof("1161298804"); break; case DATE_SHORT: blame_date_width = sizeof("2006-10-19"); break; case DATE_RELATIVE: /* * TRANSLATORS: This string is used to tell us the * maximum display width for a relative timestamp in * "git blame" output. For C locale, "4 years, 11 * months ago", which takes 22 places, is the longest * among various forms of relative timestamps, but * your language may need more or fewer display * columns. */ blame_date_width = utf8_strwidth(_("4 years, 11 months ago")) + 1; /* add the null */ break; case DATE_NORMAL: blame_date_width = sizeof("Thu Oct 19 16:00:04 2006 -0700"); break; case DATE_STRFTIME: blame_date_width = strlen(show_date(0, 0, &blame_date_mode)) + 1; /* add the null */ break; } blame_date_width -= 1; /* strip the null */ if (revs.diffopt.flags.find_copies_harder) opt |= (PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE | PICKAXE_BLAME_COPY_HARDER); /* * We have collected options unknown to us in argv[1..unk] * which are to be passed to revision machinery if we are * going to do the "bottom" processing. * * The remaining are: * * (1) if dashdash_pos != 0, it is either * "blame [revisions] -- <path>" or * "blame -- <path> <rev>" * * (2) otherwise, it is one of the two: * "blame [revisions] <path>" * "blame <path> <rev>" * * Note that we must strip out <path> from the arguments: we do not * want the path pruning but we may want "bottom" processing. */ if (dashdash_pos) { switch (argc - dashdash_pos - 1) { case 2: /* (1b) */ if (argc != 4) usage_with_options(blame_opt_usage, options); /* reorder for the new way: <rev> -- <path> */ argv[1] = argv[3]; argv[3] = argv[2]; argv[2] = "--"; /* FALLTHROUGH */ case 1: /* (1a) */ path = add_prefix(prefix, argv[--argc]); argv[argc] = NULL; break; default: usage_with_options(blame_opt_usage, options); } } else { if (argc < 2) usage_with_options(blame_opt_usage, options); if (argc == 3 && is_a_rev(argv[argc - 1])) { /* (2b) */ path = add_prefix(prefix, argv[1]); argv[1] = argv[2]; } else { /* (2a) */ if (argc == 2 && is_a_rev(argv[1]) && !get_git_work_tree()) die("missing <path> to blame"); path = add_prefix(prefix, argv[argc - 1]); } argv[argc - 1] = "--"; } revs.disable_stdin = 1; setup_revisions(argc, argv, &revs, NULL); init_scoreboard(&sb); sb.revs = &revs; sb.contents_from = contents_from; sb.reverse = reverse; setup_scoreboard(&sb, path, &o); lno = sb.num_lines; if (lno && !range_list.nr) string_list_append(&range_list, "1"); anchor = 1; range_set_init(&ranges, range_list.nr); for (range_i = 0; range_i < range_list.nr; ++range_i) { long bottom, top; if (parse_range_arg(range_list.items[range_i].string, nth_line_cb, &sb, lno, anchor, &bottom, &top, sb.path)) usage(blame_usage); if (lno < top || ((lno || bottom) && lno < bottom)) die(Q_("file %s has only %lu line", "file %s has only %lu lines", lno), path, lno); if (bottom < 1) bottom = 1; if (top < 1) top = lno; bottom--; range_set_append_unsafe(&ranges, bottom, top); anchor = top + 1; } sort_and_merge_range_set(&ranges); for (range_i = ranges.nr; range_i > 0; --range_i) { const struct range *r = &ranges.ranges[range_i - 1]; ent = blame_entry_prepend(ent, r->start, r->end, o); } o->suspects = ent; prio_queue_put(&sb.commits, o->commit); blame_origin_decref(o); range_set_release(&ranges); string_list_clear(&range_list, 0); sb.ent = NULL; sb.path = path; if (blame_move_score) sb.move_score = blame_move_score; if (blame_copy_score) sb.copy_score = blame_copy_score; sb.debug = DEBUG; sb.on_sanity_fail = &sanity_check_on_fail; sb.show_root = show_root; sb.xdl_opts = xdl_opts; sb.no_whole_file_rename = no_whole_file_rename; read_mailmap(&mailmap, NULL); sb.found_guilty_entry = &found_guilty_entry; sb.found_guilty_entry_data = π if (show_progress) pi.progress = start_delayed_progress(_("Blaming lines"), sb.num_lines); assign_blame(&sb, opt); stop_progress(&pi.progress); if (!incremental) setup_pager(); else return 0; blame_sort_final(&sb); blame_coalesce(&sb); if (!(output_option & OUTPUT_PORCELAIN)) find_alignment(&sb, &output_option); output(&sb, output_option); free((void *)sb.final_buf); for (ent = sb.ent; ent; ) { struct blame_entry *e = ent->next; free(ent); ent = e; } if (show_stats) { printf("num read blob: %d\n", sb.num_read_blob); printf("num get patch: %d\n", sb.num_get_patch); printf("num commits: %d\n", sb.num_commits); } return 0; }
static int i386_intel_operand (char *operand_string, int got_a_float) { char *saved_input_line_pointer, *buf; segT exp_seg; expressionS exp, *expP; char suffix = 0; int ret; /* Initialize state structure. */ intel_state.op_modifier = O_absent; intel_state.is_mem = 0; intel_state.base = NULL; intel_state.index = NULL; intel_state.seg = NULL; operand_type_set (&intel_state.reloc_types, ~0); gas_assert (!intel_state.in_offset); gas_assert (!intel_state.in_bracket); gas_assert (!intel_state.in_scale); saved_input_line_pointer = input_line_pointer; input_line_pointer = buf = xstrdup (operand_string); /* A '$' followed by an identifier char is an identifier. Otherwise, it's operator '.' followed by an expression. */ if (*buf == '$' && !is_identifier_char (buf[1])) *buf = '.'; intel_syntax = -1; memset (&exp, 0, sizeof(exp)); exp_seg = expression (&exp); ret = i386_intel_simplify (&exp); intel_syntax = 1; SKIP_WHITESPACE (); if (!is_end_of_line[(unsigned char) *input_line_pointer]) { as_bad (_("junk `%s' after expression"), input_line_pointer); ret = 0; } else if (exp.X_op == O_illegal || exp.X_op == O_absent) { as_bad (_("invalid expression")); ret = 0; } input_line_pointer = saved_input_line_pointer; free (buf); gas_assert (!intel_state.in_offset); gas_assert (!intel_state.in_bracket); gas_assert (!intel_state.in_scale); if (!ret) return 0; if (intel_state.op_modifier != O_absent && current_templates->start->base_opcode != 0x8d /* lea */) { i.types[this_operand].bitfield.unspecified = 0; switch (intel_state.op_modifier) { case O_byte_ptr: i.types[this_operand].bitfield.byte = 1; suffix = BYTE_MNEM_SUFFIX; break; case O_word_ptr: i.types[this_operand].bitfield.word = 1; if ((current_templates->start->name[0] == 'l' && current_templates->start->name[2] == 's' && current_templates->start->name[3] == 0) || current_templates->start->base_opcode == 0x62 /* bound */) suffix = BYTE_MNEM_SUFFIX; /* so it will cause an error */ else if (got_a_float == 2) /* "fi..." */ suffix = SHORT_MNEM_SUFFIX; else suffix = WORD_MNEM_SUFFIX; break; case O_dword_ptr: i.types[this_operand].bitfield.dword = 1; if ((current_templates->start->name[0] == 'l' && current_templates->start->name[2] == 's' && current_templates->start->name[3] == 0) || current_templates->start->base_opcode == 0x62 /* bound */) suffix = WORD_MNEM_SUFFIX; else if (flag_code == CODE_16BIT && (current_templates->start->opcode_modifier.jump || current_templates->start->opcode_modifier.jumpdword)) suffix = LONG_DOUBLE_MNEM_SUFFIX; else if (got_a_float == 1) /* "f..." */ suffix = SHORT_MNEM_SUFFIX; else suffix = LONG_MNEM_SUFFIX; break; case O_fword_ptr: i.types[this_operand].bitfield.fword = 1; if (current_templates->start->name[0] == 'l' && current_templates->start->name[2] == 's' && current_templates->start->name[3] == 0) suffix = LONG_MNEM_SUFFIX; else if (!got_a_float) { if (flag_code == CODE_16BIT) add_prefix (DATA_PREFIX_OPCODE); suffix = LONG_DOUBLE_MNEM_SUFFIX; } else suffix = BYTE_MNEM_SUFFIX; /* so it will cause an error */ break; case O_qword_ptr: i.types[this_operand].bitfield.qword = 1; if (current_templates->start->base_opcode == 0x62 /* bound */ || got_a_float == 1) /* "f..." */ suffix = LONG_MNEM_SUFFIX; else suffix = QWORD_MNEM_SUFFIX; break; case O_tbyte_ptr: i.types[this_operand].bitfield.tbyte = 1; if (got_a_float == 1) suffix = LONG_DOUBLE_MNEM_SUFFIX; else suffix = BYTE_MNEM_SUFFIX; /* so it will cause an error */ break; case O_oword_ptr: case O_xmmword_ptr: i.types[this_operand].bitfield.xmmword = 1; suffix = XMMWORD_MNEM_SUFFIX; break; case O_ymmword_ptr: i.types[this_operand].bitfield.ymmword = 1; suffix = YMMWORD_MNEM_SUFFIX; break; case O_far_ptr: suffix = LONG_DOUBLE_MNEM_SUFFIX; /* FALLTHROUGH */ case O_near_ptr: if (!current_templates->start->opcode_modifier.jump && !current_templates->start->opcode_modifier.jumpdword) suffix = got_a_float /* so it will cause an error */ ? BYTE_MNEM_SUFFIX : LONG_DOUBLE_MNEM_SUFFIX; break; default: BAD_CASE (intel_state.op_modifier); break; } if (!i.suffix) i.suffix = suffix; else if (i.suffix != suffix) { as_bad (_("conflicting operand size modifiers")); return 0; } } /* Operands for jump/call need special consideration. */ if (current_templates->start->opcode_modifier.jump || current_templates->start->opcode_modifier.jumpdword || current_templates->start->opcode_modifier.jumpintersegment) { if (i.op[this_operand].regs || intel_state.base || intel_state.index || intel_state.is_mem > 1) i.types[this_operand].bitfield.jumpabsolute = 1; else switch (intel_state.op_modifier) { case O_near_ptr: if (intel_state.seg) i.types[this_operand].bitfield.jumpabsolute = 1; else intel_state.is_mem = 1; break; case O_far_ptr: case O_absent: if (!intel_state.seg) { intel_state.is_mem = 1; if (intel_state.op_modifier == O_absent) break; as_bad (_("cannot infer the segment part of the operand")); return 0; } else if (S_GET_SEGMENT (intel_state.seg) == reg_section) i.types[this_operand].bitfield.jumpabsolute = 1; else { i386_operand_type types; if (i.imm_operands >= MAX_IMMEDIATE_OPERANDS) { as_bad (_("at most %d immediate operands are allowed"), MAX_IMMEDIATE_OPERANDS); return 0; } expP = &im_expressions[i.imm_operands++]; memset (expP, 0, sizeof(*expP)); expP->X_op = O_symbol; expP->X_add_symbol = intel_state.seg; i.op[this_operand].imms = expP; resolve_expression (expP); operand_type_set (&types, ~0); if (!i386_finalize_immediate (S_GET_SEGMENT (intel_state.seg), expP, types, operand_string)) return 0; if (i.operands < MAX_OPERANDS) { this_operand = i.operands++; i.types[this_operand].bitfield.unspecified = 1; } if (suffix == LONG_DOUBLE_MNEM_SUFFIX) i.suffix = 0; intel_state.seg = NULL; intel_state.is_mem = 0; } break; default: i.types[this_operand].bitfield.jumpabsolute = 1; break; } if (i.types[this_operand].bitfield.jumpabsolute) intel_state.is_mem |= 1; } else if (intel_state.seg) intel_state.is_mem |= 1; if (i.op[this_operand].regs) { i386_operand_type temp; /* Register operand. */ if (intel_state.base || intel_state.index || intel_state.seg) { as_bad (_("invalid operand")); return 0; } temp = i.op[this_operand].regs->reg_type; temp.bitfield.baseindex = 0; i.types[this_operand] = operand_type_or (i.types[this_operand], temp); i.types[this_operand].bitfield.unspecified = 0; ++i.reg_operands; } else if (intel_state.base || intel_state.index || intel_state.seg || intel_state.is_mem) { /* Memory operand. */ if (i.mem_operands >= 2 - !current_templates->start->opcode_modifier.isstring) { as_bad (_("too many memory references for `%s'"), current_templates->start->name); return 0; } expP = &disp_expressions[i.disp_operands]; memcpy (expP, &exp, sizeof(exp)); resolve_expression (expP); if (expP->X_op != O_constant || expP->X_add_number || (!intel_state.base && !intel_state.index)) { i.op[this_operand].disps = expP; i.disp_operands++; if (flag_code == CODE_64BIT) { i.types[this_operand].bitfield.disp32 = 1; if (!i.prefix[ADDR_PREFIX]) { i.types[this_operand].bitfield.disp64 = 1; i.types[this_operand].bitfield.disp32s = 1; } } else if (!i.prefix[ADDR_PREFIX] ^ (flag_code == CODE_16BIT)) i.types[this_operand].bitfield.disp32 = 1; else i.types[this_operand].bitfield.disp16 = 1; #if defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) /* * exp_seg is used only for verification in * i386_finalize_displacement, and we can end up seeing reg_section * here - but we know we removed all registers from the expression * (or error-ed on any remaining ones) in i386_intel_simplify. I * consider the check in i386_finalize_displacement bogus anyway, in * particular because it doesn't allow for expr_section, so I'd * rather see that check (and the similar one in * i386_finalize_immediate) use SEG_NORMAL(), but not being an a.out * expert I can't really say whether that would have other bad side * effects. */ if (OUTPUT_FLAVOR == bfd_target_aout_flavour && exp_seg == reg_section) exp_seg = expP->X_op != O_constant ? undefined_section : absolute_section; #endif if (!i386_finalize_displacement (exp_seg, expP, intel_state.reloc_types, operand_string)) return 0; } if (intel_state.base || intel_state.index) i.types[this_operand].bitfield.baseindex = 1; if (intel_state.seg) { for (;;) { expP = symbol_get_value_expression (intel_state.seg); if (expP->X_op != O_full_ptr) break; intel_state.seg = expP->X_add_symbol; } if (expP->X_op != O_register) { as_bad (_("segment register name expected")); return 0; } if (!i386_regtab[expP->X_add_number].reg_type.bitfield.sreg2 && !i386_regtab[expP->X_add_number].reg_type.bitfield.sreg3) { as_bad (_("invalid use of register")); return 0; } switch (i386_regtab[expP->X_add_number].reg_num) { case 0: i.seg[i.mem_operands] = &es; break; case 1: i.seg[i.mem_operands] = &cs; break; case 2: i.seg[i.mem_operands] = &ss; break; case 3: i.seg[i.mem_operands] = &ds; break; case 4: i.seg[i.mem_operands] = &fs; break; case 5: i.seg[i.mem_operands] = &gs; break; case RegFlat: i.seg[i.mem_operands] = NULL; break; } } /* Swap base and index in 16-bit memory operands like [si+bx]. Since i386_index_check is also used in AT&T mode we have to do that here. */ if (intel_state.base && intel_state.index && intel_state.base->reg_type.bitfield.reg16 && intel_state.index->reg_type.bitfield.reg16 && intel_state.base->reg_num >= 6 && intel_state.index->reg_num < 6) { i.base_reg = intel_state.index; i.index_reg = intel_state.base; } else { i.base_reg = intel_state.base; i.index_reg = intel_state.index; } if (!i386_index_check (operand_string)) return 0; i.types[this_operand].bitfield.mem = 1; ++i.mem_operands; } else { /* Immediate. */ if (i.imm_operands >= MAX_IMMEDIATE_OPERANDS) { as_bad (_("at most %d immediate operands are allowed"), MAX_IMMEDIATE_OPERANDS); return 0; } expP = &im_expressions[i.imm_operands++]; i.op[this_operand].imms = expP; *expP = exp; return i386_finalize_immediate (exp_seg, expP, intel_state.reloc_types, operand_string); } return 1; }
static void unbuffered(const char *arg0, int argc, char **argv) { TINO_BUF buf; if (!line_cont_suffix && !flag_hexdump) if (flag_localtime || flag_linecount || flag_utc || flag_verbose) line_cont_suffix = "\n"; producer = 0; if (argc) { int fds[2], redir[TINO_OPEN_MAX], fdmax, i; if (tino_file_pipeE(fds)) tino_exit("cannot create pipe"); fdmax = fd_in<3 ? 3 : fd_in+1; for (i=fdmax; --i>=0; ) redir[i] = -1; /* preserve all FDs */ if (fd_in<0) fd_in = 1; redir[2] = flag_both ? fds[1] : 2; /* catch stderr on -d, too */ if (fd_in==2) redir[1] = redir[2]; /* swap stdin/stderr on -i2 */ redir[fd_in] = fds[1]; /* catch the given FD */ /* catch the child's output for preprocessing */ producer = tino_fork_execO(redir, fdmax, argv, NULL, 0, NULL); tino_file_closeE(fds[1]); fd_in = fds[0]; #if 0 /* Following is a mess. It is only needed for a consumer, though. * With a producer we see EOF on the pipe. * Shall be handled implicitely by a library somehow: */ tino_sigset(SIGCHLD, terminate); terminate(); /* catch early terminated childs */ #endif } tino_buf_initO(&buf); if (producer && flag_verbose) { start_line(1, 1); add_prefix("start"); for (; *argv; argv++) add_prefix(" '%s'", *argv); /* XXX TODO sadly, escape is implemented in tino_io, not in tino_buf */ add_prefix("\n"); out_open(); tino_data_putsA(&out, tino_buf_get_sN(&prefix)); } if (fd_in<0) fd_in = 0; while (tino_buf_readE(&buf, fd_in, -1)) { size_t n; out_open(); /* XXX TODO MISSING: * for flag_buffer==1 or flag_buffer==2 * immediately write STDOUT(1), * but buffer STDERR(dump_line) */ while ((n=tino_buf_get_lenO(&buf))>0) { const char *ptr; size_t k, p; ptr = tino_buf_getN(&buf); p = 0; for (k=0; k<n; k++) if (ptr[k]==line_terminator) { dump_line(ptr+p, k-p, 1); p = k+1; } /* k=n */ if (flag_buffer && p) n = p; /* do not output incomplete line */ else if ((flag_buffer>1 && n<=99999) || flag_buffer>2) break; /* buffer fragments */ /* We shall, nonblockingly, read additional input data here, * if available. Leave this to future. */ TINO_XXX; if (p<n) dump_line(ptr+p, n-p, 0); if (flag_cat) tino_buf_advanceO(&buf, n); else if (tino_buf_write_away_allE(&buf, 1, n)) { /* silently drop out */ *tino_main_errflag = 1; break; } if (flag_buffer) break; } out_flush(); } { size_t n; /* in case of flag_buffer: send the rest */ if ((n=tino_buf_get_lenO(&buf))>0) { const char *ptr; out_open(); ptr = tino_buf_getN(&buf); dump_line(ptr, n, 0); if (!flag_cat && tino_buf_write_away_allE(&buf, 1, n)) *tino_main_errflag = 1; } } if (producer) { char *cause; #if 0 tino_sigdummy(SIGCHLD); /* prevent reentrance of waitpid() */ #endif /* wait for child to finish after the pipe was closed, * so give the child the chance to terminate. */ tino_file_closeE(0); *tino_main_errflag = tino_wait_child_exact(producer, &cause); if (flag_verbose) { start_line(1, 1); add_prefix("end %s\n", cause); out_open(); tino_data_putsA(&out, tino_buf_get_sN(&prefix)); } } out_close(); /* close(2) */ }