home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 110 / EnigmaAmiga110CD.iso / indispensabili / utility / apdf / xpdf-0.80 / xpdf / apdfcommon.cc < prev    next >
C/C++ Source or Header  |  1999-06-30  |  16KB  |  755 lines

  1. //========================================================================
  2. //
  3. // Apdfcommon.cc
  4. //
  5. // Copyright 1999 Emmanuel Lesueur
  6. //
  7. //========================================================================
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <stddef.h>
  12. #include <string.h>
  13. #define Object ZZObject
  14. #ifdef __PPC__
  15. #   include <powerup/ppcproto/exec.h>
  16. #   include <powerup/ppcproto/dos.h>
  17. #else
  18. #   include <proto/exec.h>
  19. #   include <proto/dos.h>
  20. #endif
  21. #undef Object
  22. #include "parseargs.h"
  23. #include "GString.h"
  24. #include "gmem.h"
  25. #include "Object.h"
  26. #include "Stream.h"
  27. #include "Array.h"
  28. #include "Dict.h"
  29. #include "XRef.h"
  30. #include "Catalog.h"
  31. #include "Page.h"
  32. #include "Link.h"
  33. #include "PDFDoc.h"
  34. #include "AOutputDev.h"
  35. #include "TextOutputDev.h"
  36. #include "PSOutputDev.h"
  37. #include "ImageOutputDev.h"
  38. #include "FontOutputDev.h"
  39. #include "Error.h"
  40. #include "config.h"
  41. #include "AComm.h"
  42.  
  43. #ifdef __SASC
  44. #   undef  try
  45. #   undef  catch
  46. #   define try
  47. #   define catch(x)    if(const char* msg=NULL)
  48. #endif
  49.  
  50.  
  51. #ifdef __PPC__
  52. #   define LINKAGE
  53. #else
  54. #   define LINKAGE extern "C"
  55. #endif
  56.  
  57. static int userFontMapLen,userFontMapSize;
  58. static char* fontPathInit[]={NULL};
  59. char **fontPath = fontPathInit;
  60.  
  61. static PDFDoc* doc;
  62. static AGfx* gfx;
  63. static AOutputDev* AOut;
  64. int maxColors;
  65. const char* uncompressCmd;
  66. static FontOutputDev* fOut;
  67.  
  68. extern FILE* errFile;
  69.  
  70. static BPTR olddir;
  71. static BPTR lock;
  72.  
  73. #ifdef POWERUP
  74. extern PPCPort* port68k;
  75. #endif
  76.  
  77. extern "C" {
  78.     unsigned long _MSTEP=0x10000;
  79. }
  80.  
  81. LINKAGE void clear_fontmap() {
  82.     if(userFontMap) {
  83.     for(int i=0;i<userFontMapLen;++i) {
  84.         gfree(userFontMap[i].pdfFont);
  85.         gfree(userFontMap[i].xFont);
  86.     }
  87.     userFontMap[0].pdfFont=NULL;
  88.     userFontMapLen=0;
  89.     }
  90.     //clearFontMap();
  91. }
  92.  
  93. void cleanup2() {
  94.     CurrentDir(olddir);
  95.     UnLock(lock);
  96.     delete fOut;
  97.     delete AOut;
  98.     delete gfx;
  99.     delete doc;
  100.     clear_fontmap();
  101.     gfree(userFontMap);
  102.     gfree((void*)uncompressCmd);
  103.     Object::memCheck(errFile);
  104.     gMemReport(errFile);
  105. }
  106.  
  107. LINKAGE int init(int colors,const char* gzip) {
  108.     int ok=1;
  109.  
  110.     try {
  111.  
  112.     maxColors=colors;
  113.     olddir=CurrentDir(0);
  114.     CurrentDir(olddir);
  115.  
  116.     errorInit();
  117.  
  118.     atexit(&cleanup2);
  119.  
  120.     userFontMapSize=8;
  121.     userFontMap=(FontMapEntry*)gmalloc(userFontMapSize*sizeof(FontMapEntry));
  122.     userFontMap->pdfFont=NULL;
  123.  
  124.     uncompressCmd=copyString((char*)gzip);
  125.  
  126. #ifdef POWERUP
  127.     gfx=new AGfx(port68k);
  128. #else
  129.     gfx=new AGfx;
  130. #endif
  131.  
  132.     }
  133.     catch(const char* msg) {
  134.     printf("Exception: %s\n",msg);
  135.     ok=0;
  136.     }
  137.     catch(...) {
  138.     printf("Exception caught.");
  139.     ok=0;
  140.     }
  141.  
  142.     return ok;
  143. }
  144.  
  145.  
  146.  
  147.  
  148. LINKAGE int create_doc(BPTR dir,const char* filename,size_t maxbuf,size_t blocsz) {
  149.     BPTR olddir=CurrentDir(dir);
  150.     try {
  151.     myFILE::bufsizes(blocsz,maxbuf);
  152.     PDFDoc* d=new PDFDoc(new GString((char*)filename));
  153.     if(d->isOk()) {
  154.         delete doc;
  155.         doc=d;
  156.         UnLock(lock);
  157.         lock=DupLock(dir);
  158.         CurrentDir(lock);
  159.         return 1;
  160.     }
  161.     delete d;
  162.     }
  163.     catch(const char* msg) {
  164.     printf("Exception: %s\n",msg);
  165.     }
  166.     catch(...) {
  167.     printf("Exception caught.");
  168.     }
  169.     CurrentDir(olddir);
  170.     return 0;
  171. }
  172.  
  173. #if 0
  174. LINKAGE void do_delete_doc() {
  175.     delete doc;
  176.     doc=NULL;
  177. }
  178. #endif
  179.  
  180. LINKAGE int create_output_dev(int depth,struct ColorMap* colormap) {
  181.     try {
  182.     delete AOut;
  183.     AOut=NULL; //in case the following line throws an exception
  184.     AOut=new AOutputDev(*gfx, depth, colormap);
  185.     AOutputFont::reset();
  186.     return 1;
  187.     }
  188.     catch(const char* msg) {
  189.     printf("Exception: %s\n",msg);
  190.     }
  191.     catch(...) {
  192.     printf("Exception caught.");
  193.     }
  194.     return 0;
  195. }
  196.  
  197. LINKAGE void delete_output_dev() {
  198.     delete AOut;
  199.     AOut=NULL;
  200. }
  201.  
  202. LINKAGE int get_info(int* num_pages) {
  203.     if(doc) {
  204.     *num_pages=doc->getNumPages();
  205.     return 1;
  206.     } else {
  207.     *num_pages=1;
  208.     return 0;
  209.     }
  210. }
  211.  
  212. LINKAGE int get_page_size(int page,int* width,int* height) {
  213.     if(doc) {
  214.     int w=int(doc->getPageWidth(page)+0.5);
  215.     int h=int(doc->getPageHeight(page)+0.5);
  216.     int r=doc->getPageRotate(page);
  217.     if(r==90 || r==270) {
  218.         *width=h;
  219.         *height=w;
  220.     } else {
  221.         *width=w;
  222.         *height=h;
  223.     }
  224.     return 1;
  225.     } else {
  226.     *width=612;
  227.     *height=792;
  228.     return 0;
  229.     }
  230. }
  231.  
  232. LINKAGE int simple_find(const char* str,int top,int* xmin,int* ymin,int* xmax,int* ymax) {
  233.     try {
  234.     if(AOut && AOut->findText((char*)str,top,gTrue,xmin,ymin,xmax,ymax))
  235.         return 1;
  236.     }
  237.     catch(const char* msg) {
  238.     printf("Exception: %s\n",msg);
  239.     }
  240.     catch(...) {
  241.     printf("Exception caught.");
  242.     }
  243.     return 0;
  244. }
  245.  
  246. static char* find_str;
  247. static TextOutputDev* find_dev;
  248.  
  249. LINKAGE void end_find() {
  250.     delete find_dev;
  251.     find_dev=NULL;
  252.     gfree(find_str);
  253.     find_str=NULL;
  254. }
  255.  
  256. LINKAGE int init_find(const char* str) {
  257.     try {
  258.     find_str=copyString((char*)str);
  259.     find_dev=new TextOutputDev(NULL,gFalse);
  260.     if(find_dev->isOk())
  261.         return 1;
  262.     }
  263.     catch(const char* msg) {
  264.     printf("Exception: %s\n",msg);
  265.     }
  266.     catch(...) {
  267.     printf("Exception caught.");
  268.     }
  269.     end_find();
  270.     return 0;
  271. }
  272.  
  273. LINKAGE int find(int start,int stop,int* xmin,int* ymin,int* xmax,int* ymax,int* page) {
  274.     int r=0;
  275.     try {
  276.     if(find_dev && find_str) {
  277.         for(int pg=start;pg<stop;++pg) {
  278.         double x1,x2,y1,y2;
  279.         doc->displayPage(find_dev,pg,72,0,gFalse);
  280.         if(find_dev->findText(find_str,gTrue,gTrue,&x1,&y1,&x2,&y2)) {
  281.             r=1;
  282.             *page=pg;
  283.             break;
  284.         }
  285.         }
  286.     }
  287.     }
  288.     catch(const char* msg) {
  289.     printf("Exception: %s\n",msg);
  290.     }
  291.     catch(...) {
  292.     printf("Exception caught.");
  293.     }
  294.     return r;
  295. }
  296.  
  297. LINKAGE int chklink(int mx,int my,void** maction,char* str,size_t len) {
  298.     int r=0;
  299.     try {
  300.     double x,y;
  301.     LinkAction *action;
  302.     const char *s;
  303.     if(doc && AOut) {
  304.         AOut->cvtDevToUser(mx,my,&x,&y);
  305.         if(action=doc->findLink(x,y)) {
  306.         if(action!=*maction) {
  307.             *maction=action;
  308.             s=NULL;
  309.             switch(action->getKind()) {
  310.               case actionGoTo:
  311.             s="[internal link]";
  312.             break;
  313.               case actionGoToR:
  314.             s=((LinkGoToR*)action)->getFileName()->getCString();
  315.             break;
  316.               case actionLaunch:
  317.             s=((LinkLaunch*)action)->getFileName()->getCString();
  318.             break;
  319.               case actionURI:
  320.             s=((LinkURI*)action)->getURI()->getCString();
  321.             break;
  322.               case actionUnknown:
  323.             s="[unknown link]";
  324.             break;
  325.             }
  326.             strncpy(str,s,len-1);
  327.             str[len-1]='\0';
  328.         }
  329.         r=1;
  330.         }
  331.     }
  332.     }
  333.     catch(const char* msg) {
  334.     printf("Exception: %s\n",msg);
  335.     }
  336.     catch(...) {
  337.     printf("Exception caught.");
  338.     }
  339.     return r;
  340. }
  341.  
  342. LINKAGE int dolink(int* mx,int* my,int* state,int* page,char* buf,size_t len) {
  343.     int r=0;
  344.     *state=st_unchanged;
  345.     *page=-1;
  346.     LinkDest* dest=NULL;
  347.     GString* namedDest=NULL;
  348.     GString* fileName=NULL;
  349.     PDFDoc* d=NULL;
  350.     try {
  351.     double x,y;
  352.     AOut->cvtDevToUser(*mx,*my,&x,&y);
  353.     *mx=-1;
  354.     *my=-1;
  355.     if(LinkAction* action=doc->findLink(x,y)) {
  356.         switch(LinkActionKind kind=action->getKind()) {
  357.         // GoTo / GoToR action
  358.           case actionGoTo:
  359.           case actionGoToR:
  360.         if(kind==actionGoTo) {
  361.             if(dest=((LinkGoTo*)action)->getDest())
  362.             dest=dest->copy();
  363.             else if(namedDest=((LinkGoTo*)action)->getNamedDest())
  364.             namedDest=namedDest->copy();
  365.         } else {
  366.             if(dest=((LinkGoToR*)action)->getDest())
  367.             dest=dest->copy();
  368.             else if(namedDest=((LinkGoToR*)action)->getNamedDest())
  369.             namedDest=namedDest->copy();
  370.             char* s=((LinkGoToR*)action)->getFileName()->getCString();
  371.             //~ translate path name for VMS (deal with '/')
  372.             /*if (isAbsolutePath(s))
  373.             fileName = new GString(s);
  374.             else
  375.             fileName = appendToPath(grabPath(doc->getFileName()->getCString()), s);*/
  376.             fileName=new GString(s);
  377.             d=new PDFDoc(fileName);
  378.             fileName=NULL;
  379.             if(d->isOk()) {
  380.             delete doc;
  381.             doc=d;
  382.             d=NULL;
  383.             strncpy(buf,fileName->getCString(),len-1);
  384.             buf[len-1]='\0';
  385.             *state=st_changed;
  386.             *page=1;
  387.             } else
  388.             break;
  389.         }
  390.         if(namedDest) {
  391.             dest=doc->findDest(namedDest);
  392.             //delete namedDest;
  393.             //namedDest=NULL;
  394.         }
  395.         if(!dest) {
  396.             if(kind==actionGoToR)
  397.             *page=1;
  398.         } else {
  399.             Ref pageRef;
  400.             if(dest->isPageRef()) {
  401.             pageRef=dest->getPageRef();
  402.             *page=doc->findPage(pageRef.num,pageRef.gen);
  403.             } else
  404.             *page=dest->getPageNum();
  405.             switch(dest->getKind()) {
  406.               case destXYZ: {
  407.             int dx,dy;
  408.             AOut->cvtUserToDev(dest->getLeft(),dest->getTop(),&dx,&dy);
  409.             if(dest->getChangeLeft() || dest->getChangeTop()) {
  410.                 if(dest->getChangeLeft())
  411.                 *mx=dx;
  412.                 if(dest->getChangeTop())
  413.                 *my=dy;
  414.             }
  415.             //~ what is the zoom parameter?
  416.             break;
  417.               }
  418.               case destFit:
  419.               case destFitB:
  420.             //~ do fit
  421.             *mx=0;
  422.             *my=0;
  423.             break;
  424.               case destFitH:
  425.               case destFitBH:
  426.             //~ do fit
  427.             AOut->cvtUserToDev(0,dest->getTop(),mx,my);
  428.             break;
  429.               case destFitV:
  430.               case destFitBV:
  431.             //~ do fit
  432.             AOut->cvtUserToDev(dest->getLeft(),0,mx,my);
  433.             break;
  434.               case destFitR:
  435.             //~ do fit
  436.             AOut->cvtUserToDev(dest->getLeft(),dest->getTop(),mx,my);
  437.             break;
  438.             }
  439.             //delete dest;
  440.             //dest=NULL;
  441.         }
  442.         r=1;
  443.         break;
  444.  
  445.         // Launch action
  446.           case actionLaunch: {
  447.         fileName=((LinkLaunch *)action)->getFileName();
  448.         char* s=fileName->getCString();
  449.         if(!strcmp(s+fileName->getLength()-4,".pdf") ||
  450.            !strcmp(s+fileName->getLength()-4,".PDF")) {
  451.             //~ translate path name for VMS (deal with '/')
  452.             /*if (isAbsolutePath(s))
  453.             fileName = fileName->copy();
  454.             else
  455.             fileName = appendToPath(grabPath(doc->getFileName()->getCString()), s);*/
  456.             fileName=new GString(s);
  457.             d=new PDFDoc(fileName);
  458.             fileName=NULL;
  459.             if(d->isOk()) {
  460.             delete doc;
  461.             doc=d;
  462.             d=NULL;
  463.             strncpy(buf,fileName->getCString(),len-1);
  464.             buf[len-1]='\0';
  465.             *state=st_changed;
  466.             *page=1;
  467.             } else
  468.             break;
  469.         } else {
  470.             fileName=fileName->copy();
  471.             if(((LinkLaunch*)action)->getParams()) {
  472.             fileName->append(' ');
  473.             fileName->append(((LinkLaunch*)action)->getParams());
  474.             }
  475.             fileName->insert(0,"run ");
  476.             strncpy(buf,fileName->getCString(),len-1);
  477.             buf[len-1]='\0';
  478.             *state=st_run;
  479.         }
  480.         r=1;
  481.         break;
  482.           }
  483.         // URI action
  484.           case actionURI:
  485.         strncpy(buf,((LinkURI*)action)->getURI()->getCString(),len-1);
  486.         buf[len-1]='\0';
  487.         *state=st_url;
  488.         r=1;
  489.         break;
  490.  
  491.         // unknown action type
  492.           case actionUnknown:
  493.         error(-1,"Unknown link action type: '%s'",((LinkUnknown *)action)->getAction()->getCString());
  494.         break;
  495.         }
  496.     }
  497.     }
  498.     catch(const char* msg) {
  499.     printf("Exception: %s\n",msg);
  500.     }
  501.     catch(...) {
  502.     printf("Exception caught.");
  503.     }
  504.     delete d;
  505.     delete dest;
  506.     delete namedDest;
  507.     delete fileName;
  508.     return r;
  509. }
  510.  
  511.  
  512. static OutputDev* saveDev;
  513. static int saveZoom;
  514. static int saveRotate;
  515.  
  516. LINKAGE void end_write() {
  517.     delete saveDev;
  518.     saveDev=NULL;
  519. }
  520.  
  521. LINKAGE int init_write(const char* filename,int first_page,int last_page,int zoom,int rotate,int type) {
  522.     int r=0;
  523.     if(doc) {
  524.     try {
  525.         switch(type) {
  526.           case 0: // Postscript
  527.           case 1: // Postscript Level 1
  528.         if(doc->okToPrint()) {
  529.             psOutLevel1=type==1;
  530.             saveDev=new PSOutputDev((char*)filename,doc->getCatalog(),
  531.                         first_page,last_page,gTrue,gFalse);
  532.         }
  533.         break;
  534.           case 2: // Text
  535.         saveDev=new TextOutputDev((char*)filename,gFalse);
  536.         zoom=72;
  537.         rotate=0;
  538.         break;
  539.           case 3: // PBM/PPM images
  540.           case 4: // JPEG images
  541.         saveDev=new ImageOutputDev((char*)filename,type==4);
  542.         zoom=72;
  543.         rotate=0;
  544.         break;
  545.         }
  546.         saveZoom=zoom;
  547.         saveRotate=rotate;
  548.         r=saveDev->isOk();
  549.     }
  550.     catch(const char* msg) {
  551.         printf("Exception: %s\n",msg);
  552.     }
  553.     catch(...) {
  554.         printf("Exception caught.");
  555.     }
  556.     if(!r)
  557.         end_write();
  558.     }
  559.     return r;
  560. }
  561.  
  562. LINKAGE void writefile(int first_page,int last_page) {
  563.     if(doc && saveDev) {
  564.     try {
  565.         doc->displayPages(saveDev,first_page,last_page-1,saveZoom,saveRotate);
  566.     }
  567.     catch(const char* msg) {
  568.         printf("Exception: %s\n",msg);
  569.     }
  570.     catch(...) {
  571.         printf("Exception caught.");
  572.     }
  573.     }
  574. }
  575.  
  576.  
  577. LINKAGE char* gettext(int minx,int miny,int maxx,int maxy) {
  578.     char* r=NULL;
  579.     if(doc && AOut) {
  580.     GString* s=NULL;
  581.     try {
  582.         s=AOut->getText(minx,miny,maxx,maxy);
  583.         size_t sz=s->getLength();
  584.         if(r=(char*)malloc(sz+1))
  585.         strcpy(r,s->getCString());
  586.     }
  587.     catch(const char* msg) {
  588.         printf("Exception: %s\n",msg);
  589.     }
  590.     catch(...) {
  591.         printf("Exception caught.");
  592.     }
  593.     delete s;
  594.     }
  595.     return r;
  596. }
  597.  
  598.  
  599.  
  600. LINKAGE int show_page(int page,int zoom) {
  601.     int r=0;
  602.     if(doc && AOut) {
  603.     try {
  604.         doc->displayPage(AOut,page,zoom,0,gTrue);
  605.         r=1;
  606.     }
  607.     catch(const char* msg) {
  608.         printf("Exception: %s\n",msg);
  609.     }
  610.     catch(...) {
  611.         printf("Exception caught.");
  612.     }
  613.     gfx->flush();
  614.     }
  615.     return r;
  616. }
  617.  
  618. LINKAGE void add_fontmap(const char* pdffont,
  619.              const char* afont,
  620.              int m,
  621.              int style,
  622.              int encoding) {
  623.     try {
  624.     for(int k=0;k<userFontMapLen;++k)
  625.         if(!strcmp(userFontMap[k].pdfFont,pdffont)) {
  626.         gfree(userFontMap[k].pdfFont);
  627.         gfree(userFontMap[k].xFont);
  628.         --userFontMapLen;
  629.         if(k!=userFontMapLen)
  630.             memmove(userFontMap+k,userFontMap+k+1,(userFontMapLen-k+1)*sizeof(FontMapEntry));
  631.         break;
  632.         }
  633.     if(userFontMapLen>=userFontMapSize-1) {
  634.         userFontMapSize+=8;
  635.         userFontMap=(FontMapEntry*)grealloc(userFontMap,userFontMapSize*sizeof(FontMapEntry));
  636.     }
  637.     userFontMap[userFontMapLen].pdfFont=copyString((char*)pdffont);
  638.     userFontMap[userFontMapLen].xFont=copyString((char*)afont);
  639.     userFontMap[userFontMapLen].mWidth=m;
  640.     userFontMap[userFontMapLen].style=style;
  641.     userFontMap[userFontMapLen].encoding=encoding;
  642.     userFontMap[++userFontMapLen].pdfFont=NULL;
  643.     }
  644.     catch(const char* msg) {
  645.     printf("Exception: %s\n",msg);
  646.     }
  647.     catch(...) {
  648.     printf("Exception caught.");
  649.     }
  650. }
  651.  
  652. #if 0
  653. LINKAGE void rem_fontmap(const char* pdffont) {
  654.     for(int k=0;k<devFontMapLen;++k)
  655.     if(!strcmp(devFontMap[k].pdfFont,pdffont)) {
  656.         gfree(devFontMap[k].pdfFont);
  657.         gfree(devFontMap[k].devFont);
  658.         --devFontMapLen;
  659.         if(k!=devFontMapLen)
  660.         memmove(devFontMap+k,devFontMap+k+1,(devFontMapLen-k)*sizeof(DevFontMapEntry));
  661.         break;
  662.     }
  663. }
  664.  
  665. LINKAGE void set_fontmap() {
  666.     //resetFontMap();
  667. }
  668. #endif
  669.  
  670. LINKAGE void end_scan_fonts() {
  671.     delete fOut;
  672.     fOut=NULL;
  673. }
  674.  
  675. LINKAGE int init_scan() {
  676.     int r=0;
  677.     if(doc) {
  678.     try {
  679.         end_scan_fonts();
  680.         fOut=new FontOutputDev;
  681.         r=fOut->isOk();
  682.     }
  683.     catch(const char* msg) {
  684.         printf("Exception: %s\n",msg);
  685.     }
  686.     catch(...) {
  687.         printf("Exception caught.");
  688.     }
  689.     if(r==0)
  690.         end_scan_fonts();
  691.     }
  692.     return r;
  693. }
  694.  
  695. LINKAGE int scan_fonts(int first_page,int last_page) {
  696.     int r=0;
  697.     if(doc && fOut) {
  698.     try {
  699.         doc->displayPages(fOut,first_page,last_page-1,72,0);
  700.         r=fOut->size();
  701.     }
  702.     catch(const char* msg) {
  703.         printf("Exception: %s\n",msg);
  704.     }
  705.     catch(...) {
  706.         printf("Exception caught.");
  707.     }
  708.     }
  709.     return r;
  710. }
  711.  
  712. LINKAGE int scan_default_fonts() {
  713.     int r=0;
  714.     try {
  715.     if(fOut) {
  716.         delete fOut;
  717.         fOut=NULL;
  718.     }
  719.     fOut=new DefaultFontOutputDev;
  720.     if(fOut->isOk())
  721.         r=fOut->size();
  722.     }
  723.     catch(const char* msg) {
  724.     printf("Exception: %s\n",msg);
  725.     }
  726.     catch(...) {
  727.     printf("Exception caught.");
  728.     }
  729.     if(r==0) {
  730.     delete fOut;
  731.     fOut=NULL;
  732.     }
  733.     return r;
  734. }
  735.  
  736. LINKAGE int get_font(int n,char* pdffont,int pdffontlen,
  737.               char* afont,int afontlen,
  738.               int* m,int* style,int* encoding) {
  739.     if(fOut) {
  740.     const char* p;
  741.     const char* q;
  742.     fOut->get(n,p,q,*m,*style,*encoding);
  743.     if(p) {
  744.         strncpy(pdffont,p,pdffontlen-1);
  745.         pdffont[pdffontlen-1]='\0';
  746.         strncpy(afont,q,afontlen-1);
  747.         afont[afontlen-1]='\0';
  748.         return 1;
  749.     } else
  750.         return 0;
  751.     } else
  752.     return 0;
  753. }
  754.  
  755.