Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Something
Tuesday, June 12th, 2007 at 12:35:52pm UTC 

  1. /* read_from_from:
  2.     fd - file to read rom
  3.     buffer - buffer to read into
  4.     *length - maximum amount of data to read.
  5.         On return *length becomes the amount of data actually read.
  6.     Returns true if the file is finished, or error.
  7.             false if there is still data to rbe read.
  8. */
  9. static bool read_from_from(int fd, char *buffer, size_t *length)
  10. {
  11.     size_t ret, data_read = 0;
  12.     while (*length > 0)
  13.     {
  14.         ret = read(fd, buffer, *length);
  15.         if (ret < 0) /* error */
  16.         {
  17.             *length = 0;
  18.             return true;
  19.         }
  20.         else if (ret == 0)
  21.         {
  22.             *length = data_read;
  23.             return true; /* file finished */
  24.         }
  25.         else
  26.         {
  27.             data_read += ret;
  28.             *length -= ret;
  29.         }
  30.     }
  31.     *length = data_read;
  32.     return false;
  33. }

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right