summaryrefslogtreecommitdiff
path: root/src/sm_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sm_client.c')
-rw-r--r--src/sm_client.c63
1 files changed, 47 insertions, 16 deletions
diff --git a/src/sm_client.c b/src/sm_client.c
index 3c939b8..4552819 100644
--- a/src/sm_client.c
+++ b/src/sm_client.c
@@ -204,9 +204,13 @@ SmcOpenConnection(char *networkIdsList, SmPointer context,
SIZEOF (smRegisterClientMsg), WORD64COUNT (extra),
smRegisterClientMsg, pMsg, pData);
- STORE_ARRAY8 (pData, len, previousId);
-
- IceFlush (iceConn);
+ if (pData != NULL) {
+ STORE_ARRAY8 (pData, len, previousId);
+ IceFlush (iceConn);
+ }
+ else {
+ SEND_ARRAY8 (iceConn, len, previousId);
+ }
replyWait.sequence_of_request = IceLastSentSequenceNumber (iceConn);
replyWait.major_opcode_of_request = _SmcOpcode;
@@ -260,9 +264,13 @@ SmcOpenConnection(char *networkIdsList, SmPointer context,
SIZEOF (smRegisterClientMsg), WORD64COUNT (extra),
smRegisterClientMsg, pMsg, pData);
- STORE_ARRAY8 (pData, 0, "");
-
- IceFlush (iceConn);
+ if (pData != NULL) {
+ STORE_ARRAY8 (pData, 0, "");
+ IceFlush (iceConn);
+ }
+ else {
+ SEND_ARRAY8 (iceConn, 0, "");
+ }
replyWait.sequence_of_request =
IceLastSentSequenceNumber (iceConn);
@@ -296,13 +304,24 @@ SmcCloseConnection(SmcConn smcConn, int count, char **reasonMsgs)
SIZEOF (smCloseConnectionMsg), WORD64COUNT (extra),
smCloseConnectionMsg, pMsg, pData);
- STORE_CARD32 (pData, (CARD32) count);
- pData += 4;
+ if (pData != NULL) {
+ STORE_CARD32 (pData, (CARD32) count);
+ STORE_CARD32 (pData, (CARD32) 0); /* padding */
- for (i = 0; i < count; i++)
- STORE_ARRAY8 (pData, strlen (reasonMsgs[i]), reasonMsgs[i]);
+ for (i = 0; i < count; i++)
+ STORE_ARRAY8 (pData, strlen (reasonMsgs[i]), reasonMsgs[i]);
- IceFlush (iceConn);
+ IceFlush (iceConn);
+ } else {
+ CARD32 count_header[2] = {
+ (CARD32) count,
+ (CARD32) 0 /* padding */
+ };
+ IceWriteData32 (iceConn, 8, count_header);
+
+ for (i = 0; i < count; i++)
+ SEND_ARRAY8 (iceConn, strlen (reasonMsgs[i]), reasonMsgs[i]);
+ }
IceProtocolShutdown (iceConn, _SmcOpcode);
IceSetShutdownNegotiation (iceConn, False);
@@ -412,13 +431,25 @@ SmcDeleteProperties(SmcConn smcConn, int numProps, char **propNames)
SIZEOF (smDeletePropertiesMsg), WORD64COUNT (extra),
smDeletePropertiesMsg, pMsg, pData);
- STORE_CARD32 (pData, numProps);
- pData += 4;
+ if (pData != NULL) {
+ STORE_CARD32 (pData, (CARD32) numProps);
+ STORE_CARD32 (pData, (CARD32) 0); /* padding */
- for (i = 0; i < numProps; i++)
- STORE_ARRAY8 (pData, strlen (propNames[i]), propNames[i]);
+ for (i = 0; i < numProps; i++)
+ STORE_ARRAY8 (pData, strlen (propNames[i]), propNames[i]);
- IceFlush (iceConn);
+ IceFlush (iceConn);
+ }
+ else {
+ CARD32 count_header[2] = {
+ (CARD32) numProps,
+ (CARD32) 0 /* padding */
+ };
+ IceWriteData32 (iceConn, 8, count_header);
+
+ for (i = 0; i < numProps; i++)
+ SEND_ARRAY8 (iceConn, strlen (propNames[i]), propNames[i]);
+ }
}