Exemplo n.º 1
1
int
idxread (unit *ftnunit)
{
   register int    i;
   register char  *keyval, *field;
   int             newkeyid = 0, mode = ftnunit->f77idxlist.cimatch;

   keys = ftnunit->ukeys;
   ftnunit->f77recend = i = ftnunit->url;
   if (ftnunit->url > ftnunit->f77fio_size)
      check_buflen (ftnunit, ftnunit->url);
   while (i-- > 0)
      ftnunit->f77fio_buf[i] = '\0';
   if (ftnunit->f77idxlist.cikeyid >= 0 && ftnunit->ukeyid != ftnunit->f77idxlist.cikeyid) {
      ftnunit->ukeyid = ftnunit->f77idxlist.cikeyid;
      newkeyid = 1;
   }
/* 8/23/89 fix bug 4847 */
   else if (ftnunit->ukeyid < 0) {
      ftnunit->ukeyid = ftnunit->f77idxlist.cikeyid >= 0 ? ftnunit->f77idxlist.cikeyid : 0;
      newkeyid = 1;
   }
   if (mode) {
      field = ftnunit->f77fio_buf + KEYOFF (ftnunit->ukeyid);
      if (KEYTYPE (ftnunit->ukeyid) != ftnunit->f77idxlist.cikeytype)
	 err (ftnunit->f77errlist.cierr, 154, "indexed read");
      if (KEYTYPE (ftnunit->ukeyid) == CHARTYPE) {
	 keyval = ftnunit->f77idxlist.cikeyval.cicharval;
/* fix bug 4779 */
	 if ((i = ftnunit->f77idxlist.cikeyvallen) > KEYLEN (ftnunit->ukeyid))
	    err (ftnunit->f77errlist.cierr, 155, "indexed read");
	 /* For Fortran, there's no such thing as null terminators for
	 the string values, so use the string len value only 
	 while (*keyval && i-- > 0)
	    *field++ = *keyval++;
	 while (i-- > 0)
	    *field++ = ' ';
	*/
	 while (i-- > 0)
	    *field++ = *keyval++;
      } else
	 stlong (ftnunit->f77idxlist.cikeyval.ciintval, field);
   } else
      /* If the last read operation was locked try readign the same record
      again
      mode = (newkeyid ? ISFIRST : ISNEXT);
      */
      mode = (newkeyid ? ISFIRST : ftnunit->uerror == F_ERLOCKED ? ISCURR : ISNEXT);
      ftnunit->uerror = 0;	/* clear error for new operation */
   if (newkeyid) {
      dokey (ftnunit->ukeyid, ONEKEY);
      if (isstart (ftnunit->isfd, &onekey, ftnunit->url, ftnunit->f77fio_buf, mode)
	  < SUCCESS)
	 ierr (ftnunit->f77errlist.cierr, iserrno, "indexed read");
   }
   if (isread (ftnunit->isfd, ftnunit->f77fio_buf, mode) < SUCCESS)
      if (iserrno == EENDFILE) {
	 ftnunit->uend = 1;
	 err (ftnunit->f77errlist.ciend, EOF, "indexed read");
      } else
	 ierr (ftnunit->f77errlist.cierr, iserrno, "indexed read");
   /* When the read is successful, make sure the EOF flag is not set */
   ftnunit->uend = 0;
   return SUCCESS;
}
Exemplo n.º 2
-2
int
dokey(int keyid, int mode)
{
   switch (mode) {
   case NOMATCH:
      return KEYOFF (keyid) != onekey.k_start ||
	 KEYLEN (keyid) != onekey.k_leng ||
	 KEYTYPE (keyid) != onekey.k_type;

   case ONEKEY:
      onekey.k_start = KEYOFF (keyid);
      onekey.k_leng = (short) (KEYLEN (keyid));
      onekey.k_type = KEYTYPE (keyid);
      break;

   case UNITKEY:
      KEYOFF (keyid) = onekey.k_start;
      KEYEND (keyid) = (short) (onekey.k_start + onekey.k_leng - 1);
      KEYTYPE (keyid) = onekey.k_type;
      break;
   }
   return 0; /* return value is ignored */
}
Exemplo n.º 3
-2
 bool UnSerializeExtDynamic( GI::Object *obj, GI::ByteBuffer &buf )
 {
     size_t cnt;
     if( !buf.Pop( &cnt, sizeof( cnt ) ) ) return false;
     for( size_t i = 0; i < cnt; ++ i )
     {
         short key ;
         buf.Pop( &key, sizeof( key ) );
         long v1, v2;
         buf.Pop( &v1, sizeof( v1 ) );
         buf.Pop( &v2, sizeof( v2 ) );
         obj->AddProperty( KEYTYPE( (long) key ), VALUETYPE2( v1, v2 ) );
     }
     return true;
 }