]>
iEval git - fdkaac.git/blob - compat_posix.c
1b8f14ae71e73e22793876f495b7931cfacff674
2 * Copyright (C) 2013 nu774
3 * For conditions of distribution and use, see copyright notice in COPYING
18 int64_t aacenc_timer(void)
20 struct timeval tv
= { 0 };
22 return (int64_t)tv
.tv_sec
* 1000 + tv
.tv_usec
/ 1000;
25 FILE *aacenc_fopen(const char *name
, const char *mode
)
28 if (strcmp(name
, "-") == 0)
29 fp
= (mode
[0] == 'r') ? stdin
: stdout
;
31 fp
= fopen(name
, mode
);
35 void aacenc_getmainargs(int *argc
, char ***argv
)
40 int aacenc_fprintf(FILE *fp
, const char *fmt
, ...)
46 cnt
= vfprintf(fp
, fmt
, ap
);
52 char *aacenc_to_utf8(const char *s
)
56 #else /* HAVE_ICONV */
58 #include <sys/types.h>
63 #if HAVE_LOCALCHARSET_H
64 #include <localcharset.h>
67 static const char *locale_charset(void)
69 return nl_langinfo(CODESET
);
72 static const char *locale_charset(void)
79 int utf8_from_charset(const char *charset
, const char *from
, char **to
)
82 size_t fromlen
, obsize
, ibleft
, obleft
;
85 cd
= iconv_open("UTF-8", charset
);
86 if (cd
== (iconv_t
)-1)
89 fromlen
= strlen(from
);
98 if (iconv(cd
, &ip
, &ibleft
, &op
, &obleft
) != (size_t)-1)
101 if (errno
== E2BIG
|| obleft
== 0) {
102 ptrdiff_t offset
= op
- *to
;
104 *to
= realloc(*to
, obsize
);
106 obleft
= obsize
- offset
- 1;
108 if (errno
== EILSEQ
) {
114 if (errno
!= E2BIG
&& errno
!= EILSEQ
)
120 if (fromlen
> 0 && op
== *to
) {
127 char *aacenc_to_utf8(const char *s
)
132 if ((charset
= locale_charset()) == 0)
133 charset
= "US-ASCII";
134 if (utf8_from_charset(charset
, s
, &result
) < 0)
138 #endif /* HAVE_ICONV */
This page took 0.050849 seconds and 3 git commands to generate.