OSDN Git Service

getTagDataByCID, replaceTagDataByCID の実装
authoryoya <yoya@7c90b180-03d5-4157-b861-58a559ae9d1e>
Fri, 1 Apr 2011 13:42:52 +0000 (13:42 +0000)
committeryoya <yoya@7c90b180-03d5-4157-b861-58a559ae9d1e>
Fri, 1 Apr 2011 13:42:52 +0000 (13:42 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/swfed/trunk@512 7c90b180-03d5-4157-b861-58a559ae9d1e

src/php_swfed.c
src/php_swfed.h
src/swf_object.c
src/swf_object.h

index adc78c1..596515e 100644 (file)
@@ -65,6 +65,8 @@ zend_function_entry swfed_functions[] = {
     PHP_ME(swfed,  getTagDetail, NULL, 0)
     PHP_ME(swfed,  getTagData, NULL, 0)
     PHP_ME(swfed,  replaceTagData, NULL, 0)
+    PHP_ME(swfed,  getTagDataByCID, NULL, 0)
+    PHP_ME(swfed,  replaceTagDataByCID, NULL, 0)
     PHP_ME(swfed,  getTagContentsByCID, NULL, 0)
     PHP_ME(swfed,  replaceTagContentsByCID, NULL, 0)
 
@@ -623,6 +625,49 @@ PHP_METHOD(swfed, replaceTagData) {
     RETURN_TRUE;
 }
 
+PHP_METHOD(swfed, getTagDataByCID) {
+    long cid = 0;
+    swf_object_t *swf = NULL;
+    unsigned char *data_ref = NULL;
+    unsigned long data_len = 0;
+    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &cid) == FAILURE) {
+        RETURN_FALSE;
+    }
+    swf = get_swf_object(getThis() TSRMLS_CC);
+    data_ref = swf_object_get_tagdata_bycid(swf, cid, &data_len);
+    if (data_ref == NULL) {
+        fprintf(stderr, "getTagDataByCID: Can't get_tagdata_bycid\n");
+        RETURN_FALSE;
+    }
+    RETURN_STRINGL(data_ref, data_len, 1);
+}
+
+PHP_METHOD(swfed, replaceTagDataByCID) {
+    char *data = NULL;
+    unsigned long data_len = 0;
+    long cid = 0;
+    swf_object_t *swf = NULL;
+    int result = 0;
+    switch (ZEND_NUM_ARGS()) {
+      default:
+        WRONG_PARAM_COUNT;
+        RETURN_FALSE; /* XXX */
+      case 2:
+        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &cid, &data, &data_len) == FAILURE) {
+            RETURN_FALSE;
+        }
+        break;
+    }
+    swf = get_swf_object(getThis() TSRMLS_CC);
+    result = swf_object_replace_tagdata_bycid(swf, cid,
+                                             (unsigned char *)data,
+                                             data_len);
+    if (result) {
+        RETURN_FALSE;
+    }
+    RETURN_TRUE;
+}
+
 PHP_METHOD(swfed, getTagContentsByCID) {
     long cid = 0;
     swf_object_t *swf = NULL;
index 550849a..a97dc0d 100644 (file)
@@ -57,6 +57,8 @@ PHP_METHOD(swfed, getTagDetail);
 PHP_METHOD(swfed, getTagInfo);
 PHP_METHOD(swfed, getTagData);
 PHP_METHOD(swfed, replaceTagData);
+PHP_METHOD(swfed, getTagDataByCID);
+PHP_METHOD(swfed, replaceTagDataByCID);
 PHP_METHOD(swfed, getTagContentsByCID);
 PHP_METHOD(swfed, replaceTagContentsByCID);
 //
index d14b343..58ce0ef 100644 (file)
@@ -339,8 +339,8 @@ swf_object_replace_tagdata(swf_object_t *swf, int tag_seqno,
 }
 
 unsigned char *
-swf_object_get_tag_bycid(swf_object_t *swf, int cid,
-                       unsigned long *length) {
+swf_object_get_tagdata_bycid(swf_object_t *swf, int cid,
+                            unsigned long *length) {
     swf_tag_t *tag;
     unsigned char *data = NULL;
     tag = swf_object_search_tag_bycid(swf, cid);
@@ -354,7 +354,7 @@ swf_object_get_tag_bycid(swf_object_t *swf, int cid,
 }
 
 int
-swf_object_replace_tag_bycid(swf_object_t *swf, int cid,
+swf_object_replace_tagdata_bycid(swf_object_t *swf, int cid,
                              unsigned char *data, unsigned long length) {
     swf_tag_t *old_tag, *new_tag;
     old_tag = swf_object_search_tag_bycid(swf, cid);
index 70a7d79..1fd0bf0 100644 (file)
@@ -43,13 +43,13 @@ extern unsigned char *swf_object_get_tagdata(swf_object_t *swf, int tag_seqno,
 extern int swf_object_replace_tagdata(swf_object_t *swf, int tag_seqno,
                                       unsigned char *data,
                                       unsigned long length);
-extern unsigned char *swf_object_get_tag_bycid(swf_object_t *swf,
+extern unsigned char *swf_object_get_tagdata_bycid(swf_object_t *swf,
                                                   int cid,
                                                   unsigned long *length);
-extern int swf_object_replace_tag_bycid(swf_object_t *swf,
-                                       int cid,
-                                       unsigned char *data,
-                                       unsigned long length);
+extern int swf_object_replace_tagdata_bycid(swf_object_t *swf,
+                                           int cid,
+                                           unsigned char *data,
+                                           unsigned long length);
 extern unsigned char *swf_object_get_tagcontents_bycid(swf_object_t *swf,
                                                        int cid,
                                                        unsigned long *length);