コード例 #1
0
static dbus_bool_t
init_session_address (void)
{
  dbus_bool_t retval;
 
  retval = FALSE;

  /* First, look in the environment.  This is the normal case on 
   * freedesktop.org/Unix systems. */
  get_from_env (&bus_connection_addresses[DBUS_BUS_SESSION],
                     "DBUS_SESSION_BUS_ADDRESS");
  if (bus_connection_addresses[DBUS_BUS_SESSION] == NULL)
    {
      dbus_bool_t supported;
      DBusString addr;
      DBusError error = DBUS_ERROR_INIT;

      if (!_dbus_string_init (&addr))
        return FALSE;

      supported = FALSE;
      /* So it's not in the environment - let's try a platform-specific method.
       * On MacOS, this involves asking launchd.  On Windows (not specified yet)
       * we might do a COM lookup.
       * Ignore errors - if we failed, fall back to autolaunch. */
      retval = _dbus_lookup_session_address (&supported, &addr, &error);
      if (supported && retval)
        {
          retval =_dbus_string_steal_data (&addr, &bus_connection_addresses[DBUS_BUS_SESSION]);
        }
      else if (supported && !retval)
        {
          if (dbus_error_is_set(&error))
            _dbus_warn ("Dynamic session lookup supported but failed: %s\n", error.message);
          else
            _dbus_warn ("Dynamic session lookup supported but failed silently\n");
        }
      _dbus_string_free (&addr);
    }
  else
    retval = TRUE;

  if (!retval)
    return FALSE;

  /* The DBUS_SESSION_BUS_DEFAULT_ADDRESS should have really been named
   * DBUS_SESSION_BUS_FALLBACK_ADDRESS. 
   */
  if (bus_connection_addresses[DBUS_BUS_SESSION] == NULL)
    bus_connection_addresses[DBUS_BUS_SESSION] =
      _dbus_strdup (DBUS_SESSION_BUS_DEFAULT_ADDRESS);
  if (bus_connection_addresses[DBUS_BUS_SESSION] == NULL)
    return FALSE;

  return TRUE;
}
コード例 #2
0
ファイル: parser.c プロジェクト: phrack-lp/miniComplier
int factor(){
	int t,t1,off;
	float r;
	id var;
	t = temp++;
	switch(look->tag){
		case '(':
			move();
			t1 = boolean();
			match(')');
			gen("t%d = t%d\n",t,t1);
			return t;
		case NUM:
			t1 = look->detail.num;
			gen("t%d = %d\n",t,t1);
			move();
			return t;
		case REAL:
			r = look->detail.real;
			gen("t%d = %f\n",t,r);
			move();
			return t; 
		case TRUE:
			gen("t%d = true\n",t);
			move();
			return t;
		case FALSE:
			gen("t%d = false\n",t);
			move();
			return t;
		case ID:
			var = get_from_env(top,look);
			if(var == NULL)
				error("undeclared var in factor");
			move();
			if(look->tag != '['){
				gen("t%d = %s\n",t,var->name);
			}
			else{
				off = offset(var);
				gen("t%d = %s",off,var->name);
			}
			return t;
		default:
			error("syntax error");
	}
}
コード例 #3
0
ファイル: parser.c プロジェクト: phrack-lp/miniComplier
void assign(){
	int tmp,off;
	token t = look;
	match(ID);
	id i = get_from_env(top,t);
	if(i == NULL)
		error("undeclared variable in assign");
	if(look->tag == '='){
		move();
		tmp = boolean();
		gen("%s = t%d\n",t->detail.word,tmp);
	}else{
		off = offset(i);
		match('=');
		tmp = boolean();
		gen("t%d = t%d\n",off,tmp);
	}
	match(';');
}
コード例 #4
0
ファイル: dbus-bus.c プロジェクト: 325116067/semc-qsd8x50
static dbus_bool_t
init_connections_unlocked (void)
{
  if (!initialized)
    {
      const char *s;
      int i;

      i = 0;
      while (i < N_BUS_TYPES)
        {
          bus_connections[i] = NULL;
          ++i;
        }

      /* Don't init these twice, we may run this code twice if
       * init_connections_unlocked() fails midway through.
       * In practice, each block below should contain only one
       * "return FALSE" or running through twice may not
       * work right.
       */
      
       if (bus_connection_addresses[DBUS_BUS_SYSTEM] == NULL)
         {
           _dbus_verbose ("Filling in system bus address...\n");
           
           if (!get_from_env (&bus_connection_addresses[DBUS_BUS_SYSTEM],
                              "DBUS_SYSTEM_BUS_ADDRESS"))
             return FALSE;
         }

                  
       if (bus_connection_addresses[DBUS_BUS_SYSTEM] == NULL)
         {
           /* Use default system bus address if none set in environment */
           bus_connection_addresses[DBUS_BUS_SYSTEM] =
             _dbus_strdup (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS);

           if (bus_connection_addresses[DBUS_BUS_SYSTEM] == NULL)
             return FALSE;
           
           _dbus_verbose ("  used default system bus \"%s\"\n",
                          bus_connection_addresses[DBUS_BUS_SYSTEM]);
         }
       else
         _dbus_verbose ("  used env var system bus \"%s\"\n",
                        bus_connection_addresses[DBUS_BUS_SYSTEM]);
          
      if (bus_connection_addresses[DBUS_BUS_SESSION] == NULL)
        {
          _dbus_verbose ("Filling in session bus address...\n");
          
          if (!get_from_env (&bus_connection_addresses[DBUS_BUS_SESSION],
                             "DBUS_SESSION_BUS_ADDRESS"))
            return FALSE;

	  if (bus_connection_addresses[DBUS_BUS_SESSION] == NULL)
	    bus_connection_addresses[DBUS_BUS_SESSION] =
	      _dbus_strdup (DBUS_SESSION_BUS_DEFAULT_ADDRESS);
          
          if (bus_connection_addresses[DBUS_BUS_SESSION] == NULL)
             return FALSE;

          _dbus_verbose ("  \"%s\"\n", bus_connection_addresses[DBUS_BUS_SESSION] ?
                         bus_connection_addresses[DBUS_BUS_SESSION] : "none set");
        }

      if (bus_connection_addresses[DBUS_BUS_STARTER] == NULL)
        {
          _dbus_verbose ("Filling in activation bus address...\n");
          
          if (!get_from_env (&bus_connection_addresses[DBUS_BUS_STARTER],
                             "DBUS_STARTER_ADDRESS"))
            return FALSE;
          
          _dbus_verbose ("  \"%s\"\n", bus_connection_addresses[DBUS_BUS_STARTER] ?
                         bus_connection_addresses[DBUS_BUS_STARTER] : "none set");
        }


      if (bus_connection_addresses[DBUS_BUS_STARTER] != NULL)
        {
          s = _dbus_getenv ("DBUS_STARTER_BUS_TYPE");
              
          if (s != NULL)
            {
              _dbus_verbose ("Bus activation type was set to \"%s\"\n", s);
                  
              if (strcmp (s, "system") == 0)
                activation_bus_type = DBUS_BUS_SYSTEM;
              else if (strcmp (s, "session") == 0)
                activation_bus_type = DBUS_BUS_SESSION;
            }
        }
      else
        {
          /* Default to the session bus instead if available */
          if (bus_connection_addresses[DBUS_BUS_SESSION] != NULL)
            {
              bus_connection_addresses[DBUS_BUS_STARTER] =
                _dbus_strdup (bus_connection_addresses[DBUS_BUS_SESSION]);
              if (bus_connection_addresses[DBUS_BUS_STARTER] == NULL)
                return FALSE;
            }
        }
      
      /* If we return FALSE we have to be sure that restarting
       * the above code will work right
       */
      
      if (!_dbus_setenv ("DBUS_ACTIVATION_ADDRESS", NULL))
        return FALSE;

      if (!_dbus_setenv ("DBUS_ACTIVATION_BUS_TYPE", NULL))
        return FALSE;
      
      if (!_dbus_register_shutdown_func (addresses_shutdown_func,
                                         NULL))
        return FALSE;
      
      initialized = TRUE;
    }

  return initialized;
}