Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add two new ini config default_username and default_password

  • Loading branch information...
commit 71caee45bc13556b00ce057f72d49586c27d9628 1 parent 5f7d260
Pierrick Charron authored November 18, 2012

Showing 2 changed files with 12 additions and 4 deletions. Show diff stats Hide diff stats

  1. 14  php_stomp.c
  2. 2  php_stomp.h
14  php_stomp.c
@@ -276,6 +276,8 @@ zend_module_entry stomp_module_entry = {
276 276
 
277 277
 PHP_INI_BEGIN()
278 278
 STD_PHP_INI_ENTRY("stomp.default_broker", "tcp://localhost:61613", PHP_INI_ALL, OnUpdateString, default_broker, zend_stomp_globals, stomp_globals)
  279
+STD_PHP_INI_ENTRY("stomp.default_username", "", PHP_INI_ALL, OnUpdateString, default_username, zend_stomp_globals, stomp_globals)
  280
+STD_PHP_INI_ENTRY("stomp.default_password", "", PHP_INI_ALL, OnUpdateString, default_password, zend_stomp_globals, stomp_globals)
279 281
 STD_PHP_INI_ENTRY("stomp.default_read_timeout_sec", "2", PHP_INI_ALL, OnUpdateLong, read_timeout_sec, zend_stomp_globals, stomp_globals)
280 282
 STD_PHP_INI_ENTRY("stomp.default_read_timeout_usec", "0", PHP_INI_ALL, OnUpdateLong, read_timeout_usec, zend_stomp_globals, stomp_globals)
281 283
 STD_PHP_INI_ENTRY("stomp.default_connection_timeout_sec", "2", PHP_INI_ALL, OnUpdateLong, connection_timeout_sec, zend_stomp_globals, stomp_globals)
@@ -286,6 +288,8 @@ PHP_INI_END()
286 288
 static PHP_GINIT_FUNCTION(stomp)
287 289
 {
288 290
 	stomp_globals->default_broker = NULL;
  291
+	stomp_globals->default_username = NULL;
  292
+	stomp_globals->default_password = NULL;
289 293
 	stomp_globals->read_timeout_sec = 2;
290 294
 	stomp_globals->read_timeout_usec = 0;
291 295
 	stomp_globals->connection_timeout_sec = 2;
@@ -515,11 +519,13 @@ PHP_FUNCTION(stomp_connect)
515 519
 		stomp_frame_t frame = {0};
516 520
  
517 521
 		INIT_FRAME(frame, "CONNECT");
518  
-		if (username_len == 0) {
519  
-			username = "";
  522
+		if (!username) {
  523
+			username = STOMP_G(default_username);
  524
+			username_len = strlen(username);
520 525
 		}
521  
-		if (password_len == 0) {
522  
-			password = "";
  526
+		if (!password) {
  527
+			password = STOMP_G(default_password);
  528
+			password_len = strlen(password);
523 529
 		}
524 530
 		zend_hash_add(frame.headers, "login", sizeof("login"), username, username_len + 1, NULL);
525 531
 		zend_hash_add(frame.headers, "passcode", sizeof("passcode"), password, password_len + 1, NULL);
2  php_stomp.h
@@ -97,6 +97,8 @@ ZEND_BEGIN_MODULE_GLOBALS(stomp)
97 97
 	long read_timeout_usec;
98 98
 	long connection_timeout_sec;
99 99
 	long connection_timeout_usec;
  100
+	char *default_username;
  101
+	char *default_password;
100 102
 
101 103
 	/* Others */
102 104
 	long error_no;

0 notes on commit 71caee4

Please sign in to comment.
Something went wrong with that request. Please try again.