static long compute_offset(os_context_t *context, lispobj code) { if (code == NIL) return 0; else { uword_t code_start; struct code *codeptr = (struct code *)native_pointer(code); #ifdef LISP_FEATURE_HPPA uword_t pc = *os_context_pc_addr(context) & ~3; #else uword_t pc = *os_context_pc_addr(context); #endif code_start = (uword_t)codeptr + HeaderValue(codeptr->header)*sizeof(lispobj); if (pc < code_start) return 0; else { uword_t offset = pc - code_start; if (offset >= (uword_t)fixnum_value(codeptr->code_size)) return 0; else return make_fixnum(offset); } } }
static lispobj find_code(os_context_t *context) { #ifdef reg_CODE lispobj code = *os_context_register_addr(context, reg_CODE); lispobj header; if (lowtag_of(code) != OTHER_POINTER_LOWTAG) return NIL; header = *(lispobj *)(code-OTHER_POINTER_LOWTAG); if (widetag_of(header) == CODE_HEADER_WIDETAG) return code; else return code - HeaderValue(header)*sizeof(lispobj); #else lispobj codeptr = (lispobj)component_ptr_from_pc((lispobj *)(*os_context_pc_addr(context))); if (codeptr == 0) return NIL; else return codeptr + OTHER_POINTER_LOWTAG; #endif }
static void *compute_pc(lispobj code_obj, int pc_offset) { struct code *code; code = (struct code *)native_pointer(code_obj); return (void *)((char *)code + HeaderValue(code->header)*sizeof(lispobj) + pc_offset); }
struct compiled_debug_fun * debug_function_from_pc (struct code* code, void *pc) { uword_t code_header_len = sizeof(lispobj) * HeaderValue(code->header); uword_t offset = (uword_t) pc - (uword_t) code - code_header_len; struct compiled_debug_fun *df; struct compiled_debug_info *di; struct vector *v; int i, len; if (lowtag_of(code->debug_info) != INSTANCE_POINTER_LOWTAG) return 0; di = (struct compiled_debug_info *) native_pointer(code->debug_info); v = (struct vector *) native_pointer(di->fun_map); len = fixnum_value(v->length); df = (struct compiled_debug_fun *) native_pointer(v->data[0]); if (len == 1) return df; for (i = 1;; i += 2) { unsigned next_pc; if (i == len) return ((struct compiled_debug_fun *) native_pointer(v->data[i - 1])); if (offset >= (uword_t)fixnum_value(df->elsewhere_pc)) { struct compiled_debug_fun *p = ((struct compiled_debug_fun *) native_pointer(v->data[i + 1])); next_pc = fixnum_value(p->elsewhere_pc); } else next_pc = fixnum_value(v->data[i]); if (offset < next_pc) return ((struct compiled_debug_fun *) native_pointer(v->data[i - 1])); } return NULL; }
HeaderValue HttpReqImpl::getHeaderField(ConstStrA field) const { const HdrStr *val = requestHdrs.find(field); if (val == 0) return HeaderValue(); else return HeaderValue(ConstStrA(*val)); }
HttpClient::HeaderValue HttpClient::getHeader(ConstStrA field) const { const StrRef *strr = respHdrMap.find(field); if (strr == 0) return HeaderValue(); return HeaderValue(*strr); }
virtual HeaderValue getHeaderField(HeaderField ) const {return HeaderValue();}
virtual HeaderValue getHeaderField(ConstStrA ) const {return HeaderValue();}
bool PartHandler::addHeader( const String& sKeyu, const String& sValue ) { TRACE( "Adding header: %s: %s", sKeyu.getRawStorage(), sValue.getRawStorage() ); // probably this is an overkill String sKey = URI::URLDecode( sKeyu ); HeaderMap::iterator iadd = m_mHeaders.find( sKey ); if( iadd == m_mHeaders.end() ) { iadd = m_mHeaders.insert( HeaderMap::value_type( sKey, HeaderValue() ) ).first; } HeaderValue& hv = iadd->second; // we can accept, but not canonicize, invalid parameters bool bValid = hv.parseValue( sValue ); if ( ! bValid ) { hv.setRawValue( sValue ); } // a bit of checks if ( sKey.compareIgnoreCase( "Content-Disposition" ) == 0 ) { if( ! bValid ) { m_sError = "Failed to parse header value: " + sValue; return false; } HeaderValue::ParamMap::const_iterator ni = hv.parameters().find( "name" ); if ( ni != hv.parameters().end() ) { m_sPartName = ni->second; } else { // can't be a well formed content-disposition m_sError = "Invalid Content-Disposition"; return false; } ni = hv.parameters().find( "filename" ); if ( ni != hv.parameters().end() ) { // The filename may be empty if the field wasn't sent. m_sPartFileName = ni->second; m_bPartIsFile = true; } } else if ( sKey.compareIgnoreCase( "Content-Type" ) == 0 ) { if( ! bValid ) { m_sError = "Failed to parse header value: " + sValue; return false; } if( ! hv.hasValue() ) { m_sError = "Invalid Content-Type"; return false; } m_sPartContentType = hv.value(); if( m_sPartContentType.startsWith("multipart/") ) { m_sBoundary = hv.parameters()["boundary"]; TRACE( "found boundary header: %s", m_sBoundary.getRawStorage() ); if( m_sBoundary.size() == 0 ) { m_sError = "Missing boundary in multipart Content-Type"; return false; } } } else if ( sKey.compareIgnoreCase( "Content-Length" ) == 0 ) { if( ! hv.hasValue() ) { m_sError = "Invalid Content-Length"; return false; } if (! hv.value().parseInt( m_nPartSize ) ) { m_sError = "Invalid Content-Length"; return false; } } return true; }