common NEW function for counting newlines
diff --git a/src/common.c b/src/common.c
index 0f55e32..5cd0a90 100644
--- a/src/common.c
+++ b/src/common.c
@@ -77,3 +77,17 @@
     LOGVAL(ctx, LY_VLOG_NONE, NULL, LY_VCODE_INVAL, date_len, date, stmt);
     return -1;
 }
+
+int
+lysp_get_data_line(const char *data, int fail_char)
+{
+    int i, line = 1;
+
+    for (i = 0; i < fail_char; ++i) {
+        if (data[i] == '\n') {
+            ++line;
+        }
+    }
+
+    return line;
+}
diff --git a/src/common.h b/src/common.h
index 4c6bf9e..ea116ef 100644
--- a/src/common.h
+++ b/src/common.h
@@ -138,6 +138,8 @@
 
 int lysp_check_date(struct ly_ctx *ctx, const char *date, int date_len, const char *stmt);
 
+int lysp_get_data_line(const char *data, int fail_char);
+
 /*
  * Macros to work with lysp structures arrays.
  *