void *b_fonc (void * arg) { int is, numero, i,j, m1; numero = (int)arg; m1 = 20; i = m1; printf("numero= %d, i=%d \n",numero,i); drawstr (30, 125, "_0_", 3); drawrec (100,100,100+m1*10,30); for (j=1;j<=m1;j++) { printf("num %d j=%d\n",numero,j); fillrec (100,102,100+j*10,26,"yellow"); usleep(70000); } flushdis (); return ( (void *)(numero+100) ); }
static uLong putrec (OZ_Recio_chnex *recio_chnex, OZ_Recio_filex *recio_filex, uLong size, const uByte *buff, uLong *wlen) { uLong readsize, room, sts; while (size != 0) { sts = fillrec (recio_chnex, recio_filex, size); /* maybe write last block out and read next block buffer in */ if ((sts != OZ_SUCCESS) && (sts != OZ_ENDOFFILE)) return (sts); /* return if any write or read error */ room = recio_filex -> recbuffsize - recio_chnex -> cur_ofs; /* see how much room is left in block buffer */ if (room > size) room = size; /* if more than we want, just use that much */ recio_chnex -> cur_buf -> buf_dirty = 1; /* buffer is about to be modified */ memcpy (recio_chnex -> cur_buf -> buf_data + recio_chnex -> cur_ofs, buff, room); /* copy data from user's buffer */ size -= room; /* decrement how much is left to do */ buff += room; /* increment where to get it from */ recio_chnex -> cur_ofs += room; /* increment offset where to put more */ if (recio_chnex -> cur_ofs > recio_chnex -> cur_buf -> buf_len) { recio_chnex -> cur_buf -> buf_len = recio_chnex -> cur_ofs; /* maybe have new 'end of valid data' offset */ } if (wlen != NULL) *wlen += room; /* add total length written */ } return (OZ_SUCCESS); }
uLong oz_sys_recio_read (OZ_Recio_chnex *recio_chnex, OZ_Recio_filex *recio_filex, OZ_IO_fs_readrec *readrec) { uByte *buff, *p, term_firstbyte; const uByte *trmbuff; int term_given; uLong comp, copy, room, saveofs, size, sts, trmsize; OZ_Dbn savevbn; /* If explicit position given, position there */ if (readrec -> atblock != 0) { recio_chnex -> cur_vbn = readrec -> atblock; recio_chnex -> cur_ofs = readrec -> atbyte; } /* Get bytes from record buffer until we fill user's buffer or we see the terminator */ term_given = (readrec -> trmsize != 0); /* set this flag if we were given a terminator */ if (term_given) term_firstbyte = ((uByte *)(readrec -> trmbuff))[0]; /* get first byte of terminator */ size = readrec -> size; /* get total size of user's read buffer */ buff = readrec -> buff; /* get address of user's read buffer */ while (size != 0) { /* Make sure we have some data to work with in the record buffer */ sts = fillrec (recio_chnex, recio_filex, 0); /* read in block if needed */ if (sts != OZ_SUCCESS) goto rtn_oz; /* abort if read error, including eof */ room = recio_chnex -> cur_buf -> buf_len - recio_chnex -> cur_ofs; /* If the first byte is the first byte of the terminator, see if the following string is the terminator string */ if (term_given && (recio_chnex -> cur_buf -> buf_data[recio_chnex->cur_ofs] == term_firstbyte)) { trmsize = readrec -> trmsize; /* get user's terminator string size */ trmbuff = readrec -> trmbuff; /* get user's terminator string address */ savevbn = recio_chnex -> cur_vbn; /* save our current block number */ saveofs = recio_chnex -> cur_ofs; /* save our offset in the block */ while (trmsize != 0) { /* repeat while more comparing to do */ sts = fillrec (recio_chnex, recio_filex, 0); /* make sure we have something to compare to */ if (sts != OZ_SUCCESS) goto not_terminator; /* abort if read error, including eof */ comp = recio_chnex -> cur_buf -> buf_len - recio_chnex -> cur_ofs; /* see how much is in buffer to compare */ if (comp > trmsize) comp = trmsize; /* see how many bytes we can compare */ sts = OZ_ENDOFFILE; /* this status means compare mismatched */ if (memcmp (trmbuff, recio_chnex -> cur_buf -> buf_data + recio_chnex -> cur_ofs, comp) != 0) goto not_terminator; /* if mismatch, we didn't compare */ trmsize -= comp; /* strings equal so far, inc terminator and record pointers */ trmbuff += comp; recio_chnex -> cur_ofs += comp; } /* terminator matched, leave rec pointer past terminator */ sts = OZ_SUCCESS; /* successful read status */ not_terminator: if (sts != OZ_ENDOFFILE) goto rtn_oz; /* success or read error, all done */ recio_chnex -> cur_vbn = savevbn; /* restore buffer pointer */ recio_chnex -> cur_ofs = saveofs; /* restore offset in the buffer */ sts = fillrec (recio_chnex, recio_filex, 0); /* re-read the block if needed */ if (sts != OZ_SUCCESS) goto rtn_oz; /* abort if read error, including eof */ room = recio_chnex -> cur_buf -> buf_len - recio_chnex -> cur_ofs; } /* Not terminator byte, copy as much as we can up to the first terminator byte to the user's read buffer */ if (room > size) room = size; copy = room; if (term_given) { p = recio_chnex -> cur_buf -> buf_data + recio_chnex -> cur_ofs; for (copy = 0; copy < room; copy ++) { if (*(p ++) == term_firstbyte) break; } } memcpy (buff, recio_chnex -> cur_buf -> buf_data + recio_chnex -> cur_ofs, copy); size -= copy; buff += copy; recio_chnex -> cur_ofs += copy; } sts = OZ_SUCCESS; if (term_given) sts = OZ_NOTERMINATOR; rtn_oz: size = readrec -> size - size; if ((sts == OZ_ENDOFFILE) && (size > 0)) { sts = OZ_SUCCESS; if (term_given) sts = OZ_NOTERMINATOR; } if (readrec -> rlen != NULL) *(readrec -> rlen) = size; return (sts); }