[rfc][icedtea-web] read properties values from C part - library edition :)

Omair Majid omajid at redhat.com
Wed Mar 20 09:44:55 PDT 2013

On 03/20/2013 10:19 AM, Jiri Vanek wrote:
> IcedTeaParsePropeties.h
> #include <string>
> using namespace std;

While "using namespace std" itself is probably okay [1], it's a bad idea
to add "using namespace" in header files. C preprocessors work work by
literally inserting the entire #include'd file in the file that has the
#include. So every file that #include's this header will automatically
get a "using namespace std", which could be bad if that file has classes
that conflict with classes in the standard library [2].

> //public api
> string  user_properties_file();
> bool  find_system_config_file(string& dest);
> bool  find_custom_jre(string& dest);
> bool  read_deploy_property_value(string property, string& dest);
> //end of public api

Please make sure none of these symbols are exported outside the plugin
shared object. The names are generic enough that it could lead to name
clashes easily.

> int main(void){
>         printf("user's settings file\n");
> 	cout << user_properties_file();
> 	printf("\nmain settings file:\n");
> 	cout << (main_properties_file());
> 	printf("\njava settings file \n");
> 	cout << (default_java_properties_file());
> 	printf("\nsystem config file\n");
> 	string a1;
> 	find_system_config_file(a1);
> 	cout <<  a1;
> 	printf("\ncustom jre\n");
> 	string a2;
> 	find_custom_jre(a2);
> 	cout << a2;
> 	printf("\nsome custom property\n");
> 	string a3;
> 	read_deploy_property_value("deployment.security.level", a3);
> 	cout << a3;
> 	printf("\n");

I am far from an expert on this, but please don't mix C-style printf's
and C++-style cout's like this.


[1] http://stackoverflow.com/q/1452721
[2] http://stackoverflow.com/a/4872531
PGP Key: 66484681 (http://pgp.mit.edu/)
Fingerprint = F072 555B 0A17 3957 4E95  0056 F286 F14F 6648 4681

More information about the distro-pkg-dev mailing list