}
/**
- * virBitmapParse:
+ * virBitmapParseSeparator:
* @str: points to a string representing a human-readable bitmap
* @terminator: character separating the bitmap to parse
* @bitmap: a bitmap created from @str
* Returns 0 on success, or -1 in case of error.
*/
int
-virBitmapParse(const char *str,
- char terminator,
- virBitmapPtr *bitmap,
- size_t bitmapSize)
+virBitmapParseSeparator(const char *str,
+ char terminator,
+ virBitmapPtr *bitmap,
+ size_t bitmapSize)
{
bool neg = false;
const char *cur = str;
return -1;
}
+/**
+ * virBitmapParse:
+ * @str: points to a string representing a human-readable bitmap
+ * @terminator: character separating the bitmap to parse
+ * @bitmap: a bitmap created from @str
+ * @bitmapSize: the upper limit of num of bits in created bitmap
+ *
+ * This function is the counterpart of virBitmapFormat. This function creates
+ * a bitmap, in which bits are set according to the content of @str.
+ *
+ * @str is a comma separated string of fields N, which means a number of bit
+ * to set, and ^N, which means to unset the bit, and N-M for ranges of bits
+ * to set.
+ *
+ * To allow parsing of bitmaps within larger strings it is possible to set
+ * a termination character in the argument @terminator. When the character
+ * in @terminator is encountered in @str, the parsing of the bitmap stops.
+ * Pass 0 as @terminator if it is not needed. Whitespace characters may not
+ * be used as terminators.
+ *
+ * Returns 0 on success, or -1 in case of error.
+ */
+int
+virBitmapParse(const char *str,
+ char terminator,
+ virBitmapPtr *bitmap,
+ size_t bitmapSize)
+{
+ return virBitmapParseSeparator(str, terminator, bitmap, bitmapSize);
+}
+
/**
* virBitmapNewCopy:
* @src: the source bitmap.
if (!(cpuset = virBitmapNew(numCpus)))
goto error;
} else {
- if (virBitmapParse(cur, 'n', &cpuset, numCpus) < 0)
+ if (virBitmapParseSeparator(cur, 'n', &cpuset, numCpus) < 0)
goto error;
nb_cpus = virBitmapCountBits(cpuset);
int ret = -1;
virBitmapPtr b1 = NULL, b2 = NULL, b3 = NULL, b4 = NULL;
- if (virBitmapParse("0-3,5-8,11-15", 0, &b1, 20) < 0 ||
+ if (virBitmapParseSeparator("0-3,5-8,11-15f16", 'f', &b1, 20) < 0 ||
virBitmapParse("4,9,10,16-19", 0, &b2, 20) < 0 ||
virBitmapParse("15", 0, &b3, 20) < 0 ||
virBitmapParse("0,^0", 0, &b4, 20) < 0)