ack
On Sun, Mar 27, 2011 at 1:24 AM, Russell Bryant
<russell(a)russellbryant.net> wrote:
Strip trailing whitespace. Resolve mixed usage of tabs and spaces
for indentation.
Signed-off-by: Russell Bryant <russell(a)russellbryant.net>
---
src/lib/mh_agent.cpp | 308 ++++++++++++++++++++++++-------------------------
1 files changed, 151 insertions(+), 157 deletions(-)
diff --git a/src/lib/mh_agent.cpp b/src/lib/mh_agent.cpp
index e103dc1..2048b53 100644
--- a/src/lib/mh_agent.cpp
+++ b/src/lib/mh_agent.cpp
@@ -5,12 +5,12 @@
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -64,21 +64,21 @@ RegistryRead (HKEY hHive, const wchar_t *szKeyPath, const wchar_t
*szValue, char
DWORD nSize = BUFFER_SIZE;
wchar_t szData[BUFFER_SIZE];
long lSuccess = RegOpenKey (hHive, szKeyPath, &hKey);
-
+
if (lSuccess != ERROR_SUCCESS) {
- mh_debug("Could not open %ls key from the registry: %ld", szKeyPath,
lSuccess);
- return;
+ mh_debug("Could not open %ls key from the registry: %ld", szKeyPath,
lSuccess);
+ return;
}
-
+
lSuccess = RegQueryValueEx (hKey, szValue, NULL, NULL, (LPBYTE) szData, &nSize);
if (lSuccess != ERROR_SUCCESS) {
- mh_debug("Could not read '%ls[%ls]' from the registry: %ld",
szKeyPath, szValue, lSuccess);
- return;
+ mh_debug("Could not read '%ls[%ls]' from the registry: %ld",
szKeyPath, szValue, lSuccess);
+ return;
}
mh_info("Obtained '%ls[%ls]' = '%ls' from the registry",
szKeyPath, szValue, szData);
if(out) {
- *out = (char *)malloc( BUFFER_SIZE );
- wcstombs(*out, szData, (size_t)BUFFER_SIZE);
+ *out = (char *)malloc( BUFFER_SIZE );
+ wcstombs(*out, szData, (size_t)BUFFER_SIZE);
}
}
#else
@@ -109,15 +109,15 @@ print_usage(const char *proc_name)
}
#endif
-static gboolean
+static gboolean
mh_qpid_callback(qmf::AgentSession session, qmf::AgentEvent event, gpointer user_data)
{
MatahariAgent *agent = (MatahariAgent*) user_data;
mh_trace("Qpid message recieved");
if(event.hasDataAddr()) {
- mh_trace("Message is for %s (type: %s)",
- event.getDataAddr().getName().c_str(),
- event.getDataAddr().getAgentName().c_str());
+ mh_trace("Message is for %s (type: %s)",
+ event.getDataAddr().getName().c_str(),
+ event.getDataAddr().getAgentName().c_str());
}
return agent->invoke(session, event, user_data);
}
@@ -147,159 +147,153 @@ MatahariAgent::init(int argc, char **argv, const char*
proc_name)
int serverport = MATAHARI_PORT;
/* Set up basic logging */
- mh_log_init(proc_name, LOG_INFO, FALSE);
+ mh_log_init(proc_name, LOG_INFO, FALSE);
#ifdef WIN32
- RegistryRead (
- HKEY_LOCAL_MACHINE,
- L"SYSTEM\\CurrentControlSet\\services\\Matahari",
- L"DebugLevel",
- &value);
+ RegistryRead(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\services\\Matahari",
+ L"DebugLevel",
+ &value);
if(value) {
- mh_log_level = LOG_INFO+atoi(value);
- free(value);
- value = NULL;
+ mh_log_level = LOG_INFO+atoi(value);
+ free(value);
+ value = NULL;
}
-
- RegistryRead (
- HKEY_LOCAL_MACHINE,
- L"SYSTEM\\CurrentControlSet\\services\\Matahari",
- L"Broker",
- &value);
+
+ RegistryRead(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\services\\Matahari",
+ L"Broker",
+ &value);
if(value) {
- servername = value;
- free(value);
- value = NULL;
+ servername = value;
+ free(value);
+ value = NULL;
}
- RegistryRead (
- HKEY_LOCAL_MACHINE,
- L"SYSTEM\\CurrentControlSet\\services\\Matahari",
- L"Port",
- &value);
+ RegistryRead(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\services\\Matahari",
+ L"Port",
+ &value);
if(value) {
- serverport = atoi(value);
- free(value);
- value = NULL;
+ serverport = atoi(value);
+ free(value);
+ value = NULL;
}
- RegistryRead (
- HKEY_LOCAL_MACHINE,
- L"SYSTEM\\CurrentControlSet\\services\\Matahari",
- L"Service",
- &value);
+ RegistryRead(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\services\\Matahari",
+ L"Service",
+ &value);
if(value) {
- service = value;
- free(value);
- value = NULL;
+ service = value;
+ free(value);
+ value = NULL;
}
- RegistryRead (
- HKEY_LOCAL_MACHINE,
- L"SYSTEM\\CurrentControlSet\\services\\Matahari",
- L"User",
- &value);
+ RegistryRead(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\services\\Matahari",
+ L"User",
+ &value);
if(value) {
username = value;
- free(value);
- value = NULL;
+ free(value);
+ value = NULL;
}
- RegistryRead (
- HKEY_LOCAL_MACHINE,
- L"SYSTEM\\CurrentControlSet\\services\\Matahari",
- L"Password",
- &value);
+ RegistryRead(HKEY_LOCAL_MACHINE,
+ L"SYSTEM\\CurrentControlSet\\services\\Matahari",
+ L"Password",
+ &value);
if(value) {
password = value;
- free(value);
- value = NULL;
+ free(value);
+ value = NULL;
}
#else
-
+
// Get args
while ((arg = getopt_long(argc, argv, "hdb:gu:P:s:p:v", opt, &idx)) !=
-1) {
- switch (arg) {
- case 'h':
- case '?':
- print_usage(proc_name);
- exit(0);
- break;
- case 'd':
- daemonize = true;
- break;
- case 'v':
- mh_log_level++;
- mh_enable_stderr(1);
- break;
- case 's':
- if (optarg) {
- service = optarg;
- } else {
- print_usage(proc_name);
- exit(1);
- }
- break;
- case 'u':
- if (optarg) {
- username = optarg;
- } else {
- print_usage(proc_name);
- exit(1);
- }
- break;
- case 'P':
- if (optarg) {
- password = optarg;
- } else {
- print_usage(proc_name);
- exit(1);
- }
- break;
- case 'g':
- gssapi = true;
- break;
- case 'p':
- if (optarg) {
- serverport = atoi(optarg);
- } else {
- print_usage(proc_name);
- exit(1);
- }
- break;
- case 'b':
- if (optarg) {
- servername = optarg;
- } else {
- print_usage(proc_name);
- exit(1);
- }
- break;
- default:
- fprintf(stderr, "unsupported option '-%c'. See
--help.\n", arg);
- print_usage(proc_name);
- exit(0);
- break;
- }
+ switch (arg) {
+ case 'h':
+ case '?':
+ print_usage(proc_name);
+ exit(0);
+ break;
+ case 'd':
+ daemonize = true;
+ break;
+ case 'v':
+ mh_log_level++;
+ mh_enable_stderr(1);
+ break;
+ case 's':
+ if (optarg) {
+ service = optarg;
+ } else {
+ print_usage(proc_name);
+ exit(1);
+ }
+ break;
+ case 'u':
+ if (optarg) {
+ username = optarg;
+ } else {
+ print_usage(proc_name);
+ exit(1);
+ }
+ break;
+ case 'P':
+ if (optarg) {
+ password = optarg;
+ } else {
+ print_usage(proc_name);
+ exit(1);
+ }
+ break;
+ case 'g':
+ gssapi = true;
+ break;
+ case 'p':
+ if (optarg) {
+ serverport = atoi(optarg);
+ } else {
+ print_usage(proc_name);
+ exit(1);
+ }
+ break;
+ case 'b':
+ if (optarg) {
+ servername = optarg;
+ } else {
+ print_usage(proc_name);
+ exit(1);
+ }
+ break;
+ default:
+ fprintf(stderr, "unsupported option '-%c'. See
--help.\n", arg);
+ print_usage(proc_name);
+ exit(0);
+ break;
+ }
}
if (daemonize == true) {
- if (daemon(0, 0) < 0) {
- fprintf(stderr, "Error daemonizing: %s\n", strerror(errno));
- exit(1);
- }
+ if (daemon(0, 0) < 0) {
+ fprintf(stderr, "Error daemonizing: %s\n", strerror(errno));
+ exit(1);
+ }
}
#endif
if (servername.length() == 0) {
- servername = MATAHARI_BROKER;
+ servername = MATAHARI_BROKER;
}
/* Re-initialize logging now that we've completed option processing */
@@ -312,16 +306,16 @@ MatahariAgent::init(int argc, char **argv, const char* proc_name)
qpid::types::Variant::Map options;
options["reconnect"] = bool(true);
if (!username.empty()) {
- options["username"] = username.c_str();
+ options["username"] = username.c_str();
}
if (!password.empty()) {
- options["password"] = password.c_str();
+ options["password"] = password.c_str();
}
if (!service.empty()) {
- options["sasl-service"] = service.c_str();
+ options["sasl-service"] = service.c_str();
}
if (gssapi) {
- options["sasl-mechanism"] = "GSSAPI";
+ options["sasl-mechanism"] = "GSSAPI";
}
std::stringstream url;
@@ -341,14 +335,14 @@ MatahariAgent::init(int argc, char **argv, const char* proc_name)
/* Do any setup required by our agent */
if(this->setup(_agent_session) < 0) {
- mh_err("Failed to set up broker connection to %s for %s\n",
- url.str().c_str(), proc_name);
- return -1;
+ mh_err("Failed to set up broker connection to %s for %s\n",
+ url.str().c_str(), proc_name);
+ return -1;
}
this->mainloop = g_main_new(FALSE);
- this->qpid_source = mainloop_add_qmf(
- G_PRIORITY_HIGH, _agent_session, mh_qpid_callback, mh_qpid_disconnect, this);
+ this->qpid_source = mainloop_add_qmf(G_PRIORITY_HIGH, _agent_session,
+ mh_qpid_callback, mh_qpid_disconnect, this);
return 0;
}
@@ -365,9 +359,9 @@ mainloop_qmf_prepare(GSource* source, gint *timeout)
{
mainloop_qmf_t *qmf = (mainloop_qmf_t*)source;
if (qmf->event) {
- return TRUE;
+ return TRUE;
}
-
+
*timeout = 1;
return FALSE;
}
@@ -377,10 +371,9 @@ mainloop_qmf_check(GSource* source)
{
mainloop_qmf_t *qmf = (mainloop_qmf_t*)source;
if (qmf->event) {
- return TRUE;
-
+ return TRUE;
} else if(qmf->session.nextEvent(qmf->event,
qpid::messaging::Duration::IMMEDIATE)) {
- return TRUE;
+ return TRUE;
}
return FALSE;
}
@@ -391,15 +384,15 @@ mainloop_qmf_dispatch(GSource *source, GSourceFunc callback,
gpointer userdata)
mainloop_qmf_t *qmf = (mainloop_qmf_t*)source;
mh_trace("%p", source);
if (qmf->dispatch != NULL) {
- qmf::AgentEvent event = qmf->event;
- qmf->event = NULL;
-
- if(qmf->dispatch(qmf->session, event, qmf->user_data) == FALSE) {
- g_source_unref(source); /* Really? */
- return FALSE;
- }
+ qmf::AgentEvent event = qmf->event;
+ qmf->event = NULL;
+
+ if(qmf->dispatch(qmf->session, event, qmf->user_data) == FALSE) {
+ g_source_unref(source); /* Really? */
+ return FALSE;
+ }
}
-
+
return TRUE;
}
@@ -410,7 +403,7 @@ mainloop_qmf_destroy(GSource* source)
mh_trace("%p", source);
if (qmf->dnotify) {
- qmf->dnotify(qmf->user_data);
+ qmf->dnotify(qmf->user_data);
}
}
@@ -423,8 +416,9 @@ static GSourceFuncs mainloop_qmf_funcs = {
mainloop_qmf_t*
mainloop_add_qmf(int priority, qmf::AgentSession session,
- gboolean (*dispatch)(qmf::AgentSession session, qmf::AgentEvent event,
gpointer userdata),
- GDestroyNotify notify, gpointer userdata)
+ gboolean (*dispatch)(qmf::AgentSession session,
+ qmf::AgentEvent event, gpointer userdata),
+ GDestroyNotify notify, gpointer userdata)
{
GSource *source = NULL;
mainloop_qmf_t *qmf_source = NULL;
@@ -447,7 +441,7 @@ mainloop_add_qmf(int priority, qmf::AgentSession session,
g_source_set_priority(source, priority);
g_source_set_can_recurse(source, FALSE);
-
+
qmf_source->id = g_source_attach(source, NULL);
mh_info("Added source: %d", qmf_source->id);
return qmf_source;
@@ -459,6 +453,6 @@ mainloop_destroy_qmf(mainloop_qmf_t* source)
g_source_remove(source->id);
source->id = 0;
g_source_unref((GSource*)source);
-
+
return TRUE;
}
--
1.7.4
_______________________________________________
Matahari mailing list
Matahari(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/matahari