Changeset 366
- Timestamp:
- 04/22/03 10:44:29 (6 years ago)
- Files:
-
- trunk/configure.ac (modified) (1 diff)
- trunk/src/acl.c (modified) (3 diffs)
- trunk/src/ggtrans.h (modified) (2 diffs)
- trunk/src/jabber.c (modified) (5 diffs)
- trunk/src/jid.c (modified) (3 diffs)
- trunk/src/main.c (modified) (16 diffs)
- trunk/src/register.c (modified) (8 diffs)
- trunk/src/stream.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/configure.ac
r361 r366 61 61 62 62 MKINSTALLDIRS="${MKINSTALLDIRS} -m 755" 63 XGETTEXT="${XGETTEXT} --keyword=L_" 63 64 64 65 AC_CONFIG_FILES([Makefile src/Makefile intl/Makefile po/Makefile.in]) trunk/src/acl.c
r344 r366 1 /* $Id: acl.c,v 1. 3 2003/04/16 11:10:17jajcus Exp $ */1 /* $Id: acl.c,v 1.4 2003/04/22 08:44:29 jajcus Exp $ */ 2 2 3 3 /* … … 47 47 if (!strcmp(str,"allow")) allow=1; 48 48 else if (!strcmp(str,"deny")) allow=0; 49 else g_error( N_("Invalid tag <%s/> in config section <acl/>"),str);49 else g_error(L_("Invalid tag <%s/> in config section <acl/>"),str); 50 50 what=xmlnode_get_attrib(node,"what"); 51 51 if (!what || what[0]=='\000' || !strcmp(what,"*")) what=NULL; … … 97 97 xmlnode_free(x); 98 98 g_free(jid); 99 if (result) debug( "Allowed");100 else debug( "Denied");99 if (result) debug(L_("Allowed")); 100 else debug(L_("Denied")); 101 101 return result; 102 102 } trunk/src/ggtrans.h
r316 r366 1 /* $Id: ggtrans.h,v 1.1 1 2003/04/14 09:07:29 jajcus Exp $ */1 /* $Id: ggtrans.h,v 1.12 2003/04/22 08:44:29 jajcus Exp $ */ 2 2 3 3 /* … … 29 29 #define _(String) gettext (String) 30 30 31 /* dummy gettext shortcut for translati ng error/debug messages after log handler is set*/31 /* dummy gettext shortcut for translations out-of-place */ 32 32 #define N_(String) (String) 33 34 /* gettext shortcut for translating error/debug messages (locale/encoding must be switched) */ 35 #define L_(String) local_translate(String) 36 37 const char *local_translate(const char *str); 33 38 34 39 extern GMainLoop *main_loop; trunk/src/jabber.c
r320 r366 1 /* $Id: jabber.c,v 1.2 2 2003/04/14 10:18:47jajcus Exp $ */1 /* $Id: jabber.c,v 1.23 2003/04/22 08:44:29 jajcus Exp $ */ 2 2 3 3 /* … … 63 63 } 64 64 65 g_message( N_("handshake OK"));65 g_message(L_("handshake OK")); 66 66 jabber_state=JS_CONNECTED; 67 67 users_probe_all(); … … 73 73 data=xmlnode_get_data(x); 74 74 if (data==NULL) data="-unknown-"; 75 g_critical( N_("Stream error: %s"),data);75 g_critical(L_("Stream error: %s"),data); 76 76 stream_close(s); 77 77 stop_it=1; … … 137 137 break; 138 138 default: 139 g_critical( N_("Unknown node type: %i"),type);139 g_critical(L_("Unknown node type: %i"),type); 140 140 stop_it=1; 141 141 stream_close(s); … … 217 217 node=xmlnode_get_tag(config,"service"); 218 218 if (!node) 219 g_error( N_("No <service/> found in config file"));219 g_error(L_("No <service/> found in config file")); 220 220 221 221 my_name=xmlnode_get_attrib(node,"jid"); 222 222 if (!my_name) 223 g_error( N_("<service/> without \"jid\" in config file"));223 g_error(L_("<service/> without \"jid\" in config file")); 224 224 225 225 server=config_load_string("connect/ip"); 226 226 if (!server) 227 g_error( N_("Jabberd server not found in config file"));227 g_error(L_("Jabberd server not found in config file")); 228 228 229 229 port=config_load_int("connect/port",0); 230 230 if (port<=0) 231 g_error( N_("Connect port not found in config file"));231 g_error(L_("Connect port not found in config file")); 232 232 233 233 node=xmlnode_get_tag(config,"connect/secret"); 234 234 if (node) secret=xmlnode_get_data(node); 235 235 if (!node || !secret) 236 g_error( N_("Connect secret not found in config file"));236 g_error(L_("Connect secret not found in config file")); 237 237 238 238 register_instructions=config_load_formatted_string("register/instructions"); 239 239 if (!register_instructions) 240 g_error( N_("Registration instructions not not found in config file"));240 g_error(L_("Registration instructions not not found in config file")); 241 241 242 242 search_instructions=config_load_formatted_string("search/instructions"); 243 243 if (!search_instructions) 244 g_error( N_("Search instructions not found in config file"));244 g_error(L_("Search instructions not found in config file")); 245 245 246 246 gateway_desc=config_load_formatted_string("gateway/desc"); 247 247 if (!gateway_desc) 248 g_error( N_("Gateway instructions not found in config file"));248 g_error(L_("Gateway instructions not found in config file")); 249 249 250 250 gateway_prompt=config_load_formatted_string("gateway/prompt"); 251 251 if (!gateway_prompt) 252 g_error( N_("Gateway prompt not found in config file"));252 g_error(L_("Gateway prompt not found in config file")); 253 253 254 254 jabber_state=JS_NONE; trunk/src/jid.c
r269 r366 1 /* $Id: jid.c,v 1.1 0 2003/04/06 15:42:42 mmazurExp $ */1 /* $Id: jid.c,v 1.11 2003/04/22 08:44:29 jajcus Exp $ */ 2 2 3 3 /* … … 39 39 else if (jid[i]=='@') 40 40 if (!just_digits){ 41 debug( N_("Non-digits before '@' in jid: %s"),jid);41 debug(L_("Non-digits before '@' in jid: %s"),jid); 42 42 return 0; 43 43 } … … 54 54 if (slash<0){ 55 55 if ( g_strcasecmp(jid+at+1,my_name) ){ 56 debug( N_("Bad hostname (%s) in JID: %s"),jid+at+1,jid);56 debug(L_("Bad hostname (%s) in JID: %s"),jid+at+1,jid); 57 57 return 0; 58 58 } 59 59 } else{ 60 60 if ( slash-at-1!=strlen(my_name) ){ 61 debug( N_("Bad hostname len (%i) instead of %i in JID: %s"),slash-at-1,strlen(my_name),jid);61 debug(L_("Bad hostname len (%i) instead of %i in JID: %s"),slash-at-1,strlen(my_name),jid); 62 62 return 0; 63 63 } 64 64 65 65 if ( g_strncasecmp(jid+at+1,my_name,slash-at-1) ){ 66 debug( N_("Bad hostname in JID: %s[%i:%i]"),jid,at+1,slash-at-2);66 debug(L_("Bad hostname in JID: %s[%i:%i]"),jid,at+1,slash-at-2); 67 67 return 0; 68 68 } trunk/src/main.c
r362 r366 1 /* $Id: main.c,v 1.4 7 2003/04/22 07:12:32jajcus Exp $ */1 /* $Id: main.c,v 1.48 2003/04/22 08:44:29 jajcus Exp $ */ 2 2 3 3 /* … … 31 31 #include <time.h> 32 32 #include <locale.h> 33 34 #ifdef HAVE_LANGINFO_CODESET 35 # include <langinfo.h> 36 #endif 37 33 38 #include "jabber.h" 34 39 #include "sessions.h" … … 173 178 switch(log_level){ 174 179 case G_LOG_LEVEL_ERROR: 175 fprintf(f,_("Fatal error: %s\n"), _(message));180 fprintf(f,_("Fatal error: %s\n"),message); 176 181 break; 177 182 case G_LOG_LEVEL_CRITICAL: 178 fprintf(f,_("Error: %s\n"), _(message));183 fprintf(f,_("Error: %s\n"),message); 179 184 break; 180 185 case G_LOG_LEVEL_WARNING: 181 fprintf(f,_("Warning: %s\n"), _(message));186 fprintf(f,_("Warning: %s\n"),message); 182 187 break; 183 188 case G_LOG_LEVEL_MESSAGE: … … 185 190 case G_LOG_LEVEL_INFO: 186 191 if (debug_level<0) break; 187 fprintf(f,"%s\n", _(message));192 fprintf(f,"%s\n",message); 188 193 break; 189 194 case G_LOG_LEVEL_DEBUG: 190 195 if (debug_level>0) 191 fprintf(f,_("Debug: %s\n"), _(message));196 fprintf(f,_("Debug: %s\n"),message); 192 197 break; 193 198 default: 194 fprintf(f,_("Unknown: %s\n"), _(message));199 fprintf(f,_("Unknown: %s\n"),message); 195 200 break; 196 201 } … … 202 207 switch(log_level){ 203 208 case G_LOG_LEVEL_ERROR: 204 syslog(LOG_ERR,_("Fatal error: %s"), _(message));209 syslog(LOG_ERR,_("Fatal error: %s"),message); 205 210 break; 206 211 case G_LOG_LEVEL_CRITICAL: 207 syslog(LOG_ERR,_("Error: %s"), _(message));212 syslog(LOG_ERR,_("Error: %s"),message); 208 213 break; 209 214 case G_LOG_LEVEL_WARNING: 210 syslog(LOG_WARNING,_("Warning: %s"), _(message));215 syslog(LOG_WARNING,_("Warning: %s"),message); 211 216 break; 212 217 case G_LOG_LEVEL_MESSAGE: 213 218 if (debug_level<-1) break; 214 syslog(LOG_NOTICE,"%s", _(message));219 syslog(LOG_NOTICE,"%s",message); 215 220 break; 216 221 case G_LOG_LEVEL_INFO: 217 222 if (debug_level<0) break; 218 syslog(LOG_NOTICE,"%s", _(message));223 syslog(LOG_NOTICE,"%s",message); 219 224 break; 220 225 case G_LOG_LEVEL_DEBUG: 221 226 if (debug_level>0) 222 syslog(LOG_DEBUG,_("Debug: %s\n"), _(message));227 syslog(LOG_DEBUG,_("Debug: %s\n"),message); 223 228 break; 224 229 default: 225 syslog(LOG_NOTICE,_("Unknown: %s\n"),_(message)); 226 break; 227 } 228 } 229 230 void log_handler(const gchar *log_domain, GLogLevelFlags log_level, 231 const gchar *message, gpointer user_data){ 232 233 char *lc_ctype,*lc_messages,*td_codeset; 230 syslog(LOG_NOTICE,_("Unknown: %s\n"),message); 231 break; 232 } 233 } 234 235 const char *local_translate(const char *str){ 236 const char *lc_ctype,*lc_messages,*td_codeset,*ret; 234 237 235 238 td_codeset=bind_textdomain_codeset(PACKAGE,NULL); 236 239 lc_ctype=setlocale(LC_CTYPE,NULL); 237 240 lc_messages=setlocale(LC_MESSAGES,NULL); 241 setlocale(LC_MESSAGES,""); 242 setlocale(LC_CTYPE,""); 243 #ifdef HAVE_LANGINFO_CODESET 244 bind_textdomain_codeset(PACKAGE,nl_langinfo(CODESET)); 245 #endif 246 /* textdomain(PACKAGE);*/ 247 248 ret=gettext(str); 249 250 setlocale(LC_CTYPE,lc_ctype); 251 setlocale(LC_MESSAGES,lc_ctype); 252 bind_textdomain_codeset(PACKAGE,td_codeset); 253 254 return ret; 255 } 256 257 void log_handler(const gchar *log_domain, GLogLevelFlags log_level, 258 const gchar *message, gpointer user_data){ 259 260 char *lc_ctype,*lc_messages,*td_codeset; 261 262 td_codeset=bind_textdomain_codeset(PACKAGE,NULL); 263 lc_ctype=setlocale(LC_CTYPE,NULL); 264 lc_messages=setlocale(LC_MESSAGES,NULL); 265 setlocale(LC_MESSAGES,""); 266 setlocale(LC_CTYPE,""); 267 #ifdef HAVE_LANGINFO_CODESET 268 bind_textdomain_codeset(PACKAGE,nl_langinfo(CODESET)); 269 #endif 270 /* textdomain(PACKAGE);*/ 238 271 239 272 log_level&=G_LOG_LEVEL_MASK; … … 252 285 int fd; 253 286 254 debug( N_("Daemonizing..."));287 debug(L_("Daemonizing...")); 255 288 pid=fork(); 256 if (pid==-1) g_error( N_("Failed to fork(): %s"),g_strerror(errno));289 if (pid==-1) g_error(L_("Failed to fork(): %s"),g_strerror(errno)); 257 290 if (pid){ 258 291 if (pidfile){ … … 260 293 fclose(pidfile); 261 294 } 262 debug( N_("Daemon born, pid %i."),pid);295 debug(L_("Daemon born, pid %i."),pid); 263 296 exit(0); 264 297 } … … 282 315 if (sid==-1) abort(); 283 316 foreground=FALSE; 284 debug( N_("I am a daemon, I think."));317 debug(L_("I am a daemon, I think.")); 285 318 return; 286 319 } … … 406 439 config=xmlnode_file(config_file); 407 440 if (!config){ 408 g_error( N_("Couldn't load config!"));441 g_error(L_("Couldn't load config!")); 409 442 return 1; 410 443 } 411 444 str=xmlnode_get_name(config); 412 445 if (!str || strcmp(str,"jggtrans")){ 413 g_error( N_("%s doesn't look like jggtrans config file."),config_file);446 g_error(L_("%s doesn't look like jggtrans config file."),config_file); 414 447 return 1; 415 448 } … … 438 471 if (!strcmp(facilitynames[log_facility].name,str)) break; 439 472 if (!facilitynames[log_facility].name) 440 g_error( N_("Unknown syslog facility: %s"),str);473 g_error(L_("Unknown syslog facility: %s"),str); 441 474 } 442 475 else if (!strcmp(log_type,"file")){ … … 465 498 if (r==1 && pid>0){ 466 499 r=kill(pid,0); 467 if (!r || (r && errno!=ESRCH)) g_error( N_("jggtrans already running"));500 if (!r || (r && errno!=ESRCH)) g_error(L_("jggtrans already running")); 468 501 if (r){ 469 502 g_warning(N_("Stale pid file. Removing.")); … … 471 504 } 472 505 } 473 else if (r!=EOF) g_error( N_("Invalid pid file."));506 else if (r!=EOF) g_error(L_("Invalid pid file.")); 474 507 } 475 508 pidfile=fopen(pid_filename,"w"); 476 509 if (pidfile==NULL) 477 g_error( N_("Couldn't open pidfile %s"),pid_filename);510 g_error(L_("Couldn't open pidfile %s"),pid_filename); 478 511 } 479 512 else … … 482 515 if (group){ 483 516 grp=getgrnam(group); 484 if (!grp) g_error( N_("Couldn't find group %s"),group);517 if (!grp) g_error(L_("Couldn't find group %s"),group); 485 518 newgid=grp->gr_gid; 486 519 } 487 520 if (user){ 488 521 pwd=getpwnam(user); 489 if (!pwd) g_error( N_("Couldn't find user %s"),user);522 if (!pwd) g_error(L_("Couldn't find user %s"),user); 490 523 if (newgid<=0) newgid=pwd->pw_gid; 491 524 fchown(fileno(pidfile),pwd->pw_uid,newgid); 492 if (setgid(newgid)) g_error( N_("Couldn't change group: %s"),g_strerror(errno));493 if (initgroups(user,newgid)) g_error( N_("Couldn't init groups: %s"),g_strerror(errno));494 if (setuid(pwd->pw_uid)) g_error( N_("Couldn't change user: %s"),g_strerror(errno));495 } 496 else if (uid==0 && !restarting) g_error( N_("Refusing to run with uid=0"));525 if (setgid(newgid)) g_error(L_("Couldn't change group: %s"),g_strerror(errno)); 526 if (initgroups(user,newgid)) g_error(L_("Couldn't init groups: %s"),g_strerror(errno)); 527 if (setuid(pwd->pw_uid)) g_error(L_("Couldn't change user: %s"),g_strerror(errno)); 528 } 529 else if (uid==0 && !restarting) g_error(L_("Refusing to run with uid=0")); 497 530 498 531 main_loop=g_main_new(0); … … 513 546 if (log_filename){ 514 547 log_file=fopen(log_filename,"a"); 515 if (!log_file) g_critical( N_("Couldn't open log file '%s': %s"),548 if (!log_file) g_critical(L_("Couldn't open log file '%s': %s"), 516 549 log_filename,g_strerror(errno)); 517 550 if (log_file) setvbuf(log_file,NULL,_IOLBF,0); … … 548 581 int n; 549 582 550 g_message( N_("Restarting in %i seconds.\n"),restart_timeout);583 g_message(L_("Restarting in %i seconds.\n"),restart_timeout); 551 584 if (restart_timeout>0) sleep(restart_timeout); 552 585 if (saved_pwd) chdir(saved_pwd); … … 571 604 } 572 605 573 g_message( N_("Exiting normally.\n"));606 g_message(L_("Exiting normally.\n")); 574 607 575 608 g_log_remove_handler(NULL,lh); trunk/src/register.c
r349 r366 1 /* $Id: register.c,v 1.3 7 2003/04/20 14:09:39 jajcus Exp $ */1 /* $Id: register.c,v 1.38 2003/04/22 08:44:29 jajcus Exp $ */ 2 2 3 3 /* … … 391 391 int change_password_error(struct request_s *r){ 392 392 393 g_message( N_("Password change error for user '%s'"),r->from);393 g_message(L_("Password change error for user '%s'"),r->from); 394 394 jabber_iq_send_error(r->stream,r->from,r->to,r->id,500,_("Internal Server Error")); 395 395 return 0; … … 405 405 } 406 406 407 g_message( N_("Password changed for user '%s'"),r->from);407 g_message(L_("Password changed for user '%s'"),r->from); 408 408 if (r->data){ 409 409 g_free(u->password); … … 470 470 char *jid; 471 471 472 debug( N_("Unregistering '%s'"),from);472 debug(L_("Unregistering '%s'"),from); 473 473 ses=session_get_by_jid(from,NULL); 474 474 if (ses) … … 500 500 } 501 501 presence_send_unsubscribed(s,NULL,jid); 502 g_message( N_("User '%s' unregistered"),from);502 g_message(L_("User '%s' unregistered"),from); 503 503 g_free(jid); 504 504 return 0; … … 520 520 node=xmlnode_get_firstchild(q); 521 521 if (!node){ 522 debug( N_("Set query for jabber:iq:register empty: %s"),xmlnode2str(q));522 debug(L_("Set query for jabber:iq:register empty: %s"),xmlnode2str(q)); 523 523 unregister(s,from,to,id,0); 524 524 return; … … 546 546 node=xmlnode_get_tag(q,"remove"); 547 547 if (node){ 548 debug( N_("<remove/> in jabber:iq:register set: %s"),xmlnode2str(q));548 debug(L_("<remove/> in jabber:iq:register set: %s"),xmlnode2str(q)); 549 549 unregister(s,from,to,id,0); 550 550 return; … … 606 606 if (!first && !last && !nick && !city && !born && !sex){ 607 607 if (!uin && !password){ 608 debug( N_("Set query for jabber:iq:register empty: %s"),xmlnode2str(q));608 debug(L_("Set query for jabber:iq:register empty: %s"),xmlnode2str(q)); 609 609 unregister(s,from,to,id,0); 610 610 return; trunk/src/stream.c
r332 r366 1 /* $Id: stream.c,v 1. 19 2003/04/15 16:33:04jajcus Exp $ */1 /* $Id: stream.c,v 1.20 2003/04/22 08:44:29 jajcus Exp $ */ 2 2 3 3 /* … … 74 74 fd=socket(PF_INET,SOCK_STREAM,0); 75 75 if (!fd){ 76 g_error( N_("socket: %s"),g_strerror(errno));76 g_error(L_("socket: %s"),g_strerror(errno)); 77 77 g_free(s); 78 78 return NULL; … … 116 116 else{ 117 117 if (r<0){ 118 g_error( N_("connect: %s"),g_strerror(errno));118 g_error(L_("connect: %s"),g_strerror(errno)); 119 119 g_free(s); 120 120 return NULL; … … 150 150 } 151 151 if (errno==EALREADY) return 0; 152 g_critical( N_("connect: %s"),g_strerror(errno));152 g_critical(L_("connect: %s"),g_strerror(errno)); 153 153 return -1; 154 154 } … … 163 163 s->xs->f(XSTREAM_CLOSE,NULL,s); 164 164 if (!s->connected) 165 g_critical( N_("Couldn't connect to jabber server"));165 g_critical(L_("Couldn't connect to jabber server")); 166 166 else 167 g_critical( N_("Connection to jabber server broken"));167 g_critical(L_("Connection to jabber server broken")); 168 168 do_restart=TRUE; 169 169 return FALSE; … … 197 197 g_assert(s); 198 198 199 if (!s->connected) g_error( N_("Unconnected stream"));199 if (!s->connected) g_error(L_("Unconnected stream")); 200 200 201 201 if (!s->read_buf){
