+/* remove space function */
+
+void removespace (char *s, char **p) {
+ while (*s) {
+ if ((*s == ' ') || (*s == '\t')) {
+ s++;
+ } else {
+ break;
+ }
+ }
+ if (p != NULL) {
+ *p = s;
+ }
+}
+
+/* get pattern function */
+
+int getpattern (sequence_t *seq, char *s, char **p) {
+
+ seq->sequence = s;
+ seq->length = 0;
+
+ while (*s) {
+ if ((*s == '\\') && ((s[1] == '/') || (s[1] == '\\'))) {
+ s++;
+ } else if (*s == '/') {
+ *s++ = 0;
+ break;
+ }
+ s++;
+ }
+ seq->length = specialchar (seq->sequence, seq->bytes);
+
+ if (p != NULL) {
+ *p = s;
+ }
+
+ return (seq->length == 0);
+}
+
+/* get hexa sequence function */
+
+int gethexaseq (sequence_t *seq, char *s, char **p) {
+ int i = 0;
+
+ seq->sequence = s;
+ seq->length = 0;
+
+ while (*s) {
+ if (((*s >= '0') && (*s <= '9')) ||
+ ((*s >= 'A') && (*s <= 'F')) ||
+ ((*s >= 'a') && (*s <= 'f'))) {
+ s++;
+ i++;
+ if (i % 2 == 0) {
+ seq->bytes[seq->length] = hexa (seq->sequence + 2 * seq->length, 2);
+ if (seq->bytes[seq->length] == -1) {
+ return 1;
+ }
+ seq->length++;
+ }
+ } else {
+ break;
+ }
+ }
+
+ if (p != NULL) {
+ *p = s;
+ }
+
+ return (seq->length == 0) || (i % 2 == 1);
+}
+
+/* get length function */
+
+long int getlength (char *s, char **p) {
+
+ while (*s != '\0') {
+ if ((*s == ' ') || (*s == '\t')) {
+ s++;
+ } else if ((*s >= '0') && (*s <= '9')) {
+ return strtol (s, p, 10);
+ } else if (*s == '-') {
+ if (p != NULL) {
+ *p = s + 1;
+ }
+ return -1;
+ } else {
+ VERBOSE (ERROR, fprintf (stderr, "unknown length (%s)\n", s));
+ return 0;
+ }
+ }
+
+ return 0;
+}
+