Example #1
0
static void
read_next(ParseInfo pi, const char *key) {
    VALUE	obj;

    if ((void*)&obj < pi->stack_min) {
	rb_raise(rb_eSysStackError, "JSON is too deeply nested");
    }
    next_non_white(pi);	/* skip white space */
    switch (*pi->s) {
    case '{':
	read_hash(pi, key);
	break;
    case '[':
	read_array(pi, key);
	break;
    case '"':
	read_str(pi, key);
	break;
    case '+':
    case '-':
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
	read_num(pi, key);
	break;
    case 'I':
	read_num(pi, key);
	break;
    case 't':
	read_true(pi, key);
	break;
    case 'f':
	read_false(pi, key);
	break;
    case 'n':
	read_nil(pi, key);
	break;
    case '\0':
	return;
    default:
	return;
    }
}
Example #2
0
/*------------------------------------
-- Method: Thread::exec
-- Date:    November 12 2013
-- Designer:    Sam Youssef
-- Programmer: Sam Youssef
--
-- INTERFACE:   
--              int Thread::exec(void)
-- RETURNS:
--            int. On termination.
--
-- NOTES:
-- Enters loop which polls gps device. Reads gps data into gpsd structure.
-- On success, emits a signal which is captured by GpsWindow. In turn, GpsWindow
-- displays the data. 
--
-- Is aborted when Thread class receives the appropriate disconnect signal
-- from GpsWindow, either on program close or via the user clicking 
-- disconnect.
--------------------------------------*/
int Thread::exec()
{   
    bool ab = abort = false;
    while( !ab  )
    {   
        mutex.lock();
        ab = abort;
        mutex.unlock();
        
        if( ! gps_waiting(gpsd, 2000000) ) {
            fprintf(stderr, "\tmygps: GPS timeout\n");
            break;
        }
                    
        if(gps_read(gpsd) == -1) {
            fprintf(stderr, "\targs:socket error 4\n");
            break;
        }
        
        emit(read_true());
        
    }
    return 1;
}