xLib/llsd_tool.h File Reference

LLSD用ライブラリヘッダ(サブセット版). More...

#include "xtools.h"
#include "txml.h"
Include dependency graph for llsd_tool.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define LLSD_MAKER_UNDEF   '!'
#define LLSD_MAKER_TRUE   '1'
#define LLSD_MAKER_FALSE   '0'
#define LLSD_MAKER_INT   'i'
#define LLSD_MAKER_REAL   'r'
#define LLSD_MAKER_UUID   'u'
#define LLSD_MAKER_BIN   'b'
#define LLSD_MAKER_STR   's'
#define LLSD_MAKER_URI   'l'
#define LLSD_MAKER_KEY   'k'
#define LLSD_MAKER_DATE   'd'
#define LLSD_MAKER_ARRAY   '['
#define LLSD_MAKER_ARRAY_END   ']'
#define LLSD_MAKER_MAP   '{'
#define LLSD_MAKER_MAP_END   '}'
 *ptr はマーカーの次のデータを指すポインタ.ポインタは次に進む.
#define llsd_bin_get_key(p)   llsd_bin_get_str((p))
#define llsd_bin_get_uri(p)   llsd_bin_get_str((p))
#define llsd_bin_get_map(p)   llsd_bin_get_int((p))
 要素数を返す.
#define llsd_bin_get_array(p)   llsd_bin_get_int((p))
 要素数を返す.

Functions

Buffer llsd_bin_get_str (uByte **ptr)
 ストリングマーカーの要素を返す.ポインタは次に進む.
int llsd_bin_get_int (uByte **ptr)
 整数マーカーの要素を返す.ポインタは次に進む.
double llsd_bin_get_real (uByte **ptr)
 実数マーカーの要素を返す.ポインタは次に進む.
Buffer llsd_bin_get_uuid (uByte **ptr)
 UUIDマーカーの要素を返す.ポインタは次に進む..
Buffer llsd_bin_get_bin (uByte **ptr)
 バイナリマーカーの要素を返す.ポインタは次に進む.
unsigned long long int llsd_bin_get_date (uByte **ptr)
 デイトマーカーの要素を返す.ポインタは次に進む.
int llsd_bin_get_length (uByte *ptr, int sz)
tXMLllsd_bin_parse (uByte *ptr, int sz)
 LLSD のバイナリデータを tXMLのデータに格納する..
tXMLllsd_bin_main_parse (tXML *xml, uByte *ptr, int sz)
 LLSD のバイナリデータをパースするメイン関数..
int llsd_xml_contain_key (tXML *xml, const char *key)
int llsd_xml_get_content_int (tXML *xml, const char *key, const char *item)
double llsd_xml_get_content_real (tXML *xml, const char *key, const char *item)
Buffer llsd_xml_get_content_str (tXML *xml, const char *key, const char *item)
Buffer llsd_xml_get_content_bin (tXML *xml, const char *key, const char *item)

Detailed Description

Author:
Fumi.Iseki (C)
See also:
http://wiki.secondlife.com/wiki/LLSD
http://www.nsl.tuis.ac.jp/xoops/modules/xpwiki/?LLSD

Definition in file llsd_tool.h.


Define Documentation

#define llsd_bin_get_array (  )     llsd_bin_get_int((p))

Definition at line 48 of file llsd_tool.h.

#define llsd_bin_get_key (  )     llsd_bin_get_str((p))

Definition at line 45 of file llsd_tool.h.

Referenced by llsd_bin_main_parse().

#define llsd_bin_get_map (  )     llsd_bin_get_int((p))

Definition at line 47 of file llsd_tool.h.

Referenced by llsd_bin_main_parse().

#define llsd_bin_get_uri (  )     llsd_bin_get_str((p))

Definition at line 46 of file llsd_tool.h.

Referenced by llsd_bin_main_parse().

#define LLSD_MAKER_ARRAY   '['

Definition at line 31 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().

#define LLSD_MAKER_ARRAY_END   ']'

Definition at line 32 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().

#define LLSD_MAKER_BIN   'b'

Definition at line 26 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().

#define LLSD_MAKER_DATE   'd'

Definition at line 30 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().

#define LLSD_MAKER_FALSE   '0'

Definition at line 22 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().

#define LLSD_MAKER_INT   'i'

Definition at line 23 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().

#define LLSD_MAKER_KEY   'k'

Definition at line 29 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().

#define LLSD_MAKER_MAP   '{'

Definition at line 33 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().

#define LLSD_MAKER_MAP_END   '}'

Definition at line 34 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().

#define LLSD_MAKER_REAL   'r'

Definition at line 24 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().

#define LLSD_MAKER_STR   's'

Definition at line 27 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().

#define LLSD_MAKER_TRUE   '1'

Definition at line 21 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().

#define LLSD_MAKER_UNDEF   '!'

Definition at line 20 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().

#define LLSD_MAKER_URI   'l'

Definition at line 28 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().

#define LLSD_MAKER_UUID   'u'

Definition at line 25 of file llsd_tool.h.

Referenced by llsd_bin_get_length(), and llsd_bin_main_parse().


Function Documentation

Buffer llsd_bin_get_bin ( uByte **  ptr  ) 
Parameters:
*ptr LLSD_MAKER_BIN ('b') の次のデータを指すポインタ

Definition at line 142 of file llsd_tool.c.

References init_Buffer(), and set_Buffer().

Referenced by llsd_bin_main_parse().

00143 {
00144     Buffer buf = init_Buffer();
00145 
00146     if (ptr==NULL) return buf;
00147 
00148     int size = ntohl(*(int*)(*ptr));
00149     (*ptr) += 4;
00150     
00151     uByte* bin = (uByte*)malloc(size);
00152     if (bin!=NULL) {
00153         memcpy(bin, *ptr, size);
00154         buf = set_Buffer(bin, size);
00155         free(bin);
00156     }
00157     (*ptr) += size;
00158 
00159     return buf;
00160 }

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long long int llsd_bin_get_date ( uByte **  ptr  ) 
Parameters:
*ptr LLSD_MAKER_DATE ('d') の次のデータを指すポインタ

Definition at line 70 of file llsd_tool.c.

References ntohull().

Referenced by llsd_bin_main_parse().

00071 {
00072     if (ptr==NULL) return 0ULL;
00073 
00074     unsigned long long int value = ntohull(*(unsigned long long int*)(*ptr));
00075     (*ptr) += 8;
00076 
00077     return value;
00078 }

Here is the call graph for this function:

Here is the caller graph for this function:

int llsd_bin_get_int ( uByte **  ptr  ) 
Parameters:
*ptr LLSD_MAKER_INT ('i') の次のデータを指すポインタ

Definition at line 54 of file llsd_tool.c.

Referenced by llsd_bin_main_parse().

00055 {
00056     if (ptr==NULL) return 0;
00057 
00058     int value = ntohl(*(int*)(*ptr));
00059     (*ptr) += 4;
00060 
00061     return value;
00062 }

Here is the caller graph for this function:

int llsd_bin_get_length ( uByte ptr,
int  sz 
)

Definition at line 163 of file llsd_tool.c.

References free_Buffer(), LLSD_MAKER_ARRAY, LLSD_MAKER_ARRAY_END, LLSD_MAKER_BIN, LLSD_MAKER_DATE, LLSD_MAKER_FALSE, LLSD_MAKER_INT, LLSD_MAKER_KEY, LLSD_MAKER_MAP, LLSD_MAKER_MAP_END, LLSD_MAKER_REAL, LLSD_MAKER_STR, LLSD_MAKER_TRUE, LLSD_MAKER_UNDEF, LLSD_MAKER_URI, LLSD_MAKER_UUID, LSDATA, make_Buffer(), pop_char_ringStack(), PRINT_MESG, and push_char_ringStack().

00164 {
00165     if (ptr==NULL) return 0;
00166 
00167     int cc = 0;
00168     Buffer stack = make_Buffer(LSDATA);
00169     uByte* buf   = ptr;
00170 
00171     while (buf<ptr+sz) {
00172         //
00173         if      (*buf==LLSD_MAKER_UNDEF) buf++;
00174         else if (*buf==LLSD_MAKER_TRUE)  buf++;
00175         else if (*buf==LLSD_MAKER_FALSE) buf++;
00176         else if (*buf==LLSD_MAKER_INT)   buf += 5;
00177         else if (*buf==LLSD_MAKER_REAL)  buf += 9;
00178         else if (*buf==LLSD_MAKER_UUID)  buf += 17;
00179         else if (*buf==LLSD_MAKER_BIN)   buf += ntohl(*(int*)(buf+1)) + 5;
00180         else if (*buf==LLSD_MAKER_STR)   buf += ntohl(*(int*)(buf+1)) + 5;
00181         else if (*buf==LLSD_MAKER_URI)   buf += ntohl(*(int*)(buf+1)) + 5;
00182         else if (*buf==LLSD_MAKER_KEY)   buf += ntohl(*(int*)(buf+1)) + 5;
00183         else if (*buf==LLSD_MAKER_DATE)  buf += 9;
00184         else if (*buf!=LLSD_MAKER_MAP && *buf!=LLSD_MAKER_ARRAY &&
00185                  *buf!=LLSD_MAKER_MAP_END && *buf!=LLSD_MAKER_ARRAY_END) {
00186             if (ptr==buf) return 0;
00187             PRINT_MESG("WARNING: llsd_bin_get_length: unknown marker %c: %04x\n", *buf, *buf);
00188             break;
00189         }
00190 
00191         if (*buf==LLSD_MAKER_MAP) {
00192             push_char_ringStack(&stack, LLSD_MAKER_MAP_END);
00193             cc++;
00194             buf += 5;
00195         }
00196         else if (*buf==LLSD_MAKER_ARRAY) {
00197             push_char_ringStack(&stack, LLSD_MAKER_ARRAY_END);
00198             cc++;
00199             buf += 5;
00200         }
00201         else if (*buf==LLSD_MAKER_MAP_END || *buf==LLSD_MAKER_ARRAY_END) {
00202             unsigned char marker = (unsigned char)pop_char_ringStack(&stack);
00203             if (marker!=*buf) PRINT_MESG("WARNING: llsd_bin_get_length: missmatch stack data of [ or {\n");
00204             cc--;
00205             buf++;
00206         }
00207 
00208         if (cc==0) break;
00209     }   
00210 
00211     free_Buffer(&stack);
00212 
00213     return (int)(buf - ptr);
00214 }

Here is the call graph for this function:

double llsd_bin_get_real ( uByte **  ptr  ) 
Parameters:
*ptr LLSD_MAKER_REAL ('r') の次のデータを指すポインタ

Definition at line 86 of file llsd_tool.c.

References ntohull().

Referenced by llsd_bin_main_parse().

00087 {
00088     if (ptr==NULL) return 0.0;
00089 
00090 #ifdef WIN32
00091     long long int tmp;//  __attribute__((may_alias));
00092 #else
00093     long long int tmp  __attribute__((may_alias));
00094 #endif
00095 
00096     tmp = ntohull(*(long long int*)(*ptr));
00097 
00098     long long int* ptmp = (long long int*)&tmp;
00099     double* valuep = (double*)ptmp;
00100     double  value  = *valuep;
00101 
00102 /*  UnionPtr uptr;
00103     uptr.llintp = (long long int*)&tmp;
00104     double  value = *(uptr.drealp);
00105 */
00106 //  double  value = *(double*)(&tmp);
00107 
00108     (*ptr) += 8;
00109 
00110     return value;
00111 }

Here is the call graph for this function:

Here is the caller graph for this function:

Buffer llsd_bin_get_str ( uByte **  ptr  ) 
Parameters:
*ptr LLSD_MAKER_STR ('s') の次のデータを指すポインタ

Definition at line 27 of file llsd_tool.c.

References init_Buffer(), and make_Buffer_bystr.

Referenced by llsd_bin_main_parse().

00028 {
00029     Buffer buf = init_Buffer();
00030 
00031     if (ptr==NULL) return buf;
00032 
00033     int size = ntohl(*(int*)(*ptr));
00034     (*ptr) += 4;
00035     
00036     char* str = (char*)malloc(size+1);
00037     if (str!=NULL) {
00038         memcpy(str, *ptr, size);
00039         str[size] = '\0';
00040         buf = make_Buffer_bystr(str);
00041         free(str);
00042     }
00043     (*ptr) += size;
00044 
00045     return buf;
00046 }

Here is the call graph for this function:

Here is the caller graph for this function:

Buffer llsd_bin_get_uuid ( uByte **  ptr  ) 
Parameters:
*ptr LLSD_MAKER_UUID ('u') の次のデータを指すポインタ

Definition at line 119 of file llsd_tool.c.

References init_Buffer(), and set_Buffer().

00120 {
00121     Buffer buf = init_Buffer();
00122 
00123     if (ptr==NULL) return buf;
00124 
00125     char* str = (char*)malloc(16);
00126     if (str!=NULL) {
00127         memcpy(str, *ptr, 16);
00128         buf = set_Buffer(str, 16);
00129         free(str);
00130     }
00131     (*ptr) += 16;
00132 
00133     return buf;
00134 }

Here is the call graph for this function:

tXML* llsd_bin_main_parse ( tXML xml,
uByte ptr,
int  sz 
)
Parameters:
xml XMLデータを格納するツリー構造体の先頭へのポインタ.
ptr LLSDのバイナリデータへのポインタ
sz データのサイズ
Returns:
最後に処理したノードへのポインタ.ppがNULLの場合は xml, xmlが NULLの場合は NULLが返る.
Return values:
負数 state エラーの場合は stateに 負数の値が入る.

Definition at line 279 of file llsd_tool.c.

References add_tTree_node_bystr(), Buffer::buf, dtostr_ts(), encode_base64_Buffer(), free_Buffer(), freeNull, itostr_ts(), JBXL_XML_NODE_CLOSED, JBXL_XML_NODE_OPENED, JBXL_XML_NOT_CLOSED, llsd_bin_get_bin(), llsd_bin_get_date(), llsd_bin_get_int(), llsd_bin_get_key, llsd_bin_get_map, llsd_bin_get_real(), llsd_bin_get_str(), llsd_bin_get_uri, LLSD_MAKER_ARRAY, LLSD_MAKER_ARRAY_END, LLSD_MAKER_BIN, LLSD_MAKER_DATE, LLSD_MAKER_FALSE, LLSD_MAKER_INT, LLSD_MAKER_KEY, LLSD_MAKER_MAP, LLSD_MAKER_MAP_END, LLSD_MAKER_REAL, LLSD_MAKER_STR, LLSD_MAKER_TRUE, LLSD_MAKER_UNDEF, LLSD_MAKER_URI, LLSD_MAKER_UUID, PRINT_MESG, ulltostr_ts(), uuid2guid(), XML_CONTENT_NODE, and XML_NAME_NODE.

Referenced by llsd_bin_parse().

00280 {
00281     if (ptr==NULL) return xml;
00282     if (xml==NULL) return NULL;
00283 
00284     tXML* snode = xml = add_tTree_node_bystr(xml, XML_NAME_NODE, 0, "llsd", NULL, NULL, 0);
00285 
00286     uByte* end = ptr + sz;
00287     while (ptr<end  && !(xml==snode && *ptr!=LLSD_MAKER_MAP && *ptr!=LLSD_MAKER_ARRAY)) {
00288         //
00289         if (*ptr==LLSD_MAKER_MAP) {
00290             ptr++;
00291             int num = llsd_bin_get_map(&ptr);
00292             xml = add_tTree_node_bystr(xml, XML_NAME_NODE, num, "map", NULL, NULL, 0);
00293             xml->state = JBXL_XML_NODE_OPENED;
00294         }
00295         //
00296         else if (*ptr==LLSD_MAKER_ARRAY) {
00297             ptr++;
00298             int num = llsd_bin_get_map(&ptr);
00299             xml = add_tTree_node_bystr(xml, XML_NAME_NODE, num, "array", NULL, NULL, 0);
00300             xml->state = JBXL_XML_NODE_OPENED;
00301         }
00302         //
00303         else if (*ptr==LLSD_MAKER_MAP_END) {
00304             ptr++;
00305             if (xml->state==JBXL_XML_NODE_OPENED) {
00306                 xml->state = JBXL_XML_NODE_CLOSED;
00307                 xml = xml->prev;
00308             }   
00309         }
00310         //
00311         else if (*ptr==LLSD_MAKER_ARRAY_END) {
00312             ptr++;
00313             if (xml->state==JBXL_XML_NODE_OPENED) {
00314                 xml->state = JBXL_XML_NODE_CLOSED;
00315                 xml = xml->prev;
00316             }   
00317         }
00318         //
00319         else if (*ptr==LLSD_MAKER_KEY) {
00320             ptr++;
00321             Buffer key = llsd_bin_get_key(&ptr);
00322             xml = add_tTree_node_bystr(xml, XML_NAME_NODE, 1, "key", NULL, NULL, 0);
00323             xml = add_tTree_node_bystr(xml, XML_CONTENT_NODE, 0, (char*)key.buf, NULL, NULL, 0);
00324             xml->state = JBXL_XML_NODE_CLOSED;
00325             xml = xml->prev;
00326             xml->state = JBXL_XML_NODE_CLOSED;
00327             xml = xml->prev;
00328             free_Buffer(&key);
00329         }
00330         //
00331         else if (*ptr==LLSD_MAKER_STR) {
00332             ptr++;
00333             Buffer str = llsd_bin_get_str(&ptr);
00334             xml = add_tTree_node_bystr(xml, XML_NAME_NODE, 1, "string", NULL, NULL, 0);
00335             xml = add_tTree_node_bystr(xml, XML_CONTENT_NODE, 0, (char*)str.buf, NULL, NULL, 0);
00336             xml->state = JBXL_XML_NODE_CLOSED;
00337             xml = xml->prev;
00338             xml->state = JBXL_XML_NODE_CLOSED;
00339             xml = xml->prev;
00340             free_Buffer(&str);
00341         }
00342         //
00343         else if (*ptr==LLSD_MAKER_UUID) {
00344             ptr++;
00345             Buffer uuid = llsd_bin_get_uri(&ptr);
00346             char*  guid = (char*)uuid2guid(uuid.buf);
00347             xml = add_tTree_node_bystr(xml, XML_NAME_NODE, 1, "uuid", NULL, NULL, 0);
00348             xml = add_tTree_node_bystr(xml, XML_CONTENT_NODE, 0, guid, NULL, NULL, 0);
00349             xml->state = JBXL_XML_NODE_CLOSED;
00350             xml = xml->prev;
00351             xml->state = JBXL_XML_NODE_CLOSED;
00352             xml = xml->prev;
00353             free(guid);
00354             free_Buffer(&uuid);
00355         }
00356         //
00357         else if (*ptr==LLSD_MAKER_URI) {
00358             ptr++;
00359             Buffer str = llsd_bin_get_uri(&ptr);
00360             xml = add_tTree_node_bystr(xml, XML_NAME_NODE, 1, "uri", NULL, NULL, 0);
00361             xml = add_tTree_node_bystr(xml, XML_CONTENT_NODE, 0, (char*)str.buf, NULL, NULL, 0);
00362             xml->state = JBXL_XML_NODE_CLOSED;
00363             xml = xml->prev;
00364             xml->state = JBXL_XML_NODE_CLOSED;
00365             xml = xml->prev;
00366             free_Buffer(&str);
00367         }
00368         //
00369         else if (*ptr==LLSD_MAKER_INT) {
00370             ptr++;
00371             int val = llsd_bin_get_int(&ptr);
00372             xml = add_tTree_node_bystr(xml, XML_NAME_NODE, 1, "integer", NULL, NULL, 0);
00373             char* str = itostr_ts(val);
00374             xml = add_tTree_node_bystr(xml, XML_CONTENT_NODE, 0, str, NULL, NULL, 0);
00375             freeNull(str);
00376             xml->state = JBXL_XML_NODE_CLOSED;
00377             xml = xml->prev;
00378             xml->state = JBXL_XML_NODE_CLOSED;
00379             xml = xml->prev;
00380         }
00381         //
00382         else if (*ptr==LLSD_MAKER_DATE) {
00383             ptr++;
00384             unsigned long long int val = llsd_bin_get_date(&ptr);
00385             xml = add_tTree_node_bystr(xml, XML_NAME_NODE, 1, "date", NULL, NULL, 0);
00386             char* str = ulltostr_ts(val);
00387             xml = add_tTree_node_bystr(xml, XML_CONTENT_NODE, 0, str, NULL, NULL, 0);
00388             freeNull(str);
00389             xml->state = JBXL_XML_NODE_CLOSED;
00390             xml = xml->prev;
00391             xml->state = JBXL_XML_NODE_CLOSED;
00392             xml = xml->prev;
00393         }
00394         //
00395         else if (*ptr==LLSD_MAKER_REAL) {
00396             ptr++;
00397             double val = llsd_bin_get_real(&ptr);
00398             xml = add_tTree_node_bystr(xml, XML_NAME_NODE, 1, "real", NULL, NULL, 0);
00399             char* str = dtostr_ts(val);
00400             xml = add_tTree_node_bystr(xml, XML_CONTENT_NODE, 0, str, NULL, NULL, 0);
00401             freeNull(str);
00402             xml->state = JBXL_XML_NODE_CLOSED;
00403             xml = xml->prev;
00404             xml->state = JBXL_XML_NODE_CLOSED;
00405             xml = xml->prev;
00406         }
00407         //
00408         else if (*ptr==LLSD_MAKER_BIN) {
00409             ptr++;
00410             Buffer bin = llsd_bin_get_bin(&ptr);
00411             Buffer b64 = encode_base64_Buffer(bin);
00412             xml = add_tTree_node_bystr(xml, XML_NAME_NODE, 1, "binary", NULL, NULL, 0);
00413             xml = add_tTree_node_bystr(xml, XML_CONTENT_NODE, 0, (char*)b64.buf, NULL, NULL, 0);
00414             xml->state = JBXL_XML_NODE_CLOSED;
00415             xml = xml->prev;
00416             xml->state = JBXL_XML_NODE_CLOSED;
00417             xml = xml->prev;
00418             free_Buffer(&bin);
00419             free_Buffer(&b64);
00420         }
00421         //
00422         else if (*ptr==LLSD_MAKER_TRUE) {
00423             ptr++;
00424             xml = add_tTree_node_bystr(xml, XML_NAME_NODE, 1, "boolean", NULL, NULL, 0);
00425             xml = add_tTree_node_bystr(xml, XML_CONTENT_NODE, 0, "true", NULL, NULL, 0);
00426             xml->state = JBXL_XML_NODE_CLOSED;
00427             xml = xml->prev;
00428             xml->state = JBXL_XML_NODE_CLOSED;
00429             xml = xml->prev;
00430         }
00431         //
00432         else if (*ptr==LLSD_MAKER_FALSE) {
00433             ptr++;
00434             xml = add_tTree_node_bystr(xml, XML_NAME_NODE, 1, "boolean", NULL, NULL, 0);
00435             xml = add_tTree_node_bystr(xml, XML_CONTENT_NODE, 0, "false", NULL, NULL, 0);
00436             xml->state = JBXL_XML_NODE_CLOSED;
00437             xml = xml->prev;
00438             xml->state = JBXL_XML_NODE_CLOSED;
00439             xml = xml->prev;
00440         }
00441         //
00442         else if (*ptr==LLSD_MAKER_UNDEF) {
00443             ptr++;
00444             xml = add_tTree_node_bystr(xml, XML_NAME_NODE, 0, "undef", NULL, NULL, 0);
00445             xml->state = JBXL_XML_NODE_CLOSED;
00446             xml = xml->prev;
00447         }
00448         else {
00449             PRINT_MESG("ERROR: llsd_bin_main_parse: unknown marker: %c (%04x)\n", *ptr, *ptr);
00450             ptr++;
00451         }
00452     }
00453 
00454     //
00455     if (snode==xml) xml->state = JBXL_XML_NODE_CLOSED;
00456     else           xml->state = JBXL_XML_NOT_CLOSED;
00457 
00458     xml = xml->prev;
00459 
00460     return xml;
00461 }

Here is the call graph for this function:

Here is the caller graph for this function:

tXML* llsd_bin_parse ( uByte ptr,
int  sz 
)
Parameters:
ptr LLSDのバイナリデータへのポインタ
sz データのサイズ
Returns:
XMLデータを格納した tXMLのアンカーへのポインタ.
エラーの場合,next以下のノードにはエラーを起こす直前までの内容が保存される
Return values:
0以下 エラーを起こした場合 stateに JBXL_XML_PARSED以外の値(負数)が入る.

Definition at line 232 of file llsd_tool.c.

References JBXL_XML_DEFAULT_STATE, JBXL_XML_MULTI_ROOT, JBXL_XML_NOT_CLOSED, JBXL_XML_PARSED, llsd_bin_main_parse(), new_xml_node, XML_ANCHOR_NODE, and XML_NAME_NODE.

00233 {
00234     tXML* xml;
00235     tXML* node;
00236 
00237     xml = new_xml_node();                   // アンカー
00238     xml->ldat.id = XML_ANCHOR_NODE;
00239 
00240     // パース
00241     node = llsd_bin_main_parse(xml, ptr, sz);
00242     if (node->state<0) return xml;
00243 
00244 
00245     // 元に戻ったか?
00246     if (xml==node) {
00247         xml->state = JBXL_XML_PARSED;
00248     }
00249     else {
00250         xml->state = JBXL_XML_NOT_CLOSED;
00251     }
00252 
00253     // XML rootの数
00254     if (xml->next!=NULL) {
00255         int n = 0;
00256         node = xml->next;
00257         while(node!=NULL) {
00258             if (node->ldat.id==XML_NAME_NODE) n++;
00259             node = node->ysis;
00260         }
00261         if (n!=1) xml->state = JBXL_XML_MULTI_ROOT;
00262     }
00263     else xml->state = JBXL_XML_DEFAULT_STATE;
00264 
00265     return xml;
00266 }

Here is the call graph for this function:

int llsd_xml_contain_key ( tXML xml,
const char *  key 
)

Definition at line 469 of file llsd_tool.c.

References Buffer::buf, cat_s2Buffer, FALSE, free_Buffer(), get_xml_node_bystr(), make_Buffer_bystr, and TRUE.

00470 {
00471     if (xml==NULL || key==NULL) return FALSE;
00472 
00473     Buffer buf = make_Buffer_bystr("<llsd><map><key>");
00474     cat_s2Buffer(key, &buf);
00475     cat_s2Buffer("</key>", &buf);
00476 
00477     tXML* node = get_xml_node_bystr(xml, (char*)buf.buf);
00478     free_Buffer(&buf);
00479 
00480     if (node!=NULL) return TRUE;
00481     return FALSE;
00482 }

Here is the call graph for this function:

Buffer llsd_xml_get_content_bin ( tXML xml,
const char *  key,
const char *  item 
)

Definition at line 540 of file llsd_tool.c.

References Buffer::buf, cat_s2Buffer, decode_base64_Buffer(), free_Buffer(), get_xml_char_content_bystr(), init_Buffer(), and make_Buffer_bystr.

00541 {
00542     Buffer buf = init_Buffer();
00543     if (xml==NULL || key==NULL || item==NULL) return buf;
00544 
00545     buf = make_Buffer_bystr("<llsd><map><key>");
00546     cat_s2Buffer(key, &buf);
00547     cat_s2Buffer("</key><map><key>", &buf);
00548     cat_s2Buffer(item, &buf);
00549     cat_s2Buffer("</key><binary>", &buf);
00550 
00551     char* ret = get_xml_char_content_bystr(xml, (char*)buf.buf);
00552     free_Buffer(&buf);
00553     buf = make_Buffer_bystr(ret);
00554     
00555     Buffer bin = decode_base64_Buffer(buf);
00556     free_Buffer(&buf);
00557 
00558     return bin;
00559 }

Here is the call graph for this function:

int llsd_xml_get_content_int ( tXML xml,
const char *  key,
const char *  item 
)

Definition at line 487 of file llsd_tool.c.

References Buffer::buf, cat_s2Buffer, free_Buffer(), get_xml_int_content_bystr(), and make_Buffer_bystr.

00488 {
00489     if (xml==NULL || key==NULL || item==NULL) return 0;
00490 
00491     Buffer buf = make_Buffer_bystr("<llsd><map><key>");
00492     cat_s2Buffer(key, &buf);
00493     cat_s2Buffer("</key><map><key>", &buf);
00494     cat_s2Buffer(item, &buf);
00495     cat_s2Buffer("</key><integer>", &buf);
00496 
00497     int ret = get_xml_int_content_bystr(xml, (char*)buf.buf);
00498     free_Buffer(&buf);
00499 
00500     return ret;
00501 }

Here is the call graph for this function:

double llsd_xml_get_content_real ( tXML xml,
const char *  key,
const char *  item 
)

Definition at line 504 of file llsd_tool.c.

References Buffer::buf, cat_s2Buffer, free_Buffer(), get_xml_double_content_bystr(), and make_Buffer_bystr.

00505 {
00506     if (xml==NULL || key==NULL || item==NULL) return 0.0;
00507 
00508     Buffer buf = make_Buffer_bystr("<llsd><map><key>");
00509     cat_s2Buffer(key, &buf);
00510     cat_s2Buffer("</key><map><key>", &buf);
00511     cat_s2Buffer(item, &buf);
00512     cat_s2Buffer("</key><real>", &buf);
00513 
00514     double ret = get_xml_double_content_bystr(xml, (char*)buf.buf);
00515     free_Buffer(&buf);
00516 
00517     return ret;
00518 }

Here is the call graph for this function:

Buffer llsd_xml_get_content_str ( tXML xml,
const char *  key,
const char *  item 
)

Definition at line 521 of file llsd_tool.c.

References Buffer::buf, cat_s2Buffer, free_Buffer(), get_xml_char_content_bystr(), init_Buffer(), and make_Buffer_bystr.

00522 {
00523     Buffer buf = init_Buffer();
00524     if (xml==NULL || key==NULL || item==NULL) return buf;
00525 
00526     buf = make_Buffer_bystr("<llsd><map><key>");
00527     cat_s2Buffer(key, &buf);
00528     cat_s2Buffer("</key><map><key>", &buf);
00529     cat_s2Buffer(item, &buf);
00530     cat_s2Buffer("</key><string>", &buf);
00531 
00532     char* ret = get_xml_char_content_bystr(xml, (char*)buf.buf);
00533     free_Buffer(&buf);
00534     buf = make_Buffer_bystr(ret);
00535 
00536     return buf;
00537 }

Here is the call graph for this function:


Generated on 15 Nov 2023 for JunkBox_Lib by  doxygen 1.6.1