home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Misc / Cookie / Source / Cookie.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  1.4 KB  |  109 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. #import "Cookie.h"
  5. #import <c.h>
  6.  
  7. BOOL hasTitle(char *line)
  8. {
  9.     int count;
  10.  
  11.     for(count = 0; line[count]; count++)
  12.         if(line[count] == '%')
  13.             return TRUE;
  14.  
  15.     return FALSE;
  16. }
  17.  
  18. @implementation Cookie
  19.  
  20. - (BOOL)blank
  21. {
  22.     if(!cookieLines)
  23.         return TRUE;
  24.  
  25.     if([((List *)cookieLines) count] == 0)
  26.         return TRUE;
  27.  
  28.     if(([((List *)cookieLines) count] == 1) && (!([[cookieLines objectAt:0] string][0])))
  29.         return TRUE;
  30.  
  31.     return FALSE;
  32. }
  33.  
  34. - (char *)title
  35. {
  36.     return [title string];
  37. }
  38.  
  39. - (List *)cookieLines
  40. {
  41.     return cookieLines;
  42. }
  43.  
  44. - setLines :(List *)list
  45. {
  46.     if(cookieLines)
  47.         [cookieLines free];
  48.  
  49.     cookieLines = [list copy];
  50.  
  51.     return self;
  52. }
  53.  
  54. - setTitle :(char *)string
  55. {
  56.     if(!title)
  57.         title = [[String alloc] init];
  58.  
  59.     [title setString:string];
  60.  
  61.     return self;
  62. }
  63.  
  64. - init
  65. {
  66.     [super init];
  67.  
  68.     title = NULL;
  69.     cookieLines = NULL;
  70.  
  71.     return self;
  72. }
  73.  
  74. - (void)free
  75. {
  76.     [cookieLines freeObjects];
  77.     [title free];
  78.     [super free];
  79. }
  80.  
  81. - addLine :(char *)line
  82. {
  83.     int count = 0;
  84.  
  85.     if((!title) && (hasTitle(line)))
  86.     {
  87.         char temp[1024];
  88.  
  89.         for(count = 0; line[count] != '%' && line[count]; count++)
  90.             temp[count] = line[count];
  91.         temp[count] = 0;
  92.         count++;
  93.  
  94.         if(!title)
  95.             title = [[String alloc] init];
  96.  
  97.         [title setString:temp];
  98.     }
  99.  
  100.     if(!cookieLines)
  101.         cookieLines = [[List alloc] init];
  102.  
  103.     [cookieLines addObject:[[[String alloc] init] setString:&line[count]]];
  104.  
  105.     return self;
  106. }
  107.  
  108. @end
  109.