OSSP CVS Repository

ossp - Difference in ossp-pkg/sio/al.c versions 1.37 and 1.38
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/sio/al.c 1.37 -> 1.38

--- al.c 2002/11/28 15:12:40     1.37
+++ al.c 2002/11/28 16:11:49     1.38
@@ -1186,6 +1186,64 @@
 }
 
 /*
+ * traverse assembly line forward and search first chunk
+ * that matches label and continue search until end of
+ * span of same label
+ *
+ * return offset to first byte in *offp
+ * return size of span to last byte in *spanp
+ *
+ * traversal context is kept on stack (XXX ?)
+ */
+al_rc_t
+al_spanlabel(al_t *al, size_t off, size_t n, al_label_t label,
+             size_t *offp, size_t *spanp)
+{
+    al_rc_t rc;
+    al_tx_t tx;                /* XXX - private tx structure on stack */
+    al_chunk_t *view;
+    size_t len, total, start;
+    int have_first;
+
+    /*
+     * we need to track absolute traversal position,
+     * so we have to see all chunks.. no filtering
+     * allowed
+     */
+    rc = al_traverse(al, off, n, AL_FORWARD, NULL, &tx);
+    if (rc != AL_OK)
+        return AL_RC(rc);
+
+    have_first = 0;
+    start      = 0;
+    total      = 0;
+    while ((rc = al_traverse_next(al, &tx, &view)) == AL_OK) {
+        len = AL_CHUNK_LEN(view);
+        if (AL_SAME_LABEL(view, label)) {
+            if (!have_first) {
+                start      = total;
+                have_first = 1;
+            }
+        } else if (have_first)
+            break;
+        total += len;
+    }
+
+    al_traverse_end(al, &tx, 1);
+
+    if (rc != AL_OK && rc != AL_ERR_EOF)
+        return AL_RC(rc);
+
+    if (!have_first)
+        return AL_RC(AL_ERR_EOF);
+
+    *offp   = off + start;
+    *spanp  = total - start;
+
+    return AL_OK;
+}
+
+/*
  * relay macros to caller
  *
  * al_bytes      - total number of bytes in assembly line

CVSTrac 2.0.1