move sigar_getword to sigar_util

This commit is contained in:
Doug MacEachern 2005-12-13 01:18:30 +00:00
parent 14f00b4b7c
commit 9ca64171c2
3 changed files with 26 additions and 54 deletions

View File

@ -362,33 +362,6 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
return SIGAR_OK;
}
/* XXX: could be useful elsewhere */
static char *sigar_getword(char **line, char stop)
{
char *pos = *line;
int len;
char *res;
while ((*pos != stop) && *pos) {
++pos;
}
len = pos - *line;
res = (char *)malloc(len + 1);
memcpy(res, *line, len);
res[len] = 0;
if (stop) {
while (*pos == stop) {
++pos;
}
}
*line = pos;
return res;
}
/*
* XXX: pst_cmd is only 64 chars of the command args.
* according to HP forums there isn't a way to get them

View File

@ -653,33 +653,6 @@ int sigar_proc_state_get(sigar_t *sigar, sigar_pid_t pid,
return SIGAR_OK;
}
/* XXX: copied from hpux_sigar */
static char *sigar_getword(char **line, char stop)
{
char *pos = *line;
int len;
char *res;
while ((*pos != stop) && *pos) {
++pos;
}
len = pos - *line;
res = malloc(len + 1);
memcpy(res, *line, len);
res[len] = 0;
if (stop) {
while (*pos == stop) {
++pos;
}
}
*line = pos;
return res;
}
typedef struct {
int timestamp;
char *args;

View File

@ -54,6 +54,32 @@ SIGAR_INLINE char *sigar_skip_multiple_token(char *p, int count)
return p;
}
char *sigar_getword(char **line, char stop)
{
char *pos = *line;
int len;
char *res;
while ((*pos != stop) && *pos) {
++pos;
}
len = pos - *line;
res = malloc(len + 1);
memcpy(res, *line, len);
res[len] = 0;
if (stop) {
while (*pos == stop) {
++pos;
}
}
*line = pos;
return res;
}
int sigar_file2str(const char *fname, char *buffer, int buflen)
{
int len;