📄 ncx.c
字号:
ncx_pad_getn_schar_int(const void **xpp, size_t nelems, int *tp){ size_t rndup = nelems % X_ALIGN; schar *xp = (schar *) *xpp; if(rndup) rndup = X_ALIGN - rndup; while(nelems-- != 0) { *tp++ = *xp++; } *xpp = (void *)(xp + rndup); return ENOERR;}intncx_pad_getn_schar_long(const void **xpp, size_t nelems, long *tp){ size_t rndup = nelems % X_ALIGN; schar *xp = (schar *) *xpp; if(rndup) rndup = X_ALIGN - rndup; while(nelems-- != 0) { *tp++ = *xp++; } *xpp = (void *)(xp + rndup); return ENOERR;}intncx_pad_getn_schar_float(const void **xpp, size_t nelems, float *tp){ size_t rndup = nelems % X_ALIGN; schar *xp = (schar *) *xpp; if(rndup) rndup = X_ALIGN - rndup; while(nelems-- != 0) { *tp++ = *xp++; } *xpp = (void *)(xp + rndup); return ENOERR;}intncx_pad_getn_schar_double(const void **xpp, size_t nelems, double *tp){ size_t rndup = nelems % X_ALIGN; schar *xp = (schar *) *xpp; if(rndup) rndup = X_ALIGN - rndup; while(nelems-- != 0) { *tp++ = *xp++; } *xpp = (void *)(xp + rndup); return ENOERR;}intncx_putn_schar_schar(void **xpp, size_t nelems, const schar *tp){ (void) memcpy(*xpp, tp, nelems); *xpp = (void *)((char *)(*xpp) + nelems); return ENOERR;}intncx_putn_schar_uchar(void **xpp, size_t nelems, const uchar *tp){ (void) memcpy(*xpp, tp, nelems); *xpp = (void *)((char *)(*xpp) + nelems); return ENOERR;}intncx_putn_schar_short(void **xpp, size_t nelems, const short *tp){ int status = ENOERR; schar *xp = (schar *) *xpp; while(nelems-- != 0) { if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) status = NC_ERANGE; *xp++ = (schar) *tp++; } *xpp = (void *)xp; return status;}intncx_putn_schar_int(void **xpp, size_t nelems, const int *tp){ int status = ENOERR; schar *xp = (schar *) *xpp; while(nelems-- != 0) { if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) status = NC_ERANGE; *xp++ = (schar) *tp++; } *xpp = (void *)xp; return status;}intncx_putn_schar_long(void **xpp, size_t nelems, const long *tp){ int status = ENOERR; schar *xp = (schar *) *xpp; while(nelems-- != 0) { if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) status = NC_ERANGE; *xp++ = (schar) *tp++; } *xpp = (void *)xp; return status;}intncx_putn_schar_float(void **xpp, size_t nelems, const float *tp){ int status = ENOERR; schar *xp = (schar *) *xpp; while(nelems-- != 0) { if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) status = NC_ERANGE; *xp++ = (schar) *tp++; } *xpp = (void *)xp; return status;}intncx_putn_schar_double(void **xpp, size_t nelems, const double *tp){ int status = ENOERR; schar *xp = (schar *) *xpp; while(nelems-- != 0) { if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) status = NC_ERANGE; *xp++ = (schar) *tp++; } *xpp = (void *)xp; return status;}intncx_pad_putn_schar_schar(void **xpp, size_t nelems, const schar *tp){ size_t rndup = nelems % X_ALIGN; if(rndup) rndup = X_ALIGN - rndup; (void) memcpy(*xpp, tp, nelems); *xpp = (void *)((char *)(*xpp) + nelems); if(rndup) { (void) memcpy(*xpp, nada, rndup); *xpp = (void *)((char *)(*xpp) + rndup); } return ENOERR;}intncx_pad_putn_schar_uchar(void **xpp, size_t nelems, const uchar *tp){ size_t rndup = nelems % X_ALIGN; if(rndup) rndup = X_ALIGN - rndup; (void) memcpy(*xpp, tp, nelems); *xpp = (void *)((char *)(*xpp) + nelems); if(rndup) { (void) memcpy(*xpp, nada, rndup); *xpp = (void *)((char *)(*xpp) + rndup); } return ENOERR;}intncx_pad_putn_schar_short(void **xpp, size_t nelems, const short *tp){ int status = ENOERR; size_t rndup = nelems % X_ALIGN; schar *xp = (schar *) *xpp; if(rndup) rndup = X_ALIGN - rndup; while(nelems-- != 0) { /* N.B. schar as signed */ if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) status = NC_ERANGE; *xp++ = (schar) *tp++; } if(rndup) { (void) memcpy(xp, nada, rndup); xp += rndup; } *xpp = (void *)xp; return status;}intncx_pad_putn_schar_int(void **xpp, size_t nelems, const int *tp){ int status = ENOERR; size_t rndup = nelems % X_ALIGN; schar *xp = (schar *) *xpp; if(rndup) rndup = X_ALIGN - rndup; while(nelems-- != 0) { /* N.B. schar as signed */ if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) status = NC_ERANGE; *xp++ = (schar) *tp++; } if(rndup) { (void) memcpy(xp, nada, rndup); xp += rndup; } *xpp = (void *)xp; return status;}intncx_pad_putn_schar_long(void **xpp, size_t nelems, const long *tp){ int status = ENOERR; size_t rndup = nelems % X_ALIGN; schar *xp = (schar *) *xpp; if(rndup) rndup = X_ALIGN - rndup; while(nelems-- != 0) { /* N.B. schar as signed */ if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) status = NC_ERANGE; *xp++ = (schar) *tp++; } if(rndup) { (void) memcpy(xp, nada, rndup); xp += rndup; } *xpp = (void *)xp; return status;}intncx_pad_putn_schar_float(void **xpp, size_t nelems, const float *tp){ int status = ENOERR; size_t rndup = nelems % X_ALIGN; schar *xp = (schar *) *xpp; if(rndup) rndup = X_ALIGN - rndup; while(nelems-- != 0) { /* N.B. schar as signed */ if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) status = NC_ERANGE; *xp++ = (schar) *tp++; } if(rndup) { (void) memcpy(xp, nada, rndup); xp += rndup; } *xpp = (void *)xp; return status;}intncx_pad_putn_schar_double(void **xpp, size_t nelems, const double *tp){ int status = ENOERR; size_t rndup = nelems % X_ALIGN; schar *xp = (schar *) *xpp; if(rndup) rndup = X_ALIGN - rndup; while(nelems-- != 0) { /* N.B. schar as signed */ if(*tp > X_SCHAR_MAX || *tp < X_SCHAR_MIN) status = NC_ERANGE; *xp++ = (schar) *tp++; } if(rndup) { (void) memcpy(xp, nada, rndup); xp += rndup; } *xpp = (void *)xp; return status;}/* short */intncx_getn_short_schar(const void **xpp, size_t nelems, schar *tp){ const char *xp = (const char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { const int lstatus = ncx_get_short_schar(xp, tp); if(lstatus != ENOERR) status = lstatus; } *xpp = (const void *)xp; return status;}intncx_getn_short_uchar(const void **xpp, size_t nelems, uchar *tp){ const char *xp = (const char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { const int lstatus = ncx_get_short_uchar(xp, tp); if(lstatus != ENOERR) status = lstatus; } *xpp = (const void *)xp; return status;}#if X_SIZEOF_SHORT == SIZEOF_SHORT/* optimized version */intncx_getn_short_short(const void **xpp, size_t nelems, short *tp){#ifdef WORDS_BIGENDIAN (void) memcpy(tp, *xpp, nelems * sizeof(short));# else swapn2b(tp, *xpp, nelems);# endif *xpp = (const void *)((const char *)(*xpp) + nelems * X_SIZEOF_SHORT); return ENOERR;}#elseintncx_getn_short_short(const void **xpp, size_t nelems, short *tp){ const char *xp = (const char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { const int lstatus = ncx_get_short_short(xp, tp); if(lstatus != ENOERR) status = lstatus; } *xpp = (const void *)xp; return status;}#endifintncx_getn_short_int(const void **xpp, size_t nelems, int *tp){ const char *xp = (const char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { const int lstatus = ncx_get_short_int(xp, tp); if(lstatus != ENOERR) status = lstatus; } *xpp = (const void *)xp; return status;}intncx_getn_short_long(const void **xpp, size_t nelems, long *tp){ const char *xp = (const char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { const int lstatus = ncx_get_short_long(xp, tp); if(lstatus != ENOERR) status = lstatus; } *xpp = (const void *)xp; return status;}intncx_getn_short_float(const void **xpp, size_t nelems, float *tp){ const char *xp = (const char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { const int lstatus = ncx_get_short_float(xp, tp); if(lstatus != ENOERR) status = lstatus; } *xpp = (const void *)xp; return status;}intncx_getn_short_double(const void **xpp, size_t nelems, double *tp){ const char *xp = (const char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { const int lstatus = ncx_get_short_double(xp, tp); if(lstatus != ENOERR) status = lstatus; } *xpp = (const void *)xp; return status;}intncx_pad_getn_short_schar(const void **xpp, size_t nelems, schar *tp){ const size_t rndup = nelems % 2; const char *xp = (const char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { const int lstatus = ncx_get_short_schar(xp, tp); if(lstatus != ENOERR) status = lstatus; } if(rndup != 0) xp += X_SIZEOF_SHORT; *xpp = (void *)xp; return status;}intncx_pad_getn_short_uchar(const void **xpp, size_t nelems, uchar *tp){ const size_t rndup = nelems % 2; const char *xp = (const char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { const int lstatus = ncx_get_short_uchar(xp, tp); if(lstatus != ENOERR) status = lstatus; } if(rndup != 0) xp += X_SIZEOF_SHORT; *xpp = (void *)xp; return status;}intncx_pad_getn_short_short(const void **xpp, size_t nelems, short *tp){ const size_t rndup = nelems % 2; const char *xp = (const char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { const int lstatus = ncx_get_short_short(xp, tp); if(lstatus != ENOERR) status = lstatus; } if(rndup != 0) xp += X_SIZEOF_SHORT; *xpp = (void *)xp; return status;}intncx_pad_getn_short_int(const void **xpp, size_t nelems, int *tp){ const size_t rndup = nelems % 2; const char *xp = (const char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { const int lstatus = ncx_get_short_int(xp, tp); if(lstatus != ENOERR) status = lstatus; } if(rndup != 0) xp += X_SIZEOF_SHORT; *xpp = (void *)xp; return status;}intncx_pad_getn_short_long(const void **xpp, size_t nelems, long *tp){ const size_t rndup = nelems % 2; const char *xp = (const char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { const int lstatus = ncx_get_short_long(xp, tp); if(lstatus != ENOERR) status = lstatus; } if(rndup != 0) xp += X_SIZEOF_SHORT; *xpp = (void *)xp; return status;}intncx_pad_getn_short_float(const void **xpp, size_t nelems, float *tp){ const size_t rndup = nelems % 2; const char *xp = (const char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { const int lstatus = ncx_get_short_float(xp, tp); if(lstatus != ENOERR) status = lstatus; } if(rndup != 0) xp += X_SIZEOF_SHORT; *xpp = (void *)xp; return status;}intncx_pad_getn_short_double(const void **xpp, size_t nelems, double *tp){ const size_t rndup = nelems % 2; const char *xp = (const char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { const int lstatus = ncx_get_short_double(xp, tp); if(lstatus != ENOERR) status = lstatus; } if(rndup != 0) xp += X_SIZEOF_SHORT; *xpp = (void *)xp; return status;}intncx_putn_short_schar(void **xpp, size_t nelems, const schar *tp){ char *xp = (char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { int lstatus = ncx_put_short_schar(xp, tp); if(lstatus != ENOERR) status = lstatus; } *xpp = (void *)xp; return status;}intncx_putn_short_uchar(void **xpp, size_t nelems, const uchar *tp){ char *xp = (char *) *xpp; int status = ENOERR; for( ; nelems != 0; nelems--, xp += X_SIZEOF_SHORT, tp++) { int lstatus = ncx_put_short_uchar(xp, tp); if(lstatus != ENOERR) status = lstatus; } *xpp = (void *)xp; return status;}#if X_SIZEOF_SHORT == SIZEOF_SHORT/* optimized version */intncx_putn_short_short(void **xpp, size_t nelems, const short *tp){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -