Ejemplo n.º 1
0
/*
 * logical
 */
void cev_log(void) {
  cev_cmp();                    // R = cev_cmp()
  IF_ERR_RTN;
  while (CODE(IP) == kwTYPE_LOGOPR) {
    char op;
    bcip_t shortcut;
    bcip_t shortcut_offs;

    IP++;
    op = CODE(IP);
    IP++;

    cev_add1(kwTYPE_EVPUSH);    // PUSH R (push the left side result
    cev_add1(kwTYPE_EVAL_SC);
    cev_add2(kwTYPE_LOGOPR, op);
    shortcut = bc_out->count;   // shortcut jump target (calculated below)
    cev_add_addr(0);

    cev_cmp();                  // right seg // R = cev_cmp()
    IF_ERR_RTN;
    cev_add1(kwTYPE_EVPOP);    // POP LEFT
    cev_add2(kwTYPE_LOGOPR, op); // R = LEFT op R

    shortcut_offs = bc_out->count - shortcut;
    memcpy(bc_out->ptr + shortcut, &shortcut_offs, ADDRSZ);
  }
}
Ejemplo n.º 2
0
/*
 * prim
 */
void cev_prim() {
  IF_ERR_RTN;
  byte code = CODE(IP);
  IP++;
  cev_add1(code);
  switch (code) {
  case kwTYPE_INT:
    bc_add_n(bc_out, bc_in->ptr + bc_in->cp, OS_INTSZ);
    IP += OS_INTSZ;
    cev_check_dup_prim();
    break;
  case kwTYPE_NUM:
    bc_add_n(bc_out, bc_in->ptr + bc_in->cp, OS_REALSZ);
    IP += OS_REALSZ;
    cev_check_dup_prim();
    break;
  case kwTYPE_STR:
    cev_prim_str();
    cev_check_dup_prim();
    break;
  case kwTYPE_CALL_UDP:
    cev_udp();
    cev_check_dup_prim();
    break;
  case kwTYPE_PTR:
    bc_add_n(bc_out, bc_in->ptr + bc_in->cp, ADDRSZ); // addr
    IP += ADDRSZ;
    bc_add_n(bc_out, bc_in->ptr + bc_in->cp, ADDRSZ); // return var
    IP += ADDRSZ;
    cev_check_dup_prim();
    break;
  case kwTYPE_VAR:
    cev_prim_var();
    cev_check_dup_prim();
    break;
  case kwTYPE_CALL_UDF:        // [udf1][addr2]
  case kwTYPE_CALLEXTF:        // [lib][index]
    bc_add_n(bc_out, bc_in->ptr + bc_in->cp, ADDRSZ);
    IP += ADDRSZ;              // no break here
  case kwTYPE_CALLF:           // [code]
    bc_add_n(bc_out, bc_in->ptr + bc_in->cp, ADDRSZ);
    IP += ADDRSZ;              // no break here
  default:
    if (CODE_PEEK() == kwTYPE_LEVEL_BEGIN) {
      if (CODE(IP + 1) == kwTYPE_LEVEL_END) {
        cev_empty_args();
      } else {
        cev_prim_args();
      }
    }
    if (code != kwBYREF) {
      cev_check_dup_prim();
    }
    break;
  };
}
Ejemplo n.º 3
0
static void i80286_check_permission(i8086_state *cpustate, UINT8 check_seg, UINT32 offset, UINT16 size, i80286_operation operation)
{
	int trap = 0;
	UINT8 rights;
	if (PM) {
		rights = cpustate->rights[check_seg];
		trap = i80286_verify(cpustate, cpustate->sregs[check_seg], operation, rights, cpustate->valid[check_seg]);
		if ((CODE(rights) || !EXPDOWN(rights)) && ((offset+size-1) > cpustate->limit[check_seg])) trap = GENERAL_PROTECTION_FAULT;
		if (!CODE(rights) && EXPDOWN(rights) && ((offset <= cpustate->limit[check_seg]) || ((offset+size-1) > 0xffff))) trap = GENERAL_PROTECTION_FAULT;

		if ((trap == GENERAL_PROTECTION_FAULT) && (check_seg == SS)) trap = STACK_FAULT;
		if (trap) throw TRAP(trap, 0);
	}
}
Ejemplo n.º 4
0
// =-=-=-=-=-=-=-
//
irods::error sockClientStop(
    irods::network_object_ptr _ptr,
    rodsEnv*                   _env ) {
    // =-=-=-=-=-=-=-
    // resolve a network interface plugin from the
    // network object
    irods::plugin_ptr p_ptr;
    irods::error ret_err = _ptr->resolve( irods::NETWORK_INTERFACE, p_ptr );
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to resolve network interface", ret_err );

    }

    // =-=-=-=-=-=-=-
    // make the call to the "read" interface
    irods::network_ptr net = boost::dynamic_pointer_cast< irods::network >( p_ptr );
    ret_err = net->call< rodsEnv* >( irods::NETWORK_OP_CLIENT_STOP, _ptr, _env );

    // =-=-=-=-=-=-=-
    // pass along an error from the interface or return SUCCESS
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to call 'client stop'", ret_err );

    }
    else {
        return CODE( ret_err.code() );

    }

} // sockClientStop
Ejemplo n.º 5
0
/*
 * unary
 */
void cev_unary() {
  char op;

  IF_ERR_RTN;
  if (CODE(IP) == kwTYPE_UNROPR || CODE(IP) == kwTYPE_ADDOPR) {
    op = CODE(IP + 1);
    IP += 2;
  } else {
    op = 0;
  }
  cev_parenth();        // R = cev_parenth
  if (op) {
    cev_add1(kwTYPE_UNROPR);
    cev_add1(op);       // R = op R
  }
}
Ejemplo n.º 6
0
// =-=-=-=-=-=-=-
// Top Level Interface for Resource Plugin POSIX read
irods::error fileRead(
    rsComm_t*                     _comm,
    irods::first_class_object_ptr _object,
    void*                         _buf,
    const int                     _len ) {
    // =-=-=-=-=-=-=-
    // retrieve the resource name given the object
    irods::plugin_ptr   ptr;
    irods::resource_ptr resc;
    irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to resolve resource", ret_err );
    }

    // =-=-=-=-=-=-=-
    // make the call to the "read" interface
    resc    = boost::dynamic_pointer_cast< irods::resource >( ptr );
    ret_err = resc->call< void*, const int >( _comm, irods::RESOURCE_OP_READ, _object, _buf, _len );

    // =-=-=-=-=-=-=-
    // pass along an error from the interface or return SUCCESS
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to call 'read'", ret_err );
    }
    else {
        return CODE( ret_err.code() );
    }

} // fileRead
Ejemplo n.º 7
0
// =-=-=-=-=-=-=-
// Top Level Interface for Resource Plugin truncate
irods::error fileTruncate(
    rsComm_t*                      _comm,
    irods::first_class_object_ptr _object ) {
    // =-=-=-=-=-=-=-
    // retrieve the resource name given the path
    irods::plugin_ptr   ptr;
    irods::resource_ptr resc;
    irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to resolve resource", ret_err );
    }

    // =-=-=-=-=-=-=-
    // make the call to the "truncate" interface
    resc    = boost::dynamic_pointer_cast< irods::resource >( ptr );
    ret_err = resc->call( _comm, irods::RESOURCE_OP_TRUNCATE, _object );

    // =-=-=-=-=-=-=-
    // pass along an error from the interface or return SUCCESS
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to call 'truncate'", ret_err );
    }
    else {
        return CODE( ret_err.code() );
    }

} // fileTruncate
Ejemplo n.º 8
0
// =-=-=-=-=-=-=-
// Top Level Interface for Resource Plugin POSIX rename
irods::error fileRename(
    rsComm_t*                      _comm,
    irods::first_class_object_ptr _object,
    const std::string&             _new_file_name ) {
    // =-=-=-=-=-=-=-
    // retrieve the resource name given the path
    irods::plugin_ptr   ptr;
    irods::resource_ptr resc;
    irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to resolve resource", ret_err );
    }

    // =-=-=-=-=-=-=-
    // make the call to the "rename" interface
    resc    = boost::dynamic_pointer_cast< irods::resource >( ptr );
    ret_err = resc->call<  const char* >( _comm, irods::RESOURCE_OP_RENAME,  _object, _new_file_name.c_str() );

    // =-=-=-=-=-=-=-
    // pass along an error from the interface or return SUCCESS
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to call 'rename'", ret_err );
    }
    else {
        return CODE( ret_err.code() );
    }

} // fileRename
Ejemplo n.º 9
0
// =-=-=-=-=-=-=-
// Top Level Interface for Resource Plugin POSIX readdir
irods::error fileReaddir(
    rsComm_t*                      _comm,
    irods::first_class_object_ptr _object,
    struct rodsDirent**            _dirent_ptr ) {
    // =-=-=-=-=-=-=-
    // retrieve the resource name given the path
    irods::plugin_ptr   ptr;
    irods::resource_ptr resc;
    irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to resolve resource", ret_err );
    }

    // =-=-=-=-=-=-=-
    // make the call to the "readdir" interface
    resc    = boost::dynamic_pointer_cast< irods::resource >( ptr );
    ret_err = resc->call< struct rodsDirent** >( _comm, irods::RESOURCE_OP_READDIR, _object, _dirent_ptr );

    // =-=-=-=-=-=-=-
    // pass along an error from the interface or return SUCCESS
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to call 'readdir'", ret_err );
    }
    else {
        return CODE( ret_err.code() );
    }

} // fileReaddir
Ejemplo n.º 10
0
// =-=-=-=-=-=-=-
// Top Level Interface for Resource Plugin POSIX lseek
irods::error fileLseek(
    rsComm_t*                     _comm,
    irods::first_class_object_ptr _object,
    const long long               _offset,
    const int                     _whence ) {
    // =-=-=-=-=-=-=-
    // retrieve the resource name given the path
    irods::plugin_ptr   ptr;
    irods::resource_ptr resc;
    irods::error ret_err = _object->resolve( irods::RESOURCE_INTERFACE, ptr );
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to resolve resource", ret_err );
    }

    // =-=-=-=-=-=-=-
    // make the call to the "lseek" interface
    resc    = boost::dynamic_pointer_cast< irods::resource >( ptr );
    ret_err = resc->call< const long long, const int >( _comm, irods::RESOURCE_OP_LSEEK, _object, _offset, _whence );

    // =-=-=-=-=-=-=-
    // pass along an error from the interface or return SUCCESS
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to call 'lseek'", ret_err );
    }
    else {
        return CODE( ret_err.code() );
    }

} // fileLseek
Ejemplo n.º 11
0
// =-=-=-=-=-=-=-
// helper function - get the status property of a resource given a
// match to the incoming pointer
    error get_host_status_by_host_info( rodsServerHost_t* _info ) {
        // =-=-=-=-=-=-=-
        // idiot check pointer
        if ( !_info ) {
            return ERROR( SYS_INVALID_INPUT_PARAM, "null pointer" );
        }

        // =-=-=-=-=-=-=-
        // find a matching resource
        resource_ptr resc;
        error err = resc_mgr.resolve_from_property< rodsServerHost_t* >( RESOURCE_HOST, _info, resc );
        if ( !err.ok() ) {
            return PASSMSG( "failed to resolve resource", err );
        }

        // =-=-=-=-=-=-=-
        // get the status property of the resource
        int status = -1;
        err = resc->get_property< int >( RESOURCE_STATUS, status );
        if ( !err.ok() ) {
            return PASSMSG( "failed to get resource property", err );
        }

        return CODE( status );

    } // get_host_status_by_host_info
Ejemplo n.º 12
0
//bool
//clip_line(int *pX1, int *pY1, int *pX2, int *pY2, int l, int b, int r, int t)
int
clip_line(int *pX1, int *pY1, int *pX2, int *pY2, int l, int b, int r, int t)
{
    int x1 = *pX1;
    int y1 = *pY1;
    int x2 = *pX2;
    int y2 = *pY2;
    int x = 0, y = 0;
    int c, c1, c2;

    CODE(x1, y1, c1);
    CODE(x2, y2, c2);

    while (c1 || c2) {
        if (c1 & c2)
            return (TRUE); /* Line is invisible. */
        if ((c = c1) == 0)
            c = c2;
        if (c & CODEMINX) {
            y = y1+(y2-y1)*(l-x1)/(x2-x1);
            x = l;
        } else if (c & CODEMAXX) {
            y = y1+(y2-y1)*(r-x1)/(x2-x1);
            x = r;
        } else if (c & CODEMINY) {
            x = x1+(x2-x1)*(b-y1)/(y2-y1);
            y = b;
        } else if (c & CODEMAXY) {
            x = x1+(x2-x1)*(t-y1)/(y2-y1);
            y = t;
        }
        if (c == c1) {
            x1 = x;
            y1 = y;
            CODE(x, y, c1);
        } else {
            x2 = x;
            y2 = y;
            CODE(x, y, c2);
        }
    }
    *pX1 = x1;
    *pY1 = y1;
    *pX2 = x2;
    *pY2 = y2;
    return (FALSE); /* Line is at least partially visible.*/
}
Ejemplo n.º 13
0
/*
 * mul | div | mod
 */
void cev_mul() {
  cev_pow();                    // R = cev_pow()

  IF_ERR_RTN;
  while (CODE(IP) == kwTYPE_MULOPR) {
    char op;

    op = CODE(++IP);
    IP++;
    cev_add1(kwTYPE_EVPUSH);    // PUSH R

    cev_pow();
    IF_ERR_RTN;
    cev_add1(kwTYPE_EVPOP);      // POP LEFT
    cev_add2(kwTYPE_MULOPR, op); // R = LEFT op R
  }
}
Ejemplo n.º 14
0
/*
 * compare
 */
void cev_cmp() {
  cev_add();                    // R = cev_add()

  IF_ERR_RTN;
  while (CODE(IP) == kwTYPE_CMPOPR) {
    char op;

    IP++;
    op = CODE(IP);
    IP++;
    cev_add1(kwTYPE_EVPUSH);    // PUSH R
    cev_add();                  // R = cev_add()
    IF_ERR_RTN;
    cev_add1(kwTYPE_EVPOP);         // POP LEFT
    cev_add2(kwTYPE_CMPOPR, op);    // R = LEFT op R
  }
}
Ejemplo n.º 15
0
    /// =-=-=-=-=-=-=-
    /// @brief This routine is for testing the TEST_STAGE_FILE_TYPE.
    ///        Just copy the file from filename to cacheFilename. optionalInfo info
    ///        is not used.
    irods::error univ_mss_file_stage_to_cache(
        irods::resource_plugin_context& _ctx,
        const char*                         _cache_file_name ) {
        // =-=-=-=-=-=-=-
        // check context
        irods::error err = univ_mss_check_param< irods::file_object >( _ctx );
        if ( !err.ok() ) {
            std::stringstream msg;
            msg << __FUNCTION__;
            msg << " - invalid context";
            return PASSMSG( msg.str(), err );

        }

        // =-=-=-=-=-=-=-
        // snag a ref to the fco
        irods::file_object_ptr fco = boost::dynamic_pointer_cast< irods::file_object >( _ctx.fco() );
        std::string filename = fco->physical_path();

        // =-=-=-=-=-=-=-
        // get the script property
        std::string script;
        err = _ctx.prop_map().get< std::string >( SCRIPT_PROP, script );
        if ( !err.ok() ) {
            return PASSMSG( __FUNCTION__, err );
        }

        int status = 0;
        execCmd_t execCmdInp;
        char cmdArgv[HUGE_NAME_LEN] = "";
        execCmdOut_t *execCmdOut = NULL;
        bzero( &execCmdInp, sizeof( execCmdInp ) );

        rstrcpy( execCmdInp.cmd, script.c_str(), LONG_NAME_LEN );
        strcat( cmdArgv, "stageToCache" );
        strcat( cmdArgv, " '" );
        strcat( cmdArgv, filename.c_str() );
        strcat( cmdArgv, "' '" );
        strcat( cmdArgv, _cache_file_name );
        strcat( cmdArgv, "'" );
        rstrcpy( execCmdInp.cmdArgv, cmdArgv, HUGE_NAME_LEN );
        rstrcpy( execCmdInp.execAddr, "localhost", LONG_NAME_LEN );
        status = _rsExecCmd( _ctx.comm(), &execCmdInp, &execCmdOut );

        if ( status < 0 ) {
            status = UNIV_MSS_STAGETOCACHE_ERR - errno;
            std::stringstream msg;
            msg << "univ_mss_file_stage_to_cache: staging from [";
            msg << _cache_file_name;
            msg << "] to [";
            msg << filename;
            msg << "] failed.";
            return ERROR( status, msg.str() );
        }

        return CODE( status );

    } // univ_mss_file_stage_to_cache
Ejemplo n.º 16
0
ScreenSelect::ScreenSelect( CString sClassName ) : ScreenWithMenuElements(sClassName)
{
	LOG->Trace( "ScreenSelect::ScreenSelect()" );

	m_sName = sClassName;

	//
	// Load choices
	//
	{
		// Instead of using NUM_CHOICES, use a comma-separated list of choices.  Each
		// element in the list is a choice name.  This level of indirection 
		// makes it easier to add or remove items without having to change a bunch
		// of indices.
		CStringArray asChoiceNames;
		split( CHOICE_NAMES, ",", asChoiceNames, true );

		for( unsigned c=0; c<asChoiceNames.size(); c++ )
		{
			CString sChoiceName = asChoiceNames[c];
			CString sChoice = CHOICE(sChoiceName);

			ModeChoice mc;
			mc.m_sName = sChoiceName;
			mc.Load( c, sChoice );
			m_aModeChoices.push_back( mc );
		
			CString sBGAnimationDir = THEME->GetPath(BGAnimations, m_sName, mc.m_sName, true);	// true="optional"
			if( sBGAnimationDir == "" )
				sBGAnimationDir = THEME->GetPathToB(m_sName+" background");
			BGAnimation *pBGA = new BGAnimation;
			m_vpBGAnimations.push_back( pBGA );
		}
	}

	//
	// Load codes
	//
	for( int c=0; c<NUM_CODES; c++ )
	{
		CodeItem code;
		if( !code.Load( CODE(c) ) )
			continue;

		m_aCodes.push_back( code );
		m_aCodeActions.push_back( CODE_ACTION(c) );
		ModeChoice mc;
		mc.Load( c, CODE_ACTION(c) );
		m_aCodeChoices.push_back( mc );
	}

	if( !m_aModeChoices.size() )
		RageException::Throw( "Screen \"%s\" does not set any choices", m_sName.c_str() );

	// derived classes can override if they want
	LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU );
}
Ejemplo n.º 17
0
static int i80286_verify(i80286_state *cpustate, UINT16 selector, i80286_operation operation, UINT8 rights, bool valid)
{
	if (!IDXTBL(selector) && !valid) return GENERAL_PROTECTION_FAULT;
	if (!SEGDESC(rights)) return GENERAL_PROTECTION_FAULT;

	switch(operation) {
		case I80286_READ:
			if (CODE(rights) && !READ(rights)) return GENERAL_PROTECTION_FAULT;
			break;
		case I80286_WRITE:
			if (CODE(rights) || !RW(rights)) return GENERAL_PROTECTION_FAULT;
			break;
		case I80286_EXECUTE:
			if (!CODE(rights)) return GENERAL_PROTECTION_FAULT;
			break;
	}
	return 0;
}
Ejemplo n.º 18
0
    /// =-=-=-=-=-=-=-
    /// @brief interface for POSIX chmod
    irods::error univ_mss_file_chmod(
        irods::resource_plugin_context& _ctx ) {
        // =-=-=-=-=-=-=-
        // check context
        irods::error err = univ_mss_check_param< irods::data_object >( _ctx );
        if ( !err.ok() ) {
            std::stringstream msg;
            msg << __FUNCTION__;
            msg << " - invalid context";
            return PASSMSG( msg.str(), err );

        }

        // =-=-=-=-=-=-=-
        // get the script property
        std::string script;
        err = _ctx.prop_map().get< std::string >( SCRIPT_PROP, script );
        if ( !err.ok() ) {
            return PASSMSG( __FUNCTION__, err );
        }

        // =-=-=-=-=-=-=-
        // snag a ref to the fco
        irods::data_object_ptr fco = boost::dynamic_pointer_cast< irods::data_object >( _ctx.fco() );
        std::string filename = fco->physical_path();

        int mode = fco->mode();
        int status = 0;
        execCmd_t execCmdInp;

        if ( mode != getDefDirMode() ) {
            mode = getDefFileMode();
        }

        bzero( &execCmdInp, sizeof( execCmdInp ) );
        snprintf( execCmdInp.cmd, sizeof( execCmdInp.cmd ), "%s", script.c_str() );
        snprintf( execCmdInp.cmdArgv, sizeof( execCmdInp.cmdArgv ), "chmod '%s' %o", filename.c_str(), mode );
        snprintf( execCmdInp.execAddr, sizeof( execCmdInp.execAddr ), "%s", "localhost" );
        execCmdOut_t *execCmdOut = NULL;
        status = _rsExecCmd( &execCmdInp, &execCmdOut );
        freeCmdExecOut( execCmdOut );

        if ( status < 0 ) {
            status = UNIV_MSS_CHMOD_ERR - errno;
            std::stringstream msg;
            msg << "univ_mss_file_chmod - failed for [";
            msg << filename;
            msg << "]";
            return ERROR( status, msg.str() );

        }

        return CODE( status );

    } // univ_mss_file_chmod
Ejemplo n.º 19
0
/*
 * parenthesis
 */
void cev_parenth() {
  IF_ERR_RTN;
  if (CODE_PEEK() == kwTYPE_LEVEL_BEGIN) {
    if (CODE(IP + 1) == kwTYPE_LEVEL_END) {
      cev_empty_args();
    } else {
      cev_prim_args();
    }
  } else {
    cev_prim();
  }
}
Ejemplo n.º 20
0
// function [(...)]
void cev_prim_args() {
  cev_add1(kwTYPE_LEVEL_BEGIN);
  IP++;

  if (CODE_PEEK() == kwTYPE_CALL_PTR) {
    cev_add1(CODE(IP));
    IP++;
  }

  if (CODE_PEEK() != kwTYPE_SEP) {
    // empty parameter
    cev_log();
  }
  while (CODE_PEEK() == kwTYPE_SEP) {
    // while parameters
    cev_add1(CODE(IP));
    IP++;
    cev_add1(CODE(IP));
    IP++;

    if (CODE_PEEK() != kwTYPE_LEVEL_END) {
      if (CODE_PEEK() != kwTYPE_SEP) {
        cev_log();
      }
    }
  }

  // after (), check for UDS field, eg foo(10).x
  if (CODE_PEEK() == kwTYPE_UDS_EL) {
    cev_prim_uds();
    cev_log();
  }

  if (CODE_PEEK() != kwTYPE_LEVEL_END) {
    cev_missing_rp();
  } else {
    cev_add1(kwTYPE_LEVEL_END);
    IP++;
  }
}
Ejemplo n.º 21
0
static void add_line(ushort line, uint64_t time)
{
	int n;
	char buf[32], num[16];
	char *p;
	
	n = line - _last_line;
	p = buf;
	
	if (n >= -9 && n <= 9)
		*p++ = CODE(0 + n + 9);
	else if (n >= -99 && n <= 99)
	{
		*p++ = n > 0 ? CODE(19) : CODE(20);
		*p++ = CODE(0) + abs(n) - 10;
	}
	else
	{
		*p++ = n > 0 ? CODE(21) : CODE(22);
		n = sprintf(num, "%d", abs(n));
		*p++ = CODE(n);
		strcpy(p, num);
		p += n;
	}
	
	if (time <= 9)
		*p++ = CODE(time);
	else
	{
		n = sprintf(num, "%" PRIu64, time);
		*p++ = CODE(10 + n - 2);
		strcpy(p, num);
		p += n;
	}
	
	*p = 0;
	
	fputs(buf, _file);
	
	_last_line = line;
	_new_line = FALSE;
	_count++;
	if ((_count & 0xFFFFF) == 0)
		check_size();
}
Ejemplo n.º 22
0
static void
medsa_print_full(netdissect_options *ndo,
		 const struct medsa_pkthdr *medsa,
		 u_int caplen)
{
	u_char tag = TAG(medsa);

	ND_PRINT((ndo, "%s",
		  tok2str(tag_values, "Unknown (%u)", tag)));

	switch (tag) {
	case TAG_TO_CPU:
		ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
		ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
			  SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));

		ND_PRINT((ndo, ", %s",
			  tok2str(code_values, "Unknown (%u)", CODE(medsa))));
		if (CFI(medsa))
			ND_PRINT((ndo, ", CFI"));

		ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
		break;
	case TAG_FROM_CPU:
		ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
		ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
			  SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));

		if (CFI(medsa))
			ND_PRINT((ndo, ", CFI"));

		ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
		break;
	case TAG_FORWARD:
		ND_PRINT((ndo, ", %stagged", SRC_TAG(medsa) ? "" : "un"));
		if (TRUNK(medsa))
			ND_PRINT((ndo, ", dev.trunk:vlan %d.%d:%d",
				  SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));
		else
			ND_PRINT((ndo, ", dev.port:vlan %d.%d:%d",
				  SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)));

		if (CFI(medsa))
			ND_PRINT((ndo, ", CFI"));

		ND_PRINT((ndo, ", pri %d: ", PRI(medsa)));
		break;
	default:
		ND_DEFAULTPRINT((const u_char *)medsa, caplen);
		return;
	}
}
Ejemplo n.º 23
0
void cev_prim_var() {
  bc_add_n(bc_out, bc_in->ptr + bc_in->cp, ADDRSZ);
  IP += ADDRSZ;

  cev_prim_uds();

  // support multiple ()
  while (CODE_PEEK() == kwTYPE_LEVEL_BEGIN) {
    cev_add1(kwTYPE_LEVEL_BEGIN);
    IP++;
    if (CODE_PEEK() == kwTYPE_LEVEL_END) {
      // NULL ARRAYS
      cev_add1(kwTYPE_LEVEL_END);
      IP++;
    } else {
      cev_log();

      while (CODE_PEEK() == kwTYPE_SEP || CODE_PEEK() == kwTO) {
        // DIM X(A TO B)
        if (CODE_PEEK() == kwTYPE_SEP) {
          cev_add1(CODE(IP));
          IP++;
        }
        cev_add1(CODE(IP));
        IP++;

        cev_log();
      }

      if (CODE_PEEK() != kwTYPE_LEVEL_END) {
        cev_missing_rp();
      } else {
        cev_add1(kwTYPE_LEVEL_END);
        IP++;
        cev_prim_uds();
      }
    }
  }
}
Ejemplo n.º 24
0
// test for repeated primatives
void cev_check_dup_prim() {
  switch (CODE(IP)) {
  case kwTYPE_INT:
  case kwTYPE_NUM:
  case kwTYPE_STR:
  case kwTYPE_VAR:
  case kwTYPE_CALLF:
    cev_opr_err();
    break;
  default:
    break;
  }
}
Ejemplo n.º 25
0
/*
 * pow
 */
void cev_pow() {
  cev_unary();                  // R = cev_unary

  IF_ERR_RTN;
  while (CODE(IP) == kwTYPE_POWOPR) {
    IP += 2;

    cev_add1(kwTYPE_EVPUSH);    // PUSH R
    cev_unary();                // R = cev_unary
    IF_ERR_RTN;
    cev_add1(kwTYPE_EVPOP);     // POP LEFT
    cev_add2(kwTYPE_POWOPR, '^'); // R = LEFT op R
  }
}
Ejemplo n.º 26
0
// =-=-=-=-=-=-=-
//
irods::error readMsgBody(
    irods::network_object_ptr _ptr,
    msgHeader_t*        _header,
    bytesBuf_t*         _input_struct_buf,
    bytesBuf_t*         _bs_buf,
    bytesBuf_t*         _error_buf,
    irodsProt_t         _protocol,
    struct timeval*     _time_val ) {
    // =-=-=-=-=-=-=-
    // resolve a network interface plugin from the
    // network object
    irods::plugin_ptr p_ptr;
    irods::error ret_err = _ptr->resolve( irods::NETWORK_INTERFACE, p_ptr );
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to resolve network interface", ret_err );

    }

    // =-=-=-=-=-=-=-
    // make the call to the "read" interface
    irods::first_class_object_ptr ptr = boost::dynamic_pointer_cast< irods::first_class_object >( _ptr );
    irods::network_ptr            net = boost::dynamic_pointer_cast< irods::network >( p_ptr );
    ret_err = net->call < msgHeader_t*,
    bytesBuf_t*,
    bytesBuf_t*,
    bytesBuf_t*,
    irodsProt_t,
    struct timeval* > (
        irods::NETWORK_OP_READ_BODY,
        ptr,
        _header,
        _input_struct_buf,
        _bs_buf,
        _error_buf,
        _protocol,
        _time_val );
    // =-=-=-=-=-=-=-
    // pass along an error from the interface or return SUCCESS
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to call 'read message body'", ret_err );

    }
    else {
        return CODE( ret_err.code() );

    }

} // readMsgBody
Ejemplo n.º 27
0
static void i80286_data_descriptor_full(i80286_state *cpustate, int reg, UINT16 selector, int cpl, UINT32 trap, UINT16 offset, int size)
{
	if (PM) {
		UINT16 desc[3];
		UINT8 r;
		UINT32 addr;
		/* selector format
           15..3 number/address in descriptor table
           2: 0 global, 1 local descriptor table
           1,0: requested privileg level
           must be higher or same as current privileg level in code selector */
		if ((reg != SS) && !IDXTBL(selector)) {
			cpustate->sregs[reg]=0;
			cpustate->limit[reg]=0;
			cpustate->base[reg]=0;
			cpustate->rights[reg]=0;
			cpustate->valid[reg]=0;
			return;
		}

		if ((addr = i80286_selector_address(cpustate,selector)) == -1) throw trap;

		desc[0] = ReadWord(addr);
		desc[1] = ReadWord(addr+2);
		desc[2] = ReadWord(addr+4);
		r = RIGHTS(desc);
		if (!SEGDESC(r)) throw trap;
		if (reg == SS) {
			if (!IDXTBL(selector)) throw trap;
			if (DPL(r)!=cpl) throw trap;
			if (RPL(selector)!=cpl) throw trap;
			if (!RW(r) || CODE(r)) throw trap;
			if (!PRES(r)) throw TRAP(STACK_FAULT,(IDXTBL(selector)+(trap&1)));
		} else {
			if ((DPL(r) < PMAX(cpl,RPL(selector))) && (!CODE(r) || (CODE(r) && !CONF(r)))) throw trap;
			if (CODE(r) && !READ(r)) throw trap;
			if (!PRES(r)) throw TRAP(SEG_NOT_PRESENT,(IDXTBL(selector)+(trap&1)));
		}
		if (offset+size) {
			if ((CODE(r) || !EXPDOWN(r)) && ((offset+size-1) > LIMIT(desc))) throw (reg==SS)?TRAP(STACK_FAULT,(trap&1)):trap;
			if (!CODE(r) && EXPDOWN(r) && ((offset <= LIMIT(desc)) || ((offset+size-1) > 0xffff))) throw (reg==SS)?TRAP(STACK_FAULT,(trap&1)):trap;
		}

		SET_ACC(desc);
		WriteWord(addr+4, desc[2]);
		cpustate->sregs[reg]=selector;
		cpustate->limit[reg]=LIMIT(desc);
		cpustate->base[reg]=BASE(desc);
		cpustate->rights[reg]=RIGHTS(desc);
	} else {
		cpustate->sregs[reg]=selector;
		cpustate->base[reg]=selector<<4;
	}
	cpustate->valid[reg]=1;
}
Ejemplo n.º 28
0
irods::error sendRodsMsg(
    irods::network_object_ptr _ptr,
    char*               _msg_type,
    bytesBuf_t*         _msg_buf,
    bytesBuf_t*         _bs_buf,
    bytesBuf_t*         _error_buf,
    int                 _int_info,
    irodsProt_t         _protocol ) {
    // =-=-=-=-=-=-=-
    // resolve a network interface plugin from the
    // network object
    irods::plugin_ptr p_ptr;
    irods::error ret_err = _ptr->resolve( irods::NETWORK_INTERFACE, p_ptr );
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to resolve network interface", ret_err );

    }

    // =-=-=-=-=-=-=-
    // make the call to the "write body" interface
    irods::first_class_object_ptr ptr = boost::dynamic_pointer_cast< irods::first_class_object >( _ptr );
    irods::network_ptr            net = boost::dynamic_pointer_cast< irods::network >( p_ptr );
    ret_err = net->call< char*, bytesBuf_t*, bytesBuf_t*, bytesBuf_t*, int, irodsProt_t >(
                  irods::NETWORK_OP_WRITE_BODY,
                  ptr,
                  _msg_type,
                  _msg_buf,
                  _bs_buf,
                  _error_buf,
                  _int_info,
                  _protocol );

    // =-=-=-=-=-=-=-
    // pass along an error from the interface or return SUCCESS
    if ( !ret_err.ok() ) {
        return PASSMSG( "failed to call 'write body'", ret_err );

    }
    else {
        return CODE( ret_err.code() );

    }

    return SUCCESS();

} // sendRodsMsg
Ejemplo n.º 29
0
// =-=-=-=-=-=-=-
// interface for requesting a reconnection
irods::error sendReconnMsg(
    irods::network_object_ptr _ptr,
    reconnMsg_t*        _msg ) {
    // =-=-=-=-=-=-=-
    // trap invalid param
    if ( _msg == NULL ) {
        return ERROR( USER__NULL_INPUT_ERR, "null msg buf" );
    }

    // =-=-=-=-=-=-=-
    // pack outgoing message - alway use XML for version
    bytesBuf_t* recon_buf = NULL;
    int status = packStruct(
                     static_cast<void*>( _msg ),
                     &recon_buf,
                     "ReconnMsg_PI",
                     RodsPackTable,
                     0, XML_PROT );
    if ( status < 0 ) {
        return ERROR( status, "failed to pack struct" );
    }

    // =-=-=-=-=-=-=-
    // pack outgoing message - alway use XML for version
    irods::error ret = sendRodsMsg(
                           _ptr,
                           RODS_RECONNECT_T,
                           recon_buf,
                           NULL,
                           NULL,
                           0,
                           XML_PROT );
    freeBBuf( recon_buf );
    if ( !ret.ok() ) {
        rodsLogError( LOG_ERROR, status,
                      "sendReconnMsg: sendRodsMsg of reconnect msg failed, status = %d",
                      status );
    }

    return CODE( status );

} // sendReconnMsg
Ejemplo n.º 30
0
//主函数==============================================================================================
int main()
{
    p_in=&in;
    p_out=&out;
    system("mode con cols=80 lines=22");
    CODE();//输入密码
    if(!shut)
    {
        Menu(4);//打印界面
        Menu(1);//打印选项
        Arrow();//打印光标
        gotoxy(0,0);
    }
    while(!shut)
    {
        while(!shut)
        {
            shut=0;
            MOVE();
            if(chos_in==1&&chos_out==1)
            {
                //转换进制并输出
                turn(p_in);
                turn(p_out);
                Trans(in,out);
                getch();
                //重置开关及界面等待下一次操作
                chos_in=chos_out=0;
                SPRD(3,13,50,15,19);
                Menu(1);
                break;
            }
        }
    }
    gotoxy(50,20);
    return 0;
}