Example #1
0
bool CSettings::Load()
{
	FindConfig();
	//! Reset default path variables to the right device
	SetDefault();

	char filepath[300];
	snprintf(filepath, sizeof(filepath), "%sGXGlobal.cfg", ConfigPath);

	FILE * file = fopen(filepath, "r");
	if (!file) return false;

	if(!ValidVersion(file))
	{
		fclose(file);
		return false;
	}

	char line[1024];

	while (fgets(line, sizeof(line), file))
	{
		if (line[0] == '#') continue;

		this->ParseLine(line);
	}
	fclose(file);

	// A valid config file exists on the loader
	// meaning it is not the first run of the loader.
	FirstTimeRun = false;

	return true;
}
Example #2
0
int
main( int argc, char *argv[] )
{
  if ( argc > 2 )
       return usage( argv[0] );

  const char *config_name = "lan_local";

  if ( argc == 2 )
       config_name = argv[1];

  const char **config = FindConfig( config_name );

  if ( config == 0 )
       return usage( argv[0] );

  void *dummy;
  struct oh_abi_v2 *abi = 0;
  GHashTable *params;
  void *hdl;
  uuid_t myuid;

  oh_uid_initialize();

  memcpy( &myuid, UUID_OH_ABI_V2, sizeof(myuid) );

  if (    ipmidirect_get_interface( &dummy, myuid ) < 0
       || dummy == 0 )
     {
       printf( "cannot get interface !\n" );
       return 10;
     }

  abi = (struct oh_abi_v2 *) dummy;

  if ( abi->open == 0 )
     {
       printf( "cannot get interface !\n" );
       return 10;
     }
	  
  params = AllocParams( config );

  hdl = abi->open( params );

  if ( hdl == 0 )
     {
       printf( "cannot open plugin !\n" );
       return 10;
     }

  printf( "ready.\n" );
  TestInterface( abi, hdl );

  abi->close( hdl );
  DestryParams( params );

  return 0;
}
TInt CNaptClientConfigMgr::UpdateConfigL(const TInterfaceLockInfo* aInfo, CSapNapt* aSap)
/**
 * This method updates the configuration in the list. In case configuration is already present it updates
 * the existing configuration corresponsing to interface index else it creates a new config and adds it
 * the configuration list.
 * @param const TInterfaceLockInfo* aInfo - Interface structure used for provisioning info
 * @param CSapNapt* - Pointer to SAP thru which provisioning is being done.
 * @return TInt - KErrNone in case of success.
 *
 **/
{

    TInt err = KErrNone;
    TNaptConfigInfo* cinfo = NULL;

    if(aInfo != NULL)
    {
        cinfo = aSap->GetConfigInfo();
        if(cinfo == NULL)
        {
            cinfo = FindConfig(aInfo->iIfIndex);
            if(!cinfo)
                cinfo = new(ELeave)TNaptConfigInfo;
            else
            {
                //Interface Index is already in Use, aborting operation
                err = KErrAbort;
                return err;
            }
        }
        //cinfo is initialized above, hence Pointer NULL check is not required here.
        cinfo->iPublicIap = aInfo->iPublicIap;
        cinfo->iPrivateIap = aInfo->iPrivateIap;
        TInetAddr::Cast(cinfo->iPublicGatewayIP).SetV4MappedAddress((aInfo->iPublicIp).Address());
        TInetAddr::Cast(cinfo->iPrivateIp).SetV4MappedAddress((aInfo->iPrivateIp).Address());
        //converting masklength to v6 mapped.So it will be 128-8 for class A, 128-16 for class B
        //128-24 for class C
        cinfo->iNetMaskLength = 128-(aInfo->iNetmaskLength);
        cinfo->iIfIndex = aInfo->iIfIndex;
#ifdef SYMBIAN_NETWORKING_ADDRESS_PROVISION
        cinfo->iUplinkAccess  = aInfo->iUplinkAccess;
        //Get the client IP which DHCP will offer from IAP table
        //This is a not proper and will be fixed later for full DHCP impl
        err = TNaptUtil::GetClientIp(aInfo->iPrivateIap, cinfo->iProvisionedIp);
#endif
        if(!aSap->GetConfigInfo())
        {
            AddConfigL(cinfo);
            aSap->SetConfigInfo(cinfo);
        }
    }
    return err;
}
Example #4
0
bool CSettings::Save()
{
	if (!FindConfig()) return false;

	char filedest[300];
	snprintf(filedest, sizeof(filedest), "%sGXGlobal.cfg", ConfigPath);

	if(!CreateSubfolder(ConfigPath))	return false;

	FILE * file = fopen(filedest, "w");
	if (!file) return false;

	fprintf(file, "# USB Loader GX R%s - Main settings file\n", GetRev());
	fprintf(file, "# Note: This file is automatically generated\n");
	fprintf(file, "godmode = %d\n", godmode);
	fprintf(file, "videomode = %d\n", videomode);
	fprintf(file, "videopatch = %d\n", videopatch);
	fprintf(file, "videoPatchDol = %d\n", videoPatchDol);
	fprintf(file, "language = %d\n", language);
	fprintf(file, "ocarina = %d\n", ocarina);
	fprintf(file, "hddinfo = %d\n", hddinfo);
	fprintf(file, "sinfo = %d\n", sinfo);
	fprintf(file, "rumble = %d\n", rumble);
	fprintf(file, "volume = %d\n", volume);
	fprintf(file, "sfxvolume = %d\n", sfxvolume);
	fprintf(file, "gamesoundvolume = %d\n", gamesoundvolume);
	fprintf(file, "tooltips = %d\n", tooltips);
	fprintf(file, "RememberUnlock = %d\n", RememberUnlock);
	char EncryptedTxt[50];
	EncryptString(unlockCode, EncryptedTxt);
	fprintf(file, "password = %s\n", EncryptedTxt);
	fprintf(file, "GameSort = %d\n", GameSort);
	fprintf(file, "LoaderIOS = %d\n", LoaderIOS);
	fprintf(file, "cios = %d\n", cios);
	fprintf(file, "keyset = %d\n", keyset);
	fprintf(file, "xflip = %d\n", xflip);
	fprintf(file, "gridRows = %d\n", gridRows);
	fprintf(file, "quickboot = %d\n", quickboot);
	fprintf(file, "wsprompt = %d\n", wsprompt);
	fprintf(file, "parentalcontrol = %d\n", parentalcontrol);
	fprintf(file, "covers_path = %s\n", covers_path);
	fprintf(file, "covers2d_path = %s\n", covers2d_path);
	fprintf(file, "coversFull_path = %s\n", coversFull_path);
	fprintf(file, "theme_path = %s\n", theme_path);
	fprintf(file, "theme = %s\n", theme);
	fprintf(file, "disc_path = %s\n", disc_path);
	fprintf(file, "language_path = %s\n", language_path);
	fprintf(file, "languagefiles_path = %s\n", languagefiles_path);
	fprintf(file, "TxtCheatcodespath = %s\n", TxtCheatcodespath);
	fprintf(file, "titlestxt_path = %s\n", titlestxt_path);
	fprintf(file, "gamesound = %d\n", gamesound);
	fprintf(file, "dolpath = %s\n", dolpath);
	fprintf(file, "ogg_path = %s\n", ogg_path);
	fprintf(file, "wiilight = %d\n", wiilight);
	fprintf(file, "gameDisplay = %d\n", gameDisplay);
	fprintf(file, "update_path = %s\n", update_path);
	fprintf(file, "homebrewapps_path = %s\n", homebrewapps_path);
	fprintf(file, "BNRCachePath = %s\n", BNRCachePath);
	fprintf(file, "Cheatcodespath = %s\n", Cheatcodespath);
	fprintf(file, "BcaCodepath = %s\n", BcaCodepath);
	fprintf(file, "WipCodepath = %s\n", WipCodepath);
	fprintf(file, "WDMpath = %s\n", WDMpath);
	fprintf(file, "titlesOverride = %d\n", titlesOverride);
	fprintf(file, "ForceDiscTitles = %d\n", ForceDiscTitles);
	fprintf(file, "patchcountrystrings = %d\n", patchcountrystrings);
	fprintf(file, "screensaver = %d\n", screensaver);
	fprintf(file, "musicloopmode = %d\n", musicloopmode);
	fprintf(file, "autonetwork = %d\n", autonetwork);
	fprintf(file, "discart = %d\n", discart);
	fprintf(file, "coversfull = %d\n", coversfull);
	fprintf(file, "partition = %d\n", partition);
	fprintf(file, "marknewtitles = %d\n", marknewtitles);
	fprintf(file, "ShowFreeSpace = %d\n", ShowFreeSpace);
	fprintf(file, "InstallToDir = %d\n", InstallToDir);
	fprintf(file, "GameSplit = %d\n", GameSplit);
	fprintf(file, "InstallPartitions = %08X\n", InstallPartitions);
	fprintf(file, "PlaylogUpdate = %d\n", PlaylogUpdate);
	fprintf(file, "ParentalBlocks = %08X\n", ParentalBlocks);
	fprintf(file, "returnTo = %s\n", returnTo);
	fprintf(file, "HomeMenu = %d\n", HomeMenu);
	fprintf(file, "MultiplePartitions = %d\n", MultiplePartitions);
	fprintf(file, "USBPort = %d\n", USBPort);
	fprintf(file, "USBAutoMount = %d\n", USBAutoMount);
	fprintf(file, "CacheTitles = %d\n", CacheTitles);
	fprintf(file, "BlockIOSReload = %d\n", BlockIOSReload);
	fprintf(file, "WSFactor = %0.3f\n", WSFactor);
	fprintf(file, "FontScaleFactor = %0.3f\n", FontScaleFactor);
	fprintf(file, "ClockFontScaleFactor = %0.3f\n", ClockFontScaleFactor);
	fprintf(file, "EnabledCategories = ");
	for(u32 i = 0; i < EnabledCategories.size(); ++i)
	{
		fprintf(file, "%i", EnabledCategories[i]);
		if(i+1 < EnabledCategories.size())
			fprintf(file, ",");
	}
	fprintf(file, "\n");
	fprintf(file, "RequiredCategories = ");
	for(u32 i = 0; i < RequiredCategories.size(); ++i)
	{
		fprintf(file, "%i", RequiredCategories[i]);
		if(i+1 < RequiredCategories.size())
			fprintf(file, ",");
	}
	fprintf(file, "\n");
	fprintf(file, "ForbiddenCategories = ");
	for(u32 i = 0; i < ForbiddenCategories.size(); ++i)
	{
		fprintf(file, "%i", ForbiddenCategories[i]);
		if(i+1 < ForbiddenCategories.size())
			fprintf(file, ",");
	}
	fprintf(file, "\n");
	fprintf(file, "Wiinnertag = %d\n", Wiinnertag);
	fprintf(file, "WiinnertagPath = %s\n", WiinnertagPath);
	fprintf(file, "SelectedGame = %d\n", SelectedGame);
	fprintf(file, "GameListOffset = %d\n", GameListOffset);
	fprintf(file, "sneekVideoPatch = %d\n", sneekVideoPatch);
	fprintf(file, "NandEmuMode = %d\n", NandEmuMode);
	fprintf(file, "NandEmuChanMode = %d\n", NandEmuChanMode);
	fprintf(file, "NandEmuPath = %s\n", NandEmuPath);
	fprintf(file, "NandEmuChanPath = %s\n", NandEmuChanPath);
	fprintf(file, "UseSystemFont = %d\n", UseSystemFont);
	fprintf(file, "Hooktype = %d\n", Hooktype);
	fprintf(file, "WiirdDebugger = %d\n", WiirdDebugger);
	fprintf(file, "WiirdDebuggerPause = %d\n", WiirdDebuggerPause);
	fprintf(file, "ShowPlayCount = %d\n", ShowPlayCount);
	fprintf(file, "LoaderMode = %d\n", LoaderMode);
	fprintf(file, "SearchMode = %d\n", SearchMode);
	fprintf(file, "GameAspectRatio = %d\n", GameAspectRatio);
	fprintf(file, "PointerSpeed = %g\n", PointerSpeed);
	fprintf(file, "UseChanLauncher = %d\n", UseChanLauncher);
	fprintf(file, "AdjustOverscanX = %d\n", AdjustOverscanX);
	fprintf(file, "AdjustOverscanY = %d\n", AdjustOverscanY);
	fprintf(file, "TooltipDelay = %d\n", TooltipDelay);
	fprintf(file, "GameWindowMode = %d\n", GameWindowMode);
	fprintf(file, "CacheBNRFiles = %d\n", CacheBNRFiles);
	fprintf(file, "BannerAnimStart = %d\n", BannerAnimStart);
	fprintf(file, "BannerGridSpeed = %g\n", BannerGridSpeed);
	fprintf(file, "BannerZoomDuration = %d\n", BannerZoomDuration);
	fprintf(file, "BannerProjectionOffsetX = %g\n", BannerProjectionOffsetX);
	fprintf(file, "BannerProjectionOffsetY = %g\n", BannerProjectionOffsetY);
	fprintf(file, "BannerProjectionWidth = %g\n", BannerProjectionWidth);
	fprintf(file, "BannerProjectionHeight = %g\n", BannerProjectionHeight);
	fprintf(file, "GCBannerScale = %g\n", GCBannerScale);
	fprintf(file, "GameCubePath = %s\n", GameCubePath);
	fprintf(file, "GameCubeSDPath = %s\n", GameCubeSDPath);
	fprintf(file, "GameCubeMode = %d\n", GameCubeMode);
	fprintf(file, "GameCubeSource = %d\n", GameCubeSource);
	fprintf(file, "MultiDiscPrompt = %d\n", MultiDiscPrompt);
	fprintf(file, "DMLVideo = %d\n", DMLVideo);
	fprintf(file, "DMLProgPatch = %d\n", DMLProgPatch);
	fprintf(file, "DMLNMM = %d\n", DMLNMM);
	fprintf(file, "DMLActivityLED = %d\n", DMLActivityLED);
	fprintf(file, "DMLPADHOOK = %d\n", DMLPADHOOK);
	fprintf(file, "DMLNoDisc2 = %d\n", DMLNoDisc2);
	fprintf(file, "DMLWidescreen = %d\n", DMLWidescreen);
	fprintf(file, "DMLScreenshot = %d\n", DMLScreenshot);
	fprintf(file, "DMLJPNPatch = %d\n", DMLJPNPatch);
	fprintf(file, "DMLDebug = %d\n", DMLDebug);
	fprintf(file, "NINDeflicker = %d\n", NINDeflicker);
	fprintf(file, "NINPal50Patch = %d\n", NINPal50Patch);
	fprintf(file, "NINWiiUWide = %d\n", NINWiiUWide);
	fprintf(file, "NINVideoScale = %d\n", NINVideoScale);
	fprintf(file, "NINVideoOffset = %d\n", NINVideoOffset);
	fprintf(file, "NINRemlimit = %d\n", NINRemlimit);
	fprintf(file, "NINMCEmulation = %d\n", NINMCEmulation);
	fprintf(file, "NINMCSize = %d\n", NINMCSize);
	fprintf(file, "NINAutoboot = %d\n", NINAutoboot);
	fprintf(file, "NINSettings = %d\n", NINSettings);
	fprintf(file, "NINUSBHID = %d\n", NINUSBHID);
	fprintf(file, "NINMaxPads = %d\n", NINMaxPads);
	fprintf(file, "NINNativeSI = %d\n", NINNativeSI);
	fprintf(file, "NINOSReport = %d\n", NINOSReport);
	fprintf(file, "NINLED = %d\n", NINLED);
	fprintf(file, "NINLog = %d\n", NINLog);
	fprintf(file, "DEVOMCEmulation = %d\n", DEVOMCEmulation);
	fprintf(file, "DEVOWidescreen = %d\n", DEVOWidescreen);
	fprintf(file, "DEVOActivityLED = %d\n", DEVOActivityLED);
	fprintf(file, "DEVOFZeroAX = %d\n", DEVOFZeroAX);
	fprintf(file, "DEVOTimerFix = %d\n", DEVOTimerFix);
	fprintf(file, "DEVODButtons = %d\n", DEVODButtons);
	fprintf(file, "DEVOCropOverscan = %d\n", DEVOCropOverscan);
	fprintf(file, "DEVODiscDelay = %d\n", DEVODiscDelay);
	fprintf(file, "DEVOLoaderPath = %s\n", DEVOLoaderPath);
	fprintf(file, "NINLoaderPath = %s\n", NINLoaderPath);
	fprintf(file, "GCInstallCompressed = %d\n", GCInstallCompressed);
	fprintf(file, "GCInstallAligned = %d\n", GCInstallAligned);
	fprintf(file, "PrivateServer = %d\n", PrivateServer);
	fprintf(file, "CustomBannersURL = %s\n", CustomBannersURL);
	fclose(file);

	return true;
}
Example #5
0
/*
 * loadservers - load list of NTP servers from configuration file
 */
void
loadservers(
	char *cfgpath
	)
{
	register int i;
	int errflg;
	int peerversion;
	int minpoll;
	int maxpoll;
	/* int ttl; */
	int srvcnt;
	/* u_long peerkey; */
	int peerflags;
	struct sockaddr_in peeraddr;
	FILE *fp;
	char line[MAXLINE];
	char *(tokens[MAXTOKENS]);
	int ntokens;
	int tok;
	const char *config_file;
#ifdef SYS_WINNT
	char *alt_config_file;
	LPTSTR temp;
	char config_file_storage[MAX_PATH];
	char alt_config_file_storage[MAX_PATH];
#endif /* SYS_WINNT */
	struct server *server, *srvlist;

	/*
	 * Initialize, initialize
	 */
	srvcnt = 0;
	srvlist = 0;
	errflg = 0;
#ifdef DEBUG
	debug = 0;
#endif	/* DEBUG */
#ifndef SYS_WINNT
	config_file = cfgpath ? cfgpath : CONFIG_FILE;
#else
	if (cfgpath) {
		config_file = cfgpath;
	} else {
		temp = CONFIG_FILE;
		if (!ExpandEnvironmentStrings((LPCTSTR)temp, (LPTSTR)config_file_storage, (DWORD)sizeof(config_file_storage))) {
			msyslog(LOG_ERR, "ExpandEnvironmentStrings CONFIG_FILE failed: %m\n");
			exit(1);
		}
		config_file = config_file_storage;
	}

	temp = ALT_CONFIG_FILE;
	if (!ExpandEnvironmentStrings((LPCTSTR)temp, (LPTSTR)alt_config_file_storage, (DWORD)sizeof(alt_config_file_storage))) {
		msyslog(LOG_ERR, "ExpandEnvironmentStrings ALT_CONFIG_FILE failed: %m\n");
		exit(1);
	}
	alt_config_file = alt_config_file_storage;
M
#endif /* SYS_WINNT */

	if ((fp = fopen(FindConfig(config_file), "r")) == NULL)
	{
		fprintf(stderr, "getconfig: Couldn't open <%s>\n", FindConfig(config_file));
		msyslog(LOG_INFO, "getconfig: Couldn't open <%s>", FindConfig(config_file));
#ifdef SYS_WINNT
		/* Under WinNT try alternate_config_file name, first NTP.CONF, then NTP.INI */

		if ((fp = fopen(FindConfig(alt_config_file), "r")) == NULL) {

			/*
			 * Broadcast clients can sometimes run without
			 * a configuration file.
			 */

			fprintf(stderr, "getconfig: Couldn't open <%s>\n", FindConfig(alt_config_file));
			msyslog(LOG_INFO, "getconfig: Couldn't open <%s>", FindConfig(alt_config_file));
			return;
		}
#else  /* not SYS_WINNT */
		return;
#endif /* not SYS_WINNT */
	}

	while ((tok = gettokens(fp, line, tokens, &ntokens))
	       != CONFIG_UNKNOWN) {
		switch(tok) {
		    case CONFIG_PEER:
		    case CONFIG_SERVER:
			
			if (ntokens < 2) {
				msyslog(LOG_ERR,
					"No address for %s, line ignored",
					tokens[0]);
				break;
			}
			
			if (!getnetnum(tokens[1], &peeraddr, 1)) {
				/* Resolve now, or lose! */
				break;
			} else {
				errflg = 0;
				
				/* Shouldn't be able to specify multicast */
				if (IN_CLASSD(ntohl(peeraddr.sin_addr.s_addr))
				    || ISBADADR(&peeraddr)) {
					msyslog(LOG_ERR,
						"attempt to configure invalid address %s",
						ntoa(&peeraddr));
					break;
				}
			}

			peerversion = NTP_VERSION;
			minpoll = NTP_MINDPOLL;
			maxpoll = NTP_MAXDPOLL;
			/* peerkey = 0; */
			peerflags = 0;
			/* ttl = 0; */
			for (i = 2; i < ntokens; i++)
			    switch (matchkey(tokens[i], mod_keywords)) {
				case CONF_MOD_VERSION:
				    if (i >= ntokens-1) {
					    msyslog(LOG_ERR,
						    "peer/server version requires an argument");
					    errflg = 1;
					    break;
				    }
				    peerversion = atoi(tokens[++i]);
				    if ((u_char)peerversion > NTP_VERSION
					|| (u_char)peerversion < NTP_OLDVERSION) {
					    msyslog(LOG_ERR,
						    "inappropriate version number %s, line ignored",
						    tokens[i]);
					    errflg = 1;
				    }
				    break;
					
				case CONF_MOD_KEY:
				    if (i >= ntokens-1) {
					    msyslog(LOG_ERR,
						    "key: argument required");
					    errflg = 1;
					    break;
				    }
				    ++i;
				    /* peerkey = (int)atol(tokens[i]); */
				    peerflags |= FLAG_AUTHENABLE;
				    break;

				case CONF_MOD_MINPOLL:
				    if (i >= ntokens-1) {
					    msyslog(LOG_ERR,
						    "minpoll: argument required");
					    errflg = 1;
					    break;
				    }
				    minpoll = atoi(tokens[++i]);
				    if (minpoll < NTP_MINPOLL)
					minpoll = NTP_MINPOLL;
				    break;

				case CONF_MOD_MAXPOLL:
				    if (i >= ntokens-1) {
					    msyslog(LOG_ERR,
						    "maxpoll: argument required"
						    );
					    errflg = 1;
					    break;
				    }
				    maxpoll = atoi(tokens[++i]);
				    if (maxpoll > NTP_MAXPOLL)
					maxpoll = NTP_MAXPOLL;
				    break;

				case CONF_MOD_PREFER:
				    peerflags |= FLAG_PREFER;
				    break;

				case CONF_MOD_BURST:
				    peerflags |= FLAG_BURST;
				    break;

				case CONF_MOD_SKEY:
				    peerflags |= FLAG_SKEY | FLAG_AUTHENABLE;
				    break;

				case CONF_MOD_TTL:
				    if (i >= ntokens-1) {
					    msyslog(LOG_ERR,
						    "ttl: argument required");
					    errflg = 1;
					    break;
				    }
				    ++i;
				    /* ttl = atoi(tokens[i]); */
				    break;

				case CONF_MOD_MODE:
				    if (i >= ntokens-1) {
					    msyslog(LOG_ERR,
						    "mode: argument required");
					    errflg = 1;
					    break;
				    }
				    ++i;
				    /* ttl = atoi(tokens[i]); */
				    break;

				case CONFIG_UNKNOWN:
				    errflg = 1;
				    break;
			    }
			if (minpoll > maxpoll) {
				msyslog(LOG_ERR, "config error: minpoll > maxpoll");
				errflg = 1;
			}
			if (errflg == 0) {
				server = (struct server *)emalloc(sizeof(struct server));
				memset((char *)server, 0, sizeof(struct server));
				server->srcadr = peeraddr;
				server->version = peerversion;
				server->dispersion = PEER_MAXDISP;
				server->next_server = srvlist;
				srvlist = server;
				srvcnt++;
			}
			break;
			
			case CONFIG_KEYS:
			if (ntokens >= 2) {
				key_file = (char *) emalloc(strlen(tokens[1]) + 1);
				strcpy(key_file, tokens[1]);
			}
			break;
		}
	}
	(void) fclose(fp);

	/* build final list */
	sys_numservers = srvcnt;
	sys_servers = (struct server **) 
	    emalloc(sys_numservers * sizeof(struct server *));
	for(i=0;i<sys_numservers;i++) {
		sys_servers[i] = srvlist;
		srvlist = srvlist->next_server;
	}
}