source: azure_iot_hub/trunk/musl-1.1.18/src/stdio/fwrite.c@ 388

Last change on this file since 388 was 388, checked in by coas-nagasima, 5 years ago

Azure IoT Hub Device C SDK を使ったサンプルの追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csrc
File size: 895 bytes
Line 
1#include "stdio_impl.h"
2#include <string.h>
3
4size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f)
5{
6 size_t i=0;
7
8 if (!f->wend && __towrite(f)) return 0;
9
10 if (l > f->wend - f->wpos) return f->write(f, s, l);
11
12 if (f->lbf >= 0) {
13 /* Match /^(.*\n|)/ */
14 for (i=l; i && s[i-1] != '\n'; i--);
15 if (i) {
16 size_t n = f->write(f, s, i);
17 if (n < i) return n;
18 s += i;
19 l -= i;
20 }
21 }
22
23 memcpy(f->wpos, s, l);
24 f->wpos += l;
25 return l+i;
26}
27
28size_t fwrite(const void *restrict src, size_t size, size_t nmemb, FILE *restrict f)
29{
30 size_t k, l = size*nmemb;
31 if (!size) nmemb = 0;
32 FLOCK(f);
33 k = __fwritex(src, l, f);
34 FUNLOCK(f);
35 return k==l ? nmemb : k/size;
36}
37
38#ifndef __c2__
39weak_alias(fwrite, fwrite_unlocked);
40#else
41size_t fwrite_unlocked(const void *restrict src, size_t size, size_t nmemb, FILE *restrict f)
42{
43 return fwrite(src, size, nmemb, f);
44}
45#endif
Note: See TracBrowser for help on using the repository browser.