示例#1
0
/* @note dynamic allocation confusion
char** array;
int clients;

// Read 'clients' from console:
cin >> clients;

// Allocate array of slots:
array = new char* [clients];

// Read all names from console:
char strName [128];

for (int i=0; i<clients; i++) {
  cin.getline (strName, sizeof (strName), '\n'); // Read it
  array [i] = _strdup (strName); // Get a duplicate and add it
}

// Now dump them back:
for (int n=0; n<clients; n++) {
  cout << array [i] << endl;
  free (array [i]); // De-allocate every ptr from '_strdup()'
}

// Release array itself:
delete [] array;

*/
BOOL BTIPerfClient::ParseCommandLine(Settings *pSetting, CString &szCmd)
{
	char **pargv = new char*[25]; // allocate big size
	int curPos = 0, count = 0;
	CString resToken;

	pargv[count] = new char[10];
	strcpy(pargv[count], "btiperf"); // program name
	count++;

	do
	{
		resToken= szCmd.Tokenize(L" ",curPos);
		
		pargv[count] = new char [resToken.GetLength()+1];
		unicode_to_ansi(resToken.GetBuffer(), pargv[count]);
		//pargv[count] =  argv[count];
		//*pargv++ = argv[count];

		count++;
	} while (resToken != _T(""));

	pSetting->ParseCommandLine(count-1, pargv);


	for(int i = 0; i < count; i++)
		delete pargv[i];
	delete [] pargv;


	return 0;
}
示例#2
0
void gendep(const deque<wstring>& params) {
  list<wstring> source_dirs, include_dirs;
  parse_cmd_line(params, source_dirs, include_dirs);
  wstring output;
  set<wstring> file_set;
  for (list<wstring>::const_iterator src_dir = source_dirs.begin(); src_dir != source_dirs.end(); src_dir++) {
    DirList dir_list(get_full_path_name(src_dir->empty() ? L"." : *src_dir));
    while (dir_list.next()) {
      if (!dir_list.data().is_dir() && is_valid_ext(dir_list.data().cFileName)) {
        process_file(output, file_set, add_trailing_slash(*src_dir) + dir_list.data().cFileName, include_dirs);
      }
    }
  }
  cout << unicode_to_ansi(output, CP_ACP);
}
示例#3
0
文件: sfx.cpp 项目: landswellsong/FAR
ByteVector generate_install_config(const SfxInstallConfig& config) {
  wstring text;
  text += L";!@Install@!UTF-8!\n";
  if (!config.title.empty())
    text += L"Title=\"" + config.title + L"\"\n";
  if (!config.begin_prompt.empty())
    text += L"BeginPrompt=\"" + config.begin_prompt + L"\"\n";
  if (!config.progress.empty())
    text += L"Progress=\"" + config.progress + L"\"\n";
  if (!config.run_program.empty())
    text += L"RunProgram=\"" + config.run_program + L"\"\n";
  if (!config.directory.empty())
    text += L"Directory=\"" + config.directory + L"\"\n";
  if (!config.execute_file.empty())
    text += L"ExecuteFile=\"" + config.execute_file + L"\"\n";
  if (!config.execute_parameters.empty())
    text += L"ExecuteParameters=\"" + config.execute_parameters + L"\"\n";
  text += L";!@InstallEnd@!\n";
  string utf8_text = unicode_to_ansi(text, CP_UTF8);
  return ByteVector(utf8_text.begin(), utf8_text.end());
}
示例#4
0
AnsiString unicode_to_ansi(const UnicodeString& u_str) {
  AnsiString a_str;
  unicode_to_ansi(a_str, u_str);
  return a_str;
}