#include #include #include #include "owl.h" static const char fileIdent[] = "$Id$"; int owl_text_truncate_lines(char *out, char *in, int aline, int lines) { /* start with line aline (where the first line is 1) and print * 'lines' lines */ char *ptr1, *ptr2; int i; strcpy(out, ""); if (aline==0) aline=1; /* really illegal use */ /* find the starting line */ ptr1=in; if (aline!=1) { for (i=0; i=last) { len-=last-(ptr1+len); } strncat(tmpbuff, ptr1+acol, len); strcat(tmpbuff, "\n"); ptr1=ptr2+1; } strcpy(out, tmpbuff); owl_free(tmpbuff); } void owl_text_indent(char *out, char *in, int n) { char *ptr1, *ptr2, *last; int i; strcpy(out, ""); last=in+strlen(in)-1; ptr1=in; while (ptr1<=last) { for (i=0; iptr1) { strncat(out, ptr1, ptr2-ptr1); } /* find the close bracket */ ptr3=strchr(ptr2, '>'); /* if there is no close, copy as you are and exit */ if (!ptr3) { strcat(out, ptr2); return(out); } /* look for things we know */ if (!strncasecmp(ptr2, "", 4)) { strcat(out, "\n"); ptr1=ptr3+1; continue; } /* if it wasn't something we know, copy to the > and go again */ strncat(out, ptr2, ptr3-ptr2+1); ptr1=ptr3+1; } return(out); }