Ignore:
Timestamp:
Jul 13, 2020, 8:07:55 PM (4 years ago)
Author:
coas-nagasima
Message:

ntshellアプリはnewlibを使うよう変更し、syscallの実装部分と区別がつくよう更新。

Location:
EcnlProtoTool/trunk/ntshell
Files:
3 added
22 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/ntshell/Debug/Makefile

    r441 r442  
    7171SRCLANG = c
    7272ifeq ($(SRCLANG),c)
    73         LIBS = -lm -lc -lnosys
     73        LIBS = -lm -lc
    7474endif
    7575ifeq ($(SRCLANG),c++)
     
    9393#  (カーネルライブラリもmake対象にする時は,空に定義する)
    9494#
    95 KERNEL_LIB = ../../asp3_dcre/Debug
     95KERNEL_LIB =
    9696
    9797#
     
    9999#  (システムサービスコールライブラリもmake対象にする時は,空に定義する)
    100100#
    101 SYSSVC_LIB = ../../asp3_dcre/Debug
     101SYSSVC_LIB =
    102102
    103103#
     
    209209#
    210210APPLNAME = ntshell
    211 APPLDIRS = ../src ../tlsf ../fatfs ../webserver ../ntshell ../ntshell/core ../ntshell/util
     211APPLDIRS = ../src ../fatfs ../webserver ../ntshell ../ntshell/core ../ntshell/util
    212212APPL_CFG = main.cfg
    213213APPL_CDL = main.cdl
     
    217217ifdef USE_CXX
    218218        APPL_CXXOBJS := main.o
    219         APPL_COBJS := fdtable.o stdio_stub.o pipe_stub.o io_stub.o socket_stub.o tlsf.o ffarch.o diskio.o ff.o sdfs.o ccsbcs.o base64.o http-strings.o http_parser.o httpd.o httpd-fs.o sha1.o websocket.o websocket_fbs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o mbedcall.o ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o netcmd.o
     219        APPL_COBJS := fdtable.o stdio_stub.o pipe_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.o ccsbcs.o base64.o http-strings.o http_parser.o httpd.o httpd-fs.o sha1.o websocket.o websocket_fbs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntstdio.o ntopt.o syscall.o mbedcall.o ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o netcmd.o newlib_stub.o shellif.o
    220220else
    221         APPL_COBJS := main.o fdtable.o stdio_stub.o pipe_stub.o io_stub.o socket_stub.o tlsf.o ffarch.o diskio.o ff.o sdfs.o ccsbcs.o base64.o http-strings.o http_parser.o httpd.o httpd-fs.o sha1.o websocket.o websocket_fbs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o mbedcall.o ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o netcmd.o
     221        APPL_COBJS := main.o fdtable.o stdio_stub.o pipe_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.o ccsbcs.o base64.o http-strings.o http_parser.o httpd.o httpd-fs.o sha1.o websocket.o websocket_fbs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntstdio.o ntopt.o syscall.o mbedcall.o ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o netcmd.o newlib_stub.o shellif.o
    222222endif
    223223APPL_COBJS := $(APPL_COBJS) log_output.o vasyslog.o t_perror.o strerror.o mbed_stub.o
     
    269269                                $(INIT_TECS_COBJ) $(CXXRTS)
    270270SYSSVC_CFLAGS := $(SYSSVC_CFLAGS)
    271 INCLUDES := $(INCLUDES) -I$(TECSGENDIR) -I$(SRCDIR)/tecs_kernel -I../../musl-1.1.18/include
     271INCLUDES := $(INCLUDES) -I$(TECSGENDIR) -I$(SRCDIR)/tecs_kernel
    272272
    273273#
  • EcnlProtoTool/trunk/ntshell/fatfs/ff.c

    r435 r442  
    2020#include "ff.h"                 /* Declarations of FatFs API */
    2121#include "diskio.h"             /* Declarations of disk I/O functions */
    22 #include "util/ntstdio.h"
    2322
    2423/*--------------------------------------------------------------------------
     
    39103909                                        if (dir[DIR_Attr] & AM_DIR) {   /* The new object is a directory */
    39113910                                                temp_new_path = (TCHAR *)ff_memalloc((FF_MAX_LFN + 1) * sizeof(WCHAR));
    3912                                                 ntstdio_snprintf(temp_new_path, FF_MAX_LFN, "%s/%s", path_new, basename((char *)path_old));
     3911                                                snprintf(temp_new_path, FF_MAX_LFN, "%s/%s", path_new, basename((char *)path_old));
    39133912                                                res = follow_path(&djn, temp_new_path);
    39143913                                        }
  • EcnlProtoTool/trunk/ntshell/fatfs/sdfs.c

    r435 r442  
    118118//#include "mbed_debug.h"
    119119#include "mbed_wait_api.h"
    120 #include "util/ntstdio.h"
    121120
    122121void sdfs_debug(const char *fmt, ...);
  • EcnlProtoTool/trunk/ntshell/ntshell/core/ntshell.c

    r331 r442  
    108108 * @param HANDLE A pointer of the handle.
    109109 */
    110 #define PROMPT_WRITE(HANDLE)            SERIAL_WRITE((HANDLE), (HANDLE)->prompt, ntlibc_strlen((HANDLE)->prompt))
     110#define PROMPT_WRITE(HANDLE)            SERIAL_WRITE((HANDLE), (HANDLE)->prompt, strlen((HANDLE)->prompt))
    111111
    112112/**
     
    115115 * @param HANDLE A pointer of the handle.
    116116 */
    117 #define PROMPT_NEWLINE(HANDLE)          SERIAL_WRITE((HANDLE), NTSHELL_PROMPT_NEWLINE, ntlibc_strlen(NTSHELL_PROMPT_NEWLINE))
     117#define PROMPT_NEWLINE(HANDLE)          SERIAL_WRITE((HANDLE), NTSHELL_PROMPT_NEWLINE, strlen(NTSHELL_PROMPT_NEWLINE))
    118118
    119119/**
     
    400400                                 * Found the suggestion.
    401401                                 */
    402                                 int n = ntlibc_strlen((const char *)buf);
     402                                int n = strlen((const char *)buf);
    403403                                VTSEND_ERASE_LINE(ntshell);
    404404                                VTSEND_CURSOR_HEAD(ntshell);
     
    430430                         * Found the suggestion.
    431431                         */
    432                         int n = ntlibc_strlen((const char *)buf);
     432                        int n = strlen((const char *)buf);
    433433                        VTSEND_ERASE_LINE(ntshell);
    434434                        VTSEND_CURSOR_HEAD(ntshell);
     
    442442                         * Recall the previous input text string.
    443443                         */
    444                         int n = ntlibc_strlen(SUGGEST_SOURCE(ntshell));
     444                        int n = strlen(SUGGEST_SOURCE(ntshell));
    445445                        VTSEND_ERASE_LINE(ntshell);
    446446                        VTSEND_CURSOR_HEAD(ntshell);
     
    485485        UNUSED_VARIABLE(ch);
    486486        text_editor_get_text(GET_EDITOR(ntshell), buf, sizeof(buf));
    487         len = ntlibc_strlen((const char *)buf);
     487        len = strlen((const char *)buf);
    488488        VTSEND_CURSOR_HEAD(ntshell);
    489489        PROMPT_WRITE(ntshell);
     
    607607        p->func_callback = func_callback;
    608608        p->extobj = extobj;
    609         ntlibc_strcpy(p->prompt, NTSHELL_PROMPT_DEFAULT);
     609        strcpy(p->prompt, NTSHELL_PROMPT_DEFAULT);
    610610
    611611        p->vtrecv.user_data = p;
     
    667667        }
    668668
    669         ntlibc_strcpy(p->prompt, prompt);
     669        strcpy(p->prompt, prompt);
    670670}
    671671
  • EcnlProtoTool/trunk/ntshell/ntshell/core/text_history.c

    r331 r442  
    146146        char *buf, const int siz)
    147147{
    148         const int text_len = ntlibc_strlen((const char *)text);
     148        const int text_len = strlen((const char *)text);
    149149        int found = 0;
    150150        int i;
     
    152152                int target = (p->rp + i) % TEXTHISTORY_DEPTH;
    153153                char *txtp = p->history + (TEXTHISTORY_MAXLEN * target);
    154                 const int target_len = ntlibc_strlen((const char *)txtp);
     154                const int target_len = strlen((const char *)txtp);
    155155                int comp_len = (target_len < text_len) ? target_len : text_len;
    156                 if ((ntlibc_strncmp(
     156                if ((strncmp(
    157157                        (const char *)txtp,
    158158                        (const char *)text, comp_len) == 0) && (comp_len > 0)) {
    159159                        if (found == index) {
    160                                 if (siz <= ntlibc_strlen(txtp)) {
     160                                if (siz <= strlen(txtp)) {
    161161                                        return -1;
    162162                                }
    163                                 ntlibc_strcpy((char *)buf, (char *)txtp);
     163                                strcpy((char *)buf, (char *)txtp);
    164164                                return 0;
    165165                        }
  • EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c

    r441 r442  
    3232
    3333#include "shellif.h"
     34#include <getopt.h>
    3435#include <kernel.h>
    3536#include <t_syslog.h>
     
    4546#include "core/ntshell.h"
    4647#include "core/ntlibc.h"
    47 #include "util/ntstdio.h"
    48 
    49 extern ntstdio_t *ntstdio;
     48
    5049extern int ntshell_exit;
    51 
    52 /* musl_getopt from msul */
    53 char *optarg;
    54 int /*optind=1, opterr=1, */optopt, optpos, optreset=0;
    55 extern int optind, opterr;
    56 
    57 static void ntstdio_write(ntstdio_t *handle, const char *str, int l)
    58 {
    59         for (; *str && l >= 0; l--) {
    60                 ntstdio_putc(handle, *str++);
    61         }
    62 }
    63 
    64 static void __getopt_msg(const char *a, const char *b, const char *c, size_t l)
    65 {
    66         ntstdio_puts(&ntstdio, a);
    67         ntstdio_write(&ntstdio, b, ntlibc_strlen(b));
    68         ntstdio_write(&ntstdio, c, l);
    69         ntstdio_putc(&ntstdio, '\n');
    70 }
    71 
    72 static int musl_getopt(int argc, char * const argv[], const char *optstring)
    73 {
    74         int i;
    75         wchar_t c, d;
    76         int k, l;
    77         char *optchar;
    78 
    79         if (!optind || optreset) {
    80                 optreset = 0;
    81                 optpos = 0;
    82                 optind = 1;
    83         }
    84 
    85         if (optind >= argc || !argv[optind])
    86                 return -1;
    87 
    88         if (argv[optind][0] != '-') {
    89                 if (optstring[0] == '-') {
    90                         optarg = argv[optind++];
    91                         return 1;
    92                 }
    93                 return -1;
    94         }
    95 
    96         if (!argv[optind][1])
    97                 return -1;
    98 
    99         if (argv[optind][1] == '-' && !argv[optind][2])
    100                 return optind++, -1;
    101 
    102         if (!optpos) optpos++;
    103         if ((k = mbtowc(&c, argv[optind]+optpos, MB_LEN_MAX)) < 0) {
    104                 k = 1;
    105                 c = 0xfffd; /* replacement char */
    106         }
    107         optchar = argv[optind]+optpos;
    108         optopt = c;
    109         optpos += k;
    110 
    111         if (!argv[optind][optpos]) {
    112                 optind++;
    113                 optpos = 0;
    114         }
    115 
    116         if (optstring[0] == '-' || optstring[0] == '+')
    117                 optstring++;
    118 
    119         i = 0;
    120         d = 0;
    121         do {
    122                 l = mbtowc(&d, optstring+i, MB_LEN_MAX);
    123                 if (l>0) i+=l; else i++;
    124         } while (l && d != c);
    125 
    126         if (d != c) {
    127                 if (optstring[0] != ':' && opterr)
    128                         __getopt_msg(argv[0], ": unrecognized option: ", optchar, k);
    129                 return '?';
    130         }
    131         if (optstring[i] == ':') {
    132                 if (optstring[i+1] == ':') optarg = 0;
    133                 else if (optind >= argc) {
    134                         if (optstring[0] == ':') return ':';
    135                         if (opterr) __getopt_msg(argv[0],
    136                                 ": option requires an argument: ",
    137                                 optchar, k);
    138                         return '?';
    139                 }
    140                 if (optstring[i+1] != ':' || optpos) {
    141                         optarg = argv[optind++] + optpos;
    142                         optpos = 0;
    143                 }
    144         }
    145         return c;
    146 }
    14750
    14851void put_rc(const char *func, FRESULT rc)
     
    15861                while (*p++);
    15962        }
    160         ntstdio_printf(ntstdio, "%s() =>%u FR_%s\n", func, (UINT)rc, p);
     63        printf("%s() =>%u FR_%s\n", func, (UINT)rc, p);
    16164}
    16265
     
    17073                while (*p++);
    17174        }
    172         ntstdio_printf(ntstdio, "%s() =>%u %s\n", func, (UINT)rc, p);
     75        printf("%s() =>%u %s\n", func, (UINT)rc, p);
    17376}
    17477
     
    17780        size_t i, j;
    17881        if (!s || !*s) return ".";
    179         i = ntlibc_strlen(s) - 1;
     82        i = strlen(s) - 1;
    18083        for (j = 0; j <= i; j++) if (s[j] == ':') { s = &s[j + 1]; i -= j; break; }
    18184        for (; i&&s[i] == '/'; i--) s[i] = 0;
     
    18992        size_t i, j;
    19093        if (!s || !*s) return ".";
    191         i = ntlibc_strlen(s) - 1;
     94        i = strlen(s) - 1;
    19295        for (j = 0; j <= i; j++) if (s[j] == ':') { s = &s[j + 1]; i -= j; break; }
    19396        for (; s[i] == '/'; i--) if (!i) return (s == _s) ? "/" : _s;
     
    219122        }
    220123
    221         ntlibc_strlcat(path, "\n", sizeof(path));
    222         ntstdio_printf(ntstdio, path);
     124        strlcat(path, "\n", sizeof(path));
     125        printf(path);
    223126
    224127        return 0;
     
    243146
    244147        if (list_option & LS_LONG) {
    245                 ntstdio_printf(ntstdio, "%c%c%c%c%c %04d/%02d/%02d %02d:%02d:%02d ",
     148                printf("%c%c%c%c%c %04d/%02d/%02d %02d:%02d:%02d ",
    246149                        (fno->fattrib & AM_DIR) ? 'd' : '-',
    247150                        (fno->fattrib & AM_RDO) ? 'r' : '-',
     
    257160
    258161                if (fno->fattrib & AM_DIR) {                    /* It is a directory */
    259                         ntstdio_printf(ntstdio, "%10s ", " ");
     162                        printf("%10s ", " ");
    260163                }
    261164                else {
    262                         ntstdio_printf(ntstdio, "%10lu ", fno->fsize);
     165                        printf("%10lu ", fno->fsize);
    263166                }
    264167        }
    265168
    266169        if (fno->fattrib & AM_DIR) {                    /* It is a directory */
    267                 ntstdio_printf(ntstdio, "\x1B[32m%s\x1B[0m\n", fn);
     170                printf("\x1B[32m%s\x1B[0m\n", fn);
    268171        }
    269172        else {
    270                 ntstdio_printf(ntstdio, "%s\n", fn);
     173                printf("%s\n", fn);
    271174        }
    272175}
     
    287190        path_backup = ff_memalloc(LFN_BUF_SIZE);
    288191        if (path_backup == NULL) {
    289                 ntstdio_printf(ntstdio, "ff_memalloc err.\n");
     192                printf("ff_memalloc err.\n");
    290193                return;
    291194        }
     
    295198        lfn = ff_memalloc(LFN_BUF_SIZE);
    296199        if (lfn == NULL) {
    297                 ntstdio_printf(ntstdio, "ff_memalloc err.\n");
     200                printf("ff_memalloc err.\n");
    298201                ff_memfree(path_backup);
    299202                return;
     
    317220                        fn = *fno.lfname ? fno.lfname : fno.fname;
    318221#else
    319                         fn = fno->fname;
     222                        fn = fno.fname;
    320223#endif
    321224                        if ((res = f_getcwd(path_backup, LFN_BUF_SIZE)) != FR_OK) {
     
    331234                        }
    332235
    333                         ntstdio_printf(ntstdio, "\n%s/%s:\n", path_p, fn);
     236                        printf("\n%s/%s:\n", path_p, fn);
    334237
    335238                        print_ls(fn, NULL, list_option);
    336239
    337                         ntstdio_printf(ntstdio, "\n");
     240                        printf("\n");
    338241
    339242                        if ((res = f_chdrive(path_backup)) != FR_OK) {
     
    370273        BYTE list_option = 0;
    371274
    372         while ((c = musl_getopt(argc, argv, "al")) != -1) {
     275        while ((c = getopt(argc, argv, "al")) != -1) {
    373276                switch (c) {
    374277                case 'a':
     
    385288
    386289        if (pattern_p != NULL)
    387                 ntlibc_strlcpy(default_pattern, pattern_p, sizeof(default_pattern));
     290                strlcpy(default_pattern, pattern_p, sizeof(default_pattern));
    388291        basename_p = basename(pattern_p);
    389292        dirname_p = dirname(default_pattern);
    390293        if (((dirname_p[0] == '/') && (basename_p[0] == '/')) ||
    391                 (!ntlibc_strncmp(dirname_p, ".", ntlibc_strlen(dirname_p)) && !ntlibc_strncmp(basename_p, ".", ntlibc_strlen(basename_p))))
     294                (!strncmp(dirname_p, ".", strlen(dirname_p)) && !strncmp(basename_p, ".", strlen(basename_p))))
    392295        {
    393296                basename_p = NULL;
     
    432335        lfn = ff_memalloc(LFN_BUF_SIZE);
    433336        if (lfn == NULL) {
    434                 ntstdio_printf(ntstdio, "alloc err.\n");
     337                printf("alloc err.\n");
    435338                goto cp_end;
    436339        }
     
    442345        local_buff = ff_memalloc(64);
    443346        if (local_buff == NULL) {
    444                 ntstdio_printf(ntstdio, "alloc err.\n");
     347                printf("alloc err.\n");
    445348                goto cp_end;
    446349        }
     
    452355        if (res != FR_OK) {
    453356                if (res == FR_NO_FILE)
    454                         ntstdio_printf(ntstdio, "src no file.\n");
     357                        printf("src no file.\n");
    455358                else
    456                         ntstdio_printf(ntstdio, "src stat err(%d).\n", res);
     359                        printf("src stat err(%d).\n", res);
    457360                goto cp_end;
    458361        }
     
    463366                res = f_open(&src_fp, src_str_p, (FA_OPEN_EXISTING | FA_READ));
    464367                if (res != FR_OK) {
    465                         ntstdio_printf(ntstdio, "src open err(%d).\n", res);
     368                        printf("src open err(%d).\n", res);
    466369                        goto cp_end;
    467370                }
     
    478381                                dst_mod_str_p = ff_memalloc(LFN_BUF_SIZE);
    479382                                if (dst_mod_str_p == NULL) {
    480                                         ntstdio_printf(ntstdio, "alloc err.\n");
     383                                        printf("alloc err.\n");
    481384                                        goto cp_end;
    482385                                }
    483                                 ntstdio_snprintf(dst_mod_str_p, LFN_BUF_SIZE, "%s/%s\0", dst_str_p, src_basename_p);
     386                                snprintf(dst_mod_str_p, LFN_BUF_SIZE, "%s/%s\0", dst_str_p, src_basename_p);
    484387                                dst_str_p = dst_mod_str_p;
    485388                        }
    486389                        else {
    487                                 ntstdio_printf(ntstdio, "dst file exists.\n");
     390                                printf("dst file exists.\n");
    488391                                goto cp_end_1;
    489392                        }
    490393                }
    491394                else {
    492                         ntstdio_printf(ntstdio, "src stat err(%d).\n", res);
     395                        printf("src stat err(%d).\n", res);
    493396                        goto cp_end_1;
    494397                }
     
    496399        res = f_open(&dst_fp, dst_str_p, (FA_CREATE_NEW | FA_WRITE));
    497400        if (res != FR_OK) {
    498                 ntstdio_printf(ntstdio, "dst open err(%d).\n", res);
     401                printf("dst open err(%d).\n", res);
    499402                goto cp_end_1;
    500403        }
     
    507410                res = f_read(&src_fp, local_buff, sizeof(local_buff), &read_size);
    508411                if (res != FR_OK) {
    509                         ntstdio_printf(ntstdio, "src read err(%d).\n", res);
     412                        printf("src read err(%d).\n", res);
    510413                        goto cp_end_2;
    511414                }
     
    514417                res = f_write(&dst_fp, local_buff, read_size, &write_size);
    515418                if (res != FR_OK) {
    516                         ntstdio_printf(ntstdio, "dst write err(%d).\n", res);
     419                        printf("dst write err(%d).\n", res);
    517420                        goto cp_end_2;
    518421                }
    519422                if (read_size != write_size) {
    520                         ntstdio_printf(ntstdio, "dst write err(disk full).\n");
     423                        printf("dst write err(disk full).\n");
    521424                        goto cp_end_2;
    522425                }
     
    604507        unsigned int op_offset = 0, op_size = 0, op_end = 0;
    605508
    606         while ((op = musl_getopt(argc, argv, "hduos0123456789xX")) != -1) {
     509        while ((op = getopt(argc, argv, "hduos0123456789xX")) != -1) {
    607510                switch (op) {
    608511                case 'h': /* help */
    609                         ntstdio_printf(ntstdio, " hexdump [OPTION] file\n");
    610                         ntstdio_printf(ntstdio, "  -h : help\n");
    611                         ntstdio_printf(ntstdio, "  -d : print all byte with convert and color [in character area] (default)\n");
    612                         ntstdio_printf(ntstdio, "  -u : try print UTF-8 code [in character area]\n");
    613                         ntstdio_printf(ntstdio, "  -oOFFSET : print start offset address from top\n");
    614                         ntstdio_printf(ntstdio, "  -sSIZE   : print size\n");
     512                        printf(" hexdump [OPTION] file\n");
     513                        printf("  -h : help\n");
     514                        printf("  -d : print all byte with convert and color [in character area] (default)\n");
     515                        printf("  -u : try print UTF-8 code [in character area]\n");
     516                        printf("  -oOFFSET : print start offset address from top\n");
     517                        printf("  -sSIZE   : print size\n");
    615518                        break;
    616519                case 'd': /* print one byte character [in character area] (default) */
     
    622525                case 'o': /* print start offset address from top */
    623526                        option_ptr = *(argv + optind);
    624                         op_offset = ntlibc_strtoul(&option_ptr[2], &option_endptr, 0);
     527                        op_offset = strtoul(&option_ptr[2], &option_endptr, 0);
    625528                        break;
    626529                case 's': /* print size */
    627530                        option_ptr = *(argv + optind);
    628                         op_size = ntlibc_strtoul(&option_ptr[2], &option_endptr, 0);
     531                        op_size = strtoul(&option_ptr[2], &option_endptr, 0);
    629532                        break;
    630533                default:
     
    643546        /* position adjusting */
    644547        if (op_offset >= fsrc.fsize) {
    645                 ntstdio_printf(ntstdio, "error : input offset is bigger than file size(0x%lX).\n", fsrc.fsize);
     548                printf("error : input offset is bigger than file size(0x%lX).\n", fsrc.fsize);
    646549                return 0;
    647550        }
     
    656559                char *pos = line;
    657560                int rst = sizeof(line);
    658                 int len = ntstdio_snprintf(pos, rst, "%08X: ", i);
     561                int len = snprintf(pos, rst, "%08X: ", i);
    659562                pos += len;
    660563                rst -= len;
     
    675578                        unsigned char c = data[j];
    676579                        if (j != 7)
    677                                 len = ntstdio_snprintf(pos, rst, "%02X ", c);
     580                                len = snprintf(pos, rst, "%02X ", c);
    678581                        else
    679                                 len = ntstdio_snprintf(pos, rst, "%02X-", c);
     582                                len = snprintf(pos, rst, "%02X-", c);
    680583                        pos += len;
    681584                        rst -= len;
     
    705608                                                                break;
    706609                                                        if (j + k != 7)
    707                                                                 len = ntstdio_snprintf(pos, rst, "%02X ", data[j + k]);
     610                                                                len = snprintf(pos, rst, "%02X ", data[j + k]);
    708611                                                        else
    709                                                                 len = ntstdio_snprintf(pos, rst, "%02X-", data[j + k]);
     612                                                                len = snprintf(pos, rst, "%02X-", data[j + k]);
    710613                                                        pos += len;
    711614                                                        rst -= len;
     
    725628                                apos += len;
    726629                                arst -= len;
    727                                 len = ntstdio_snprintf(apos, arst, "\x1B[%dm%c\x1B[0m", CCOLOR_RESET, ' ');
     630                                len = snprintf(apos, arst, "\x1B[%dm%c\x1B[0m", CCOLOR_RESET, ' ');
    728631                                utf8_odd_bytes--;
    729632                        }
     
    745648                                        c = '?';
    746649                                }
    747                                 len = ntstdio_snprintf(apos, arst, "\x1B[%dm%c\x1B[0m", ccolor, c);
     650                                len = snprintf(apos, arst, "\x1B[%dm%c\x1B[0m", ccolor, c);
    748651                        }
    749652
     
    754657                for (int j = br; j < 16; j++) {
    755658                        if (j != 7)
    756                                 len = ntstdio_snprintf(pos, rst, "   ");
     659                                len = snprintf(pos, rst, "   ");
    757660                        else
    758                                 len = ntstdio_snprintf(pos, rst, "  -");
     661                                len = snprintf(pos, rst, "  -");
    759662                        pos += len;
    760663                        rst -= len;
    761664                }
    762665
    763                 len = ntstdio_snprintf(pos, rst, ": %s\n", ascii);
     666                len = snprintf(pos, rst, ": %s\n", ascii);
    764667                pos += len;
    765668                rst -= len;
    766669
    767                 ntstdio_puts(ntstdio, line);
     670                printf(line);
    768671        }
    769672
     
    780683        ret = shell_clock_gettime(CLOCK_REALTIME, &tp);
    781684        if (ret != 0) {
    782                 ntstdio_printf(ntstdio, "clock_gettime error %d", ret);
     685                printf("clock_gettime error %d", ret);
    783686                return 0;
    784687        }
     
    786689        memset(buf, 0, sizeof(buf));
    787690        if (ctime_r(&tp.tv_sec, buf) == NULL) {
    788                 ntstdio_printf(ntstdio, "ctime_r error");
     691                printf("ctime_r error");
    789692                return 0;
    790693        }
    791694
    792695        /* 改行コードの削除 */
    793         ret = ntlibc_strlen(buf);
     696        ret = strlen(buf);
    794697        buf[ret - 1] = '\0';
    795698
    796         ntstdio_printf(ntstdio, "%s .%09ld\n", buf, tp.tv_nsec);
     699        printf("%s .%09ld\n", buf, tp.tv_nsec);
    797700        return 0;
    798701}
     
    801704{
    802705        if (argc != 2) {
    803                 ntstdio_printf(ntstdio, "info sys\n");
    804                 ntstdio_printf(ntstdio, "info ver\n");
    805                 return 0;
    806         }
    807         if (ntlibc_strcmp(argv[1], "sys") == 0) {
    808                 ntstdio_printf(ntstdio, TARGET_NAME" Monitor\n");
    809                 return 0;
    810         }
    811         if (ntlibc_strcmp(argv[1], "ver") == 0) {
     706                printf("info sys\n");
     707                printf("info ver\n");
     708                return 0;
     709        }
     710        if (strcmp(argv[1], "sys") == 0) {
     711                printf(TARGET_NAME" Monitor\n");
     712                return 0;
     713        }
     714        if (strcmp(argv[1], "ver") == 0) {
    812715                int mj, mn, bd;
    813716                ntshell_version(&mj, &mn, &bd);
    814                 ntstdio_printf(ntstdio, "Version %d.%d.%d\n", mj, mn, bd);
    815                 return 0;
    816         }
    817         ntstdio_printf(ntstdio, "Unknown sub command found\n");
     717                printf("Version %d.%d.%d\n", mj, mn, bd);
     718                return 0;
     719        }
     720        printf("Unknown sub command found\n");
    818721        return -1;
    819722}
  • EcnlProtoTool/trunk/ntshell/src/fdtable.c

    r441 r442  
    3636 */
    3737#include "shellif.h"
    38 #include <stdint.h>
    3938#include <kernel.h>
    4039#include <t_syslog.h>
     
    4645#include "fdtable.h"
    4746#include "kernel_cfg.h"
    48 #include <string.h>
    49 #include "util/ntstdio.h"
    5047#include "hal/serial_api.h"
    5148
  • EcnlProtoTool/trunk/ntshell/src/io_stub.c

    r441 r442  
    3636 */
    3737#include "shellif.h"
    38 #include <stdint.h>
    3938#include "ff.h"
    4039#include <kernel.h>
     
    4241#include <t_stdlib.h>
    4342#include <sil.h>
    44 #include <string.h>
    4543#include "syssvc/serial.h"
    4644#include "syssvc/syslog.h"
    4745#include "fdtable.h"
    48 #include "util/ntstdio.h"
    4946#include "usrcmd.h"
    5047#include "core/ntlibc.h"
     
    305302        fi.lfsize = sizeof lfn;
    306303#endif
    307         if (ntlibc_strcmp(path, ".") == 0) {
     304        if (strcmp(path, ".") == 0) {
    308305                char cwd[FF_MAX_LFN];
    309306                if ((ret = f_getcwd(cwd, sizeof(cwd))) != FR_OK) {
    310307                        return fresult2errno(ret);
    311308                }
    312                 int l = ntlibc_strlen(cwd);
     309                int l = strlen(cwd);
    313310                // ルートディレクトリの場合
    314311                if (cwd[l - 2] == ':' && cwd[l - 1] == '/') {
     
    485482        memset(de, 0, sizeof(*de));
    486483#if FF_USE_LFN
    487         ntlibc_strlcpy(de->d_name, *fno.lfname ? fno.lfname : fno.fname, sizeof(de->d_name));
     484        strlcpy(de->d_name, *fno.lfname ? fno.lfname : fno.fname, sizeof(de->d_name));
    488485#else
    489         ntlibc_strlcpy(de->d_name, fno.fname, sizeof(de->d_name));
     486        strlcpy(de->d_name, fno.fname, sizeof(de->d_name));
    490487#endif
    491488
     
    559556pid_t shell_getpid(void)
    560557{
    561         return 1;
     558        return 2;
    562559}
    563560
  • EcnlProtoTool/trunk/ntshell/src/main.c

    r441 r442  
    4040 */
    4141
    42 #include "shellif.h"
    4342#include <kernel.h>
    4443#include <t_stdlib.h>
     
    5150#include "kernel_cfg.h"
    5251#include "main.h"
     52#include "mbed_retarget.h"
    5353#include "fdtable.h"
    5454#ifndef NTSHELL_NO_SOCKET
     
    6969#include "core/ntshell.h"
    7070#include "core/ntlibc.h"
    71 #include "util/ntstdio.h"
    7271#include "usrcmd.h"
    7372#include "util/ntopt.h"
     
    7978ID ws_api_mailboxid = MAIN_DATAQUEUE;
    8079ID ws_mempoolid = MPF_NET_BUF_256;
    81 extern ntstdio_t *ntstdio;
    8280
    8381char command[NTOPT_TEXT_MAXLEN];
    8482
    8583const uint8_t mac_addr[6] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC};
    86 const struct utsname host_name = {
    87         "TOPPERS/ASP3",
    88         TARGET_NAME,
    89         "3.5.0",
    90         "3.5.0",
    91         TARGET_NAME,
    92         "toppers.jp"
    93 };
    94 
    95 int shell_uname(struct utsname *uts)
    96 {
    97         memcpy(uts, &host_name, sizeof(host_name));
    98         return 0;
    99 }
    10084
    10185enum main_state_t {
     
    220204{
    221205        if (text != NULL) {
    222                 ntlibc_strlcpy(command, text, sizeof(command));
     206                strlcpy(command, text, sizeof(command));
    223207        }
    224208        ER ret;
     
    552536                return result;
    553537
    554         if (ntlibc_strcmp((const char *)args[1], "help") == 0) {
    555                 found = 1;
     538        if (strcmp((const char *)args[1], "help") == 0) {
    556539                result = usrcmd_help(args[0], (char **)&args[1]);
    557540        }
    558541        else for (int i = 0; i < cmd_table_info.count; i++) {
    559                 if (ntlibc_strcmp((const char *)args[1], p->cmd) == 0) {
     542                if (strcmp((const char *)args[1], p->cmd) == 0) {
    560543                        found = 1;
    561544                        result = p->func(args[0], (char **)&args[1]);
     
    571554
    572555        if ((found == 0) && (((const char *)args[1])[0] != '\0'))
    573                 ntstdio_printf(ntstdio, "Unknown command found. %s \n", (const char *)args[1]);
     556                printf("Unknown command found. %s \n", (const char *)args[1]);
    574557
    575558        return result;
     
    580563        const cmd_table_t *p = cmd_table_info.table;
    581564        for (int i = 0; i < cmd_table_info.count; i++) {
    582                 ntstdio_puts(ntstdio, p->cmd);
    583                 ntstdio_puts(ntstdio, "\t:");
    584                 ntstdio_puts(ntstdio, p->desc);
    585                 ntstdio_puts(ntstdio, "\n");
     565                printf(p->cmd);
     566                printf("\t:");
     567                puts(p->desc);
    586568                p++;
    587569        }
     
    599581        /* shellcmdタスクの優先度に戻す */
    600582        chg_pri(SHELLCMD_PRIORITY, SHELLCMD_PRIORITY);
    601 }
    602 
    603 void shell_abort()
    604 {
    605         shellcmd_exit_code = -1;
    606         longjmp(shellcmd_exit, 1);
    607 }
    608 
    609 void shell_exit(int exitcd)
    610 {
    611         shellcmd_exit_code = exitcd;
    612         longjmp(shellcmd_exit, 1);
    613 }
    614 
    615 void shell_exit_group(int exitcd)
    616 {
    617         shellcmd_exit_code = exitcd;
    618         longjmp(shellcmd_exit, 1);
    619583}
    620584
     
    679643}
    680644
    681 int shell_clock_getres(clockid_t clk_id, struct timespec *res)
    682 {
    683         if ((clk_id != CLOCK_REALTIME) && (clk_id != CLOCK_MONOTONIC))
    684                 return -EINVAL;
    685 
    686         memset(&res->tv_sec, 0xFF, sizeof(res->tv_sec));
    687         res->tv_nsec = 0;
    688 
    689         return 0;
    690 }
    691 
    692 int shell_clock_gettime(clockid_t clk_id, struct timespec *tp)
    693 {
    694         SYSTIM now = 0;
    695 
    696         if ((clk_id != CLOCK_REALTIME) && (clk_id != CLOCK_MONOTONIC))
    697                 return -EINVAL;
    698 
    699         get_tim(&now);
    700         tp->tv_sec = now / 1000000;
    701         tp->tv_nsec = (now % 1000000) * 1000;
    702 
    703         return 0;
    704 }
    705 
    706 int shell_clock_settime(clockid_t clk_id, const struct timespec *tp)
    707 {
    708         if ((clk_id != CLOCK_REALTIME) && (clk_id != CLOCK_MONOTONIC))
    709                 return -EINVAL;
    710 
    711         SYSTIM time;
    712         ER ret;
    713 
    714         time = (tp->tv_sec * 1000000ll) + (tp->tv_nsec / 1000ll);
    715 
    716         ret = set_tim(time);
    717         if (ret != E_OK) {
    718                 return -EPERM;
    719         }
    720 
    721         return 0;
    722 }
    723 
    724 sigset_t g_sigmask;
    725 
    726 int shell_sigprocmask(int how, const sigset_t *restrict set, sigset_t *restrict old)
    727 {
    728         if (old != NULL)
    729                 memcpy(old, &g_sigmask, sizeof(sigset_t));
    730 
    731         switch (how) {
    732         case SIG_BLOCK:
    733                 for (int i = 0; i < sizeof(g_sigmask.__bits) / sizeof(g_sigmask.__bits[0]); i++) {
    734                         g_sigmask.__bits[i] |= set->__bits[i];
    735                 }
    736                 break;
    737         case SIG_UNBLOCK:
    738                 for (int i = 0; i < sizeof(g_sigmask.__bits) / sizeof(g_sigmask.__bits[0]); i++) {
    739                         g_sigmask.__bits[i] &= ~set->__bits[i];
    740                 }
    741                 break;
    742         case SIG_SETMASK:
    743                 memcpy(&g_sigmask, set, sizeof(sigset_t));
    744                 break;
    745         default:
    746                 return -EINVAL;
    747         }
    748 
    749         return 0;
    750 }
    751 
    752 // musl-1.1.18\src\internal\ksigaction.h
    753 struct k_sigaction {
    754         void(*handler)(int);
    755         unsigned long flags;
    756         void(*restorer)(void);
    757         unsigned mask[2];
    758 };
    759 
    760 struct k_sigaction sigtable[7];
    761 
    762 int shell_sigaction(int sig, const struct k_sigaction *restrict sa,
    763         struct k_sigaction *restrict old, size_t size)
    764 {
    765         struct k_sigaction *sat;
    766 
    767         switch(sig){
    768         case SIGALRM:
    769                 sat = &sigtable[0];
    770                 break;
    771         case SIGFPE:
    772                 sat = &sigtable[1];
    773                 break;
    774         case SIGILL:
    775                 sat = &sigtable[2];
    776                 break;
    777         case SIGSEGV:
    778                 sat = &sigtable[3];
    779                 break;
    780         case SIGBUS:
    781                 sat = &sigtable[4];
    782                 break;
    783         case SIGABRT:
    784                 sat = &sigtable[5];
    785                 break;
    786         case SIGPIPE:
    787                 sat = &sigtable[6];
    788                 break;
    789         default:
    790                 return -EINVAL;
    791         }
    792 
    793         if (old != NULL)
    794                 memcpy(old, sat, offsetof(struct k_sigaction, mask) + size);
    795 
    796         memcpy(sat, sa, offsetof(struct k_sigaction, mask) + size);
    797 
    798         return 0;
    799 }
    800 
    801 int shell_madvise(void *a, size_t b, int c)
    802 {
    803         return 0;
    804 }
    805 
    806 int shell_gettid()
    807 {
    808         ID tskid;
    809         ER ret;
    810 
    811         ret = get_tid(&tskid);
    812         if (ret != E_OK)
    813                 return -1;
    814 
    815         return tskid;
    816 }
    817 
    818 int shell_tkill(int tid, int sig)
    819 {
    820         if ((tid == SHELLCMD_TASK) && (sig == SIGABRT)) {
    821                 shell_abort();
    822         }
    823 
    824         no_implement("tkill");
    825         return -1;
    826 }
    827 
    828 int shell_kill(int pid, int sig)
    829 {
    830         DebugBreak();
    831         return -1;
    832 }
    833 
    834 int shell_gettimeofday(struct timeval *tv, void *tzvp)
    835 {
    836         SYSTIM time;
    837         if (!tv) return 0;
    838         get_tim(&time);
    839         tv->tv_sec = time / 1000000;
    840         tv->tv_usec = time - (tv->tv_sec * 1000000);
    841         return 0;
    842 }
    843 
    844 int shell_nanosleep(const struct timespec *req, struct timespec *rem)
    845 {
    846         ER ret;
    847         TMO tmo;
    848         SYSTIM prev, now, diff;
    849 
    850         if ((req == NULL) || (req->tv_nsec < 0) || (req->tv_nsec >= 1000000000))
    851                 return -EINVAL;
    852 
    853         get_tim(&prev);
    854 
    855         tmo = req->tv_sec * 1000000 + req->tv_nsec / 1000;
    856         ret = tslp_tsk(tmo);
    857         if (ret == E_OK) {
    858                 if (rem != NULL) {
    859                         get_tim(&now);
    860                         diff = now - prev;
    861                         rem->tv_sec = diff / 1000000ll;
    862                         rem->tv_nsec = (diff - (rem->tv_sec * 1000000ll)) * 1000ll;
    863                 }
    864                 return 0;
    865         }
    866         else if (ret == E_TMOUT) {
    867                 if (rem != NULL) {
    868                         rem->tv_sec = 0;
    869                         rem->tv_nsec = 0;
    870                 }
    871                 return 0;
    872         }
    873 
    874         return -EFAULT;
    875 }
    876 
    877 ssize_t shell_getrandom(void *buf, size_t buflen, unsigned int flags)
    878 {
    879         SYSTIM now;
    880         int32_t i;
    881         int *output = (int *)buf;
    882         size_t sz = buflen / 4;
    883 
    884         get_tim(&now);
    885         srand(now);
    886 
    887         for (i = 0; i < sz; i++)
    888                 output[i] = rand();
    889 
    890         for (i = 4 * sz; i < buflen; i++)
    891                 ((char *)buf)[i] = rand();
    892 
    893         return buflen;
    894 }
    895 
    896 extern uint32_t  __CmdBase;
    897 extern uint32_t  __CmdLimit;
    898 
    899 void *shell_brk(void *addr)
    900 {
    901         if (addr == 0) {
    902                 return (void *)((intptr_t)&__CmdBase + 0x40000);
    903         }
    904         if ((addr >= (intptr_t)&__CmdBase + 0x40000) && (addr < &__CmdLimit)) {
    905                 return addr;
    906         }
    907         return (void *)-1;
    908 }
    909 
    910 void *shell_mmap2(void *start, size_t length, int prot, int flags, int fd, off_t pgoffset)
    911 {
    912         if (fd != -1)
    913                 return -EINVAL;
    914 
    915         if ((length >= 0) && (length <= (intptr_t)&__CmdLimit - ((intptr_t)&__CmdBase + 0x40000))) {
    916                 return &__CmdBase + 0x40000;
    917         }
    918         return (void *)-1;
    919 }
    920 
    921 int shell_mprotect(void *addr, size_t len, int prot)
    922 {
    923         //if ((addr >= (intptr_t)&__CmdBase + 0x40000) && ((intptr_t)addr + len < &__CmdLimit)) {
    924                 return 0;
    925         //}
    926         //return -1;
    927 }
  • EcnlProtoTool/trunk/ntshell/src/netcmd.c

    r441 r442  
    4040#include <t_stdlib.h>
    4141#include <sil.h>
    42 #include <string.h>
    4342#include "syssvc/serial.h"
    4443#include "syssvc/syslog.h"
     
    5958#include <netapp/resolver.h>
    6059#include "core/ntlibc.h"
    61 #include "util/ntstdio.h"
    62 #include <stdio.h>
    6360#include "ntp_cli.h"
    6461#include "kernel_cfg.h"
     
    7168extern void ping6(T_IN6_ADDR *addr, uint_t tmo, uint_t len);
    7269extern void ping4(T_IN4_ADDR *addr, uint_t tmo, uint_t len);
    73 extern ntstdio_t *ntstdio;
    7470
    7571/*
     
    255251
    256252        if (apip == '1')
    257                 ntlibc_strcpy(line, i6rlp_pmtu_str1);
     253                strcpy(line, i6rlp_pmtu_str1);
    258254        else if (apip == '2')
    259                 ntlibc_strcpy(line, i6rlp_pmtu_str2);
     255                strcpy(line, i6rlp_pmtu_str2);
    260256        else if (apip == '3')
    261                 ntlibc_strcpy(line, i6rlp_pmtu_str3);
     257                strcpy(line, i6rlp_pmtu_str3);
    262258
    263259#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     
    280276
    281277        if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
    282                 ntstdio_printf(ntstdio, "[PING] unknown host.\n");
     278                printf("[PING] unknown host.\n");
    283279                return 0;
    284280        }
     
    299295#if defined(SUPPORT_INET4)
    300296        if (apip == API_PROTO_IPV6) {
    301                 ntstdio_printf(ntstdio, "[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
     297                printf("[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
    302298                ping6(&addr, (uint_t)tmo, (uint_t)size);
    303299        }
    304300        else {
    305301                addr4 = ntohl(addr.s6_addr32[3]);
    306                 ntstdio_printf(ntstdio, "[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr4));
     302                printf("[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr4));
    307303                ping4(&addr4, (uint_t)tmo, (uint_t)size);
    308304        }
    309305#else /* of #if defined(SUPPORT_INET4) */
    310         ntstdio_printf(ntstdio, "[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
     306        printf("[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
    311307        ping6(&addr, (uint_t)tmo, (uint_t)size);
    312308#endif  /* of #if defined(SUPPORT_INET4) */
    313309#else   /* of #if defined(SUPPORT_INET6) */
    314         ntstdio_printf(ntstdio, "[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr));
     310        printf("[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr));
    315311        ping4(&addr, (uint_t)tmo, (uint_t)size);
    316312#endif  /* of #if defined(SUPPORT_INET6) */
     
    331327                pos = str_ipv4addr(temp, sizeof(temp), &svaddr, 0);
    332328                temp[pos] = '\0';
    333                 ntstdio_printf(ntstdio, "DHCPv4 server: %s,\n", temp);
    334                 ntstdio_printf(ntstdio, "  Renew:       %u:%02u:%02u,\n",
     329                printf("DHCPv4 server: %s,\n", temp);
     330                printf("  Renew:       %u:%02u:%02u,\n",
    335331                        renew / 3600, (renew / 60) % 60, renew % 60);
    336                 ntstdio_printf(ntstdio, "  Rebind:      %u:%02u:%02u, Expire:   %u:%02u:%02u.\n",
     332                printf("  Rebind:      %u:%02u:%02u, Expire:   %u:%02u:%02u.\n",
    337333                        rebind / 3600, (rebind / 60) % 60, rebind % 60,
    338334                        expire / 3600, (expire / 60) % 60, expire % 60);
    339335        }
    340336        else if (ret == E_OBJ)
    341                 ntstdio_printf(ntstdio, "DHCPv4 server: not available.\n");
     337                printf("DHCPv4 server: not available.\n");
    342338}
    343339
     
    349345                return 0;
    350346
    351         if (ntlibc_strcmp(argv[1], "rel") == 0) {
     347        if (strcmp(argv[1], "rel") == 0) {
    352348                ret = dhcp4c_rel_info();
    353                 ntstdio_printf(ntstdio, "dhcp4c_rel_info %d\n", ret);
    354         }
    355         else if (ntlibc_strcmp(argv[1], "renew") == 0) {
     349                printf("dhcp4c_rel_info %d\n", ret);
     350        }
     351        else if (strcmp(argv[1], "renew") == 0) {
    356352                ret = dhcp4c_renew_info();
    357                 ntstdio_printf(ntstdio, "dhcp4c_renew_info %d\n", ret);
     353                printf("dhcp4c_renew_info %d\n", ret);
    358354        }
    359355        else {
     
    383379                else {
    384380                        for (c = 1; c <= *ptr; c++)
    385                                 ntstdio_printf(ntstdio, "%c", *(ptr + c));
     381                                printf("%c", *(ptr + c));
    386382                        ptr += *ptr + 1;
    387383                        if (*ptr)
    388                                 ntstdio_printf(ntstdio, ".");
     384                                printf(".");
    389385                }
    390386        }
     
    406402                return error;
    407403
    408         ntstdio_printf(ntstdio, "    mname:   ");
     404        printf("    mname:   ");
    409405        rn_offset = s_show_dns_domain_name(msg, offset);
    410406        putchar('\n');
    411         ntstdio_printf(ntstdio, "    rname:   ");
     407        printf("    rname:   ");
    412408        s_show_dns_domain_name(msg, rn_offset);
    413409        putchar('\n');
    414410
    415         ntstdio_printf(ntstdio, "    serial:  %d\n", soa.serial);
    416         ntstdio_printf(ntstdio, "    refresh: %d\n", soa.refresh);
    417         ntstdio_printf(ntstdio, "    retry:   %d\n", soa.retry);
    418         ntstdio_printf(ntstdio, "    expirel: %d\n", soa.expire);
    419         ntstdio_printf(ntstdio, "    minimum: %d\n", soa.minimum);
     411        printf("    serial:  %d\n", soa.serial);
     412        printf("    refresh: %d\n", soa.refresh);
     413        printf("    retry:   %d\n", soa.retry);
     414        printf("    expirel: %d\n", soa.expire);
     415        printf("    minimum: %d\n", soa.minimum);
    420416
    421417        return E_OK;
     
    433429        int             scount;
    434430
    435         ntstdio_printf(ntstdio, "question   section: %d\n", rslv->dns_hdr.qdcount);
     431        printf("question   section: %d\n", rslv->dns_hdr.qdcount);
    436432        offset = rslv->qd_offset;
    437433        for (scount = 1; scount <= rslv->dns_hdr.qdcount; scount++) {
     
    439435                        return error;
    440436
    441                 ntstdio_printf(ntstdio, "%2d: ", scount);
     437                printf("%2d: ", scount);
    442438                s_show_dns_domain_name(msg, offset);
    443                 ntstdio_printf(ntstdio, "\n    type: %-4s, class: %2s\n", dns_strtype(qd.type), dns_strclass(qd.class));
     439                printf("\n    type: %-4s, class: %2s\n", dns_strtype(qd.type), dns_strclass(qd.class));
    444440                offset = error;
    445441        }
     
    463459        int pos;
    464460
    465         ntstdio_printf(ntstdio, "%10s section: %d\n", title, scount);
     461        printf("%10s section: %d\n", title, scount);
    466462        for (count = 1; count <= scount; count++) {
    467463                if ((error = dns_analyze_rr(&rr, offset, msg, length)) < 0)
    468464                        return error;
    469465
    470                 ntstdio_printf(ntstdio, "%2d: ", count);
     466                printf("%2d: ", count);
    471467                s_show_dns_domain_name(msg, offset);
    472                 ntstdio_printf(ntstdio, "\n    type: %-4s, class: %2s, TTL: %2d, len: %3d, offset: 0x%02x\n",
     468                printf("\n    type: %-4s, class: %2s, TTL: %2d, len: %3d, offset: 0x%02x\n",
    473469                        dns_strtype(rr.type), dns_strclass(rr.class), rr.ttl, rr.rdlength, rr.rdata_offset);
    474470
     
    479475                        pos = str_ipv4addr(temp, sizeof(temp), &in4_addr, 0);
    480476                        temp[pos] = '\0';
    481                         ntstdio_printf(ntstdio, "    IPv4 addr: %s\n", temp);
     477                        printf("    IPv4 addr: %s\n", temp);
    482478                        break;
    483479                case DNS_TYPE_NS:
    484                         ntstdio_printf(ntstdio, "    host: ");
     480                        printf("    host: ");
    485481                        s_show_dns_domain_name(msg, rr.rdata_offset);
    486482                        putchar('\n');
    487483                        break;
    488484                case DNS_TYPE_CNAME:
    489                         ntstdio_printf(ntstdio, "    host: ");
     485                        printf("    host: ");
    490486                        s_show_dns_domain_name(msg, rr.rdata_offset);
    491487                        putchar('\n');
     
    495491                        break;
    496492                case DNS_TYPE_PTR:
    497                         ntstdio_printf(ntstdio, "     PTR: ");
     493                        printf("     PTR: ");
    498494                        s_show_dns_domain_name(msg, rr.rdata_offset);
    499495                        putchar('\n');
     
    503499                        pos = str_ipv6addr(temp, sizeof(temp), &in6_addr, 0);
    504500                        temp[pos] = '\0';
    505                         ntstdio_printf(ntstdio, "    IPv6 addr: %s\n", temp);
     501                        printf("    IPv6 addr: %s\n", temp);
    506502                        break;
    507503                default:
    508                         ntstdio_printf(ntstdio, "    data: ");
     504                        printf("    data: ");
    509505                        col = 32;
    510506                        for (dcount = 0; dcount < rr.rdlength; dcount++) {
    511                                 ntstdio_printf(ntstdio, "%02x", *(msg + rr.rdata_offset + dcount));
     507                                printf("%02x", *(msg + rr.rdata_offset + dcount));
    512508                                if (--col == 0) {
    513                                         ntstdio_printf(ntstdio, "\n          ");
     509                                        printf("\n          ");
    514510                                        col = 32;
    515511                                }
     
    539535#if defined(SUPPORT_INET6)
    540536
    541         ntstdio_printf(ntstdio, "domain name:     %s\n", dns_in6_get_dname());
     537        printf("domain name:     %s\n", dns_in6_get_dname());
    542538
    543539#else   /* of #if defined(SUPPORT_INET6) */
    544540
    545         ntstdio_printf(ntstdio, "domain name:     %s\n", dns_in4_get_dname());
     541        printf("domain name:     %s\n", dns_in4_get_dname());
    546542
    547543#endif  /* of #if defined(SUPPORT_INET6) */
     
    549545#if defined(SUPPORT_INET6)
    550546        dns_in6_get_addr(&in6_addr);
    551         ntstdio_printf(ntstdio, "IPv6 DNS server: ");
     547        printf("IPv6 DNS server: ");
    552548        if (IN6_IS_ADDR_UNSPECIFIED(&in6_addr))
    553                 ntstdio_printf(ntstdio, "not available.\n");
     549                printf("not available.\n");
    554550        else {
    555551                pos = str_ipv6addr(temp, sizeof(temp), &in6_addr, 0);
    556552                temp[pos] = '\0';
    557                 ntstdio_printf(ntstdio, "%s.\n", temp);
     553                printf("%s.\n", temp);
    558554        }
    559555#endif  /* of #if defined(SUPPORT_INET6) */
     
    561557#if defined(SUPPORT_INET4)
    562558        dns_in4_get_addr(&in4_addr);
    563         ntstdio_printf(ntstdio, "IPv4 DNS server: ");
     559        printf("IPv4 DNS server: ");
    564560        if (in4_addr == IPV4_ADDRANY)
    565                 ntstdio_printf(ntstdio, "not available.\n");
     561                printf("not available.\n");
    566562        else {
    567563                pos = str_ipv4addr(temp, sizeof(temp), &in4_addr, 0);
    568564                temp[pos] = '\0';
    569                 ntstdio_printf(ntstdio, "%s.\n", temp);
     565                printf("%s.\n", temp);
    570566        }
    571567#endif  /* of #if defined(SUPPORT_INET4) */
     
    596592        uint8_t         *msg;
    597593
    598         if (ntlibc_strcmp(line, "info") == 0) {
     594        if (strcmp(line, "info") == 0) {
    599595                dns_info();
    600596                return 0;
     
    604600        line = skip_blanks(resolv_options(&flags, line, DEFAULT_API_PROTO));
    605601        if ((flags & (DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4)) == 0) {
    606                 ntstdio_printf(ntstdio, "DNS server not available.\n");
     602                printf("DNS server not available.\n");
    607603                return 0;
    608604        }
     
    620616
    621617        if ((error = tget_mpf(MPF_RSLV_SRBUF, (void*)&msg, TMO_FEVR)) != E_OK) {
    622                 ntstdio_printf(ntstdio, "get buffer error: %s.\n", itron_strerror(error));
     618                printf("get buffer error: %s.\n", itron_strerror(error));
    623619                return 0;
    624620        }
    625621
    626622        if ((length = dns_lookup_host(flags | DNS_LUP_FLAGS_MSG, line, msg, DNS_UDP_MSG_LENGTH, &rslv)) < 0) {
    627                 //ntstdio_printf(ntstdio, "error: %s.\n", itron_strerror(length));
     623                //printf("error: %s.\n", itron_strerror(length));
    628624                goto err_ret;
    629625        }
    630626
    631627        dly_tsk(1 * 1000);
    632         ntstdio_printf(ntstdio, "DNS header: flags: ");
     628        printf("DNS header: flags: ");
    633629        if (rslv.dns_hdr.code & (DNS_QR_RESPONSE | DNS_AUTHORITATIVE |
    634630                DNS_TRUN_CATION | DNS_RECURSION_DESIRED | DNS_RECURSION_AVAILABLE)) {
    635                 ntstdio_printf(ntstdio, (rslv.dns_hdr.code & DNS_QR_RESPONSE) ? "QR," : "");
    636                 ntstdio_printf(ntstdio, (rslv.dns_hdr.code & DNS_AUTHORITATIVE) ? "AA," : "");
    637                 ntstdio_printf(ntstdio, (rslv.dns_hdr.code & DNS_TRUN_CATION) ? "TC," : "");
    638                 ntstdio_printf(ntstdio, (rslv.dns_hdr.code & DNS_RECURSION_DESIRED) ? "RD," : "");
    639                 ntstdio_printf(ntstdio, (rslv.dns_hdr.code & DNS_RECURSION_AVAILABLE) ? "RA," : "");
    640                 ntstdio_printf(ntstdio, " ");
    641         }
    642         ntstdio_printf(ntstdio, "opcode: ");
    643         ntstdio_printf(ntstdio, (rslv.dns_hdr.code & DNS_OPCODE_REVERSE) ? "RV" : "FW");
    644         ntstdio_printf(ntstdio, (rslv.dns_hdr.code & DNS_OPCODE_STATUS) ? ",ST" : "");
    645         ntstdio_printf(ntstdio, ", rcode: %s.\n",
     631                printf((rslv.dns_hdr.code & DNS_QR_RESPONSE) ? "QR," : "");
     632                printf((rslv.dns_hdr.code & DNS_AUTHORITATIVE) ? "AA," : "");
     633                printf((rslv.dns_hdr.code & DNS_TRUN_CATION) ? "TC," : "");
     634                printf((rslv.dns_hdr.code & DNS_RECURSION_DESIRED) ? "RD," : "");
     635                printf((rslv.dns_hdr.code & DNS_RECURSION_AVAILABLE) ? "RA," : "");
     636                printf(" ");
     637        }
     638        printf("opcode: ");
     639        printf((rslv.dns_hdr.code & DNS_OPCODE_REVERSE) ? "RV" : "FW");
     640        printf((rslv.dns_hdr.code & DNS_OPCODE_STATUS) ? ",ST" : "");
     641        printf(", rcode: %s.\n",
    646642                (rslv.dns_hdr.code & DNS_RCODE_MASK) > DNS_RCODE_REFUSED
    647643                ? "6" : rcode_str[rslv.dns_hdr.code & DNS_RCODE_MASK]);
    648644
    649645        if ((offset = show_dns_qdsection(msg, length, &rslv)) < 0) {
    650                 ntstdio_printf(ntstdio, "msg error: %s.\n", itron_strerror(offset));
     646                printf("msg error: %s.\n", itron_strerror(offset));
    651647        }
    652648        if ((offset = show_dns_section(msg, length, rslv.dns_hdr.ancount, rslv.an_offset, "answer")) < 0) {
    653                 ntstdio_printf(ntstdio, "msg error: %s.\n", itron_strerror(offset));
     649                printf("msg error: %s.\n", itron_strerror(offset));
    654650        }
    655651        if ((offset = show_dns_section(msg, length, rslv.dns_hdr.nscount, rslv.ns_offset, "authority")) < 0) {
    656                 ntstdio_printf(ntstdio, "msg error: %s.\n", itron_strerror(offset));
     652                printf("msg error: %s.\n", itron_strerror(offset));
    657653        }
    658654        if ((offset = show_dns_section(msg, length, rslv.dns_hdr.arcount, rslv.ar_offset, "additional")) < 0) {
    659                 ntstdio_printf(ntstdio, "msg error: %s.\n", itron_strerror(offset));
     655                printf("msg error: %s.\n", itron_strerror(offset));
    660656        }
    661657
    662658err_ret:
    663659        if ((error = rel_mpf(MPF_RSLV_SRBUF, msg)) != E_OK)
    664                 ntstdio_printf(ntstdio, "release buffer error: %s.\n", itron_strerror(error));
     660                printf("release buffer error: %s.\n", itron_strerror(error));
    665661        return 0;
    666662}
  • EcnlProtoTool/trunk/ntshell/src/ntp_cli.c

    r441 r442  
    271271
    272272        nc->buf[0] = '\0';
    273 #ifdef __NEED_struct_timespec
     273#ifdef _TIME_H_
    274274        if (ctime_r(&tp.tv_sec, nc->buf) != NULL)
    275275#else
  • EcnlProtoTool/trunk/ntshell/src/pipe_stub.c

    r441 r442  
    3636 */
    3737#include "shellif.h"
    38 #include <stdint.h>
    3938#include <kernel.h>
    4039#include <t_syslog.h>
     
    4645#include "fdtable.h"
    4746#include "kernel_cfg.h"
    48 #include <string.h>
    49 #include "util/ntstdio.h"
    5047#include "hal/serial_api.h"
    5148
  • EcnlProtoTool/trunk/ntshell/src/shellif.h

    r441 r442  
    8888#define NCCS 32
    8989
     90#include "../musl-1.1.18/include/stdint.h"
     91#include "../musl-1.1.18/include/strings.h"
     92#define _STRINGS_H_ // newlibのstrings.hのincludeを抑止
     93#include "../musl-1.1.18/include/string.h"
     94#define _STRING_H_ // newlibのstring.hのincludeを抑止
    9095#include "../musl-1.1.18/include/bits/fcntl.h"
    9196#include "../musl-1.1.18/include/bits/termios.h"
     
    9398#include "../musl-1.1.18/include/sys/select.h"
    9499#include "../musl-1.1.18/include/time.h"
     100#define _TIME_H_ // newlibのtime.hのincludeを抑止
    95101#include "../musl-1.1.18/include/signal.h"
    96102#include "../musl-1.1.18/include/stdio.h"
     103#define _STDIO_H_ // newlibのstdio.hのincludeを抑止
    97104#include "../musl-1.1.18/include/sys/utsname.h"
    98105#include "../musl-1.1.18/include/dirent.h"
     
    104111#include <stddef.h>
    105112#include <stdarg.h>
     113#include <setjmp.h>
    106114
    107115#define DebugBreak()    asm("bkpt #0")
  • EcnlProtoTool/trunk/ntshell/src/socket_stub.c

    r441 r442  
    3939#include <t_syslog.h>
    4040#include <t_stdlib.h>
    41 #include <string.h>
    4241#include <sil.h>
    4342#include "syssvc/syslog.h"
  • EcnlProtoTool/trunk/ntshell/src/stdio_stub.c

    r441 r442  
    3636 */
    3737#include "shellif.h"
    38 #include <stdint.h>
    3938#include <kernel.h>
    4039#include <t_syslog.h>
     
    4645#include "fdtable.h"
    4746#include "kernel_cfg.h"
    48 #include <string.h>
    49 #include <errno.h>
    5047#include "util/ntstdio.h"
    5148#include "hal/serial_api.h"
     
    5855#endif
    5956
    60 int shell_errno;
     57#undef errno
     58extern int errno;
    6159
    6260extern bool_t sio_isr_snd(ID siopid);
     
    105103
    106104stdio_sio_t stdio_sio;
    107 ntstdio_t *ntstdio = &stdio_sio.ntstdio;
    108105
    109106void sys_init(intptr_t exinf)
     
    573570        struct SHELL_FILE *fp = fd_to_fp(fd);
    574571        if ((fp == NULL) || (fp->type != &IO_TYPE_SIO)) {
    575                 shell_errno = EBADF;
     572                errno = EBADF;
    576573                return -1;
    577574        }
    578575
    579         shell_errno = sio_close(fp);
    580         if (shell_errno != 0)
     576        errno = sio_close(fp);
     577        if (errno != 0)
    581578                return 1;
    582579        return 0;
     
    587584        struct SHELL_FILE *fp = fd_to_fp(fd);
    588585        if ((fp == NULL) || ((fp->type != &IO_TYPE_STDIN) && (fp->type != &IO_TYPE_SIO))) {
    589                 shell_errno = EBADF;
     586                errno = EBADF;
    590587                return -1;
    591588        }
     
    604601        if ((fp == NULL) || ((fp->type != &IO_TYPE_STDOUT) && (fp->type != &IO_TYPE_STDERR)
    605602                && (fp->type != &IO_TYPE_SIO))) {
    606                 shell_errno = EBADF;
     603                errno = EBADF;
    607604                return -1;
    608605        }
     
    621618        if ((fp == NULL) || ((fp->type != &IO_TYPE_STDIN) && (fp->type != &IO_TYPE_STDOUT)
    622619                && (fp->type != &IO_TYPE_STDERR) && (fp->type != &IO_TYPE_SIO))) {
    623                 shell_errno = EBADF;
     620                errno = EBADF;
    624621                return -1;
    625622        }
    626623
    627         shell_errno = sio_tcsetattr(fp, act, tio);
    628         if (shell_errno != 0)
     624        errno = sio_tcsetattr(fp, act, tio);
     625        if (errno != 0)
    629626                return 1;
    630627        return 0;
     
    636633        if ((fp == NULL) || ((fp->type != &IO_TYPE_STDIN) && (fp->type != &IO_TYPE_STDOUT)
    637634                && (fp->type != &IO_TYPE_STDERR) && (fp->type != &IO_TYPE_SIO))) {
    638                 shell_errno = EBADF;
     635                errno = EBADF;
    639636                return -1;
    640637        }
    641638
    642         shell_errno = sio_tcgetattr(fp, tio);
    643         if (shell_errno != 0)
     639        errno = sio_tcgetattr(fp, tio);
     640        if (errno != 0)
    644641                return 1;
    645642        return 0;
     
    651648        if ((fp == NULL) || ((fp->type != &IO_TYPE_STDIN) && (fp->type != &IO_TYPE_STDOUT)
    652649                && (fp->type != &IO_TYPE_STDERR) && (fp->type != &IO_TYPE_SIO))) {
    653                 shell_errno = EBADF;
     650                errno = EBADF;
    654651                return -1;
    655652        }
     
    660657        va_end(ap);
    661658
    662         shell_errno = sio_ioctl(fp, cmd, arg);
    663         if (shell_errno != 0)
     659        errno = sio_ioctl(fp, cmd, arg);
     660        if (errno != 0)
    664661                return 1;
    665662        return 0;
  • EcnlProtoTool/trunk/ntshell/src/syscall.c

    r441 r442  
    102102        case SYS__llseek:
    103103                ret = shell_llseek(r->a, (((off_t)r->b) << 32) + (off_t)r->c, (off_t *)r->d, r->e);
     104                break;
    104105        case SYS__newselect:
    105106                ret = shell_select(r->a, (fd_set *)r->b, (fd_set *)r->c, (fd_set *)r->d, (struct timeval *)r->e);
  • EcnlProtoTool/trunk/ntshell/src/tSIOPortNTShell.cdl

    r441 r442  
    4949 *  NTShell に関する定義
    5050 */
    51 import_C("termios.h");
     51import_C("mbed_retarget.h");
    5252
    5353/*
  • EcnlProtoTool/trunk/ntshell/src/tSIOPortNTShellMain.c

    r441 r442  
    4646#include <t_syslog.h>
    4747#include <errno.h>
    48 #include <termios.h>
    49 #include <unistd.h>
    50 #include <fcntl.h>
    5148#include "tSIOPortNTShellMain_tecsgen.h"
    5249#include "syssvc/siofd.h"
    5350 
    54 extern int shell_errno;
     51#undef errno
     52extern int errno;
    5553
    5654/*
     
    130128                }
    131129                else {
    132                         assert(n < 0 && shell_errno == EAGAIN);
     130                        assert(n < 0 && errno == EAGAIN);
    133131                        VAR_snd_flag = true;
    134132                        VAR_snd_buf = c;
     
    159157        }
    160158        else {
    161                 assert(n < 0 && shell_errno == EAGAIN);
     159                assert(n < 0 && errno == EAGAIN);
    162160                return(-1);
    163161        }
  • EcnlProtoTool/trunk/ntshell/webserver/base64.c

    r331 r442  
    8686    unsigned char *pdst;
    8787    int i, j = 0, k = 0;
    88     size_t srcsiz = ntlibc_strlen((const char *)src);
     88    size_t srcsiz = strlen((const char *)src);
    8989
    9090    if ((srcsiz % 4) != 0) {
  • EcnlProtoTool/trunk/ntshell/webserver/http_parser.c

    r331 r442  
    23722372  if (u->field_set & (1 << UF_PORT)) {
    23732373    /* Don't bother with endp; we've already validated the string */
    2374     unsigned long v = ntlibc_strtoul(buf + u->field_data[UF_PORT].off, NULL, 10);
     2374    unsigned long v = strtoul(buf + u->field_data[UF_PORT].off, NULL, 10);
    23752375
    23762376    /* Ports have a max value of 2^16 */
  • EcnlProtoTool/trunk/ntshell/webserver/httpd-fs.c

    r441 r442  
    4545#include "kernel_cfg.h"
    4646#include "syssvc/syslog.h"
    47 #include "util/ntstdio.h"
    4847
    4948#ifndef _MSC_VER
    5049#ifndef strcat_s
    51 #define strcat_s(dst, dsz, src) ntlibc_strcat(dst, src)
     50#define strcat_s(dst, dsz, src) strcat(dst, src)
    5251#endif
    5352#endif
     
    6261#define NULL 0
    6362#endif /* NULL */
    64 
    65 extern ntstdio_t *ntstdio;
    6663
    6764/*-----------------------------------------------------------------------------------*/
     
    7774        res = f_opendir(&dir, path);
    7875        if (res == FR_OK) {
    79                 i = ntlibc_strlen(path);
     76                i = strlen(path);
    8077                for (;;) {
    8178                        res = f_readdir(&dir, &fno);
     
    8380                        fn = fno.fname;
    8481                        if (fno.fattrib & AM_DIR) {
    85                                 ntstdio_sprintf(&path[i], "0:/%s", fn);
     82                                sprintf(&path[i], "0:/%s", fn);
    8683                                res = scan_files(path, size);
    8784                                if (res != FR_OK) break;
     
    8986                        }
    9087                        else {
    91                                 ntstdio_printf(ntstdio, "%s/%s\n", path, fn);
     88                                printf("%s/%s\n", path, fn);
    9289                        }
    9390                }
     
    114111        if ((res = f_open(fd, name, FA_OPEN_EXISTING | FA_READ)) != FR_OK) {
    115112                if ((res = f_opendir(&dir, name)) != FR_OK) {
    116                         ntstdio_printf(ntstdio, "f_opendir(%s) => %d\n", name, res);
     113                        printf("f_opendir(%s) => %d\n", name, res);
    117114                        return 0;
    118115                }
    119116
    120117                if ((res = f_readdir(&dir, &fno)) != FR_OK) {
    121                         ntstdio_printf(ntstdio, "f_readdir(%s) => %d\n", name, res);
     118                        printf("f_readdir(%s) => %d\n", name, res);
    122119                        return 0;
    123120                }
     
    132129
    133130                if (res != FR_OK) {
    134                         ntstdio_printf(ntstdio, "f_open(%s) => %d %x\n", name, res, fno.fattrib);
     131                        printf("f_open(%s) => %d %x\n", name, res, fno.fattrib);
    135132                        return 0;
    136133                }
     
    139136        file->len = fd->fsize;
    140137
    141         //ntstdio_printf(ntstdio, "httpd_fs_open(%s) %d\n", name, file->len);
     138        //printf("httpd_fs_open(%s) %d\n", name, file->len);
    142139
    143140        return 1;
     
    158155
    159156        if ((res = f_open(fd, name, FA_CREATE_ALWAYS | FA_WRITE)) != FR_OK) {
    160                 ntstdio_printf(ntstdio, "f_open(%s) => %d\n", name, res);
     157                printf("f_open(%s) => %d\n", name, res);
    161158                return 0;
    162159        }
     
    165162        file->len = 0;
    166163
    167         //ntstdio_printf(ntstdio, "httpd_fs_create(%s) %d\n", file->name, file->len);
     164        //printf("httpd_fs_create(%s) %d\n", file->name, file->len);
    168165
    169166        return 1;
     
    179176
    180177        if ((ret = f_lseek(fd, file->pos)) != FR_OK) {
    181                 ntstdio_printf(ntstdio, "f_lseek(%s, %d) => %d\n", file->name, file->pos, ret);
     178                printf("f_lseek(%s, %d) => %d\n", file->name, file->pos, ret);
    182179                return 0;
    183180        }
    184181
    185182        if (file->pos != fd->fptr) {
    186                 ntstdio_printf(ntstdio, "f_lseek(%s, %d) != %d\n", file->name, file->pos, fd->fptr);
     183                printf("f_lseek(%s, %d) != %d\n", file->name, file->pos, fd->fptr);
    187184        }
    188185
    189186        if ((ret = f_read(fd, dst, len, &rlen)) != FR_OK) {
    190                 ntstdio_printf(ntstdio, "f_read(%s, 0x%p, %d) => %d\n", file->name, dst, len, ret);
    191                 return 0;
    192         }
    193 
    194         //ntstdio_printf(ntstdio, "httpd_fs_read(%s, %d, %d) => %d\n", file->name, file->pos, len, rlen);
     187                printf("f_read(%s, 0x%p, %d) => %d\n", file->name, dst, len, ret);
     188                return 0;
     189        }
     190
     191        //printf("httpd_fs_read(%s, %d, %d) => %d\n", file->name, file->pos, len, rlen);
    195192
    196193        return rlen;
     
    206203
    207204        if ((ret = f_lseek(fd, file->pos)) != FR_OK) {
    208                 ntstdio_printf(ntstdio, "f_lseek(%s, %d) => %d\n", file->name, file->pos, ret);
     205                printf("f_lseek(%s, %d) => %d\n", file->name, file->pos, ret);
    209206                return 0;
    210207        }
    211208
    212209        if (file->pos != fd->fptr) {
    213                 ntstdio_printf(ntstdio, "f_lseek(%s, %d) != %d\n", file->name, file->pos, fd->fptr);
     210                printf("f_lseek(%s, %d) != %d\n", file->name, file->pos, fd->fptr);
    214211        }
    215212
    216213        if ((ret = f_write(fd, src, len, &rlen)) != FR_OK) {
    217                 ntstdio_printf(ntstdio, "f_write(%s, 0x%p, %d) => %d\n", file->name, src, len, ret);
     214                printf("f_write(%s, 0x%p, %d) => %d\n", file->name, src, len, ret);
    218215                return 0;
    219216        }
     
    222219        file->len += rlen;
    223220
    224         //ntstdio_printf(ntstdio, "httpd_fs_write(%s, %d, %d) => %d\n", file->name, file->pos, len, rlen);
     221        //printf("httpd_fs_write(%s, %d, %d) => %d\n", file->name, file->pos, len, rlen);
    225222
    226223        return rlen;
     
    234231
    235232        if ((ret = f_close(fd)) != FR_OK) {
    236                 ntstdio_printf(ntstdio, "f_close(%s) => %d\n", file->name, ret);
     233                printf("f_close(%s) => %d\n", file->name, ret);
    237234                return 0;
    238235        }
  • EcnlProtoTool/trunk/ntshell/webserver/httpd.c

    r441 r442  
    5353#include "base64.h"
    5454#include "sha1.h"
    55 #include "util/ntstdio.h"
    5655#include "core/ntlibc.h"
    5756
     
    5958#define FALSE 0
    6059
    61 extern ntstdio_t *ntstdio;
    6260SYSTIM httpd_time;
    6361struct httpd_state *uploding;
     
    111109void strcpy_s(char *dst, int size, const char *src)
    112110{
    113         int slen = ntlibc_strlen(src);
     111        int slen = strlen(src);
    114112        if (slen >= size)
    115113                slen = size - 1;
     
    120118void strcat_s(char *dst, int size, const char *src)
    121119{
    122         int dlen = ntlibc_strlen(dst);
    123         int slen = ntlibc_strlen(src);
     120        int dlen = strlen(dst);
     121        int slen = strlen(src);
    124122        if (dlen + slen >= size)
    125123                slen = size - 1 - dlen;
     
    235233        struct message *m = &s->message;
    236234
    237         if (ntlibc_strncmp("Referer", buf, len) == 0) {
     235        if (strncmp("Referer", buf, len) == 0) {
    238236                m->num_headers = 1;
    239237        }
    240         else if (ntlibc_strncmp("Host", buf, len) == 0) {
     238        else if (strncmp("Host", buf, len) == 0) {
    241239                m->num_headers = 2;
    242240        }
    243         else if (ntlibc_strncmp("Upgrade", buf, len) == 0) {
     241        else if (strncmp("Upgrade", buf, len) == 0) {
    244242                m->num_headers = 3;
    245243        }
    246         else if (ntlibc_strncmp("Connection", buf, len) == 0) {
     244        else if (strncmp("Connection", buf, len) == 0) {
    247245                m->num_headers = 4;
    248246        }
    249         else if (ntlibc_strncmp("Sec-WebSocket-Key", buf, len) == 0) {
     247        else if (strncmp("Sec-WebSocket-Key", buf, len) == 0) {
    250248                m->num_headers = 5;
    251249        }
    252         else if (ntlibc_strncmp("Origin", buf, len) == 0) {
     250        else if (strncmp("Origin", buf, len) == 0) {
    253251                m->num_headers = 6;
    254252        }
    255         else if (ntlibc_strncmp("Sec-WebSocket-Protocol", buf, len) == 0) {
     253        else if (strncmp("Sec-WebSocket-Protocol", buf, len) == 0) {
    256254                m->num_headers = 7;
    257255        }
    258         else if (ntlibc_strncmp("Sec-WebSocket-Version", buf, len) == 0) {
     256        else if (strncmp("Sec-WebSocket-Version", buf, len) == 0) {
    259257                m->num_headers = 8;
    260258        }
     
    334332                        // アップロード先はSDカード
    335333                        s->filename[0] = '1';
    336                         ntstdio_printf(ntstdio, "create:    %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
     334                        printf("create:    %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
    337335                        if (!httpd_fs_create(s->filename, &s->file)) {
    338336                                goto error;
     
    341339                        s->in.state = IN_STATE_UPLOAD;
    342340                }
    343                 else if (ntlibc_strcmp(s->filename, uploding->filename) == 0) {
    344                         ntstdio_printf(ntstdio, "collision: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
     341                else if (strcmp(s->filename, uploding->filename) == 0) {
     342                        printf("collision: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
    345343                        goto error;
    346344                }
     
    374372
    375373        if (s->message.body_is_final) {
    376                 ntstdio_printf(ntstdio, "\n\n *** Error http_body_is_final() should return 1 \n"
     374                printf("\n\n *** Error http_body_is_final() should return 1 \n"
    377375                        "on last on_body callback call "
    378376                        "but it doesn't! ***\n\n");
     
    387385
    388386        if (s->message.body_is_final) {
    389                 ntstdio_printf(ntstdio, "close:     %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
     387                printf("close:     %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
    390388                httpd_fs_close(&s->file);
    391389                memset(&s->file, 0, sizeof(s->file));
     
    412410        struct httpd_state *s = get_context(p);
    413411        if (s->message.should_keep_alive != http_should_keep_alive(p)) {
    414                 ntstdio_printf(ntstdio, "\n\n *** Error http_should_keep_alive() should have same \n"
     412                printf("\n\n *** Error http_should_keep_alive() should have same \n"
    415413                        "value in both on_message_complete and on_headers_complete "
    416414                        "but it doesn't! ***\n\n");
     
    421419                http_body_is_final(p) &&
    422420                !s->message.body_is_final) {
    423                 ntstdio_printf(ntstdio, "\n\n *** Error http_body_is_final() should return 1 \n"
     421                printf("\n\n *** Error http_body_is_final() should return 1 \n"
    424422                        "on last on_body callback call "
    425423                        "but it doesn't! ***\n\n");
     
    493491                slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
    494492                if (slen < 0) {
    495                         ntstdio_printf(ntstdio, "send_file#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
     493                        printf("send_file#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
    496494                        s->state = STATE_CLOSING;
    497495                        break;
     
    506504                len = httpd_fs_read(&s->file, buf, len);
    507505                if (len <= 0) {
    508                         ntstdio_printf(ntstdio, "send_file#httpd_fs_read(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, len);
     506                        printf("send_file#httpd_fs_read(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, len);
    509507                        break;
    510508                }
     
    514512
    515513                if ((slen = tcp_snd_buf(s->cepid, len)) != E_OK) {
    516                         ntstdio_printf(ntstdio, "send_file#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
     514                        printf("send_file#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
    517515                        s->state = STATE_CLOSING;
    518516                        break;
     
    520518        }
    521519
    522         ntstdio_printf(ntstdio, "close:     %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
     520        printf("close:     %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
    523521        httpd_fs_close(&s->file);
    524522        s->file.len = 0;
     
    536534                slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
    537535                if (slen < 0) {
    538                         ntstdio_printf(ntstdio, "send_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
     536                        printf("send_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
    539537                        s->state = STATE_CLOSING;
    540538                        break;
     
    553551
    554552                if ((slen = tcp_snd_buf(s->cepid, len)) != E_OK) {
    555                         ntstdio_printf(ntstdio, "send_data#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
     553                        printf("send_data#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
    556554                        s->state = STATE_CLOSING;
    557555                        break;
     
    571569        char *ptr;
    572570
    573         len = ntlibc_strlen(statushdr);
     571        len = strlen(statushdr);
    574572        tcp_snd_dat(s->cepid, (void *)statushdr, len, TMO_FEVR);
    575573
     
    586584                        tcp_snd_dat(s->cepid, "/~", len, TMO_FEVR);
    587585                }
    588                 len = ntlibc_strlen(s->filename);
     586                len = strlen(s->filename);
    589587                tcp_snd_dat(s->cepid, s->filename, len, TMO_FEVR);
    590588                if (s->query != NULL) {
    591589                        tcp_snd_dat(s->cepid, "?", 1, TMO_FEVR);
    592                         len = ntlibc_strlen(s->query);
     590                        len = strlen(s->query);
    593591                        tcp_snd_dat(s->cepid, s->query, len, TMO_FEVR);
    594592                }
     
    602600                tcp_snd_dat(s->cepid, (void *)http_content_type_binary, len, TMO_FEVR);
    603601        }
    604         else if (ntlibc_strncmp(http_html, ptr, sizeof(http_html) - 1) == 0 ||
    605                 ntlibc_strncmp(http_htm, ptr, sizeof(http_htm) - 1) == 0) {
     602        else if (strncmp(http_html, ptr, sizeof(http_html) - 1) == 0 ||
     603                strncmp(http_htm, ptr, sizeof(http_htm) - 1) == 0) {
    606604                len = sizeof(http_content_type_html) - 1;
    607605                tcp_snd_dat(s->cepid, (void *)http_content_type_html, len, TMO_FEVR);
    608606        }
    609         else if (ntlibc_strncmp(http_css, ptr, sizeof(http_css) - 1) == 0) {
     607        else if (strncmp(http_css, ptr, sizeof(http_css) - 1) == 0) {
    610608                len = sizeof(http_content_type_css) - 1;
    611609                tcp_snd_dat(s->cepid, (void *)http_content_type_css, len, TMO_FEVR);
    612610        }
    613         else if (ntlibc_strncmp(http_js, ptr, sizeof(http_js) - 1) == 0) {
     611        else if (strncmp(http_js, ptr, sizeof(http_js) - 1) == 0) {
    614612                len = sizeof(http_content_type_js) - 1;
    615613                tcp_snd_dat(s->cepid, (void *)http_content_type_js, len, TMO_FEVR);
    616614        }
    617         else if (ntlibc_strncmp(http_json, ptr, sizeof(http_json) - 1) == 0) {
     615        else if (strncmp(http_json, ptr, sizeof(http_json) - 1) == 0) {
    618616                len = sizeof(http_content_type_json) - 1;
    619617                tcp_snd_dat(s->cepid, (void *)http_content_type_json, len, TMO_FEVR);
    620618        }
    621         else if (ntlibc_strncmp(http_png, ptr, sizeof(http_png) - 1) == 0) {
     619        else if (strncmp(http_png, ptr, sizeof(http_png) - 1) == 0) {
    622620                len = sizeof(http_content_type_png) - 1;
    623621                tcp_snd_dat(s->cepid, (void *)http_content_type_png, len, TMO_FEVR);
    624622        }
    625         else if (ntlibc_strncmp(http_gif, ptr, sizeof(http_gif) - 1) == 0) {
     623        else if (strncmp(http_gif, ptr, sizeof(http_gif) - 1) == 0) {
    626624                len = sizeof(http_content_type_gif) - 1;
    627625                tcp_snd_dat(s->cepid, (void *)http_content_type_gif, len, TMO_FEVR);
    628626        }
    629         else if (ntlibc_strncmp(http_jpg, ptr, sizeof(http_jpg) - 1) == 0) {
     627        else if (strncmp(http_jpg, ptr, sizeof(http_jpg) - 1) == 0) {
    630628                len = sizeof(http_content_type_jpg) - 1;
    631629                tcp_snd_dat(s->cepid, (void *)http_content_type_jpg, len, TMO_FEVR);
    632630        }
    633         else if (ntlibc_strncmp(http_svg, ptr, sizeof(http_svg) - 1) == 0) {
     631        else if (strncmp(http_svg, ptr, sizeof(http_svg) - 1) == 0) {
    634632                len = sizeof(http_content_type_svg) - 1;
    635633                tcp_snd_dat(s->cepid, (void *)http_content_type_svg, len, TMO_FEVR);
    636634        }
    637         else if (ntlibc_strncmp(http_text, ptr, sizeof(http_text) - 1) == 0) {
     635        else if (strncmp(http_text, ptr, sizeof(http_text) - 1) == 0) {
    638636                len = sizeof(http_content_type_text) - 1;
    639637                tcp_snd_dat(s->cepid, (void *)http_content_type_text, len, TMO_FEVR);
    640638        }
    641         else if (ntlibc_strncmp(http_eot, ptr, sizeof(http_eot) - 1) == 0) {
     639        else if (strncmp(http_eot, ptr, sizeof(http_eot) - 1) == 0) {
    642640                len = sizeof(http_content_type_eot) - 1;
    643641                tcp_snd_dat(s->cepid, (void *)http_content_type_eot, len, TMO_FEVR);
    644642        }
    645         else if (ntlibc_strncmp(http_ttf, ptr, sizeof(http_ttf) - 1) == 0) {
     643        else if (strncmp(http_ttf, ptr, sizeof(http_ttf) - 1) == 0) {
    646644                len = sizeof(http_content_type_ttf) - 1;
    647645                tcp_snd_dat(s->cepid, (void *)http_content_type_ttf, len, TMO_FEVR);
    648646        }
    649         else if (ntlibc_strncmp(http_woff, ptr, sizeof(http_woff) - 1) == 0) {
     647        else if (strncmp(http_woff, ptr, sizeof(http_woff) - 1) == 0) {
    650648                len = sizeof(http_content_type_woff) - 1;
    651649                tcp_snd_dat(s->cepid, (void *)http_content_type_woff, len, TMO_FEVR);
    652650        }
    653         else if (ntlibc_strncmp(http_woff2, ptr, sizeof(http_woff2) - 1) == 0) {
     651        else if (strncmp(http_woff2, ptr, sizeof(http_woff2) - 1) == 0) {
    654652                len = sizeof(http_content_type_woff2) - 1;
    655653                tcp_snd_dat(s->cepid, (void *)http_content_type_woff2, len, TMO_FEVR);
    656654        }
    657         else if (ntlibc_strncmp(http_ico, ptr, sizeof(http_ico) - 1) == 0) {
     655        else if (strncmp(http_ico, ptr, sizeof(http_ico) - 1) == 0) {
    658656                len = sizeof(http_content_type_ico) - 1;
    659657                tcp_snd_dat(s->cepid, (void *)http_content_type_ico, len, TMO_FEVR);
     
    667665                len = sizeof(http_content_length) - 1;
    668666                tcp_snd_dat(s->cepid, (void *)http_content_length, len, TMO_FEVR);
    669                 len = ntstdio_snprintf(s->temp, sizeof(s->temp), "%d\r\n", s->file.len);
     667                len = snprintf(s->temp, sizeof(s->temp), "%d\r\n", s->file.len);
    670668                tcp_snd_dat(s->cepid, (void *)s->temp, len, TMO_FEVR);
    671669        }
     
    699697                break;
    700698        case OUT_STATE_OPEN_GET_FILE:
    701                 ntstdio_printf(ntstdio, "open:      %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
     699                printf("open:      %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
    702700                if (!httpd_fs_open(s->filename, sizeof(s->message.request_url), &s->file)) {
    703701                        s->filename = NULL;
     
    713711                break;
    714712        case OUT_STATE_WAIT_POST_BODY:
    715                 //ntstdio_printf(ntstdio, "wait post body\n");
     713                //printf("wait post body\n");
    716714                s->out.wait = true;
    717715                break;
    718716        case OUT_STATE_BODY_RECEIVED:
    719                 //ntstdio_printf(ntstdio, "body received\n");
     717                //printf("body received\n");
    720718                s->out.statushdr = http_header_200;
    721719                s->out.state = OUT_STATE_SEND_HEADER;
    722720                break;
    723721        case OUT_STATE_SEND_HEADER:
    724                 //ntstdio_printf(ntstdio, "send header\n");
     722                //printf("send header\n");
    725723                send_headers(s, s->out.statushdr);
    726724                break;
    727725        case OUT_STATE_SEND_FILE:
    728                 //ntstdio_printf(ntstdio, "send file %d\n", s->file.len);
     726                //printf("send file %d\n", s->file.len);
    729727                send_file(s);
    730728                break;
    731729        case OUT_STATE_SEND_DATA:
    732                 //ntstdio_printf(ntstdio, "send data %d\n", s->response_len);
     730                //printf("send data %d\n", s->response_len);
    733731                send_data(s);
    734732                break;
    735733        case OUT_STATE_SEND_END:
    736                 //ntstdio_printf(ntstdio, "send end\n");
     734                //printf("send end\n");
    737735                s->out.wait = true;
    738736                if (s->message.should_keep_alive && s->reset == 0) {
     
    750748        int len;
    751749
    752         len = ntlibc_strlen(statushdr);
     750        len = strlen(statushdr);
    753751        tcp_snd_dat(s->cepid, (void *)statushdr, len, TMO_FEVR);
    754752
    755753        len = sizeof(http_upgrade) - 1;
    756754        tcp_snd_dat(s->cepid, (void *)http_upgrade, len, TMO_FEVR);
    757         len = ntlibc_strlen(s->message.upgrade);
     755        len = strlen(s->message.upgrade);
    758756        tcp_snd_dat(s->cepid, s->message.upgrade, len, TMO_FEVR);
    759757        len = sizeof(http_crnl) - 1;
     
    762760        len = sizeof(http_connection) - 1;
    763761        tcp_snd_dat(s->cepid, (void *)http_connection, len, TMO_FEVR);
    764         len = ntlibc_strlen(s->message.connection);
     762        len = strlen(s->message.connection);
    765763        tcp_snd_dat(s->cepid, s->message.connection, len, TMO_FEVR);
    766764        len = sizeof(http_crnl) - 1;
     
    769767        len = sizeof(http_sec_websocket_accept) - 1;
    770768        tcp_snd_dat(s->cepid, (void *)http_sec_websocket_accept, len, TMO_FEVR);
    771         len = ntlibc_strlen(s->message.response_key);
     769        len = strlen(s->message.response_key);
    772770        tcp_snd_dat(s->cepid, s->message.response_key, len, TMO_FEVR);
    773771        len = sizeof(http_crnl) - 1;
     
    776774        len = sizeof(http_sec_websocket_protocol) - 1;
    777775        tcp_snd_dat(s->cepid, (void *)http_sec_websocket_protocol, len, TMO_FEVR);
    778         len = ntlibc_strlen(s->message.sec_websocket_protocol);
     776        len = strlen(s->message.sec_websocket_protocol);
    779777        tcp_snd_dat(s->cepid, s->message.sec_websocket_protocol, len, TMO_FEVR);
    780778        len = sizeof(http_crnl) - 1;
     
    792790        slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
    793791        if (slen < 0) {
    794                 ntstdio_printf(ntstdio, "send_ws_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
     792                printf("send_ws_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
    795793                return;
    796794        }
     
    856854                                //}
    857855                        }
    858                         ntstdio_printf(ntstdio, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
     856                        printf("handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
    859857                        uploding = NULL;
    860858                        s->state = STATE_CLOSING;
     
    864862                tcp_rel_buf(s->cepid, done);
    865863                if (s->parser.http_errno != HPE_OK) {
    866                         ntstdio_printf(ntstdio, "http_parser error %s.%d => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->parser.http_errno);
     864                        printf("http_parser error %s.%d => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->parser.http_errno);
    867865                        uploding = NULL;
    868866                        s->state = STATE_CLOSING;
     
    889887                                        break;
    890888                                }
    891                                 ntstdio_printf(ntstdio, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
     889                                printf("handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
    892890                                s->state = STATE_CLOSING;
    893891                                break;
     
    927925
    928926        if (s == NULL)
    929                 ntstdio_printf(ntstdio, "callback_nblk_tcp(%d, %d)\n", fncd, cepid);
     927                printf("callback_nblk_tcp(%d, %d)\n", fncd, cepid);
    930928        else
    931                 ntstdio_printf(ntstdio, "callback_nblk_tcp(%d, %s.%d)\n", fncd, s->addr, ((T_IPV4EP *)s->dst)->portno);
     929                printf("callback_nblk_tcp(%d, %s.%d)\n", fncd, s->addr, ((T_IPV4EP *)s->dst)->portno);
    932930
    933931        return E_PAR;
     
    945943                ret2 = get_tim(&httpd_time);
    946944                if (ret2 != E_OK) {
    947                         ntstdio_printf(ntstdio, "get_tim\n");
     945                        printf("get_tim\n");
    948946                        return;
    949947                }
     
    953951                        memset(&s->dst, 0, sizeof(s->dst));
    954952                        if ((ret = tcp_acp_cep(s->cepid, TCP_REPID, (T_IPV4EP *)s->dst, TMO_FEVR)) != E_OK) {
    955                                 ntstdio_printf(ntstdio, "tcp_acp_cep(%d) => %d\n", s->cepid, ret);
     953                                printf("tcp_acp_cep(%d) => %d\n", s->cepid, ret);
    956954                                tslp_tsk(100 * 1000);   // TODO
    957955                                s->state = STATE_CLOSING;
     
    959957                        }
    960958                        IP2STR(s->addr, &((T_IPV4EP *)s->dst)->ipaddr);
    961                         ntstdio_printf(ntstdio, "connected: %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);
     959                        printf("connected: %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);
    962960                        memset(&s->in, 0, sizeof(s->in));
    963961                        memset(&s->out, 0, sizeof(s->out));
     
    974972                        break;
    975973                case STATE_CLOSING:
    976                         ntstdio_printf(ntstdio, "close:     %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);
     974                        printf("close:     %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);
    977975                        tcp_sht_cep(s->cepid);
    978976                        tcp_cls_cep(s->cepid, TMO_FEVR);
Note: See TracChangeset for help on using the changeset viewer.