]>
iEval git - fdkaac.git/blob - compat_win32.c
a68fa3f3341d1c7565ae10f8ec98aaa86e30d1d0
2 * Copyright (C) 2013 nu774
3 * For conditions of distribution and use, see copyright notice in COPYING
17 #include <sys/timeb.h>
19 #define WIN32_LEAN_AND_MEAN
28 int __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, _startupinfo
*);
30 int64_t aacenc_timer(void)
34 return (int64_t)tv
.time
* 1000 + tv
.millitm
;
38 int codepage_decode_wchar(int codepage
, const char *from
, wchar_t **to
)
40 int nc
= MultiByteToWideChar(codepage
, 0, from
, -1, 0, 0);
43 *to
= malloc(nc
* sizeof(wchar_t));
44 MultiByteToWideChar(codepage
, 0, from
, -1, *to
, nc
);
49 int codepage_encode_wchar(int codepage
, const wchar_t *from
, char **to
)
51 int nc
= WideCharToMultiByte(codepage
, 0, from
, -1, 0, 0, 0, 0);
55 WideCharToMultiByte(codepage
, 0, from
, -1, *to
, nc
, 0, 0);
59 FILE *aacenc_fopen(const char *name
, const char *mode
)
61 wchar_t *wname
, *wmode
;
64 if (strcmp(name
, "-") == 0) {
65 fp
= (mode
[0] == 'r') ? stdin
: stdout
;
66 _setmode(_fileno(fp
), _O_BINARY
);
68 codepage_decode_wchar(CP_UTF8
, name
, &wname
);
69 codepage_decode_wchar(CP_UTF8
, mode
, &wmode
);
70 fp
= _wfopen(wname
, wmode
);
77 void aacenc_getmainargs(int *argc
, char ***argv
)
80 wchar_t **wargv
, **envp
;
81 _startupinfo si
= { 0 };
83 __wgetmainargs(argc
, &wargv
, &envp
, 1, &si
);
84 *argv
= malloc((*argc
+ 1) * sizeof(char*));
85 for (i
= 0; i
< *argc
; ++i
)
86 codepage_encode_wchar(CP_UTF8
, wargv
[i
], &(*argv
)[i
]);
90 char *aacenc_to_utf8(const char *s
)
95 int aacenc_fprintf(FILE *fp
, const char *fmt
, ...)
99 HANDLE fh
= (HANDLE
)_get_osfhandle(_fileno(fp
));
101 if (GetFileType(fh
) != FILE_TYPE_CHAR
) {
103 cnt
= vfprintf(fp
, fmt
, ap
);
111 cnt
= _vscprintf(fmt
, ap
);
117 cnt
= _vsnprintf(s
, cnt
+ 1, fmt
, ap
);
120 codepage_decode_wchar(CP_UTF8
, s
, &ws
);
123 WriteConsoleW(fh
, ws
, cnt
, &nw
, 0);
This page took 0.048659 seconds and 3 git commands to generate.