+ /* Copy old tail area to new tail area */
+ silc_buffer_put_tail(sb, sb->tail - size, silc_buffer_taillen(sb));
+
+ return TRUE;
+}
+
+/****f* silcutil/SilcBufferAPI/silc_buffer_strchr
+ *
+ * SYNOPSIS
+ *
+ * static inline
+ * unsigned char *silc_buffer_strchr(SilcBuffer sb, int c, SilcBool first);
+ *
+ * DESCRIPTION
+ *
+ * Returns pointer to the occurence of the character `c' in the buffer
+ * `sb'. If the `first' is TRUE this finds the first occurene of `c',
+ * if it is FALSE this finds the last occurence of `c'. If the character
+ * is found the `sb' data area is moved to that location and its pointer
+ * is returned. The silc_buffer_data call will return the same pointer.
+ * Returns NULL if such character could not be located and the buffer
+ * remains unmodified.
+ *
+ * This call is equivalent to strchr(), strrchr(), memchr() and memrchr()
+ * except it works with SilcBuffer.
+ *
+ * NOTES
+ *
+ * This searches only the data area of the buffer. Head and tail area
+ * are not searched.
+ *
+ * The `sb' data need not be NULL terminated.
+ *
+ ***/
+
+static inline
+unsigned char *silc_buffer_strchr(SilcBuffer sb, int c, SilcBool first)
+{
+ int i;
+
+ if (first) {
+ for (i = 0; i < silc_buffer_len(sb); i++) {
+ if (sb->data[i] == (unsigned char)c) {
+ sb->data = &sb->data[i];
+ return sb->data;
+ }
+ }
+ } else {
+ for (i = silc_buffer_len(sb) - 1; 1 >= 0; i--) {
+ if (sb->data[i] == (unsigned char)c) {
+ sb->data = &sb->data[i];
+ return sb->data;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+/****f* silcutil/SilcBufferAPI/silc_buffer_cmp
+ *
+ * SYNOPSIS
+ *
+ * static inline
+ * SilcBool silc_buffer_equal(SilcBuffer sb1, SilcBuffer sb2)
+ *
+ * DESCRIPTION
+ *
+ * Compares if the data area of the buffer `sb1' and `sb2' are identical.
+ * Returns TRUE if they match and FALSE if they differ.
+ *
+ ***/
+
+static inline
+SilcBool silc_buffer_equal(SilcBuffer sb1, SilcBuffer sb2)
+{
+ if (silc_buffer_len(sb1) != silc_buffer_len(sb2))
+ return FALSE;
+ return memcmp(sb1->data, sb2->data, silc_buffer_len(sb1)) == 0;
+}
+
+/****f* silcutil/SilcBufferAPI/silc_buffer_printf
+ *
+ * SYNOPSIS
+ *
+ * static inline
+ * void silc_buffer_printf(SilcBuffer sb, SilcBool newline);
+ *
+ * DESCRIPTION
+ *
+ * Prints the current data area of `sb' into stdout. If `newline' is
+ * TRUE prints '\n' after the data in the buffer.
+ *
+ ***/
+
+static inline
+void silc_buffer_printf(SilcBuffer sb, SilcBool newline)
+{
+ silc_file_write(1, silc_buffer_data(sb), silc_buffer_len(sb));
+ if (newline)
+ printf("\n");
+ fflush(stdout);