Browse Source

Add ts_privsec_is_same()

Georgi Chorbadzhiyski 13 years ago
parent
commit
ec49b5349d
2 changed files with 8 additions and 0 deletions
  1. 1
    0
      tsfuncs.h
  2. 7
    0
      tsfuncs_privsec.c

+ 1
- 0
tsfuncs.h View File

@@ -203,6 +203,7 @@ struct ts_privsec *	ts_privsec_alloc();
203 203
 void				ts_privsec_free			(struct ts_privsec **pprivsec);
204 204
 
205 205
 struct ts_privsec *	ts_privsec_push_packet	(struct ts_privsec *privsec, uint8_t *ts_packet);
206
+int					ts_privsec_is_same		(struct ts_privsec *p1, struct ts_privsec *p2);
206 207
 void				ts_privsec_dump			(struct ts_privsec *privsec);
207 208
 
208 209
 // Time

+ 7
- 0
tsfuncs_privsec.c View File

@@ -55,6 +55,13 @@ OUT:
55 55
 	return privsec;
56 56
 }
57 57
 
58
+int ts_privsec_is_same(struct ts_privsec *p1, struct ts_privsec *p2) {
59
+	if (p1 == p2) return 1; // Same
60
+	if ((!p1 && p2) || (p1 && !p2)) return 0; // Not same (one is NULL)
61
+	if (p1->section_header->section_length != p1->section_header->section_length) return 0; // Not same
62
+	return memcmp(p1->section_header->section_data, p2->section_header->section_data, p1->section_header->section_length) == 0;
63
+}
64
+
58 65
 void ts_privsec_dump(struct ts_privsec *privsec) {
59 66
 	struct ts_section_header *sec = privsec->section_header;
60 67
 	ts_section_dump(sec);

Loading…
Cancel
Save