scribble/inc/ink_rw.h File Reference

#include <libermanifest/ermanifest.h>
#include "ink.h"

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

PtrInk file_read_ink (const char *inkfile)
unsigned char file_write_ink (PtrInk ink, const char *inkfile)
PtrInk xml_read_ink (erManifest *pXmlHandle, const char *sPageName)
int xml_write_irxHead (erManifest *pErManiHandle)
gboolean xml_write_ink (erManifest *pXmlHandle, const char *xpath, const PtrInk pink, const char *sPageName)


Function Documentation

PtrInk file_read_ink ( const char *  inkfile  ) 

Copyright (C) 2005-2008 iRex Technologies B.V. All rights reserved.

Definition at line 72 of file ink_rw_file.c.

00073 {
00074     FILE *file = NULL;
00075     PtrInk ink = NULL;
00076     unsigned char ret;
00077     if (inkfile == NULL || strlen (inkfile) == 0)
00078     {
00079         SB_INKERRPRINTF("failed:incorrect arguments\n");
00080         return NULL;
00081     }
00082     file = fopen (inkfile, "rb");
00083     if (file == NULL)
00084     {
00085         SB_INKERRPRINTF("fopen failed \n");
00086         return NULL;
00087     }
00088 
00089     ink = construct_ink ();
00090     if (ink == NULL)
00091     {
00092         fclose (file);
00093         return NULL;
00094     }
00095     ret = read_ink (file, ink);
00096     if (ret == 0)
00097     {
00098         destroy_ink (ink);
00099         fclose (file);
00100         return NULL;
00101     }
00102 
00103     SB_INKPRINTF("succeeded,return ink=%p\n", ink);
00104     fclose (file);
00105     return ink;
00106 }

Here is the call graph for this function:

unsigned char file_write_ink ( PtrInk  ink,
const char *  inkfile 
)

Definition at line 237 of file ink_rw_file.c.

00238 {
00239     FILE *file = NULL;
00240     unsigned char ret;
00241 
00242     if (ink == NULL || ink->nStrokes == 0 || inkfile == NULL
00243         || strlen (inkfile) == 0)
00244     {
00245         return 0;
00246     }
00247     file = fopen (inkfile, "wb+");
00248     if (file == NULL)
00249     {
00250         SB_INKERRPRINTF("fopen failed \n");
00251         return 0;
00252     }
00253     ret = write_ink (ink, file);
00254     fclose (file);
00255     return ret;
00256 }

Here is the call graph for this function:

PtrInk xml_read_ink ( erManifest pXmlHandle,
const char *  sPageName 
)

Definition at line 135 of file ink_rw_xml.c.

00136 {    
00137     if( NULL==pXmlHandle || NULL==sPageName)
00138     {
00139         SB_INKERRPRINTF("error:invalid parameter\n");
00140         return NULL;
00141     }
00142     PtrInk pink = construct_ink ();
00143     if (NULL == pink )
00144     {
00145         SB_INKERRPRINTF("error:construct_ink\n");
00146         return NULL;
00147     }
00148     
00149     if( !xml_page_exist(pXmlHandle,sPageName) )
00150     {
00151         return pink;
00152     }
00153     
00154     char sStrPoints[MAX_STOKE_STR];    
00155     char sStrokeXPath[MAX_XPATH];
00156     int i=1;
00157     char sHtmlColor[HTMLCOLOR_LEN];
00158     while(TRUE)
00159     {
00160         snprintf(sStrokeXPath,MAX_XPATH,
00161                  "/notes/pages/page[@id=\"%s\"]/strokes/stroke[%d]",
00162                  sPageName, i );
00163         //SB_FMPRINTF("path=\n%s\n",sStrokeXPath);
00164         if( RET_OK!=ermXmlGetString(pXmlHandle,sStrokeXPath, 
00165                                     sStrPoints, MAX_STOKE_STR) )
00166         {
00167             break;
00168         }
00169         //SB_INKPRINTF("\n\npoints=%s\n\n",sStrPoints);   
00170         PtrStroke pStroke = construct_stroke ();
00171         if (pStroke == NULL)
00172         {
00173             SB_INKERRPRINTF("return: construct_stroke failed \n");
00174             break;
00175         }
00176         xml_parse_stroke (pStroke,sStrPoints);
00177         
00178         ermXmlGetAttributeInt(pXmlHandle,sStrokeXPath,
00179                               "pensize",&pStroke->iPenSize);
00180         ermXmlGetAttributeString(pXmlHandle,sStrokeXPath,
00181                               "color",sHtmlColor,HTMLCOLOR_LEN);
00182         Util_GdkColorFromHtmlColor(&pStroke->gdkColor,sHtmlColor);
00183         
00184         ink_add_stroke (pink, pStroke);
00185         i++;
00186     }
00187     SB_FMPRINTF("read %d strokes \n",i);
00188     return pink;
00189 }

Here is the call graph for this function:

gboolean xml_write_ink ( erManifest pXmlHandle,
const char *  xpath,
const PtrInk  pink,
const char *  sPageName 
)

Definition at line 269 of file ink_rw_xml.c.

00271 {
00272     if( NULL==pXmlHandle || NULL==xpath || NULL==sPageName )//0==pink->nStrokes
00273     {
00274         return FALSE;
00275     }    
00276     SB_FMPRINTF("--page,path=[%s],sPageName=%s",xpath,sPageName);
00277     
00278     char sCurrXPath[MAX_XPATH];
00279     
00280     //if the page exist,we first empty it.
00281     if( !xml_page_exist(pXmlHandle,sPageName) )
00282     {
00283         ermXmlNewString(pXmlHandle, xpath, "page", "");
00284         
00285         snprintf(sCurrXPath,MAX_XPATH,"%s/page[last()]",xpath);   
00286         ermXmlSetAttributeString(pXmlHandle,sCurrXPath,
00287                                 "id",sPageName,strlen(sPageName) );
00288         snprintf(sCurrXPath,MAX_XPATH,"%s/page[@id=\"%s\"]",xpath,sPageName); 
00289     }
00290     else
00291     { //empty it firstly
00292         snprintf(sCurrXPath,MAX_XPATH,"%s/page[@id=\"%s\"]",xpath,sPageName); 
00293         ermXmlSetString(pXmlHandle,sCurrXPath, "");
00294     }
00295     if( NULL==pink || 0==pink->nStrokes )
00296     {
00297         return TRUE;
00298     }
00299      
00300     xml_write_page_head(pXmlHandle,sCurrXPath);
00301     
00302     SB_FMPRINTF("ink->nStrokes=%d \n", pink->nStrokes);
00303     PtrStroke pStroke = pink->firstStroke;
00304     int i=1;
00305     char strokesPath[MAX_XPATH];
00306     snprintf(strokesPath,MAX_XPATH,"%s/strokes",sCurrXPath);
00307     char sLastStrokeXPath[MAX_XPATH];//xpath for last stroke
00308 
00309     while (pStroke)
00310     {     
00311         ermXmlNewString(pXmlHandle, strokesPath, "stroke", "");
00312         snprintf(sLastStrokeXPath,MAX_XPATH,"%s/stroke[%d]",strokesPath,i);
00313         //SB_FMPRINTF("\nsLastStrokeXPath=[%s]\n",sLastStrokeXPath);
00314         xml_write_stroke(pXmlHandle,sLastStrokeXPath,pStroke);
00315         pStroke = pStroke->nextStroke;
00316         i++;
00317     }
00318     return TRUE;
00319 }

Here is the call graph for this function:

int xml_write_irxHead ( erManifest pErManiHandle  ) 

Definition at line 240 of file ink_rw_xml.c.

00241 {
00242     ermXmlNewString(pErManiHandle, "/", "notes", "");
00243     ermXmlNewString(pErManiHandle, "/notes", "version", "");
00244     ermXmlNewString(pErManiHandle, "/notes/version", "number", "1.0");
00245     ermXmlNewString(pErManiHandle, "/notes/version","orgnization", "iRex Technologies");
00246     
00247     ermXmlNewString(pErManiHandle, "/notes", "screen", "");
00248     //units can be px,mm or in.
00249     ermXmlNewString(pErManiHandle, "/notes/screen", "units", "px");
00250     ermXmlNewInt(pErManiHandle, "/notes/screen","dpi", 160);
00251         
00252     ermXmlNewString(pErManiHandle, "/notes", "pages", "");
00253     
00254     return 0;
00255 }

Here is the call graph for this function:


Generated on Sun Dec 14 17:14:27 2008 by  doxygen 1.5.6