コード例 #1
0
/**
 * @brief Returns the index of the specified path.
 *
 * The column of the returned index is always FILE_COLUMN.
 *
 * @param path Path of a file.
 * @return The corresponding index. An invalid index is returned if the path
 * does not exist in the model.
 */
QModelIndex QuestFilesModel::get_file_index(const QString& path) const {

  const QModelIndex& index_from_source = mapFromSource(source_model->index(path, 0));
  if (index_from_source.isValid()) {
    // The path exists in the source model and therefore on the filesystem.
    return index_from_source;
  }

  // The file does not exist.
  // It can be a resource element added to the tree but whose file is missing.
  // Find its place in the tree to know the row.
  QDir parent_dir(path);
  if (!parent_dir.cdUp()) {
    return QModelIndex();
  }
  const QModelIndex& parent = get_file_index(parent_dir.path());

  const ExtraPaths* extra_paths = get_extra_paths(parent);
  if (extra_paths == nullptr) {
    // Path not in the model.
    return QModelIndex();
  }

  const auto& it = extra_paths->path_indexes.find(path);
  if (it == extra_paths->path_indexes.end()) {
    // Path not in the model.
    return QModelIndex();
  }
  const int index_in_extra = it.value();
  const int row = QSortFilterProxyModel::rowCount(parent) + index_in_extra;
  return index(row, 0, parent);
}
コード例 #2
0
ファイル: database.c プロジェクト: quickhand/madshelf
int clear_file_extractor_data(char *filename)
{
    long fileindex=get_file_index(filename,0);
    if(fileindex==-1)
        return -1;
    //erase titles
    char *temp;
    temp=sqlite3_mprintf("DELETE FROM titles WHERE titles.titleid NOT IN (SELECT titleid FROM booktitles WHERE fileid != %d) AND titles.titleid IN (SELECT titleid FROM booktitles WHERE fileid=%d)",fileindex,fileindex);
    sqlite3_exec(madshelf_database,temp,NULL,NULL,NULL);
    sqlite3_free(temp);
    temp=sqlite3_mprintf("DELETE FROM booktitles WHERE fileid = %d",fileindex);
    sqlite3_exec(madshelf_database,temp,NULL,NULL,NULL);
    sqlite3_free(temp);
    //erase authors    
    temp=sqlite3_mprintf("DELETE FROM authors WHERE authors.authorid NOT IN (SELECT authorid FROM bookauthors WHERE fileid != %d) AND authors.authorid IN (SELECT authorid FROM bookauthors WHERE fileid=%d)",fileindex,fileindex);   
    sqlite3_exec(madshelf_database,temp,NULL,NULL,NULL);
    sqlite3_free(temp);
    temp=sqlite3_mprintf("DELETE FROM bookauthors WHERE fileid = %d",fileindex);
    sqlite3_exec(madshelf_database,temp,NULL,NULL,NULL);
    sqlite3_free(temp);
    //erase series
    temp=sqlite3_mprintf("DELETE FROM series WHERE series.seriesid NOT IN (SELECT seriesid FROM bookseries WHERE fileid != %d) AND series.seriesid IN (SELECT seriesid FROM bookseries WHERE fileid=%d)",fileindex,fileindex);
    sqlite3_exec(madshelf_database,temp,NULL,NULL,NULL);
    sqlite3_free(temp);
    temp=sqlite3_mprintf("DELETE FROM bookseries WHERE fileid = %d",fileindex);
    sqlite3_exec(madshelf_database,temp,NULL,NULL,NULL);
    sqlite3_free(temp);
    return 0;
    
}
コード例 #3
0
ファイル: smbvfs-wraps.c プロジェクト: pombredanne/cliffs
static uint32 smbvfs_wrap_open (PCONN_HND pcon,
			PFILE_HND *file_hnd,
			SMBSTR * fname, 
			uint16 info,
			uint16 share_mode,
			uint16 ofun, uint16 smb_attr,
			uint16 *Access,
			uint16 *action,
			uint16 *fnum)
{
	files_struct *fsp = NULL;
	struct vfs_connection_struct *conn = NULL;
	uint32 err = NT_STATUS_NOPROBLEMO;

	if (!get_conn_info(pcon, &conn, NULL, NULL, NULL))
		return NT_STATUS_INVALID_HANDLE;

	if (conn == NULL)
		return NT_STATUS_ACCESS_DENIED;

	if (fname == NULL)
		return NT_STATUS_NO_SUCH_FILE;

	DEBUG(10,("file: [%s]\n", smbstrA(fname)));

	if (!create_file_hnd(pcon, file_hnd, NULL) ||
	    *file_hnd == NULL ||
	    !get_file_index(*file_hnd, fnum))
	{
		err = NT_STATUS_INVALID_HANDLE;
		goto end;
	}

	err = open_file_shared_dos(conn, fname, info,
			share_mode, ofun, smb_attr, Access,
			action, &fsp);

	if (err != NT_STATUS_NOPROBLEMO)
		goto end;

	if (fsp == NULL)
	{
		err = ERRDOS | ERRnoaccess;
		goto end;
	}

	if (!set_file_info(*file_hnd, fsp))
	{
		err = NT_STATUS_INVALID_HANDLE;
		goto end;
	}

end:
	if (err != NT_STATUS_NOPROBLEMO)
		file_close_hnd(*file_hnd);
	return err;
}
コード例 #4
0
ファイル: database.c プロジェクト: quickhand/madshelf
int remove_tag(char *filename,char *tagname)
{
    long fileindex=get_file_index(filename,0);
    if(fileindex==-1)
        return -1;
    //erase titles
    char *temp=sqlite3_mprintf("DELETE FROM tags WHERE tagname = \'%q\' AND tags.tagid NOT IN (SELECT tagid FROM booktags WHERE fileid != %d) AND tags.tagid IN (SELECT tagid FROM booktags WHERE fileid=%d)",tagname,fileindex,fileindex);
    sqlite3_exec(madshelf_database,temp,NULL,NULL,NULL);
    sqlite3_free(temp);
    temp=sqlite3_mprintf("DELETE FROM booktags WHERE (tagid = (SELECT tagid FROM tags WHERE tagname= \'%q\')) AND (fileid = %d)",tagname,fileindex);
    sqlite3_exec(madshelf_database,temp,NULL,NULL,NULL);
    sqlite3_free(temp);
    return 0;
    
}
コード例 #5
0
ファイル: file_table.c プロジェクト: huairen/JArchive
struct file_entry * get_file_entry( struct archive *arc, const char *filename )
{
	ar_uint index;
	ar_uint64 key;

	if(arc->file_table == NULL)
		return NULL;

	key = hash_string(filename);
	index = get_file_index(arc, key);
	if(index >= arc->file_table_size)
		return NULL;

	return arc->file_table + index;
}
コード例 #6
0
/**
 * @brief Returns the parent of the model item with the given index.
 *
 * Reimplemented from QSortFilterProxyModel to support extra indexes
 * that do not exist in the source model.
 *
 * @param index Index to get the parent of.
 * @return The parent index, or an invalid index if the item has no parent.
 */
QModelIndex QuestFilesModel::parent(const QModelIndex& index) const {

  QString path;
  if (is_extra_path(index, path)) {
    // Index that does not exist in the source model.
    QDir parent_dir(path);
    if (!parent_dir.cdUp()) {
      return QModelIndex();
    }
    return get_file_index(parent_dir.path());
  }

  // Regular QSortFilterProxyModel index.
  return QSortFilterProxyModel::parent(index);
}
コード例 #7
0
ファイル: database.c プロジェクト: quickhand/madshelf
void set_tags(char *filename,const char *tags[],int numtags)
{
    long fileindex=get_file_index(filename,1);
    long tagindex;

    if(fileindex==(-1))
        return;
    
    int i;
    for(i=0;i<numtags;i++)
    {
        tagindex=get_tag_index(tags[i]);
        if(tagindex!=-1)
        {
            char *temp=sqlite3_mprintf("INSERT INTO booktags (fileid,tagid) VALUES(%d,%d)",fileindex,tagindex);
            sqlite3_exec(madshelf_database,temp,NULL,NULL,NULL);
            sqlite3_free(temp);
        }
    }
}
コード例 #8
0
ファイル: database.c プロジェクト: quickhand/madshelf
void set_authors(char *filename,const char *authors[],int numauthors)
{
    long fileindex=get_file_index(filename,1);
    long authorindex;

    if(fileindex==(-1))
        return;
    
    int i;
    for(i=0;i<numauthors;i++)
    {
        authorindex=get_author_index(authors[i]);
        if(authorindex!=-1)
        {
            char *temp=sqlite3_mprintf("INSERT INTO bookauthors (fileid,authorid) VALUES(%d,%d)",fileindex,authorindex);
            sqlite3_exec(madshelf_database,temp,NULL,NULL,NULL);
            sqlite3_free(temp);
        }
    }
}
コード例 #9
0
ファイル: database.c プロジェクト: quickhand/madshelf
void set_series(char *filename,const char *series[],int *seriesnum,int numseries)
{
    long fileindex=get_file_index(filename,1);
    long seriesindex;

    if(fileindex==(-1))
        return;
    
    int i;
    for(i=0;i<numseries;i++)
    {
        seriesindex=get_series_index(series[i]);
        if(seriesindex!=-1)
        {
            char *temp=sqlite3_mprintf("INSERT INTO bookseries (fileid,seriesid,seriesnum) VALUES(%d,%d,%d)",fileindex,seriesindex,*(seriesnum+i));
            sqlite3_exec(madshelf_database,temp,NULL,NULL,NULL);
            sqlite3_free(temp);
        }
    }
    
}
コード例 #10
0
comp_flow_list* get_flow_packets(display_rule *dr,char *path,capture_time *time_cap)
{
	file_list* file_names;
	comp_flow_list *start_flow=0,*end_flow=0;
	file_names=get_filename(time_cap,path);
	while(file_names)
	{
		int file_index=get_file_index(file_names->filename);
		flow_rec_nos* t=decode_bitmap(get_final_bitmap(dr,file_names->filename,path),MAX_FLOW_REC);
		traverse_flow_list(t,path,file_index);
		printf("\nFilename is:%s",file_names->filename);
		if(start_flow==0)
			start_flow=end_flow=get_comp_flow_list_node(t);
		else
	{
			end_flow->down=get_comp_flow_list_node(t);
			end_flow=end_flow->down;
		}
		file_names=file_names->next;
	}
	return start_flow;
}
コード例 #11
0
ファイル: srv_file_state.c プロジェクト: pombredanne/cliffs
/****************************************************************************
  set fileection info
****************************************************************************/
BOOL set_file_info(PFILE_HND hnd, files_struct *fsp)
{
	struct file_state *state;
	state = (struct file_state*)get_policy_state_info(hnd);

	DEBUG(3, ("Setting policy file info: %d %s\n",
				fsp->fd, smbstrA(fsp->fsp_name)));

	if (state == NULL)
	{
		state = create_state(hnd);
	}
	if (state == NULL)
	{
		return False;
	}

	get_file_index(hnd, &fsp->fnum);
	state->fsp = fsp;

	return True;
}
コード例 #12
0
ファイル: write_slab.c プロジェクト: armnlib/librmn
ftnword f77name(slabend)(ftnword *f_hand, char *f_sf_hand, int l1)
 {
  int end, taille, i, ix, fd; 
  int nBytes;
  int n;

  if ((ix = get_file_index( (int ) *f_hand)) < 0 ) return(slab_exit(-3));
  fd = (int) *f_hand;
  intBuffer = file_table[ix].buffer;
  pos = file_table[ix].pos;
  fBuffer = (float *) intBuffer;

  end = (f_sf_hand[0] << 24) | (f_sf_hand[1]  << 16) | 
                       (f_sf_hand[2] << 8) | (f_sf_hand[3]);
  for (i=0; i < MAX_SLAB_TYPES; i++)
  /* check to see if number of values written equal to what is requested */
  /* this is only a valid check if one CPU is used */
  if(file_table[ix].nio_njo[i] != file_table[ix].count[i] && numproc == 1 )
     {
      fprintf(stderr,"\n***ERROR in SLABEND(%s)slabid %d\n",
                                    file_table[ix].file_name,i);
      fprintf(stderr,"   Value of nio*njo must be equal to number of valid values in xnio\n");
      fprintf(stderr,"   No. of selected elements in xnio = %d, nio*njo=%d\n",
                      file_table[ix].count[i],file_table[ix].nio_njo[i]);
      return(slab_exit(-2));   
      }

  slab_end.id_end = end;

  if(slab_end.id_end != 'SLB9')
     {
      fprintf(stderr,"\n***ERROR in SLABEND(%s):end indicator of slabend must be -> SLB9\n\n",file_table[ix].file_name);
      return(slab_exit(-2));
      }

  iVal = (int *) &slab_end;

  taille = sizeof(slab_end) / sizeof(int);
  /* add SLB9 if only one CPU is used */
  if (numproc == 1) put_in_buffer(iVal,intBuffer,pos,taille);

  if(pos == 0)
     {
      taille=sizeof(slab_end);
      nBytes = write(fd,intBuffer,taille);
      if(nBytes != taille)
	 {
          fprintf(stderr,"\n***ERROR in SLABEND(%s): WRITE ERROR in slab file\n",file_table[ix].file_name);
	  return(slab_exit(-2));
	  }
      }
  
  else{
       taille = sizeof(int) * pos;
       nBytes = write(fd,intBuffer,taille);
       if(nBytes != taille)
	  {
	  fprintf(stderr,"\n***ERROR in SLABEND(%s): WRITE ERROR in slab file\n",file_table[ix].file_name);
	  return(slab_exit(-2));
	  }
       
       }

  free(intBuffer);
  file_table[ix].buffer = NULL;
  file_table[ix].pos = 0;
   for (i=0;i < MAX_SLAB_TYPES; i++){
       file_table[ix].count[i] = 0;
       file_table[ix].nrows[i] = 0;
       file_table[ix].nio_njo[i] = 0;
       }
  f_index[ix] = -1; /* reset to -1 */
  if (numproc == 1) return(0); /* indicates that SLB9 was added */
  else return(1); /* indicates that SLB9 was not added */
  }/* end slabend */
コード例 #13
0
ファイル: write_slab.c プロジェクト: armnlib/librmn
ftnword f77name (slabxtr)(ftnword *f_hand, ftnword *f_snum, ftnword *f_nx,
		      ftnword *f_xnio,ftnword *f_mt,ftnword *f_mtas,
		      ftnfloat *f_mtadd, ftnfloat *f_mtmult, ftnfloat *f_mtval)
{                                               
 int i, j, ix, ij = 0, 
     taille,
     nrows = 0,
     nX = 0,
     nBytes, Nrows, Nx, fd, snum;
 int n;

 Nrows = (int ) *f_mt;
 Nx    = (int ) *f_nx; 
 snum  = (int ) *f_snum;
if ( (ix = get_file_index( (int ) *f_hand)) < 0 ) return(slab_exit(-3));
 fd = (int) *f_hand;
 intBuffer = file_table[ix].buffer; 
 pos = file_table[ix].pos;
 fBuffer = (float *) intBuffer;


 for(j = 0; j < Nrows; j++)
    if(f_mtas[j] != 0)
       nrows++;
 
 if(nrows != file_table[ix].nrows[snum])
   {
    fprintf(stderr,"***ERROR in SLABXTR(%s)slabid %d:\n",
             file_table[ix].file_name,snum);
    fprintf(stderr,"  nrows in mtas(=%d) must be equal to SLABDSC mtout(=%d)\n",
   nrows,file_table[ix].nrows[snum]);
    return(slab_exit(-2));
    }

 for(i = 0; i < Nx; i++)
    if(f_xnio[i] != 0)
       nX++;
 
 file_table[ix].count[snum] += nX;
 
 data_block.slb2 = 'SLB2';
 data_block.nBytes = 4 * (3 + nX * (1 + nrows));
 data_block.slab_id = (int ) *f_snum;
 data_block.nX = nX; 
 data_block.Nrows = nrows;
 
 iVal = (int *) &data_block;
 taille = (sizeof(data_block) / sizeof(int));

 put_in_buffer(iVal,intBuffer,pos,taille);

 for(i=0; i < Nx; i++)
    { 
     if(f_xnio[i] != 0)
       {
        if(pos >= BUFSIZE)
          {
	   taille = sizeof(float) * pos;
           nBytes =  write(fd, fBuffer, taille);
	   if(nBytes != (sizeof(float) *  BUFSIZE))
	      {
	       fprintf(stderr,"\n***ERROR in SLABXTR(%s)slabid %d: WRITE ERROR in slab file\n",file_table[ix].file_name,snum);
	       return(slab_exit(-2));
	       }
	   pos=0;
	   }
 	intBuffer[pos] = (int  ) f_xnio[i];
        pos++;
	}
     }/* end for */
 
 for(j = 0; j < Nrows; j++)
    {
     if(f_mtas[j] != 0)
       {
        if((pos + nX) <= BUFSIZE)
           {
            if(nX == Nx )  /* Si le nombre de colonnes a     */
              {            /* extraire est egale au nombre   */
               for(i = 0; i < Nx; i++) /* de colonnes de chaque slab     */
                  {                                            
                   fBuffer[pos] = (float)(f_mtval[ij]*f_mtmult[j] + f_mtadd[j]);
                   pos++;
                   ij++;

                   }/* end for */
                }
            else{         /* Si le nombre de colonnes a     */
                 for(i = 0; i < Nx; i++)  /* extraire est different a celui */
                    {                     /* de slab                        */
                     if(f_xnio[i] != 0)   /* je cherche les valeurs valides */
                       {                  /* une par une                    */
                        fBuffer[pos] = (float)(f_mtval[ij]*f_mtmult[j] + f_mtadd[j]);
                        pos++;
                        }
                     
                      ij++;

                    }/* end for */

                 }

            }
        else{                             /* Si la taille qui reste dans le */
             for(i = 0; i < Nx; i++)      /* buffer est inssufisante pour   */
                {                         /* le reste des donnees que j'ai  */
                 if(pos >= BUFSIZE)
		   {     
                    taille = sizeof(float) * pos;  
                    /* alors, on ecrit le buffer dans */
                    nBytes =  write(fd, fBuffer, taille);
		    if(nBytes != (sizeof(float) *  pos))
		       {
		        fprintf(stderr,"\n***ERROR in SLABXTR(%s)slabid %d: WRITE ERROR in slab file\n",file_table[ix].file_name,snum);
			return(slab_exit(-2));
			}
	            pos = 0;             /* le fichier slab et on met le   */
                                         /* buffer a zero                  */
		    }

                 if(f_xnio[i] != 0)      /* a extraire,                    */
                   {                                          
                    fBuffer[pos] =(float)(f_mtval[ij]*f_mtmult[j] + f_mtadd[j]);
                    pos++;
                    }
                 
                 ij++;

                 }/* end for */
             
             }

        }
     
     else ij += Nx;

     }/* end for */

 file_table[ix].pos = pos;
 return(0);
 }/* end slabxtr */
コード例 #14
0
ファイル: write_slab.c プロジェクト: armnlib/librmn
ftnword f77name(slabdsc)(ftnword *f_hand, ftnword *f_snum,char *f_gxtyp,
		     ftnword *f_ixyg1,ftnword *f_ixyg2,
                     ftnword *f_ixyg3, ftnword *f_ixyg4,ftnword *f_nio,
		     ftnword *f_njo, ftnword *f_nxgrid,
                     ftnword *f_nygrid, ftnfloat *f_xgrid,ftnfloat *f_ygrid,
		     char *f_grtyp,ftnword *f_ig1,
		     ftnword *f_ig2,ftnword *f_ig3,ftnword *f_ig4,
		     ftnword *f_mtout, ftnword *f_np, 
                     char *f_typvar, char *f_nomvar,ftnword *f_ip1,
		     ftnword *f_ip2, ftnword *f_ip3,
                     ftnword *f_datyp,ftnword *f_nbits,ftnword *f_iflt,
		     ftnfloat *f_xp, int l1, int l2, int l3, int l4)
{
 int nrows, nio, njo, nxtra, 
     taille, i, x, MAX_GRTYP;
 int lng, n, nn, ix, snum;
 char grtyp[MAX_LEN], grtyp_[MAX_LEN];
 char *nomvars, *nomvars_0, *typvars, *typvars_0, *p_nomvar, *p_typvar;
 ftnword *p_ip1,*p_ip2,*p_ip3,*p_datyp,*p_nbits,*p_iflt;

/* for debug only 
  int ip1[20],ip2[20],ip3[20],datyp[20],nbits[20],iflt[20];
  ftnword *p_ip1,*p_ip2,*p_ip3,*p_datyp,*p_nbits,*p_iflt; 
*/

 MAX_GRTYP = strlen(GRTYPES);
 nio = (int ) *f_nio;
 njo = (int ) *f_njo;
 nrows = (int ) *f_mtout;
 nxtra = (int ) *f_np;
 if ( (ix = get_file_index( (int ) *f_hand)) < 0 ) return(slab_exit(-3));

 intBuffer = file_table[ix].buffer;
 pos = file_table[ix].pos;

 snum = (int ) *f_snum;
 
 if (snum < MAX_SLAB_TYPES && snum >=0){
       if (file_table[ix].nrows[snum] == 0){
           file_table[ix].nrows[snum] = nrows;
           file_table[ix].nio_njo[snum] = nio*njo;
           }
       else{
       fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d is already defined\n",
                       file_table[ix].file_name,snum);
       fprintf(stderr,"   mtout=%d, nio*njo=%d\n",
                       file_table[ix].nrows[snum],file_table[ix].nio_njo[snum]);
       fprintf(stderr,"   set to: mtout=%d, nio=%d njo=%d ??\n",
                       nrows,nio,njo);
       return(slab_exit(-2));
       }
       }
 else{
       fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d is out of range\n",file_table[ix].file_name,snum);
       fprintf(stderr,"  slabid MUST be from 0 to %d\n",MAX_SLAB_TYPES-1);
       return(slab_exit(-2));
     }
 if (nio < 1 || nio > 32767){
      fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: invalid NIO=%d\n",file_table[ix].file_name,snum,nio); 
      return(slab_exit(-2));
      }
 if (njo < 1 || njo > 32767){
      fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: invalid NJO=%d\n",file_table[ix].file_name,snum,njo); 
      return(slab_exit(-2));
      }
 if ((nomvars_0 = malloc(4 * nrows))==NULL)
    {
     fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: Cannot allocate memory for nomvars\n",file_table[ix].file_name,snum);
     return(slab_exit(-3));
     }

 if ((typvars_0 = malloc(4 * nrows))==NULL)
    {
     fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: Can not allocate memory for typvars\n",file_table[ix].file_name,snum);
     return(slab_exit(-3));
     }

 nomvars = nomvars_0;
 typvars = typvars_0;
 p_nomvar = f_nomvar;
 p_typvar = f_typvar;

 lng = (l4 < 4) ? l4 : 4;
 for (n=0; n < nrows; n++) {
   for (i=0; i < lng; i++) {
     *nomvars = *p_nomvar;
     nomvars++;
     p_nomvar++;
   }
   for (i=lng; i < 4; i++) {
     *nomvars = ' ';
     nomvars++;
   }
 }

 lng = (l3 < 4) ? l3 : 4;
 for (n=0; n < nrows; n++) {
   for (i=0; i < lng; i++) {
     *typvars = *p_typvar;
     typvars++;
     p_typvar++;
   }
   for (i=lng; i < 4; i++) {
     *typvars = ' ';
     typvars++;
   }
 }

/* No checks on ip1s */

/* check ip2s */
     p_ip2 = f_ip2;
     for (n=0; n< nrows; n++){
      if ( (int) *p_ip2 < 0 || (int) *p_ip2 > 32767){
      fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: ip2[%d]=%d\n",file_table[ix].file_name,snum,n+1,(int) *p_ip2);
      return(slab_exit(-2));
      }
      p_ip2++;
      }

/* check ip3s */
     p_ip3 = f_ip3;
     for (n=0; n< nrows; n++){
      if ( (int) *p_ip3 < 0 || (int) *p_ip3 > 32767){
      fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: ip3[%d]=%d\n",file_table[ix].file_name,snum,n+1,(int) *p_ip3);
      return(slab_exit(-2));
      }
      p_ip3++;
      }

/* check datyps */
     p_datyp = f_datyp;
     for (n=0; n< nrows; n++){
      if ( (int) *p_datyp < 0  || (int) *p_datyp > 5){
      fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: datyp[%d]=%d\n",file_table[ix].file_name,snum,n+1,(int) *p_datyp);
      return(slab_exit(-2));
      }
      p_datyp++;
      }

/* check nbits */
     p_nbits = f_nbits;
     for (n=0; n< nrows; n++){
      if ( (int) *p_nbits < 0 || (int) *p_nbits >  32767){
      fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: nbits[%d]=%d\n",file_table[ix].file_name,snum,n+1,(int) *p_nbits);
      return(slab_exit(-2));
      }
      p_nbits++;
      }

/* check iflts */
     p_iflt = f_iflt;
     for (n=0; n< nrows; n++){
      if ( (int) *p_iflt < 0 || (int) *p_iflt >  32767){
      fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: iflt[%d]=%d\n",file_table[ix].file_name,snum,n+1,(int) *p_iflt);
      return(slab_exit(-2));
      }
      p_iflt++;
      }

/* for debug only 
     printf("INSIDE SLABDSC ix=%d\n",ix);
     printf("l1=%d,l2=%d,l3=%d,l4=%d\n",l1,l2,l3,l4);
     printf("nio=%d,njo=%d,snum=%d,nrows=%d, nxtra=%d\n",
                           nio,njo,snum,nrows,nxtra);
     printf("ip1= ");
     p_ip1 = f_ip1;
     for (n=0; n< nrows; n++){
      ip1[n] = (int )*p_ip1;
      p_ip1++;
      printf("%d,",ip1[n]);
      }
     printf("\n");
     printf("ip2= ");
     p_ip2 = f_ip2;
     for (n=0; n< nrows; n++){
      ip2[n] = (int )*p_ip2;
      p_ip2++;
      printf("%d,",ip2[n]);
      }
     printf("\n");
     printf("ip3= ");
     p_ip3 = f_ip3;
     for (n=0; n< nrows; n++){
      ip3[n] = (int )*p_ip3;
      p_ip3++;
      printf("%d,",ip3[n]);
      }
     printf("\n");
     printf("datyp= ");
     p_datyp = f_datyp;
     for (n=0; n< nrows; n++){
      datyp[n] = (int )*p_datyp;
      p_datyp++;
      printf("%d,",datyp[n]);
      }
     printf("\n");
     printf("nbits= ");
     p_nbits = f_nbits;
     for (n=0; n< nrows; n++){
      nbits[n] = (int )*p_nbits;
      p_nbits++;
      printf("%d,",nbits[n]);
      }
     printf("\n");
     printf("iflt= ");
     p_iflt = f_iflt;
     for (n=0; n< nrows; n++){
      iflt[n] = (int )*p_iflt;
      p_iflt++;
      printf("%d,",iflt[n]);
      }
     printf("\n");
     printf("typvars=%s\n",typvars_0);
     printf("nomvars=%s\n",nomvars_0); 
     printf("grtyp=%s,",f_grtyp);
     printf("nxgrid=%d,nygrid=%d\n",(int )*f_nxgrid,(int )*f_nygrid);
     printf("gxtyp=%s\n",f_gxtyp);
     printf("ig1=%d,ig2=%d,ig3=%d,ig4=%d\n",
           (int) *f_ig1,(int) *f_ig2,(int) *f_ig3,(int) *f_ig4);
     printf("ixyg1=%d,ixyg2=%d,ixyg3=%d,ixyg4=%d\n",
           (int) *f_ixyg1, (int) *f_ixyg2, (int) *f_ixyg3, (int) *f_ixyg4);
     printf("\n");
*/ 

 slab_descrt.slb1 = 'SLB1';
 slab_descrt.nBytes = 4 * (15 + nrows * (8 + nxtra) + (int) *f_nxgrid + (int) *f_nygrid);
 slab_descrt.slab_id = (int ) *f_snum;
  
 l3 = (l3 < MAX_LEN) ? l3 : MAX_LEN-1;
 strncpy(grtyp,f_grtyp,l3);
 grtyp[l3] ='\0';
 
/* check gridtype requested */
 if (l3 == 0 || *grtyp==' '){
      fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: invalid GRTYP='%s'\n",file_table[ix].file_name,snum,grtyp);
      return(slab_exit(-2));
      }
 n=0;
 while (*grtyp != GRTYPES[n] && n < MAX_GRTYP) n++;
 if (*grtyp != GRTYPES[n]){
    fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: invalid GRTYP='%s'\n",
            file_table[ix].file_name,snum,grtyp);
      return(slab_exit(-2));
      }
 strcpy(slab_descrt.grtyp,grtyp);
 
 slab_descrt.ig1    = (int ) *f_ig1;
 slab_descrt.ig2    = (int ) *f_ig2;
 slab_descrt.ig3    = (int ) *f_ig3;
 slab_descrt.ig4    = (int ) *f_ig4;
 slab_descrt.Nrows  = (int ) *f_mtout;
 slab_descrt.Niout  = (int ) *f_nio;
 slab_descrt.Njout  = (int ) *f_njo;
 slab_descrt.nxgrid = (int ) *f_nxgrid;
 slab_descrt.nygrid = (int ) *f_nygrid;
 slab_descrt.Nextra = (int ) *f_np;
 
 strcpy(slab_descrt.grtyp_,"    ");
 slab_descrt.ig1_   = -2;
 slab_descrt.ig2_   = -2;
 slab_descrt.ig3_   = -2;
 slab_descrt.ig4_   = -2;

 if(*f_grtyp == 'Z')
    {
      if(njo != (int ) *f_nygrid)
	{
	  fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: nygrid should be equal to njo for Z grid\n",file_table[ix].file_name,snum);
  fprintf(stderr," nygrid = %d njo = %d\n",(int )*f_nygrid, njo);
	  return(slab_exit(-2));
	}
      if( (int)*f_nxgrid != nio && (int)*f_nxgrid != (nio+1) )
	{
  fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: nxgrid should be equal to nio or (nio+1) for Z grid\n",file_table[ix].file_name,snum);
  fprintf(stderr," nxgrid = %d nio = %d\n",(int )*f_nxgrid, nio);
  return(slab_exit(-2));
        }
    }

 if(*f_grtyp == 'Y')
    {
    if( (nio*njo) != (int ) *f_nxgrid)
	{
	  fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: nxgrid should be equal to nio*njo for Y grid\n",file_table[ix].file_name,snum);
  fprintf(stderr," nxgrid = %d nio = %d njo = %d\n",(int )*f_nxgrid, nio,njo);
	  return(slab_exit(-2));
	}
    if( (nio*njo) != (int ) *f_nygrid)
	{
	  fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: nygrid should be equal to nio*njo for Y grid\n",file_table[ix].file_name,snum);
  fprintf(stderr," nygrid = %d nio = %d njo = %d\n",(int )*f_nygrid, nio,njo);
	  return(slab_exit(-2));
	}
     }
 if(*f_grtyp == 'Z' || *f_grtyp == 'Y'){
      l1 = (l1 < MAX_LEN) ? l1 : MAX_LEN-1;
      strncpy(grtyp_,f_gxtyp,l1);
      grtyp_[l1] = '\0';
      strcpy(slab_descrt.grtyp_,grtyp_);
      if (l1 == 0 || *grtyp_==' '){
      fprintf(stderr,"\n***ERROR in SLABDSC(%s)slabid %d: invalid GXTYP='%s'\n",file_table[ix].file_name,snum,grtyp_);
      return(slab_exit(-2));
      }
      
      slab_descrt.ig1_ = (int ) *f_ixyg1;
      slab_descrt.ig2_ = (int ) *f_ixyg2;
      slab_descrt.ig3_ = (int ) *f_ixyg3;
      slab_descrt.ig4_ = (int ) *f_ixyg4;
    }

 if (proc0) 
 {
 taille = (sizeof(slab_descrt) / sizeof(int));
 iVal = (int *) &slab_descrt;
 put_in_buffer(iVal,intBuffer,pos,taille);
 pVal = f_ip1;
 put_in_buffer(pVal,intBuffer,pos,nrows);
 pVal = f_ip2;
 put_in_buffer(pVal,intBuffer,pos,nrows);
 pVal = f_ip3;
 put_in_buffer(pVal,intBuffer,pos,nrows);
 pVal = f_nbits;
 put_in_buffer(pVal,intBuffer,pos,nrows);
 pVal = f_datyp;
 put_in_buffer(pVal,intBuffer,pos,nrows);
 iVal = (int *)nomvars_0;
 put_in_buffer(iVal,intBuffer,pos,nrows);
 iVal = (int *)typvars_0;
 put_in_buffer(iVal,intBuffer,pos,nrows);

 fBuffer = (float *) intBuffer;  

 if((*f_grtyp == 'Z')  || ( *f_grtyp == 'Y'))
    {
     fVal = f_xgrid;
     put_in_buffer(fVal, fBuffer, pos, *f_nxgrid);
     fVal = f_ygrid;
     put_in_buffer(fVal, fBuffer, pos, *f_nygrid);
     }

 pVal = f_iflt;
 put_in_buffer(pVal,intBuffer,pos,nrows);
 
 if(nxtra != 0)
   {
    taille = (int )(*f_mtout)  *  (int )(*f_np);
    fVal = f_xp;
    put_in_buffer(fVal,fBuffer,pos,taille);
    }
 }
 file_table[ix].pos = pos;
 free (nomvars_0);
 nomvars_0 = NULL;
 free (typvars_0);
 typvars_0 = NULL;
 return(0);
 }/* end slabdsc */