Esempio n. 1
0
int TB_init()
{
  ToolBus = TBfalse;
  init_terms();
  init_utils();
  return gethostname(this_host, MAXHOSTNAMELEN);
}
JD_METHOD JavaPluginFactory5::Create(ISupports* sm,   
				     const JDIID& aIID,    
				     void* *aInstancePtr) {

    JDresult rv = JD_ERROR_FAILURE;
    if (aInstancePtr == NULL) {
        plugin_error("Received a null pointer to pointer in Create!\n");
    } else {
        JavaPluginFactory5 *res;

        if (!g_plugin_factory) {
	    IPluginServiceProvider* spService;
	    if (JD_FAILED(sm->QueryInterface(jIPluginServiceProviderIID, (void**)&spService)))
	        return rv;
	    
            res = new JavaPluginFactory5(spService); // g_plugin_factory set in here
            // The peice of shit browser does not seem to call Initialize
            // on this code path!!!
            spService->Release();
	    res->Initialize(); 
            init_utils();
        } else {
            res = g_plugin_factory;
        }
        rv = res->QueryInterface(aIID,aInstancePtr);
    }
    return rv;
}
Esempio n. 3
0
void setup()
{
	struct sigaction sa;
	sa.sa_handler = sigint_handler;
	if (sigaction(SIGINT, &sa, NULL) == -1)
	{
		printf("sigaction error\n");
		exit(EXIT_FAILURE);
	}
	init_utils(utils);
}
Esempio n. 4
0
File: calc.c Progetto: NegMozzie/42
t_k		calc(double x, double y, t_param *param, t_k *k)
{
	t_k		closest;
	t_objet	*tmp;
	t_utils	utils;

	k = NULL;
	init_k(&closest);
	init_utils(&utils);
	tmp = param->objet;
	init_utils_eye(&utils, param, x, y);
	obj_rot(&utils, NULL, -1, 0);
	while (tmp != NULL)
	{
		k = search_k(tmp, utils, k, param);
		tmp = tmp->next;
	}
	closest = fill_closest(k, closest);
	if (k)
		free(k);
	return (closest);
}
Esempio n. 5
0
int TBinit(char *tname, int argc, char *argv[],
       TBcallbackTerm fun, term * (check_in_sign)(term *))
{
  char *s;
  char host_toolbus[MAXHOSTNAMELEN];
  int fromToolBus, i = 1;
  TBbool local_ports = TBfalse;
  term *trm;

  tool_name = (tname) ? tname : "anonymous_tool";
  ToolBus = TBfalse;
  init_terms();
  init_utils();

  if(gethostname(this_host, MAXHOSTNAMELEN) < 0)
    err_sys_fatal("TBinit -- can't get host name");

  strcpy(host_toolbus, this_host);
  WellKnownSocketPort = TB_PORT;
  while(i < argc){
    if(streq(argv[i], "-help")){
      help(); exit(0);
    } else if(streq(argv[i], "-verbose")){
      TBverbose = TBtrue;
    } else if(streq(argv[i], "-TB_HOST")){
      i++;
      if(strlen(argv[i]) > MAXHOSTNAMELEN)
        err_fatal("TBinit -- name of ToolBus host too long");
      strcpy(host_toolbus, argv[i]);
      i++;
    } else if(streq(argv[i],"-TB_PORT")){
      i++;
      WellKnownSocketPort = atoi(argv[i++]);
   } else if(streq(argv[i],"-TB_TOOL_ID")){
     i++;
     this_tool_id = atoi(argv[i++]);
   } else if(streq(argv[i], "-TB_TOOL_NAME")){
     tool_name = argv[i+1];
     i += 2;
   } else if(streq(argv[i], "-TB_SINGLE")){
     i++;
     stand_alone = TBtrue;  
   } else if(streq(argv[i],"-TB_LOCAL_PORTS")){
     i++;
     local_ports = TBtrue;
   } else
     i++;
  }

  if((s = getenv("TB_VERBOSE")) && 
     streq(s ,"true"))
    TBverbose = TBtrue;

  if((s = getenv("TB_LOCAL_PORTS")) && 
     streq(s ,"true"))
    local_ports = TBtrue;


  if(stand_alone || !fun){ /* execute stand alone */
    /* TBaddTermPort(0, fun); */
    return TB_OK;
  }

  if(mkports(local_ports, tool_name, host_toolbus, &this_tool_id, &fromToolBus,
             &toToolBus) == TB_ERROR)
    err_fatal("TBinit -- can't connect to ToolBus");


  TBaddTermPort(fromToolBus, fun);

  Snd_Void = TBmake("snd-void()");
  TBprotect(&Snd_Void);

  trm = TBread(fromToolBus); /* obtain the tool signature from the ToolBus */

  if(TBmatch(trm, "rec-do(signature(%t,%t))", &tool_in_sign, &tool_out_sign)){
    TBsend(Snd_Void);
    if(check_in_sign){
      trm = (*check_in_sign)(tool_in_sign);
      if(trm)
	err_fatal("TBinit -- NOT IN INPUT SIGNATURE: %t", trm);
    }
  } else
    err_fatal("signature information garbled: %t", trm);


  return TB_OK;
}
Esempio n. 6
0
nsresult JPI_NSGetFactory(nsISupports * pProvider,
			  const nsCID &aClass,
			  const char * aClassName,
			  const char * aProgID,
			  nsIFactory **aFactory) 
{
  (void) aClassName; // defeat compiler "not used" warning.
  (void) aProgID;

  trace("JPI_NSGetFactory\n");

  if (aFactory == NULL){
	plugin_error("Received a null pointer to pointer in NSGetFactory!\n");
	return NS_ERROR_UNEXPECTED;
    }

    if (aClass.Equals(kPluginCID)) {

#ifdef __linux__
	void *handle = 0;
#else
	void *handle = dlopen("libnspr4.so", RTLD_LAZY);
#endif
	if (!handle) {

	    /* Navigator 4.0 or less */
	    in_oji_version = 0;
	    *aFactory = new CJavaPluginFactory();
	} else {

	    TRACE("Detected Mozilla 5 or greater\n");
	    char factory5path[MAXPATHLEN];
	    in_oji_version = 1;
	    // Initialize the 5.0 factory functions from libjavaplugin5.so
	    char *home = getenv("HOME");
	    if (home == NULL) {
		plugin_error("Could not load 5.0 plugin. $HOME not set", 
			     PLUGIN_OJI_SO);
		return NS_ERROR_UNEXPECTED;
	    }

	    trace("$HOME for loading %s = %s\n", PLUGIN_OJI_SO, home);
	    if ((strlen(home) + 100) > MAXPATHLEN) {
		plugin_error("Too long $HOME %s \n", home);
		return NS_ERROR_UNEXPECTED;
	    }

	    sprintf(factory5path, "%s/.netscape/java/lib/%s",
		    home, PLUGIN_OJI_SO);
	    if (tracing) 
		trace("Loading Mozilla 5 plugin from: %s \n", factory5path);
	    void *factory5_handle = dlopen(factory5path, RTLD_LAZY);

	    if (!factory5_handle) {
		plugin_error("Could not load %s: linking error=%s\n",
			     PLUGIN_OJI_SO, dlerror());
		return NS_ERROR_UNEXPECTED;
	    }

	    CreateFactoryFnType create_factory_fn =
	      (CreateFactoryFnType) (jlong)
	      load_function(factory5_handle, "CreateOJIFactory");
	    *aFactory = (*create_factory_fn)(pProvider);
	} 	

	init_utils();
	(*aFactory)->AddRef();
	return NS_OK;
    }
    
    return NS_ERROR_NO_INTERFACE;
}