xls.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "machine.h"
#include "MALLOC.h"
#include "sciprint.h"

Include dependency graph for xls.c:

Go to the source code of this file.

Defines

#define typ_short   "s"
#define typ_ushort   "us"
#define typ_char   "c"
#define typ_uchar   "uc"
#define typ_double   "d"
#define typ_int   "i"
#define Min(x, y)   ((x) < (y) ? (x) : (y))

Functions

int ripole (char *inputfile, char *outputfile, int debug, int verbose)
void C2F() mgetnc (integer *fd, void *res, integer *n, char *type, integer *ierr)
void C2F() mtell (integer *fd, double *offset, integer *err)
void C2F() mseek (integer *fd, integer *offset, char *flag, integer *err)
FILE * GetFile (integer *fd)
int GetSwap (integer *fd)
void xls_read (int *fd, int *cur_pos, double **data, int **chainesind, int *N, int *M, int *err)
void xls_open (int *err, int *fd, char ***sst, int *ns, char ***Sheetnames, int **Abspos, int *nsheets)
static double NumFromRk2 (long rk)
static void getBoundsheets (int *fd, char ***Sheetnames, int **Abspos, int *nsheets, int *cur_pos, int *err)
static void getSST (int *fd, short Len, int BIFF, int *ns, char ***sst, int *err)
static void getBOF (int *fd, int *Data, int *err)
static void getString (int *fd, short *count, short *Len, int flag, char **str, int *err)
static int get_oleheader (int *fd)
static double return_a_nan ()


Define Documentation

#define Min ( x,
y   )     ((x) < (y) ? (x) : (y))

Definition at line 17 of file xls.c.

#define typ_char   "c"

Definition at line 13 of file xls.c.

Referenced by getBoundsheets(), and getString().

#define typ_double   "d"

Definition at line 15 of file xls.c.

Referenced by xls_read().

#define typ_int   "i"

Definition at line 16 of file xls.c.

Referenced by getBOF(), getBoundsheets(), getSST(), getString(), and xls_read().

#define typ_short   "s"

Definition at line 11 of file xls.c.

Referenced by getBOF(), getString(), and xls_read().

#define typ_uchar   "uc"

Definition at line 14 of file xls.c.

Referenced by get_oleheader().

#define typ_ushort   "us"

Definition at line 12 of file xls.c.

Referenced by getBOF(), getBoundsheets(), getString(), xls_open(), and xls_read().


Function Documentation

static int get_oleheader ( int fd  )  [static]

Definition at line 744 of file xls.c.

References C2F, ierr, memcmp(), mgetnc(), and typ_uchar.

00745 {
00746   unsigned char MAGIC[8] = { 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1 };
00747   unsigned char header[512];
00748   int c,ierr;
00749 
00750   C2F(mgetnc) (fd, (void *)header,(c=512,&c), typ_uchar, &ierr);
00751   if (ierr !=0)  return 1;
00752   if (memcmp (header, MAGIC, sizeof (MAGIC)) != 0) return 1;
00753   return 0;
00754 }

Here is the call graph for this function:

static void getBOF ( int fd,
int Data,
int err 
) [static]

Definition at line 361 of file xls.c.

References C2F, Len(), mgetnc(), typ_int, typ_short, and typ_ushort.

Referenced by xls_open(), and xls_read().

00362 {
00363   /* return Data a vector [BIFF  Version DataType Identifier Year HistoryFlags LowestXlsVersion]
00364    * works for BIFF2 to BIFF8 records */
00365   int BIFF;
00366   short Version;
00367   short DataType;
00368   short Identifier=0;
00369   short Year=0;
00370   int HistoryFlags=0;
00371   int LowestXlsVersion=0;
00372 
00373   unsigned short Opcode;
00374   unsigned short Len;
00375   int one=1;
00376 
00377   C2F(mgetnc) (fd, (void*)&Opcode, &one, typ_ushort, err);
00378   if (*err > 0) return;
00379   C2F(mgetnc) (fd, (void*)&Len, &one, typ_ushort, err);
00380   if (*err > 0) return;
00381 
00382   switch(Opcode) {
00383   case 2057:     /*Begin of file, BOF for BIFF5 BIFF7 BIFF8 BIFF8X*/
00384     C2F(mgetnc) (fd, (void*)&Version, &one, typ_short, err);
00385     if (*err > 0) return;
00386     C2F(mgetnc) (fd, (void*)&DataType, &one, typ_short, err);
00387     if (*err > 0) return;
00388     C2F(mgetnc) (fd, (void*)&Identifier, &one, typ_short, err);
00389     if (*err > 0) return;
00390     C2F(mgetnc) (fd, (void*)&Year, &one, typ_short, err);
00391     if (*err > 0) return;
00392     if (Len==16) {
00393       C2F(mgetnc) (fd, (void*)&HistoryFlags, &one, typ_int, err);
00394       if (*err > 0) return;
00395       C2F(mgetnc) (fd, (void*)&LowestXlsVersion, &one, typ_int, err);
00396       if (*err > 0) return;
00397       BIFF=8;
00398       if (Version != 1536) return;
00399     }
00400     else
00401       BIFF=7;
00402     break;
00403   case 1033 : /*Interprétation du BIFF4  0409 H*/
00404     C2F(mgetnc) (fd, (void*)&Version, &one, typ_short, err);
00405     if (*err > 0) return;
00406     C2F(mgetnc) (fd, (void*)&DataType, &one, typ_short, err);
00407     if (*err > 0) return;
00408     BIFF=4;
00409     break;
00410   case 521 : /*Interprétation du BIFF3  0209 H*/
00411     C2F(mgetnc) (fd, (void*)&Version, &one, typ_short, err);
00412     if (*err > 0) return;
00413     C2F(mgetnc) (fd, (void*)&DataType, &one, typ_short, err);
00414     if (*err > 0) return;
00415     BIFF=3;
00416     break;
00417   case 9 : /*Interprétation du BIFF2  0009 H*/
00418     C2F(mgetnc) (fd, (void*)&Version, &one, typ_short, err);
00419     if (*err > 0) return;
00420     C2F(mgetnc) (fd, (void*)&DataType, &one, typ_short, err);
00421     if (*err > 0) return;
00422     BIFF=2;
00423     break;
00424   default:
00425     BIFF=-1; /* not a BOF record */
00426     Version=0;
00427     DataType=0;
00428   }
00429   Data[0]=BIFF;
00430   Data[1]=Version;
00431   Data[2]=DataType;
00432   Data[3]=Identifier;
00433   Data[4]=Year;
00434   Data[5]=HistoryFlags;
00435   Data[6]=LowestXlsVersion;
00436 
00437 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void getBoundsheets ( int fd,
char ***  Sheetnames,
int **  Abspos,
int nsheets,
int cur_pos,
int err 
) [static]

Definition at line 657 of file xls.c.

References C2F, count, FREE, getString(), i, Len(), MALLOC, mgetnc(), mseek(), NULL, pos, typ_char, typ_int, and typ_ushort.

Referenced by xls_open().

00658 {/* the global workbook contains a sequence of boudsheets this procedure reads all
00659  * the sequence and returns a vector o sheetnames, a vector of absolute sheet positions*/
00660   int abspos; /* Absolute stream position of BoF*/
00661   char visibility,sheettype;/*Visiblity , Sheet type*/
00662   int pos;
00663   unsigned short Opcode;
00664   unsigned short Len;
00665   int one=1;
00666   int ns,i;
00667 
00668   *Sheetnames=(char **)NULL;
00669   *Abspos=(int *)NULL;
00670   *err=0;
00671 
00672   /* memorize the first boundsheet beginning */
00673   pos=*cur_pos;
00674   /* Count number of boundsheets */
00675   ns=0;
00676   while(1) {
00677     C2F(mseek) (fd, cur_pos, "set", err);
00678     if (*err > 0) goto ErrL;
00679     C2F(mgetnc) (fd, &Opcode, &one, typ_ushort, err);
00680     if (*err > 0) goto ErrL;
00681     C2F(mgetnc) (fd, &Len, &one, typ_ushort, err);
00682     if (*err > 0) goto ErrL;
00683     if (Opcode==133) {
00684       C2F(mgetnc) (fd, (void*)&abspos, &one, typ_int, err);
00685       if (*err > 0) goto ErrL;
00686       C2F(mgetnc) (fd, (void*)&visibility, &one, typ_char, err);
00687       if (*err > 0) goto ErrL;
00688       C2F(mgetnc) (fd, (void*)&sheettype, &one, typ_char, err);
00689       if (sheettype==0) {/* worksheet */
00690         ns++;
00691       }
00692       *cur_pos=*cur_pos+4+Len;
00693     }
00694     else
00695       break;
00696 
00697     }
00698 
00699   *nsheets=ns;
00700   /*alloc the Sheetnames ans Abspos arrays */
00701    if( (*Sheetnames=(char **)MALLOC(ns*sizeof(char*)))==NULL)  goto ErrL;
00702    if( (*Abspos=(int *)MALLOC(ns*sizeof(int)))==NULL)  goto ErrL;
00703 
00704    /* rescan boundsheet sequence to get the data */
00705    *cur_pos=pos;
00706    i=-1;
00707    while(1) {
00708      C2F(mseek) (fd, cur_pos, "set", err);
00709      if (*err > 0) goto ErrL;
00710      C2F(mgetnc) (fd, &Opcode, &one, typ_ushort, err);
00711      C2F(mgetnc) (fd, &Len, &one, typ_ushort, err);
00712      if (Opcode==133) {
00713        C2F(mgetnc) (fd, (void*)&abspos, &one, typ_int, err);
00714        if (*err > 0) goto ErrL;
00715        C2F(mgetnc) (fd, (void*)&visibility, &one, typ_char, err);
00716        if (*err > 0) goto ErrL;
00717        C2F(mgetnc) (fd, (void*)&sheettype, &one, typ_char, err);
00718        if (sheettype==0) {/* worksheet */
00719          short count=0;
00720          i++;
00721          (*Abspos)[i]=abspos;
00722          getString(fd,&count,&Len, 0,&((*Sheetnames)[i]),err);
00723          if (*err > 0) goto ErrL;
00724        }
00725        *cur_pos=*cur_pos+4+Len;
00726      }
00727      else
00728        break;
00729 
00730    }
00731    return;
00732  ErrL:
00733    if (*Sheetnames != NULL) {
00734      for (i=0;i<ns;i++)
00735        if ( (*Sheetnames)[i]!= NULL ) FREE((*Sheetnames)[i]);
00736      FREE(*Sheetnames);
00737    }
00738    FREE(*Abspos);
00739    if (*err==0)
00740      *err=3; /* malloc problem */
00741    else
00742      *err=4; /* read problem */
00743 }

Here is the call graph for this function:

Here is the caller graph for this function:

FILE* GetFile ( integer fd  ) 

Definition at line 181 of file files.c.

References Max, MAXF, and Min.

00182 {
00183   int fd1;
00184   fd1 = (*fd != -1) ?  Min(Max(*fd,0),MAXF-1) : CurFile ;
00185   if ( fd1 != -1 ) 
00186     return(ftformat[fd1]);
00187   else
00188     return((FILE *) 0);
00189 }

static void getSST ( int fd,
short  Len,
int  BIFF,
int ns,
char ***  sst,
int err 
) [static]

Definition at line 439 of file xls.c.

References C2F, count, FREE, getString(), i, MALLOC, mgetnc(), NULL, and typ_int.

Referenced by xls_open().

00440 {
00441   int i,one=1;
00442   /* SST data */
00443   int ntot; /*total number of strings */
00444   int nm;/*Number of following strings*/
00445   short count=0;
00446 
00447   char *transfert;  /*temp*/
00448   transfert=(char *)NULL;
00449   *ns=0;
00450   *sst=NULL;
00451 
00452   if(BIFF==8) {
00453     /*Total number of strings in the workbook*/
00454     C2F(mgetnc) (fd, (void*)&ntot, &one, typ_int, err);
00455     if (*err > 0) goto ErrL;
00456     C2F(mgetnc) (fd, (void*)&nm, &one, typ_int, err);
00457     if (*err > 0) goto ErrL;
00458     *ns=nm;
00459     count+=8;
00460     if (nm !=0) {
00461       if( (*sst=(char **)MALLOC(nm*sizeof(char*)))==NULL)  goto ErrL;
00462       for (i=0;i<nm;i++) (*sst)[i]=NULL;
00463       for(i=0;i<nm;i++) {/* LOOP ON STRINGS */
00464         *err=i;/*for debug*/
00465         getString(fd,&count,&Len,1,&((*sst)[i]),err);
00466         if (*err > 0) goto ErrL;
00467         /*printf("i=%d, %s\n",i,(*sst)[i]);*/
00468       }
00469     }
00470   }
00471   return;
00472  ErrL:
00473   if (*sst != NULL) {
00474     for (i=0;i<nm;i++)
00475       if ( (*sst)[i]!= NULL ) FREE((*sst)[i]);
00476     FREE(*sst);
00477   }
00478 
00479   if (*err==0)
00480     *err=3; /* malloc problem */
00481   else
00482     *err=4; /* read problem */
00483 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void getString ( int fd,
short *  count,
short *  Len,
int  flag,
char **  str,
int err 
) [static]

Definition at line 485 of file xls.c.

References C2F, FREE, j, ln, MALLOC, mgetnc(), Min, mseek(), NULL, str1, strindex(), sz, typ_char, typ_int, typ_short, and typ_ushort.

Referenced by getBoundsheets(), and getSST().

00486 {
00487   short ln=0;
00488   short Opcode;/* to store tag information */
00489   int BytesToBeRead,one=1,strindex;
00490   char OptionFlag=0;
00491   int sz; /* for extended string data */
00492   short rt;/* for rich string data */
00493   int UTFEncoding,extendedString,richString;
00494   int j,l1;
00495 
00496   *str=(char *)NULL;
00497   *err=0;
00498   ln=0;
00499 
00500   /*check for continue tag */
00501  if (flag&&(*PosInRecord==*RecordLen)) {/* data limit encountered */
00502     /*check for continue tag */
00503       /*lecture de l'Opcode et de la RecordLen du tag*/
00504       C2F(mgetnc) (fd, &Opcode, &one, typ_ushort, err);
00505       if ((*err > 0)||(Opcode!=60)) goto ErrL;
00506       C2F(mgetnc) (fd, RecordLen, &one, typ_ushort, err);
00507       if (*err > 0) goto ErrL;
00508       *PosInRecord=0;
00509   }
00510 
00511  /* get the number of characters included in the string (number of bytes or number of couple of bytes) */
00512   if (flag){  /* getString called by getSST */
00513     C2F(mgetnc) (fd, (void*)&ln, &one, typ_short, err);
00514     if (*err > 0) goto ErrL;
00515     *PosInRecord+=2;
00516   }
00517   else { /* getString called by getBoundsheets */
00518     C2F(mgetnc) (fd, (void*)&ln, &one, typ_char, err);
00519     if (*err > 0) goto ErrL;
00520     *PosInRecord+=1;
00521   }
00522 
00523   /*get the encoding options */
00524   C2F(mgetnc) (fd, (void*)&OptionFlag, &one, typ_char, err);
00525   if (*err > 0) goto ErrL;
00526   *PosInRecord+=1;
00527 
00528   UTFEncoding = (OptionFlag&0x01) == 1;
00529   extendedString = (OptionFlag & 0x04) != 0;
00530   richString = (OptionFlag & 0x08) != 0;
00531 
00532  if (richString) { /*richString*/
00533     C2F(mgetnc) (fd, (void*)&rt, &one, typ_short, err);
00534     *PosInRecord+=2;
00535     if (*err > 0) goto ErrL;
00536   }
00537 
00538   if (extendedString) {/* extendedString */
00539     C2F(mgetnc) (fd, (void*)&sz, &one, typ_int, err);
00540     if (*err > 0) goto ErrL;
00541     *PosInRecord+=4;
00542   }
00543 
00544   /* number of bytes to be read */
00545   BytesToBeRead = (UTFEncoding)? ln*2 : ln;
00546 
00547 
00548   if ((*str= (char*) MALLOC((BytesToBeRead+1)*sizeof(char)))==NULL)  goto ErrL;
00549   /* read the bytes */
00550 
00551   if (!flag||(*PosInRecord+BytesToBeRead<=*RecordLen)) {        
00552     /* all bytes are in the same record */
00553     C2F(mgetnc) (fd, (void*)*str, &BytesToBeRead, typ_char, err);
00554     if (*err > 0) goto ErrL;
00555     *PosInRecord+=BytesToBeRead;
00556   }
00557   else {/* char stream contains at least one "continue" */
00558     int bytesRead = *RecordLen-*PosInRecord; /* number of bytes before continue */
00559     strindex=0; /*current position in str*/
00560     /* read bytes before the "continue"  */
00561     /* according to documentation  bytesRead should be strictly positive */
00562     C2F(mgetnc) (fd, (void*)(*str+strindex), &bytesRead, typ_char, err);
00563     if (*err > 0) goto ErrL;
00564     strindex+=bytesRead;
00565     *PosInRecord+=bytesRead;
00566     while (BytesToBeRead-bytesRead > 0){
00567       /*"continue" tag assumed, verify */
00568       C2F(mgetnc) (fd, &Opcode, &one, typ_ushort, err);
00569       if ((*err > 0)||(Opcode!=60)) goto ErrL;
00570       C2F(mgetnc) (fd, RecordLen, &one, typ_ushort, err);
00571       if (*err > 0) goto ErrL;
00572       *PosInRecord=0;
00573       /* encoding option may change !!!! */
00574       C2F(mgetnc) (fd, (void*)&OptionFlag, &one, typ_char, err);
00575       if (*err > 0) goto ErrL;
00576       *PosInRecord+=1;
00577 
00578       if ((!UTFEncoding && (OptionFlag == 0))||(UTFEncoding && (OptionFlag != 0))) {
00579         /*string encoding does not change */
00580         l1=Min(BytesToBeRead-bytesRead,*RecordLen-*PosInRecord);
00581         C2F(mgetnc) (fd, (void*)(*str+strindex), &l1, typ_char, err);
00582         if (*err > 0) goto ErrL;
00583         bytesRead+=l1;
00584         strindex+=l1;
00585         *PosInRecord+=l1;
00586       }
00587       else if (UTFEncoding && (OptionFlag  == 0)) {
00588         /* character  encoding changes from twobytes to a single byte*/
00589         /* may this happen ???? */
00590         l1=Min(BytesToBeRead-bytesRead,*RecordLen-*PosInRecord);
00591         for (j=0;j<l1;j++){
00592           C2F(mgetnc) (fd, (void*)(*str+strindex), &one, typ_char, err);
00593           if (*err > 0) goto ErrL;
00594           (*str)[strindex+1]='\0';
00595           strindex+=2;
00596           *PosInRecord+=2;
00597           UTFEncoding =0;
00598         }
00599       }
00600       else {
00601         /* character encoding changes from a single byte to two bytes */
00602         /* first, convert read characters to two bytes*/
00603         char *str1=*str;
00604         strindex=0;
00605         if ((str= (char*) MALLOC((2*BytesToBeRead+1)*sizeof(char)))==NULL)  goto ErrL;
00606         for (j=0;j<bytesRead;j++) {
00607           (*str)[strindex]=str1[j];
00608           (*str)[strindex+1]='\0';
00609           strindex+=2;
00610         }
00611         FREE(str1);
00612         BytesToBeRead=BytesToBeRead*2;
00613         bytesRead=bytesRead*2;
00614         /* read following two bytes characters */
00615         l1=Min((BytesToBeRead-bytesRead)*2,*RecordLen-*PosInRecord);
00616         C2F(mgetnc) (fd, (void*)(*str+strindex), &l1, typ_char, err);
00617         if (*err > 0) goto ErrL;
00618         bytesRead+=l1;
00619         strindex+=l1;
00620         *PosInRecord+=l1;
00621         UTFEncoding =1;
00622       }
00623 
00624     }
00625 
00626   } /*all character read */
00627 
00628   /* For extended strings, skip over the extended string data*/
00629   /* may continuation records appear here? */
00630   l1=4*rt;
00631   if (richString) {C2F(mseek) (fd, &l1, "cur", err);*PosInRecord+=l1;}
00632   if (extendedString) {C2F(mseek) (fd, &sz, "cur", err);*PosInRecord+=sz;}
00633 
00634   /* add string terminaison */
00635   if (UTFEncoding) {
00636     /* Scilab currently do not support unicode, so we remove the second byte*/
00637     strindex=0;
00638     for (j=0;j<BytesToBeRead;j+=2) {
00639       (*str)[strindex]=(*str)[j];
00640       strindex++;
00641     }
00642     BytesToBeRead=BytesToBeRead/2;
00643   }
00644   (*str)[BytesToBeRead]='\0';
00645 
00646 
00647   return;
00648  ErrL:
00649   if (*err == 0) {
00650     FREE(*str);
00651     *err=3; /* malloc problem */
00652   }
00653   else
00654     *err=4; /* read problem */
00655 }       

Here is the call graph for this function:

Here is the caller graph for this function:

int GetSwap ( integer fd  ) 

Definition at line 195 of file files.c.

References Max, MAXF, and Min.

00196 {
00197   int fd1;
00198   fd1 = (*fd != -1) ?  Min(Max(*fd,0),MAXF-1) : CurFile ;
00199   if ( fd1 != -1 ) 
00200     return(ftswap[fd1]);
00201   else
00202     return(0);
00203 }

void C2F() mgetnc ( integer fd,
void *  res,
integer n,
char *  type,
integer ierr 
)

Definition at line 642 of file files.c.

References c1, GetFile(), GetSwap(), i, ierr, MGET_CHAR_NC, MGET_GEN_NC, NULL, sciprint(), swapd(), swapf(), swapi(), swapl(), and swapw().

Referenced by get_oleheader(), getBOF(), getBoundsheets(), getSST(), getString(), xls_open(), and xls_read().

00643 {  
00644   char c1,c2;
00645   int i,items=*n1,n=*n1;
00646   FILE *fa;
00647 
00648 
00649   *ierr=0;
00650   if ((fa = GetFile(fd)) ==NULL) {
00651     sciprint("No input file associated to logical unit %d\r\n",*fd);
00652     *ierr=3;
00653     return;
00654   }
00655   swap = GetSwap(fd);
00656   c1 = ( strlen(type) > 1) ? type[1] : ' '; 
00657   c2 = ( strlen(type) > 2) ? type[2] : ' '; 
00658   switch ( type[0] )
00659     {
00660     case 'i' : MGET_GEN_NC(int,swapi,c1);break;
00661     case 'l' : MGET_GEN_NC(long,swapl,c1);break;
00662     case 's' : MGET_GEN_NC(short,swapw,c1);break;
00663     case 'c' : MGET_CHAR_NC(char) ; break;
00664     case 'd' : MGET_GEN_NC(double,swapd,c1);break;
00665     case 'f' : MGET_GEN_NC(float,swapf,c1);break;
00666     case 'u' :
00667       switch ( c1 )
00668         {
00669         case 'i' :  MGET_GEN_NC(unsigned int,swapi,c2); break;
00670         case 'l' :  MGET_GEN_NC(unsigned long,swapl,c2); break;
00671         case 's' :  MGET_GEN_NC(unsigned short,swapw,c2); break;
00672         case ' ' :  MGET_GEN_NC(unsigned int,swapi,' '); break;
00673         case 'c' :  MGET_CHAR_NC(unsigned char); break;
00674         default : *ierr=1; return; break;
00675         }
00676       break;
00677     default :
00678       *ierr=1;
00679       return ;
00680     }
00681   if ( items != n ) 
00682     {
00683       *ierr = -(items) -1 ;
00685     }
00686   return;
00687 }

Here is the call graph for this function:

Here is the caller graph for this function:

void C2F() mseek ( integer fd,
integer offset,
char *  flag,
integer err 
)

Definition at line 362 of file files.c.

References err, GetFile(), iflag, irep, sciprint(), SEEK_CUR, SEEK_END, SEEK_SET, and strerror().

Referenced by getBoundsheets(), getString(), intsmseek(), xls_open(), and xls_read().

00363 {     
00364   int iflag;
00365 #if (defined(sun) && !defined(SYSV)) || defined(sgi)
00366   int irep;
00367 #endif
00368   FILE *fa= GetFile(fd);
00369   *err=0;
00370   if ( fa == (FILE *) 0 ) 
00371     {
00372       sciprint("mseek: wrong file logical unit \r\n");
00373       *err=1;
00374       return;
00375     }
00376   if ( strncmp(flag,"set",3)==0 ) 
00377     iflag = SEEK_SET;
00378   else if ( strncmp(flag,"cur",3)==0 ) 
00379     iflag = SEEK_CUR;
00380   else if ( strncmp(flag,"end",3)==0 ) 
00381     iflag = SEEK_END;
00382   else 
00383     {
00384       sciprint("mseek : flag = %s not recognized \r\n");
00385       *err=1;
00386       return;
00387     }
00388 #if (defined(sun) && !defined(SYSV)) || defined(sgi)
00389   irep = fseek(fa,(long) *offset,iflag) ;
00390   if ( irep != 0 ) 
00391     {
00392       sciprint(strerror(irep));
00393       *err=1;
00394     }
00395   else
00396     *err=0;
00397 #else
00398   if (fseek(fa,(long) *offset,iflag) == -1 ) 
00399     {
00400       sciprint("mseek: error\r\n");
00401       *err=1;
00402     }
00403   else 
00404     *err=0;
00405 #endif
00406 }

Here is the call graph for this function:

Here is the caller graph for this function:

void C2F() mtell ( integer fd,
double *  offset,
integer err 
)

Definition at line 412 of file files.c.

References err, GetFile(), and sciprint().

Referenced by intsmtell(), xls_open(), and xls_read().

00413 {     
00414   FILE *fa= GetFile(fd);
00415   if ( fa == (FILE *) 0 ) 
00416     {
00417       sciprint("mtell: wrong file logical unit \r\b");
00418       *err=1;
00419       return;
00420     }
00421   *err=0;
00422   *offset = (double) ftell(fa) ;
00423 }

Here is the call graph for this function:

Here is the caller graph for this function:

static double NumFromRk2 ( long  rk  )  [static]

Definition at line 341 of file xls.c.

References num.

Referenced by xls_read().

00342 {
00343   double num;
00344   if(rk & 0x02)
00345     {
00346       /* int*/
00347       num = (double) (rk >> 2);
00348     }
00349   else
00350     {
00351       /* hi words of IEEE num*/
00352       *((int *)&num+1) = rk & 0xfffffffc;
00353       *((int *)&num) = 0;
00354     }
00355   if(rk & 0x01)
00356     /* divide by 100*/
00357     num /= 100;
00358   return num;
00359 }

Here is the caller graph for this function:

static double return_a_nan (  )  [static]

Definition at line 39 of file xls.c.

References first.

Referenced by xls_read().

00040 {
00041   static int first = 1;
00042   static double nan = 1.0;
00043 
00044   if ( first )
00045     {
00046       nan = (nan - (double) first)/(nan - (double) first);
00047       first = 0;
00048     }
00049   return (nan);
00050 }

Here is the caller graph for this function:

int ripole ( char *  inputfile,
char *  outputdir,
int  debug,
int  verbose 
)

end of ripOLE

Definition at line 369 of file ripole.c.

References _LOGGER_STDOUT, LOGGER_log(), LOGGER_set_output_mode(), OLE_DEBUG_NORMAL, OLE_decode_file(), OLE_decode_file_done(), OLE_init(), OLE_set_debug(), OLE_set_filename_report_fn(), OLE_set_save_unknown_streams(), OLE_set_verbose(), OLE_VERBOSE_NORMAL, and ROLE_report_filename_decoded().

Referenced by intopenxls().

00370 {
00371   /*struct OLE_object *ole = NULL;*/
00372   struct OLE_object ole;
00373        int result = 0;
00374 
00375        /*ole = MALLOC(sizeof(struct OLE_object));
00376        if (ole == NULL)
00377        {
00378                LOGGER_log("ripOLE: Cannot allocate memory for OLE object");
00379                return 1;
00380        }*/
00381 
00382        LOGGER_set_output_mode(_LOGGER_STDOUT);
00383 
00384        OLE_init(&ole);
00385        if (debug ==1 ) OLE_set_debug(&ole, OLE_DEBUG_NORMAL);
00386        if (verbose == 1) OLE_set_verbose(&ole, OLE_VERBOSE_NORMAL);
00387        /*ole->save_unknown_streams==2 added for Scilab to extract onlyexcel streams
00388          see  OLE_decode_stream in ole.c file */
00389        OLE_set_save_unknown_streams(&ole, 2); /* get only excel streams */
00390 
00391        OLE_set_filename_report_fn(&ole, ROLE_report_filename_decoded );
00392 
00393        result = OLE_decode_file( &ole, inputfile, outputdir);
00394        OLE_decode_file_done(&ole);
00395 
00396 
00397        if ((result != 0)&&(verbose==1))
00398          LOGGER_log("ripOLE: decoding of %s resulted in error %d\n", inputfile, result );
00399 
00400        /*if (ole != NULL) FREE(ole);*/
00401        return result;
00402 }

Here is the call graph for this function:

Here is the caller graph for this function:

void xls_open ( int err,
int fd,
char ***  sst,
int ns,
char ***  Sheetnames,
int **  Abspos,
int nsheets 
)

void xls_read ( int fd,
int cur_pos,
double **  data,
int **  chainesind,
int N,
int M,
int err 
)


Generated on Sun Mar 4 15:19:25 2007 for Scilab [trunk] by  doxygen 1.5.1