cleanup libustcmd patch
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 1 Sep 2009 17:39:49 +0000 (13:39 -0400)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 1 Sep 2009 17:39:49 +0000 (13:39 -0400)
libustcmd/ustcmd.c
libustcmd/ustcmd.h

index 3f09c5036627cddffcb932bcbe90a05cca2a44af..55ac02a6193996afd109269bc077d6792feffe28 100644 (file)
@@ -61,9 +61,9 @@ pid_t* ustcmd_get_online_pids(void) {
                }
        }
 
-       ret[i] = 0; // Array end
+       ret[i] = 0; /* Array end */
 
-       if (ret[0] == 0) { // No PID at all..
+       if (ret[0] == 0) { /* No PID at all.. */
                free(ret);
                return NULL;
        }
@@ -236,38 +236,9 @@ int ustcmd_get_cmsf(struct USTcmd_cmsf** cmsf, const pid_t pid) {
                return USTCMD_ERR_GEN;
        }
 
-       // Parse received reply string (format: "[chan]/[mark] [st] [fs]"):
+       /* Parse received reply string (format: "[chan]/[mark] [st] [fs]"): */
        unsigned int i = 0, cur_st, cmsf_ind = 0;
        while (big_str[i] != '\0') {
-               /* RAW METHOD (REPLACED BY SSCANF):
-               cur_st = i; // Set current start at beginning of current line
-               while (big_str[i] != '/') {
-                       ++i; // Go to next '/'
-               }
-               tmp_cmsf[cmsf_ind].channel =
-                       strndup(big_str + cur_st, i - cur_st);
-
-               ++i; // Go after '/'
-               cur_st = i; // Set current start at beginning of marker name
-               while (big_str[i] != ' ') {
-                       ++i; // Go to next ' '
-               }
-               tmp_cmsf[cmsf_ind].marker =
-                       strndup(big_str + cur_st, i - cur_st);
-
-               ++i; // Go after ' '
-               tmp_cmsf[cmsf_ind].state = (big_str[i] == USTCMD_MS_CHR_ON ?
-                       USTCMD_MS_ON : USTCMD_MS_OFF); // Marker state
-
-               i += 2; // Go to format string (after state and another ' ')
-               cur_st = i; // Set current start at beginning of format string
-               while (big_str[i] != '\n') {
-                       ++i; // Go to next '\n'
-               }
-               tmp_cmsf[cmsf_ind].fs =
-                       strndup(big_str + cur_st, i - cur_st);
-               */
-
                char state;
                sscanf(big_str + i, "%a[^/]/%a[^ ] %c %a[^\n]",
                        &tmp_cmsf[cmsf_ind].channel,
@@ -275,12 +246,12 @@ int ustcmd_get_cmsf(struct USTcmd_cmsf** cmsf, const pid_t pid) {
                        &state,
                        &tmp_cmsf[cmsf_ind].fs);
                tmp_cmsf[cmsf_ind].state = (state == USTCMD_MS_CHR_ON ?
-                       USTCMD_MS_ON : USTCMD_MS_OFF); // Marker state
+                       USTCMD_MS_ON : USTCMD_MS_OFF); /* Marker state */
 
                while (big_str[i] != '\n') {
-                       ++i; // Go to next '\n'
+                       ++i; /* Go to next '\n' */
                }
-               ++i; // Skip current pointed '\n'
+               ++i; /* Skip current pointed '\n' */
                ++cmsf_ind;
        }
        tmp_cmsf[cmsf_ind].channel = NULL;
@@ -318,4 +289,3 @@ int ustcmd_shoot(const char* cmd, const pid_t pid, char** reply) {
 
        return 0;
 }
-
index ad6c531864f3134fdb3eb552c133eafc393f96c5..8bca50974bb03c572422382eba5ead88b9f01210 100644 (file)
 #include "ustcomm.h"
 #include "ustcmd.h"
 
-#define USTCMD_ERR_CONN                1 // Process connection error 
-#define USTCMD_ERR_ARG         2 // Invalid function argument
-#define USTCMD_ERR_GEN         3 // General ustcmd error
+#define USTCMD_ERR_CONN                1 /* Process connection error */
+#define USTCMD_ERR_ARG         2 /* Invalid function argument */
+#define USTCMD_ERR_GEN         3 /* General ustcmd error */
 
-#define USTCMD_MS_CHR_OFF      '0' // Marker state 'on' character
-#define USTCMD_MS_CHR_ON       '1' // Marker state 'on' character
-#define USTCMD_MS_OFF          0 // Marker state 'on' value
-#define USTCMD_MS_ON           1 // Marker state 'on' value
+#define USTCMD_MS_CHR_OFF      '0' /* Marker state 'on' character */
+#define USTCMD_MS_CHR_ON       '1' /* Marker state 'on' character */
+#define USTCMD_MS_OFF          0   /* Marker state 'on' value */
+#define USTCMD_MS_ON           1   /* Marker state 'on' value */
 
-#define USTCMD_SOCK_PATH       "/tmp/socks/" // UST sockets directory
+#define USTCMD_SOCK_PATH       "/tmp/socks/"
 
-// Channel/marker/state/format string (cmsf) info. structure
+/* Channel/marker/state/format string (cmsf) info. structure */
 struct USTcmd_cmsf {
-       char* channel; // Channel name (end of USTcmd_cmsf array if NULL)
-       char* marker; // Marker name (end of USTcmd_cmsf array if NULL)
-       int state; // State (0 := marker disabled, 1 := marker enabled)
-       char* fs; // Format string (end of USTcmd_cmsf array if NULL)
+       char* channel; /* Channel name (end of USTcmd_cmsf array if NULL) */
+       char* marker; /* Marker name (end of USTcmd_cmsf array if NULL) */
+       int state; /* State (0 := marker disabled, 1 := marker enabled) */
+       char* fs; /* Format string (end of USTcmd_cmsf array if NULL) */
 };
 
 pid_t* ustcmd_get_online_pids(void);
@@ -40,4 +40,4 @@ unsigned int ustcmd_count_nl(const char*);
 int ustcmd_shoot(const char*, pid_t, char**);
 int ustcmd_get_cmsf(struct USTcmd_cmsf**, pid_t);
 
-#endif // _USTCMD_H
+#endif /* _USTCMD_H */
This page took 0.026348 seconds and 4 git commands to generate.