added qse_mbstoipad4()/qse_wcstoipad4()/qse_ipad4tombs()/qse_ipad4towcs()
This commit is contained in:
parent
ada60acf67
commit
ee8609daf4
@ -65,31 +65,43 @@ int qse_mbstoipad4 (
|
||||
|
||||
int qse_mbsntoipad4 (
|
||||
const qse_mchar_t* mbs,
|
||||
qse_size_t len
|
||||
qse_size_t len,
|
||||
qse_ipad4_t* ipad
|
||||
);
|
||||
|
||||
int qse_ipad4tombs (
|
||||
int qse_wcstoipad4 (
|
||||
const qse_wchar_t* wcs,
|
||||
qse_ipad4_t* ipad
|
||||
);
|
||||
|
||||
int qse_wcsntoipad4 (
|
||||
const qse_wchar_t* wcs,
|
||||
qse_size_t len,
|
||||
qse_ipad4_t* ipad
|
||||
);
|
||||
|
||||
qse_size_t qse_ipad4tombs (
|
||||
const qse_ipad4_t* ipad,
|
||||
qse_mchar_t* mbs,
|
||||
qse_size_t len
|
||||
);
|
||||
|
||||
int qse_wcstoipad4 (
|
||||
const qse_wchar_t* wcs,
|
||||
qse_ipad4_t* ipad
|
||||
);
|
||||
|
||||
int qse_wcstoipad4 (
|
||||
const qse_wchar_t* wcs,
|
||||
qse_ipad4_t* ipad
|
||||
);
|
||||
|
||||
int qse_ipad4towcs (
|
||||
qse_size_t qse_ipad4towcs (
|
||||
const qse_ipad4_t* ipad,
|
||||
qse_wchar_t* wcs,
|
||||
qse_size_t len
|
||||
);
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
# define qse_strtoipad4(ptr,ipad) qse_mbstoipad4(ptr,ipad)
|
||||
# define qse_strntoipad4(ptr,len,ipad) qse_mbsntoipad4(ptr,len,ipad)
|
||||
# define qse_ipad4tostr(ipad,ptr,len) qse_ipad4tombs(ipad,ptr,len)
|
||||
#else
|
||||
# define qse_strtoipad4(ptr,ipad) qse_wcstoipad4(ptr,ipad)
|
||||
# define qse_strntoipad4(ptr,len,ipad) qse_wcsntoipad4(ptr,len,ipad)
|
||||
# define qse_ipad4tostr(ipad,ptr,len) qse_ipad4towcs(ipad,ptr,len)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -743,6 +743,14 @@ struct qse_cmgr_t
|
||||
|
||||
typedef struct qse_cmgr_t qse_cmgr_t;
|
||||
|
||||
#if 0
|
||||
struct qse_tmgr_t
|
||||
{
|
||||
int gettimeoffset
|
||||
};
|
||||
typedef struct qse_tmgr_t qse_tmgr_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The #qse_foff_t type defines an integer that can represent a file offset.
|
||||
* Depending on your system, it's defined to one of #qse_int64_t, #qse_int32_t,
|
||||
|
@ -67,52 +67,15 @@ const qse_ipad6_t qse_ipad6_loopback =
|
||||
};
|
||||
#endif
|
||||
|
||||
int qse_strtoipad4 (const qse_char_t* str, qse_ipad4_t* ipad)
|
||||
static int str_to_ipad4 (int mbs, const void* str, qse_size_t len, qse_ipad4_t* ipad)
|
||||
{
|
||||
qse_char_t c;
|
||||
const void* end;
|
||||
int dots = 0, digits = 0;
|
||||
qse_uint32_t acc = 0, addr = 0;
|
||||
qse_wchar_t c;
|
||||
|
||||
do
|
||||
{
|
||||
c = *str;
|
||||
|
||||
if (c == QSE_T('\0'))
|
||||
{
|
||||
if (dots < 3 || digits == 0) return -1;
|
||||
addr = (addr << 8) | acc;
|
||||
break;
|
||||
}
|
||||
else if (c >= QSE_T('0') && c <= QSE_T('9'))
|
||||
{
|
||||
if (digits > 0 && acc == 0) return -1;
|
||||
acc = acc * 10 + (c - QSE_T('0'));
|
||||
if (acc > 255) return -1;
|
||||
digits++;
|
||||
}
|
||||
else if (c == QSE_T('.'))
|
||||
{
|
||||
if (dots >= 3 || digits == 0) return -1;
|
||||
addr = (addr << 8) | acc;
|
||||
dots++; acc = 0; digits = 0;
|
||||
}
|
||||
else return -1;
|
||||
|
||||
str++;
|
||||
}
|
||||
while (1);
|
||||
|
||||
if (ipad != QSE_NULL) ipad->value = qse_hton32(addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qse_strxtoipad4 (
|
||||
const qse_char_t* str, qse_size_t len, qse_ipad4_t* ipad)
|
||||
{
|
||||
qse_char_t c;
|
||||
int dots = 0, digits = 0;
|
||||
qse_uint32_t acc = 0, addr = 0;
|
||||
const qse_char_t* end = str + len;
|
||||
end = (mbs? (const void*)((const qse_mchar_t*)str + len):
|
||||
(const void*)((const qse_wchar_t*)str + len));
|
||||
|
||||
do
|
||||
{
|
||||
@ -123,24 +86,31 @@ int qse_strxtoipad4 (
|
||||
break;
|
||||
}
|
||||
|
||||
c = *str;
|
||||
if (mbs)
|
||||
{
|
||||
c = *(const qse_mchar_t*)str;
|
||||
str = (const qse_mchar_t*)str + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = *(const qse_wchar_t*)str;
|
||||
str = (const qse_wchar_t*)str + 1;
|
||||
}
|
||||
|
||||
if (c >= QSE_T('0') && c <= QSE_T('9'))
|
||||
if (c >= QSE_WT('0') && c <= QSE_WT('9'))
|
||||
{
|
||||
if (digits > 0 && acc == 0) return -1;
|
||||
acc = acc * 10 + (c - QSE_T('0'));
|
||||
if (acc > 255) return -1;
|
||||
digits++;
|
||||
}
|
||||
else if (c == QSE_T('.'))
|
||||
else if (c == QSE_WT('.'))
|
||||
{
|
||||
if (dots >= 3 || digits == 0) return -1;
|
||||
addr = (addr << 8) | acc;
|
||||
dots++; acc = 0; digits = 0;
|
||||
}
|
||||
else return -1;
|
||||
|
||||
str++;
|
||||
}
|
||||
while (1);
|
||||
|
||||
@ -148,20 +118,40 @@ int qse_strxtoipad4 (
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define __BTOA(b,p,end) \
|
||||
int qse_mbstoipad4 (const qse_mchar_t* str, qse_ipad4_t* ipad)
|
||||
{
|
||||
return str_to_ipad4 (1, str, qse_mbslen(str), ipad);
|
||||
}
|
||||
|
||||
int qse_wcstoipad4 (const qse_wchar_t* str, qse_ipad4_t* ipad)
|
||||
{
|
||||
return str_to_ipad4 (0, str, qse_wcslen(str), ipad);
|
||||
}
|
||||
|
||||
int qse_mbsntoipad4 (const qse_mchar_t* str, qse_size_t len, qse_ipad4_t* ipad)
|
||||
{
|
||||
return str_to_ipad4 (1, str, len, ipad);
|
||||
}
|
||||
|
||||
int qse_wcsntoipad4 (const qse_wchar_t* str, qse_size_t len, qse_ipad4_t* ipad)
|
||||
{
|
||||
return str_to_ipad4 (0, str, len, ipad);
|
||||
}
|
||||
|
||||
#define __BTOA(type_t,b,p,end) \
|
||||
do { \
|
||||
qse_char_t* sp = p; \
|
||||
type_t* sp = p; \
|
||||
do { \
|
||||
if (p >= end) { \
|
||||
if (p == sp) break; \
|
||||
if (p - sp > 1) p[-2] = p[-1]; \
|
||||
p[-1] = (b % 10) + QSE_T('0'); \
|
||||
p[-1] = (b % 10) + '0'; \
|
||||
} \
|
||||
else *p++ = (b % 10) + QSE_T('0'); \
|
||||
else *p++ = (b % 10) + '0'; \
|
||||
b /= 10; \
|
||||
} while (b > 0); \
|
||||
if (p - sp > 1) { \
|
||||
qse_char_t t = sp[0]; \
|
||||
type_t t = sp[0]; \
|
||||
sp[0] = p[-1]; \
|
||||
p[-1] = t; \
|
||||
} \
|
||||
@ -170,14 +160,14 @@ int qse_strxtoipad4 (
|
||||
#define __ADDDOT(p, end) \
|
||||
do { \
|
||||
if (p >= end) break; \
|
||||
*p++ = QSE_T('.'); \
|
||||
*p++ = '.'; \
|
||||
} while (0)
|
||||
|
||||
qse_size_t qse_ipad4tostrx (
|
||||
const qse_ipad4_t* ipad, qse_char_t* buf, qse_size_t size)
|
||||
qse_size_t qse_ipad4tombs (
|
||||
const qse_ipad4_t* ipad, qse_mchar_t* buf, qse_size_t size)
|
||||
{
|
||||
qse_byte_t b;
|
||||
qse_char_t* p, * end;
|
||||
qse_mchar_t* p, * end;
|
||||
qse_uint32_t ip;
|
||||
|
||||
if (size <= 0) return 0;
|
||||
@ -188,23 +178,56 @@ qse_size_t qse_ipad4tostrx (
|
||||
end = buf + size - 1;
|
||||
|
||||
#if defined(QSE_ENDIAN_BIG)
|
||||
b = (ip >> 24) & 0xFF; __BTOA (b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 16) & 0xFF; __BTOA (b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 8) & 0xFF; __BTOA (b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 0) & 0xFF; __BTOA (b, p, end);
|
||||
b = (ip >> 24) & 0xFF; __BTOA (qse_mchar_t, b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 16) & 0xFF; __BTOA (qse_mchar_t, b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 8) & 0xFF; __BTOA (qse_mchar_t, b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 0) & 0xFF; __BTOA (qse_mchar_t, b, p, end);
|
||||
#elif defined(QSE_ENDIAN_LITTLE)
|
||||
b = (ip >> 0) & 0xFF; __BTOA (b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 8) & 0xFF; __BTOA (b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 16) & 0xFF; __BTOA (b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 24) & 0xFF; __BTOA (b, p, end);
|
||||
b = (ip >> 0) & 0xFF; __BTOA (qse_mchar_t, b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 8) & 0xFF; __BTOA (qse_mchar_t, b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 16) & 0xFF; __BTOA (qse_mchar_t, b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 24) & 0xFF; __BTOA (qse_mchar_t, b, p, end);
|
||||
#else
|
||||
# error Unknown Endian
|
||||
#endif
|
||||
|
||||
*p = QSE_T('\0');
|
||||
*p = QSE_MT('\0');
|
||||
return p - buf;
|
||||
}
|
||||
|
||||
qse_size_t qse_ipad4towcs (
|
||||
const qse_ipad4_t* ipad, qse_wchar_t* buf, qse_size_t size)
|
||||
{
|
||||
qse_byte_t b;
|
||||
qse_wchar_t* p, * end;
|
||||
qse_uint32_t ip;
|
||||
|
||||
if (size <= 0) return 0;
|
||||
|
||||
ip = ipad->value;
|
||||
|
||||
p = buf;
|
||||
end = buf + size - 1;
|
||||
|
||||
#if defined(QSE_ENDIAN_BIG)
|
||||
b = (ip >> 24) & 0xFF; __BTOA (qse_wchar_t, b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 16) & 0xFF; __BTOA (qse_wchar_t, b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 8) & 0xFF; __BTOA (qse_wchar_t, b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 0) & 0xFF; __BTOA (qse_wchar_t, b, p, end);
|
||||
#elif defined(QSE_ENDIAN_LITTLE)
|
||||
b = (ip >> 0) & 0xFF; __BTOA (qse_wchar_t, b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 8) & 0xFF; __BTOA (qse_wchar_t, b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 16) & 0xFF; __BTOA (qse_wchar_t, b, p, end); __ADDDOT (p, end);
|
||||
b = (ip >> 24) & 0xFF; __BTOA (qse_wchar_t, b, p, end);
|
||||
#else
|
||||
# error Unknown Endian
|
||||
#endif
|
||||
|
||||
*p = QSE_WT('\0');
|
||||
return p - buf;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int qse_strtoipad6 (const qse_char_t* src, qse_ipad6_t* ipad)
|
||||
{
|
||||
#if 0
|
||||
@ -549,28 +572,4 @@ qse_size_t qse_ipad6tostrx (
|
||||
#undef IP6ADDR_NWORDS
|
||||
}
|
||||
|
||||
#if 0
|
||||
int qse_strtoipad (const qse_char_t* str, qse_ipad_t* ipad)
|
||||
{
|
||||
if (qse_strtoipad4 (str, &ipad->u.ip4) <= -1)
|
||||
{
|
||||
if (qse_strtoipad6 (str, &ipad->u.ip6) <= -1) return -1;
|
||||
ipad->type = QSE_IPAD_IP6;
|
||||
}
|
||||
else ipad->type = QSE_IPAD_IP4;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qse_strxtoipad (const qse_char_t* str, qse_size_t len, qse_ipad_t* ipad)
|
||||
{
|
||||
if (qse_strxtoipad4 (str, len, &ipad->u.ip4) <= -1)
|
||||
{
|
||||
if (qse_strxtoipad6 (str, len, &ipad->u.ip6) <= -1) return -1;
|
||||
ipad->type = QSE_IPAD_IP6;
|
||||
}
|
||||
else ipad->type = QSE_IPAD_IP4;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -17,6 +17,7 @@ bin_PROGRAMS = \
|
||||
fmt02 \
|
||||
fs01 \
|
||||
htb \
|
||||
ipad01 \
|
||||
lda \
|
||||
main01 \
|
||||
main02 \
|
||||
@ -55,6 +56,7 @@ fmt01_SOURCES = fmt01.c
|
||||
fmt02_SOURCES = fmt02.c
|
||||
fs01_SOURCES = fs01.c
|
||||
htb_SOURCES = htb.c
|
||||
ipad01_SOURCES = ipad01.c
|
||||
lda_SOURCES = lda.c
|
||||
main01_SOURCES = main01.c
|
||||
main02_SOURCES = main02.c
|
||||
|
@ -36,12 +36,12 @@ build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
bin_PROGRAMS = chr01$(EXEEXT) env$(EXEEXT) dll$(EXEEXT) fio01$(EXEEXT) \
|
||||
fio02$(EXEEXT) fma$(EXEEXT) fmt01$(EXEEXT) fmt02$(EXEEXT) \
|
||||
fs01$(EXEEXT) htb$(EXEEXT) lda$(EXEEXT) main01$(EXEEXT) \
|
||||
main02$(EXEEXT) mbwc01$(EXEEXT) mbwc02$(EXEEXT) oht$(EXEEXT) \
|
||||
path01$(EXEEXT) pio$(EXEEXT) pma$(EXEEXT) rex01$(EXEEXT) \
|
||||
rbt$(EXEEXT) sio01$(EXEEXT) sio02$(EXEEXT) sio03$(EXEEXT) \
|
||||
sll$(EXEEXT) slmb01$(EXEEXT) str01$(EXEEXT) time$(EXEEXT) \
|
||||
tre01$(EXEEXT) xma$(EXEEXT)
|
||||
fs01$(EXEEXT) htb$(EXEEXT) ipad01$(EXEEXT) lda$(EXEEXT) \
|
||||
main01$(EXEEXT) main02$(EXEEXT) mbwc01$(EXEEXT) \
|
||||
mbwc02$(EXEEXT) oht$(EXEEXT) path01$(EXEEXT) pio$(EXEEXT) \
|
||||
pma$(EXEEXT) rex01$(EXEEXT) rbt$(EXEEXT) sio01$(EXEEXT) \
|
||||
sio02$(EXEEXT) sio03$(EXEEXT) sll$(EXEEXT) slmb01$(EXEEXT) \
|
||||
str01$(EXEEXT) time$(EXEEXT) tre01$(EXEEXT) xma$(EXEEXT)
|
||||
@WIN32_TRUE@am__append_1 = $(UNICOWS_LIBS)
|
||||
subdir = samples/cmn
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
@ -101,6 +101,10 @@ am_htb_OBJECTS = htb.$(OBJEXT)
|
||||
htb_OBJECTS = $(am_htb_OBJECTS)
|
||||
htb_LDADD = $(LDADD)
|
||||
htb_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
||||
am_ipad01_OBJECTS = ipad01.$(OBJEXT)
|
||||
ipad01_OBJECTS = $(am_ipad01_OBJECTS)
|
||||
ipad01_LDADD = $(LDADD)
|
||||
ipad01_DEPENDENCIES = $(am__DEPENDENCIES_2)
|
||||
am_lda_OBJECTS = lda.$(OBJEXT)
|
||||
lda_OBJECTS = $(am_lda_OBJECTS)
|
||||
lda_LDADD = $(LDADD)
|
||||
@ -197,23 +201,23 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
SOURCES = $(chr01_SOURCES) $(dll_SOURCES) $(env_SOURCES) \
|
||||
$(fio01_SOURCES) $(fio02_SOURCES) $(fma_SOURCES) \
|
||||
$(fmt01_SOURCES) $(fmt02_SOURCES) $(fs01_SOURCES) \
|
||||
$(htb_SOURCES) $(lda_SOURCES) $(main01_SOURCES) \
|
||||
$(main02_SOURCES) $(mbwc01_SOURCES) $(mbwc02_SOURCES) \
|
||||
$(oht_SOURCES) $(path01_SOURCES) $(pio_SOURCES) $(pma_SOURCES) \
|
||||
$(rbt_SOURCES) $(rex01_SOURCES) $(sio01_SOURCES) \
|
||||
$(sio02_SOURCES) $(sio03_SOURCES) $(sll_SOURCES) \
|
||||
$(slmb01_SOURCES) $(str01_SOURCES) $(time_SOURCES) \
|
||||
$(tre01_SOURCES) $(xma_SOURCES)
|
||||
$(htb_SOURCES) $(ipad01_SOURCES) $(lda_SOURCES) \
|
||||
$(main01_SOURCES) $(main02_SOURCES) $(mbwc01_SOURCES) \
|
||||
$(mbwc02_SOURCES) $(oht_SOURCES) $(path01_SOURCES) \
|
||||
$(pio_SOURCES) $(pma_SOURCES) $(rbt_SOURCES) $(rex01_SOURCES) \
|
||||
$(sio01_SOURCES) $(sio02_SOURCES) $(sio03_SOURCES) \
|
||||
$(sll_SOURCES) $(slmb01_SOURCES) $(str01_SOURCES) \
|
||||
$(time_SOURCES) $(tre01_SOURCES) $(xma_SOURCES)
|
||||
DIST_SOURCES = $(chr01_SOURCES) $(dll_SOURCES) $(env_SOURCES) \
|
||||
$(fio01_SOURCES) $(fio02_SOURCES) $(fma_SOURCES) \
|
||||
$(fmt01_SOURCES) $(fmt02_SOURCES) $(fs01_SOURCES) \
|
||||
$(htb_SOURCES) $(lda_SOURCES) $(main01_SOURCES) \
|
||||
$(main02_SOURCES) $(mbwc01_SOURCES) $(mbwc02_SOURCES) \
|
||||
$(oht_SOURCES) $(path01_SOURCES) $(pio_SOURCES) $(pma_SOURCES) \
|
||||
$(rbt_SOURCES) $(rex01_SOURCES) $(sio01_SOURCES) \
|
||||
$(sio02_SOURCES) $(sio03_SOURCES) $(sll_SOURCES) \
|
||||
$(slmb01_SOURCES) $(str01_SOURCES) $(time_SOURCES) \
|
||||
$(tre01_SOURCES) $(xma_SOURCES)
|
||||
$(htb_SOURCES) $(ipad01_SOURCES) $(lda_SOURCES) \
|
||||
$(main01_SOURCES) $(main02_SOURCES) $(mbwc01_SOURCES) \
|
||||
$(mbwc02_SOURCES) $(oht_SOURCES) $(path01_SOURCES) \
|
||||
$(pio_SOURCES) $(pma_SOURCES) $(rbt_SOURCES) $(rex01_SOURCES) \
|
||||
$(sio01_SOURCES) $(sio02_SOURCES) $(sio03_SOURCES) \
|
||||
$(sll_SOURCES) $(slmb01_SOURCES) $(str01_SOURCES) \
|
||||
$(time_SOURCES) $(tre01_SOURCES) $(xma_SOURCES)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
@ -380,6 +384,7 @@ fmt01_SOURCES = fmt01.c
|
||||
fmt02_SOURCES = fmt02.c
|
||||
fs01_SOURCES = fs01.c
|
||||
htb_SOURCES = htb.c
|
||||
ipad01_SOURCES = ipad01.c
|
||||
lda_SOURCES = lda.c
|
||||
main01_SOURCES = main01.c
|
||||
main02_SOURCES = main02.c
|
||||
@ -507,6 +512,9 @@ fs01$(EXEEXT): $(fs01_OBJECTS) $(fs01_DEPENDENCIES)
|
||||
htb$(EXEEXT): $(htb_OBJECTS) $(htb_DEPENDENCIES)
|
||||
@rm -f htb$(EXEEXT)
|
||||
$(LINK) $(htb_OBJECTS) $(htb_LDADD) $(LIBS)
|
||||
ipad01$(EXEEXT): $(ipad01_OBJECTS) $(ipad01_DEPENDENCIES)
|
||||
@rm -f ipad01$(EXEEXT)
|
||||
$(LINK) $(ipad01_OBJECTS) $(ipad01_LDADD) $(LIBS)
|
||||
lda$(EXEEXT): $(lda_OBJECTS) $(lda_DEPENDENCIES)
|
||||
@rm -f lda$(EXEEXT)
|
||||
$(LINK) $(lda_OBJECTS) $(lda_LDADD) $(LIBS)
|
||||
@ -584,6 +592,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmt02.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htb.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ipad01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lda.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main01.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main02.Po@am__quote@
|
||||
|
@ -16,7 +16,7 @@ static void list (qse_fs_t* fs, const qse_char_t* name)
|
||||
|
||||
if (qse_fs_chdir (fs, name) <= -1)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR, QSE_T("Error: Cannot change directory to %s - %s\n"), name, qse_fs_geterrmsg(fs));
|
||||
qse_fprintf (QSE_STDERR, QSE_T("Error: Cannot change directory to %s - code %d\n"), name, (int)qse_fs_geterrnum(fs));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ static void list (qse_fs_t* fs, const qse_char_t* name)
|
||||
{
|
||||
qse_fs_errnum_t e = qse_fs_geterrnum(fs);
|
||||
if (e != QSE_FS_ENOERR)
|
||||
qse_fprintf (QSE_STDERR, QSE_T("Error: Read error - %s\n"), qse_fs_geterrmsg(fs));
|
||||
qse_fprintf (QSE_STDERR, QSE_T("Error: Read error - code %d\n"), (int)qse_fs_geterrnum(fs));
|
||||
break;
|
||||
}
|
||||
|
||||
|
118
qse/samples/cmn/ipad01.c
Normal file
118
qse/samples/cmn/ipad01.c
Normal file
@ -0,0 +1,118 @@
|
||||
#include <qse/cmn/ipad.h>
|
||||
#include <qse/cmn/main.h>
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/stdio.h>
|
||||
|
||||
#include <locale.h>
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
static int test_main (int argc, qse_char_t* argv[], qse_char_t* envp[])
|
||||
{
|
||||
qse_ipad4_t ipad4;
|
||||
qse_char_t buf[32];
|
||||
qse_mchar_t mbsbuf[32];
|
||||
qse_wchar_t wcsbuf[32];
|
||||
qse_size_t i;
|
||||
|
||||
static qse_char_t* ipstr[] =
|
||||
{
|
||||
QSE_T("192.168.1.1"),
|
||||
QSE_T("255.255.255.255"),
|
||||
QSE_T("4.3.0.0"),
|
||||
QSE_T("4.3.0.0X"),
|
||||
QSE_T("65.1234.11.34"),
|
||||
QSE_T("65.123.11.34"),
|
||||
QSE_T("1.1.1.1")
|
||||
};
|
||||
|
||||
static qse_mchar_t* ipstr_mbs[] =
|
||||
{
|
||||
QSE_MT("192.168.1.1"),
|
||||
QSE_MT("255.255.255.255"),
|
||||
QSE_MT("4.3.0.0"),
|
||||
QSE_MT("4.3.0.0X"),
|
||||
QSE_MT("65.1234.11.34"),
|
||||
QSE_MT("65.123.11.34"),
|
||||
QSE_MT("1.1.1.1")
|
||||
};
|
||||
|
||||
static qse_wchar_t* ipstr_wcs[] =
|
||||
{
|
||||
QSE_WT("192.168.1.1"),
|
||||
QSE_WT("255.255.255.255"),
|
||||
QSE_WT("4.3.0.0"),
|
||||
QSE_WT("4.3.0.0X"),
|
||||
QSE_WT("65.1234.11.34"),
|
||||
QSE_WT("65.123.11.34"),
|
||||
QSE_WT("1.1.1.1")
|
||||
};
|
||||
|
||||
for (i = 0; i < QSE_COUNTOF(ipstr); i++)
|
||||
{
|
||||
if (qse_strtoipad4 (ipstr[i], &ipad4) <= -1)
|
||||
{
|
||||
qse_printf (QSE_T("Failed to convert %s\n"), ipstr[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_ipad4tostr (&ipad4, buf, QSE_COUNTOF(buf));
|
||||
qse_printf (QSE_T("Converted [%s] to [%s]\n"), ipstr[i], buf);
|
||||
}
|
||||
}
|
||||
|
||||
qse_printf (QSE_T("-------------------\n"));
|
||||
for (i = 0; i < QSE_COUNTOF(ipstr_mbs); i++)
|
||||
{
|
||||
if (qse_mbstoipad4 (ipstr_mbs[i], &ipad4) <= -1)
|
||||
{
|
||||
qse_printf (QSE_T("Failed to convert %hs\n"), ipstr_mbs[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_ipad4tombs (&ipad4, mbsbuf, QSE_COUNTOF(mbsbuf));
|
||||
qse_printf (QSE_T("Converted [%hs] to [%hs]\n"), ipstr[i], mbsbuf);
|
||||
}
|
||||
}
|
||||
|
||||
qse_printf (QSE_T("-------------------\n"));
|
||||
for (i = 0; i < QSE_COUNTOF(ipstr_wcs); i++)
|
||||
{
|
||||
if (qse_wcstoipad4 (ipstr_wcs[i], &ipad4) <= -1)
|
||||
{
|
||||
qse_printf (QSE_T("Failed to convert %ls\n"), ipstr_wcs[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_ipad4towcs (&ipad4, wcsbuf, QSE_COUNTOF(wcsbuf));
|
||||
qse_printf (QSE_T("Converted [%ls] to [%ls]\n"), ipstr[i], wcsbuf);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qse_main (int argc, qse_achar_t* argv[], qse_achar_t* envp[])
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
char locale[100];
|
||||
UINT codepage = GetConsoleOutputCP();
|
||||
if (codepage == CP_UTF8)
|
||||
{
|
||||
/*SetConsoleOUtputCP (CP_UTF8);*/
|
||||
qse_setdflcmgr (qse_utf8cmgr);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (locale, ".%u", (unsigned int)codepage);
|
||||
setlocale (LC_ALL, locale);
|
||||
qse_setdflcmgr (qse_slmbcmgr);
|
||||
}
|
||||
#else
|
||||
setlocale (LC_ALL, "");
|
||||
qse_setdflcmgr (qse_slmbcmgr);
|
||||
#endif
|
||||
return qse_runmainwithenv (argc, argv, envp, test_main);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user