Example #1
0
void MyDialog2::Reset(void)
{
	char PathName[MAX_PATH + 50];
	char *Walker;
	int i;

	::GetModuleFileName(NULL, PathName, MAX_PATH);

	for (Walker = PathName; *Walker != 0; Walker++);
	
	while (*Walker != '\\')
		Walker--;

	lstrcpy(Walker + 1, "Default.olsr");

	if (OpenConfigFile(PathName) < 0)
		return;

	m_Ipv6Check.SetCheck(FALSE);

	if (Conf->interfaces == NULL)
	{
		for (i = 0; i < Interfaces->GetSize(); i++)
		{
			if ((*IsWlan)[i] == "-")
				m_InterfaceList.SetCheck(i, FALSE);

			else
				m_InterfaceList.SetCheck(i, TRUE);
		}
	}
}
Example #2
0
void ParticleEditor::on_actionOpenConfig_triggered()
{
	QString openFile = QFileDialog::getOpenFileName(this, FontChina::G2U("打开一个配置文件"), g_save_Dir, tr("Conf (*.conf)"));
	if (!openFile.isEmpty()){
		fileName = openFile;
		g_save_Dir = fileName.section("/", 0, -2);
		OpenConfigFile(fileName);
	}
}
Example #3
0
void MyDialog2::OnOpenButton()
{
	CFileDialog FileDialog(TRUE);
	CString FileName = "Default.olsr";
	CString PathName;

	FileDialog.m_ofn.lpstrFilter = "Configuration file (*.olsr)\0*.olsr\0";
	FileDialog.m_ofn.nFilterIndex = 1;

	FileDialog.m_ofn.lpstrFile = FileName.GetBuffer(500);
	FileDialog.m_ofn.nMaxFile = 500;

	if (FileDialog.DoModal() == IDOK)
	{
		PathName = FileDialog.GetPathName();

		if (OpenConfigFile(PathName) < 0)
			AfxMessageBox("Cannot open configuration file '" + PathName + "'.");
	}

	FileName.ReleaseBuffer();
}
Example #4
0
bool CleanFiles(HWND window) {
  auto config = ReadConfig(OpenConfigFile());

  auto keep_count = config["keep_count"].get_int64();
  if (keep_count <= 0)
    return false;

  auto path_ns = config["path_to_clean"].get_string();
  if (path_ns.empty())
    return false;

  plx::FilePath path(std::wstring(path_ns.begin(), path_ns.end()));
  auto dir = OpenDirectory(path);
  if (dir.status() != (plx::File::directory | plx::File::existing))
    return false;

  if (!EnumAndClean(plx::FilesInfo::FromDir(dir), path, keep_count))
    return false;

  int timer_ms = 1000 * plx::To<int>(config["check_frequency"].get_int64());
  ::SetTimer(window, 1007, timer_ms , nullptr);
  return true;
}
Example #5
0
int
main(int argc, char **argv)
{
    char username[256];
    char password[256];
    char wstr[256];
    int err = 0;

    openlog("msnt_auth", LOG_PID, LOG_USER);
    setbuf(stdout, NULL);

    /* Read configuration file. Abort wildly if error. */
    if (OpenConfigFile() == 1)
	return 1;

    /*
     * Read denied and allowed user files.
     * If they fails, there is a serious problem.
     * Check syslog messages. Deny all users while in this state.
     * The msntauth process should then be killed.
     */
    if ((Read_denyusers() == 1) || (Read_allowusers() == 1)) {
	while (1) {
	    memset(wstr, '\0', sizeof(wstr));
	    fgets(wstr, 255, stdin);
	    puts("ERR");
	}
    }
    /*
     * Make Check_forchange() the handle for HUP signals.
     * Don't use alarms any more. I don't think it was very
     * portable between systems.
     * XXX this should be sigaction()
     */
    signal(SIGHUP, Check_forchange);

    while (1) {
	int n;
	/* Read whole line from standard input. Terminate on break. */
	memset(wstr, '\0', sizeof(wstr));
	if (fgets(wstr, 255, stdin) == NULL)
	    break;
	/* ignore this line if we didn't get the end-of-line marker */
	if (NULL == strchr(wstr, '\n')) {
	    err = 1;
	    continue;
	}
	if (err) {
	    syslog(LOG_WARNING, "oversized message");
	    goto error;
	}

	/*
	 * extract username and password.
	 * XXX is sscanf() safe?
	 */
	username[0] = '\0';
	password[0] = '\0';
	n = sscanf(wstr, "%s %[^\n]", username, password);
	if (2 != n) {
	    puts("ERR");
	    continue;
	}
	/* Check for invalid or blank entries */
	if ((username[0] == '\0') || (password[0] == '\0')) {
	    puts("ERR");
	    continue;
	}
	Checktimer();		/* Check if the user lists have changed */

	rfc1738_unescape(username);
	rfc1738_unescape(password);

	/*
	 * Check if user is explicitly denied or allowed.
	 * If user passes both checks, they can be authenticated.
	 */
	if (Check_user(username) == 1) {
	    syslog(LOG_INFO, "'%s' denied", username);
	    puts("ERR");
	} else if (QueryServers(username, password) == 0)
	    puts("OK");
	else {
	    syslog(LOG_INFO, "'%s' login failed", username);
error:
	    puts("ERR");
	}
	err = 0;
    }

    return 0;
}