Changeset 255
- Timestamp:
- 04/04/03 19:59:32 (6 years ago)
- Files:
-
- trunk (modified) (1 prop)
- trunk/.cvsignore (modified) (1 diff)
- trunk/Makefile.am (modified) (1 diff)
- trunk/autogen.sh (modified) (1 diff)
- trunk/configure.ac (modified) (2 diffs)
- trunk/po (added)
- trunk/po/.cvsignore (added)
- trunk/po/POTFILES.in (added)
- trunk/po/pl.po (added)
- trunk/src/ggtrans.h (modified) (2 diffs)
- trunk/src/main.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk
- Property svn:ignore changed from
Makefile
Makefile.in
aclocal.m4
autoscan.log
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
missing
mkinstalldirs
stamp-h
stamp-h.in
stamp-h1
jabber-gg-transport-*.tar.gz
autom4te.cache to
Makefile
Makefile.in
aclocal.m4
autoscan.log
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
depcomp
install-sh
libtool
ltmain.sh
missing
mkinstalldirs
stamp-h
stamp-h.in
stamp-h1
jabber-gg-transport-*.tar.gz
autom4te.cache
intl
- Property svn:ignore changed from
trunk/.cvsignore
r174 r255 21 21 jabber-gg-transport-*.tar.gz 22 22 autom4te.cache 23 intl trunk/Makefile.am
r116 r255 1 1 2 SUBDIRS = libxode src2 SUBDIRS = intl libxode src po 3 3 4 4 EXTRA_DIST = jggtrans.xml jggtrans.xml.Pl TODO BUGS README.Pl INSTALL.Pl trunk/autogen.sh
r130 r255 3 3 ( cd libxode ; ./autogen.sh ) || exit 1 4 4 5 libtoolize --copy --force 6 aclocal 5 libtoolize --force 6 rm -f po/ChangeLog 7 gettextize --force 8 aclocal 7 9 autoheader 8 10 automake -a trunk/configure.ac
r254 r255 49 49 AC_CHECK_HEADERS([sys/socket.h netdb.h netinet/in.h]) 50 50 AC_CHECK_HEADERS([sys/time.h unistd.h errno.h fcntl.h]) 51 AC_NEED_STDINT_H52 51 53 52 # Checks for typedefs, structures, and compiler characteristics. … … 67 66 AC_CONFIG_SUBDIRS([libxode]) 68 67 69 AC_CONFIG_FILES([Makefile src/Makefile ])68 AC_CONFIG_FILES([Makefile src/Makefile intl/Makefile po/Makefile.in]) 70 69 AC_OUTPUT trunk/src/ggtrans.h
r185 r255 1 /* $Id: ggtrans.h,v 1. 6 2003/01/15 14:13:12 jajcus Exp $ */1 /* $Id: ggtrans.h,v 1.7 2003/04/04 17:59:32 jajcus Exp $ */ 2 2 3 3 /* … … 22 22 23 23 #include <libxode.h> 24 #include <libintl.h> 24 25 #include <glib.h> 25 26 #include "../config.h" 27 28 /* gettext shortcut for translating messages */ 29 #define _(String) gettext (String) 30 31 /* dummy gettext shortcut for translating error/debug messages after log handler is set */ 32 #define __(String) gettext (String) 26 33 27 34 extern GMainLoop *main_loop; trunk/src/main.c
r241 r255 1 /* $Id: main.c,v 1.3 4 2003/03/24 14:43:37jajcus Exp $ */1 /* $Id: main.c,v 1.35 2003/04/04 17:59:32 jajcus Exp $ */ 2 2 3 3 /* … … 162 162 switch(log_level){ 163 163 case G_LOG_LEVEL_ERROR: 164 fprintf(f, "Fatal error: %s\n",message);164 fprintf(f,_("Fatal error: %s\n"),_(message)); 165 165 break; 166 166 case G_LOG_LEVEL_CRITICAL: 167 fprintf(f, "Error: %s\n",message);167 fprintf(f,_("Error: %s\n"),_(message)); 168 168 break; 169 169 case G_LOG_LEVEL_WARNING: 170 fprintf(f, "Warning: %s\n",message);170 fprintf(f,_("Warning: %s\n"),_(message)); 171 171 break; 172 172 case G_LOG_LEVEL_MESSAGE: … … 174 174 case G_LOG_LEVEL_INFO: 175 175 if (debug_level<0) break; 176 fprintf(f,"%s\n", message);176 fprintf(f,"%s\n",_(message)); 177 177 break; 178 178 case G_LOG_LEVEL_DEBUG: 179 179 if (debug_level>0) 180 fprintf(f, "Debug: %s\n",message);180 fprintf(f,_("Debug: %s\n"),_(message)); 181 181 break; 182 182 default: 183 fprintf(f, "Unknown: %s\n",message);183 fprintf(f,_("Unknown: %s\n"),_(message)); 184 184 break; 185 185 } … … 191 191 switch(log_level){ 192 192 case G_LOG_LEVEL_ERROR: 193 syslog(LOG_ERR, "Fatal error: %s",message);193 syslog(LOG_ERR,_("Fatal error: %s"),_(message)); 194 194 break; 195 195 case G_LOG_LEVEL_CRITICAL: 196 syslog(LOG_ERR, "Error: %s",message);196 syslog(LOG_ERR,_("Error: %s"),_(message)); 197 197 break; 198 198 case G_LOG_LEVEL_WARNING: 199 syslog(LOG_WARNING, "Warning: %s",message);199 syslog(LOG_WARNING,_("Warning: %s"),_(message)); 200 200 break; 201 201 case G_LOG_LEVEL_MESSAGE: 202 202 if (debug_level<-1) break; 203 syslog(LOG_NOTICE,"%s", message);203 syslog(LOG_NOTICE,"%s",_(message)); 204 204 break; 205 205 case G_LOG_LEVEL_INFO: 206 206 if (debug_level<0) break; 207 syslog(LOG_NOTICE,"%s", message);207 syslog(LOG_NOTICE,"%s",_(message)); 208 208 break; 209 209 case G_LOG_LEVEL_DEBUG: 210 210 if (debug_level>0) 211 syslog(LOG_DEBUG, "Debug: %s\n",message);211 syslog(LOG_DEBUG,_("Debug: %s\n"),_(message)); 212 212 break; 213 213 default: 214 syslog(LOG_NOTICE, "Unknown: %s\n",message);214 syslog(LOG_NOTICE,_("Unknown: %s\n"),_(message)); 215 215 break; 216 216 } … … 220 220 const gchar *message, gpointer user_data){ 221 221 222 char *lc_ctype,*lc_messages; 223 224 lc_ctype=setlocale(LC_CTYPE,NULL); 225 lc_messages=setlocale(LC_MESSAGES,NULL); 226 222 227 log_level&=G_LOG_LEVEL_MASK; 223 228 if (foreground) log_handler_file(stderr,log_domain,log_level,message); 224 229 if (log_file) log_handler_file(log_file,log_domain,log_level,message); 225 230 if (use_syslog) log_handler_syslog(log_domain,log_level,message); 231 232 setlocale(LC_CTYPE,lc_ctype); 233 setlocale(LC_MESSAGES,lc_ctype); 226 234 } 227 235 … … 231 239 int fd; 232 240 233 debug( "Daemonizing...");241 debug(__("Daemonizing...")); 234 242 pid=fork(); 235 if (pid==-1) g_error( "Failed to fork(): %s",g_strerror(errno));243 if (pid==-1) g_error(__("Failed to fork(): %s"),g_strerror(errno)); 236 244 if (pid){ 237 245 if (pidfile){ … … 239 247 fclose(pidfile); 240 248 } 241 debug( "Daemon born, pid %i.",pid);249 debug(__("Daemon born, pid %i."),pid); 242 250 exit(0); 243 251 } … … 261 269 if (sid==-1) abort(); 262 270 foreground=FALSE; 263 debug( "I am a daemon, I think.");271 debug(__("I am a daemon, I think.")); 264 272 return; 265 273 } … … 270 278 p=strrchr(name,'/'); 271 279 if (p) name=p+1; 272 printf( "\nJabber GaduGadu Transport %s\n",VERSION);273 printf( "\n");274 printf( "\tUsage: %s [OPTIONS]... [<config file>]\n",name);275 printf( "\nOptions:\n");276 printf( "\t-h This message\n");277 printf( "\t-f Run in foreground. Debug/error messages will be sent to stderr\n");278 printf( "\t-d <n> Log level (0(default) - normal, >0 more, <0 less)\n");279 printf( "\t-D <n> libgg debug level (enables also -f)\n");280 printf( "\t-u <user> Switch to uid of <user> on startup\n");281 printf( "\t-g <group> Switch to gid of <group> on startup\n");282 printf( "\n");280 printf(_("\nJabber GaduGadu Transport %s\n"),VERSION); 281 printf(_("\n")); 282 printf(_("\tUsage: %s [OPTIONS]... [<config file>]\n"),name); 283 printf(_("\nOptions:\n")); 284 printf(_("\t-h This message\n")); 285 printf(_("\t-f Run in foreground. Debug/error messages will be sent to stderr\n")); 286 printf(_("\t-d <n> Log level (0(default) - normal, >0 more, <0 less)\n")); 287 printf(_("\t-D <n> libgg debug level (enables also -f)\n")); 288 printf(_("\t-u <user> Switch to uid of <user> on startup\n")); 289 printf(_("\t-g <group> Switch to gid of <group> on startup\n")); 290 printf(_("\n")); 283 291 } 284 292 … … 311 319 newgid=0; user=NULL; group=NULL; 312 320 321 /* use local locale for error and debug messages */ 322 setlocale(LC_MESSAGES,""); 323 setlocale(LC_CTYPE,""); 324 textdomain(PACKAGE); 325 313 326 saved_pwd=getcwd(saved_pwd_b,1024); 314 327 opterr=0; … … 334 347 break; 335 348 case 'u': 336 if (uid!=0) g_error( "Cannot change user.");349 if (uid!=0) g_error(_("Cannot change user.")); 337 350 user=optarg; 338 351 break; 339 352 case 'g': 340 if (uid!=0) g_error( "Cannot change group.");353 if (uid!=0) g_error(_("Cannot change group.")); 341 354 group=optarg; 342 355 break; 343 356 case '?': 344 357 if (isprint(optopt)) 345 fprintf(stderr, "Unknown command-line option: -%c.\n",optopt);358 fprintf(stderr,_("Unknown command-line option: -%c.\n"),optopt); 346 359 else 347 fprintf(stderr, "Unknown command-line option: -\\%03o.\n",optopt);360 fprintf(stderr,_("Unknown command-line option: -\\%03o.\n"),optopt); 348 361 usage(argv[0]); 349 362 return 1; 350 363 default: 351 g_error( "Error while processing command line options");364 g_error(_("Error while processing command line options")); 352 365 break; 353 366 } … … 355 368 356 369 if (optind<argc-1){ 357 fprintf(stderr, "Unexpected argument: %s\n",argv[optind]);370 fprintf(stderr,_("Unexpected argument: %s\n"),argv[optind]); 358 371 usage(argv[0]); 359 372 return 1; … … 368 381 | G_LOG_LEVEL_DEBUG,log_handler,NULL); 369 382 383 /* now the log handlers worry about the right language */ 384 setlocale(LC_MESSAGES,"C"); 385 setlocale(LC_CTYPE,"C"); 386 370 387 config=xmlnode_file(config_file); 371 388 if (!config){ 372 g_error( "Couldn't load config!");389 g_error(__("Couldn't load config!")); 373 390 return 1; 374 391 } 375 392 str=xmlnode_get_name(config); 376 393 if (!str || strcmp(str,"jggtrans")){ 377 g_error( "%s doesn't look like jggtrans config file.",config_file);394 g_error(__("%s doesn't look like jggtrans config file."),config_file); 378 395 return 1; 379 396 } … … 386 403 if (!strcmp(log_type,"syslog")){ 387 404 if (log_facility!=-1){ 388 g_warning( "Multiple syslog configs specified. Using only one.");405 g_warning(__("Multiple syslog configs specified. Using only one.")); 389 406 continue; 390 407 } … … 397 414 if (!strcmp(facilitynames[log_facility].name,str)) break; 398 415 if (!facilitynames[log_facility].name) 399 g_error( "Unknown syslog facility: %s",str);416 g_error(__("Unknown syslog facility: %s"),str); 400 417 } 401 418 else if (!strcmp(log_type,"file")){ 402 if (log_filename) g_warning( "Multiple log files specified. Using only one.");419 if (log_filename) g_warning(__("Multiple log files specified. Using only one.")); 403 420 else{ 404 421 data=xmlnode_get_data(tag); … … 407 424 } 408 425 } 409 else g_warning( "Ignoring unknown log type: %s",xmlnode2str(tag));426 else g_warning(__("Ignoring unknown log type: %s"),xmlnode2str(tag)); 410 427 } 411 428 … … 424 441 if (r==1 && pid>0){ 425 442 r=kill(pid,0); 426 if (!r || (r && errno!=ESRCH)) g_error( "jggtrans already running");443 if (!r || (r && errno!=ESRCH)) g_error(__("jggtrans already running")); 427 444 if (r){ 428 g_warning( "Stale pid file. Removing.");445 g_warning(__("Stale pid file. Removing.")); 429 446 unlink(pid_filename); 430 447 } 431 448 } 432 else if (r!=EOF) g_error( "Invalid pid file.");449 else if (r!=EOF) g_error(__("Invalid pid file.")); 433 450 } 434 451 pidfile=fopen(pid_filename,"w"); 435 452 if (pidfile==NULL) 436 g_error( "Couldn't open pidfile %s",pid_filename);453 g_error(__("Couldn't open pidfile %s"),pid_filename); 437 454 } 438 455 else … … 441 458 if (group){ 442 459 grp=getgrnam(group); 443 if (!grp) g_error( "Couldn't find group %s",group);460 if (!grp) g_error(__("Couldn't find group %s"),group); 444 461 newgid=grp->gr_gid; 445 462 } 446 463 if (user){ 447 464 pwd=getpwnam(user); 448 if (!pwd) g_error( "Couldn't find user %s",user);465 if (!pwd) g_error(__("Couldn't find user %s"),user); 449 466 if (newgid<=0) newgid=pwd->pw_gid; 450 467 fchown(fileno(pidfile),pwd->pw_uid,newgid); 451 if (setgid(newgid)) g_error( "Couldn't change group: %s",g_strerror(errno));452 if (initgroups(user,newgid)) g_error( "Couldn't init groups: %s",g_strerror(errno));453 if (setuid(pwd->pw_uid)) g_error( "Couldn't change user: %s",g_strerror(errno));454 } 455 else if (uid==0 && !restarting) g_error( "Refusing to run with uid=0");468 if (setgid(newgid)) g_error(__("Couldn't change group: %s"),g_strerror(errno)); 469 if (initgroups(user,newgid)) g_error(__("Couldn't init groups: %s"),g_strerror(errno)); 470 if (setuid(pwd->pw_uid)) g_error(__("Couldn't change user: %s"),g_strerror(errno)); 471 } 472 else if (uid==0 && !restarting) g_error(__("Refusing to run with uid=0")); 456 473 457 474 main_loop=g_main_new(0); … … 471 488 if (log_filename){ 472 489 log_file=fopen(log_filename,"a"); 473 if (!log_file) g_critical( "Couldn't open log file '%s': %s",490 if (!log_file) g_critical(__("Couldn't open log file '%s': %s"), 474 491 log_filename,g_strerror(errno)); 475 492 if (log_file) setvbuf(log_file,NULL,_IOLBF,0); … … 503 520 int n; 504 521 505 g_message( "Restarting in %i seconds.\n",restart_timeout);522 g_message(__("Restarting in %i seconds.\n"),restart_timeout); 506 523 if (restart_timeout>0) sleep(restart_timeout); 507 524 if (saved_pwd) chdir(saved_pwd); … … 524 541 } 525 542 526 g_message( "Exiting normally.\n");543 g_message(__("Exiting normally.\n")); 527 544 528 545 g_log_remove_handler(NULL,lh);
