Exemplo n.º 1
0
 void set(char const * name, char const * value) {
     bool error = false;
     std::string error_msg;
     #pragma omp critical (gparams)
     {
         try {
             symbol m, p;
             normalize(name, m, p);
             if (m == symbol::null) {
                 validate_type(p, value, get_param_descrs());
                 set(get_param_descrs(), p, value, m);
             }
             else {
                 param_descrs * d;
                 if (get_module_param_descrs().find(m, d)) {
                     validate_type(p, value, *d);
                     set(*d, p, value, m);
                 }
                 else {
                     std::stringstream strm;
                     strm << "invalid parameter, unknown module '" << m << "'";
                     throw exception(strm.str());
                 }
             }
         }
         catch (z3_exception & ex) {
             // Exception cannot cross critical section boundaries.
             error = true;
             error_msg = ex.msg();
         }
     }
     if (error)
         throw exception(std::move(error_msg));
 }
Exemplo n.º 2
0
static gboolean
gnc_html_price_url_cb (const char *location, const char *label,
                       gboolean new_window, GNCURLResult *result)
{
    QofBook     * book = gnc_get_current_book();
    GncGUID       guid;
    QofInstance * entity = NULL;

    g_return_val_if_fail (location != NULL, FALSE);
    g_return_val_if_fail (result != NULL, FALSE);

    result->load_to_stream = FALSE;

    /* href="gnc-register:guid=12345678901234567890123456789012" */
    if (strncmp ("price-guid=", location, strlen ("price-guid=")) == 0)
    {
        if (!validate_type("price-guid=", location, GNC_ID_PRICE, result, &guid, &entity))
            return FALSE;

        if (!gnc_price_edit_by_guid (NULL, &guid))
        {
            result->error_message = g_strdup_printf (_("No such price: %s"),
                                    location);
            return FALSE;
        }
    }
    else
    {
        result->error_message = g_strdup_printf (_("Badly formed URL %s"),
                                location);
        return FALSE;
    }

    return TRUE;
}
Exemplo n.º 3
0
void __indirect_glDrawElements(GLenum mode, GLsizei count, GLenum type,
		    const GLvoid *indices)
{
    __GLXcontext *gc = __glXGetCurrentContext();
    const __GLXattribute * state = 
       (const __GLXattribute *)(gc->client_state_private);
    struct array_state_vector * arrays = state->array_state;


    if ( validate_mode(gc, mode) && validate_count(gc, count)
	 && validate_type(gc, type) ) {
	if ( ! arrays->array_info_cache_valid ) {
	    fill_array_info_cache( arrays );
	}

	arrays->DrawElements(mode, count, type, indices);
    }
}
Exemplo n.º 4
0
    bool read_pkt(buf_ptr &buf_out)
    {
        buf_ptr buf_in = super::buffer();

        if (!is_done() && is_partial_complete()) {
            get_pkt(buf_out);
            return true;
        } else if (is_done()) {
            increment();
            return false;
        }

        while (true) {
            super::rlnc_hdr_reserve(buf_in);

            if (!super::read_pkt(buf_in))
                break;

            if (!validate_type(buf_in))
                continue;

            put_pkt(buf_in);
            process_rank();
            buf_in->reset();

            if (is_complete()) {
                send_ack(super::rlnc_hdr_block(), base::m_coder->rank());
                break;
            }
        }

        if (!is_partial_complete())
            return false;

        get_pkt(buf_out);

        return true;
    }
Exemplo n.º 5
0
void __indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei *count,
			 GLenum type, const GLvoid ** indices,
			 GLsizei primcount)
{
    __GLXcontext *gc = __glXGetCurrentContext();
    const __GLXattribute * state = 
       (const __GLXattribute *)(gc->client_state_private);
    struct array_state_vector * arrays = state->array_state;
    GLsizei  i;


    if ( validate_mode(gc, mode) && validate_type(gc, type) ) {
	if ( ! arrays->array_info_cache_valid ) {
	    fill_array_info_cache( arrays );
	}

	for ( i = 0 ; i < primcount ; i++ ) {
	    if ( validate_count( gc, count[i] ) ) {
		arrays->DrawElements(mode, count[i], type, indices[i]);
	    }
	}
    }
}
Exemplo n.º 6
0
int ts::demuxer::demux_ts_packet(const char* ptr)
{
    u_int32_t timecode=0;
    if(hdmv)
    {
        timecode=to_int32(ptr)&0x3fffffff;
        ptr+=4;
    }
    
    const char* end_ptr=ptr+188;
    
    if(ptr[0]!=0x47)            // ts sync byte
        return -1;
    
    u_int16_t pid=to_int(ptr+1);
    u_int8_t flags=to_byte(ptr+3);
    
    bool transport_error=pid&0x8000;
    bool payload_unit_start_indicator=pid&0x4000;
    bool adaptation_field_exist=flags&0x20;
    bool payload_data_exist=flags&0x10;
    u_int8_t continuity_counter=flags&0x0f;
    pid&=0x1fff;
    
    if(transport_error)
        return -2;
    
    if(pid==0x1fff || !payload_data_exist)
        return 0;
    
    ptr+=4;
    
    // skip adaptation field
    if(adaptation_field_exist)
    {
        ptr+=to_byte(ptr)+1;
        if(ptr>=end_ptr)
            return -3;
    }
#ifdef VERBOSE
    if(dump==1)
        printf("%.4x: [%c%c%c%c] %u.%i\n",
               pid,
               transport_error?'e':'-',
               payload_data_exist?'p':'-',
               payload_unit_start_indicator?'s':'-',
               adaptation_field_exist?'a':'-',
               timecode,
               continuity_counter
               );
#endif
    
    
    stream& s=streams[pid];
    
    if(!pid || (s.channel!=0xffff && s.type==0xff))
    {
        // PSI
        
        if(payload_unit_start_indicator)
        {
            // begin of PSI table
            
            ptr++;
            
            if(ptr>=end_ptr)
                return -4;
            
            if(*ptr!=0x00 && *ptr!=0x02)
                return 0;
            
            if(end_ptr-ptr<3)
                return -5;
            
            u_int16_t l=to_int(ptr+1);
            
            if((l&0x3000)!=0x3000)
                return -6;
            
            l&=0x0fff;
            
            ptr+=3;
            
            int len=end_ptr-ptr;
            
            if(l>len)
            {
                if(l>ts::table::max_buf_len)
                    return -7;
                
                s.psi.reset();
                
                memcpy(s.psi.buf,ptr,len);
                s.psi.offset+=len;
                s.psi.len=l;
                
                return 0;
            }else
                end_ptr=ptr+l;
        }else
        {
            // next part of PSI
            if(!s.psi.offset)
                return -8;
            
            int len=end_ptr-ptr;
            
            if(len>ts::table::max_buf_len-s.psi.offset)
                return -9;
            
            memcpy(s.psi.buf+s.psi.offset,ptr,len);
            s.psi.offset+=len;
            
            if(s.psi.offset<s.psi.len)
                return 0;
            else
            {
                ptr=s.psi.buf;
                end_ptr=ptr+s.psi.len;
            }
        }
        
        if(!pid)
        {
            // PAT
            
            ptr+=5;
            
            if(ptr>=end_ptr)
                return -10;
            
            int len=end_ptr-ptr-4;
            
            if(len<0 || len%4)
                return -11;
            
            int n=len/4;
            
            for(int i=0;i<n;i++,ptr+=4)
            {
                u_int16_t channel=to_int(ptr);
                u_int16_t pid=to_int(ptr+2);
                
                if((pid&0xe000)!=0xe000)
                    return -12;
                
                pid&=0x1fff;
                
                if(!demuxer::channel || demuxer::channel==channel)
                {
                    stream& ss=streams[pid];
                    ss.channel=channel;
                    ss.type=0xff;
                }
            }
        }else
        {
            // PMT
            
            ptr+=7;
            
            if(ptr>=end_ptr)
                return -13;
            
            u_int16_t info_len=to_int(ptr)&0x0fff;
            
            ptr+=info_len+2;
            end_ptr-=4;
            
            if(ptr>=end_ptr)
                return -14;
            
            while(ptr<end_ptr)
            {
                if(end_ptr-ptr<5)
                    return -15;
                
                u_int8_t type=to_byte(ptr);
                u_int16_t pid=to_int(ptr+1);
                
                if((pid&0xe000)!=0xe000)
                    return -16;
                
                pid&=0x1fff;
                
                info_len=to_int(ptr+3)&0x0fff;
                
                ptr+=5+info_len;
                
                // ignore unknown streams
                if(validate_type(type))
                {
                    stream& ss=streams[pid];
                    
                    if(ss.channel!=s.channel || ss.type!=type)
                    {
                        ss.channel=s.channel;
                        ss.type=type;
                        ss.id=++s.id;
                        
                        if(!parse_only && !ss.file.is_opened())
                        {
                            if(dst.length())
                            {
                                ss.file.open(file::out,"%s%c%s%s",dst.c_str(),os_slash,prefix.c_str(),get_stream_ext(get_stream_type(ss.type)));
                                fprintf(stderr,"%s%c%s%s\n",dst.c_str(),os_slash,prefix.c_str(),get_stream_ext(get_stream_type(ss.type)));
                            }
                            
                            
                            else
                                ss.file.open(file::out,"%s%s",prefix.c_str(),get_stream_ext(get_stream_type(ss.type)));
                        }
                    }
                }
            }
            
            if(ptr!=end_ptr)
                return -18;
        }
    }else
    {
        if(s.type!=0xff)
        {
            // PES
            
            if(payload_unit_start_indicator)
            {
                s.psi.reset();
                s.psi.len=9;
            }
            
            while(s.psi.offset<s.psi.len)
            {
                int len=end_ptr-ptr;
                
                if(len<=0)
                    return 0;
                
                int n=s.psi.len-s.psi.offset;
                
                if(len>n)
                    len=n;
                
                memcpy(s.psi.buf+s.psi.offset,ptr,len);
                s.psi.offset+=len;
                
                ptr+=len;
                
                if(s.psi.len==9)
                    s.psi.len+=to_byte(s.psi.buf+8);
            }
            
            if(s.psi.len)
            {
                if(memcmp(s.psi.buf,"\x00\x00\x01",3))
                    return -19;
                
                s.stream_id=to_byte(s.psi.buf+3);
                
                u_int8_t flags=to_byte(s.psi.buf+7);
                
                s.frame_num++;
                
                switch(flags&0xc0)
                {
                    case 0x80:          // PTS only
                    {
                        u_int64_t pts=decode_pts(s.psi.buf+9);
#ifdef VERBOSE
                        if(dump==2)
                            printf("%.4x: %llu\n",pid,pts);
                        else if(dump==3)
                            printf("%.4x: track=%.4x.%.2i, type=%.2x, stream=%.2x, pts=%llums\n",pid,s.channel,s.id,s.type,s.stream_id,pts/90);
#endif
                        if(s.dts>0 && pts>s.dts)
                            s.frame_length=(u_int32_t)(pts-s.dts);
                        s.dts=pts;
                        
                        if(pts>s.last_pts)
                            s.last_pts=pts;
                        
                        if(!s.first_pts)
                            s.first_pts=pts;
                    }
                        break;
                    case 0xc0:          // PTS,DTS
                    {
                        u_int64_t pts=decode_pts(s.psi.buf+9);
                        u_int64_t dts=decode_pts(s.psi.buf+14);
#ifdef VERBOSE
                        if(dump==2)
                            printf("%.4x: %llu %llu\n",pid,pts,dts);
                        else if(dump==3)
                            printf("%.4x: track=%.4x.%.2i, type=%.2x, stream=%.2x, pts=%llums, dts=%llums\n",pid,s.channel,s.id,s.type,s.stream_id,pts/90,dts/90);
#endif
                        if(s.dts>0 && dts>s.dts)
                            s.frame_length=(u_int32_t)(dts-s.dts);
                        s.dts=dts;
                        
                        if(pts>s.last_pts)
                            s.last_pts=pts;
                        
                        if(!s.first_dts)
                            s.first_dts=dts;
                    }
                        break;
                }
                
                if(pes_output && s.file.is_opened())
                    s.file.write(s.psi.buf,s.psi.len);
                
                s.psi.reset();
            }
            
            if(s.frame_num)
            {
                int len=end_ptr-ptr;
                
                if(es_parse)
                {
                    switch(s.type)
                    {
                        case 0x1b:
                            s.frame_num_h264.parse(ptr,len);
                            break;
                        case 0x06:
                        case 0x81:
                        case 0x83:
                            s.frame_num_ac3.parse(ptr,len);
                            break;
                    }
                }
                
                if(s.file.is_opened())
                    s.file.write(ptr,len);
            }
        }
    }
    
    return 0;
}
Exemplo n.º 7
0
static gboolean
gnc_html_register_url_cb (const char *location, const char *label,
                          gboolean new_window, GNCURLResult *result)
{
    GncPluginPage *page = NULL;
    GNCSplitReg * gsr   = NULL;
    Split       * split = NULL;
    Account     * account = NULL;
    Transaction * trans;
    GList       * node;
    QofBook     * book = gnc_get_current_book();
    GncGUID       guid;
    QofInstance * entity = NULL;

    g_return_val_if_fail (location != NULL, FALSE);
    g_return_val_if_fail (result != NULL, FALSE);

    result->load_to_stream = FALSE;

    /* href="gnc-register:account=My Bank Account" */
    if (strncmp("account=", location, 8) == 0)
    {
        account = gnc_account_lookup_by_full_name (gnc_get_current_root_account (),
                  location + 8);
    }

    /* href="gnc-register:guid=12345678901234567890123456789012" */
    else if (strncmp ("acct-guid=", location, strlen ("acct-guid=")) == 0)
    {
        if (!validate_type("acct-guid=", location, GNC_ID_ACCOUNT, result, &guid, &entity))
            return FALSE;

        account = GNC_ACCOUNT(entity);
    }

    else if (strncmp ("trans-guid=", location, strlen ("trans-guid=")) == 0)
    {
        if (!validate_type("trans-guid=", location, GNC_ID_TRANS, result, &guid, &entity))
            return FALSE;

        trans = (Transaction *) entity;

        for (node = xaccTransGetSplitList (trans); node; node = node->next)
        {
            split = node->data;
            account = xaccSplitGetAccount(split);
            if (account) break;
        }

        if (!account)
        {
            result->error_message =
                g_strdup_printf (_("Transaction with no Accounts: %s"), location);
            return FALSE;
        }
    }

    else if (strncmp ("split-guid=", location, strlen ("split-guid=")) == 0)
    {
        if (!validate_type("split-guid=", location, GNC_ID_SPLIT, result, &guid, &entity))
            return FALSE;

        split = (Split *) entity;
        account = xaccSplitGetAccount(split);
    }
    else
    {
        result->error_message =
            g_strdup_printf (_("Unsupported entity type: %s"), location);
        return FALSE;
    }

    page = gnc_plugin_page_register_new (account, FALSE);
    gnc_main_window_open_page (NULL, page);
    if (split)
    {
        gsr = gnc_plugin_page_register_get_gsr(page);
        gnc_split_reg_jump_to_split( gsr, split );
    }

    return TRUE;
}