~ubuntu-branches/ubuntu/trusty/styx/trusty

« back to all changes in this revision

Viewing changes to libbase/line_scn.c

  • Committer: Bazaar Package Importer
  • Author(s): Frederik Schüler
  • Date: 2007-07-01 23:06:53 UTC
  • mfrom: (0.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070701230653-8tcr3ow0d49alwj2
Tags: 1.7.5-1
* New upstream version.
* Bump standard to 2.7.2, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 supports simple text replacement. Each occurance of a key in the given text will
35
35
 be replaced by the associated value.
36
36
 
37
 
  5. The following functions support the removement/extraction of HTML/XML-tags, 
 
37
  5. The primitive
 
38
 
 
39
  |      bool Line_split(string txt, string pat, string* left, string* right)
 
40
 
 
41
 supports simple text separation. If 'pat' is a substring of 'txt' the prefix
 
42
 will be assigned to 'left' and the suffix to 'right'.
 
43
 
 
44
  6. The following functions support the removement/extraction of HTML/XML-tags, 
38
45
     C-comments and spaces in a given text.
39
46
 
40
47
  |      string Line_withTag(string txt)
45
52
  |      string Line_withoutWhite(string txt)
46
53
  |      string Line_clip[L|R](string txt)
47
54
 
48
 
  6. Finally this module defines a set of functions for URI-Creation/Evaluation. ( RFC 2396 )
 
55
  7. Finally this module defines a set of functions for URI-Creation/Evaluation. ( RFC 2396 )
49
56
 
50
57
*/
51
58
 
487
494
  return Sink_close(snk);
488
495
}
489
496
 
 
497
c_bool Line_split(c_string txt, c_string pat, c_string* left, c_string* right)
 
498
/* separates 'txt'; allocs memory:
 
499
   'txt' = 'pat' . suffix          --> RC = true, *left=NULL,   *right=suffix
 
500
   'txt' = prefix . 'pat'          --> RC = true, *left=prefix, *right=NULL
 
501
   'txt' = prefix . 'pat' . suffix --> RC = true, *left=prefix, *right=suffix
 
502
   else                            --> RC = false
 
503
*/
 
504
{ c_string tmp = strstr(txt,pat);
 
505
  *left = *right = (c_string)NULL;
 
506
  if( tmp != (c_string)NULL )
 
507
  { int len = strlen(pat);
 
508
    if( tmp != txt )
 
509
    {
 
510
      *left = SubStrCopy(txt,tmp-txt); 
 
511
    }
 
512
    if( *(tmp+len) != '\0' ) *right = StrCopy(tmp+len);
 
513
    return C_True;
 
514
  }
 
515
  return C_False;
 
516
}
 
517
 
490
518
/*I-------------------------- URI Generation & Evaluation ----------------- */
491
519
 
492
520
/*DOC_INTERFACE*/