Changeset 2595dab in mainline for uspace/lib/libc/include


Ignore:
Timestamp:
2009-06-03T19:26:28Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d00ae4c
Parents:
ca3ba3a
Message:

I/O subsystem overhaul:

  • add more POSIX-like file and stream functions (with real functionality of stdin, stdout, stderr)
  • cleanup console access methods (now generic to any console-like device)
  • remove unsafe stream functions
  • add special open_node(), fd_node(), fd_phone() (file) and fopen_node(), fnode(), fphone() (stream) functions for HelenOS-specific I/O operations
Location:
uspace/lib/libc/include
Files:
1 deleted
7 edited
5 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/include/dirent.h

    rca3ba3a r2595dab  
    3636#define LIBC_DIRENT_H_
    3737
    38 #define NAME_MAX        256     
     38#define NAME_MAX  256
    3939
    4040struct dirent {
     
    4747} DIR;
    4848
    49 
    5049extern DIR *opendir(const char *);
    5150extern struct dirent *readdir(DIR *);
  • uspace/lib/libc/include/fcntl.h

    rca3ba3a r2595dab  
    3636#define LIBC_FCNTL_H_
    3737
    38 #define O_CREAT         1
    39 #define O_EXCL          2
    40 #define O_TRUNC         4
    41 #define O_APPEND        8
    42 #define O_RDONLY        16
    43 #define O_RDWR          32
    44 #define O_WRONLY        64
     38#define O_CREAT   1
     39#define O_EXCL    2
     40#define O_TRUNC   4
     41#define O_APPEND  8
     42#define O_RDONLY  16
     43#define O_RDWR    32
     44#define O_WRONLY  64
    4545
    4646extern int open(const char *, int, ...);
  • uspace/lib/libc/include/fibril.h

    rca3ba3a r2595dab  
    4141
    4242#ifndef context_set
    43 #define context_set(c, _pc, stack, size, ptls)                  \
    44         (c)->pc = (sysarg_t) (_pc);                             \
    45         (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA;     \
    46         (c)->tls = (sysarg_t) (ptls);
     43#define context_set(c, _pc, stack, size, ptls) \
     44        (c)->pc = (sysarg_t) (_pc); \
     45        (c)->sp = ((sysarg_t) (stack)) + (size) - SP_DELTA; \
     46        (c)->tls = (sysarg_t) (ptls);
    4747#endif /* context_set */
    4848
    49 #define FIBRIL_SERIALIZED   1
     49#define FIBRIL_SERIALIZED  1
    5050
    5151typedef enum {
  • uspace/lib/libc/include/io/color.h

    rca3ba3a r2595dab  
    2828
    2929/** @addtogroup libc
    30  * @{ 
     30 * @{
    3131 */
    3232/** @file
    3333 */
    3434
    35 #ifndef LIBC_CONSOLE_COLOR_H_
    36 #define LIBC_CONSOLE_COLOR_H_
     35#ifndef LIBC_IO_COLOR_H_
     36#define LIBC_IO_COLOR_H_
    3737
    3838enum console_color {
    39         COLOR_BLACK     = 0,
    40         COLOR_BLUE      = 1,
    41         COLOR_GREEN     = 2,
    42         COLOR_CYAN      = 3,
    43         COLOR_RED       = 4,
    44         COLOR_MAGENTA   = 5,
    45         COLOR_YELLOW    = 6,
    46         COLOR_WHITE     = 7,
    47 
    48         CATTR_BRIGHT    = 8,
    49         CATTR_BLINK     = 8
     39        COLOR_BLACK   = 0,
     40        COLOR_BLUE    = 1,
     41        COLOR_GREEN   = 2,
     42        COLOR_CYAN    = 3,
     43        COLOR_RED     = 4,
     44        COLOR_MAGENTA = 5,
     45        COLOR_YELLOW  = 6,
     46        COLOR_WHITE   = 7,
     47       
     48        CATTR_BRIGHT  = 8,
     49        CATTR_BLINK   = 8
    5050};
    5151
    5252#endif
    53  
     53
    5454/** @}
    5555 */
  • uspace/lib/libc/include/io/console.h

    rca3ba3a r2595dab  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2008 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2828
    2929/** @addtogroup libc
    30  * @{ 
     30 * @{
    3131 */
    3232/** @file
    3333 */
    3434
    35 #ifndef LIBC_KBD_H_
    36 #define LIBC_KBD_H_
     35#ifndef LIBC_IO_CONSOLE_H_
     36#define LIBC_IO_CONSOLE_H_
    3737
    38 #include <sys/types.h>
     38#include <ipc/ipc.h>
     39#include <bool.h>
    3940
    40 typedef enum kbd_ev_type {
    41         KE_PRESS,
    42         KE_RELEASE
    43 } kbd_ev_type_t;
     41typedef enum {
     42        KEY_PRESS,
     43        KEY_RELEASE
     44} console_ev_type_t;
    4445
    45 /** Keyboard event structure. */
     46/** Console event structure. */
    4647typedef struct {
    4748        /** Press or release event. */
    48         kbd_ev_type_t type;
    49 
     49        console_ev_type_t type;
     50       
    5051        /** Keycode of the key that was pressed or released. */
    5152        unsigned int key;
    52 
     53       
    5354        /** Bitmask of modifiers held. */
    5455        unsigned int mods;
    55 
     56       
    5657        /** The character that was generated or '\0' for none. */
    5758        wchar_t c;
    58 } kbd_event_t;
     59} console_event_t;
    5960
    60 extern int kbd_get_event(kbd_event_t *);
     61extern void console_clear(int phone);
     62
     63extern int console_get_size(int phone, ipcarg_t *rows, ipcarg_t *cols);
     64extern void console_goto(int phone, ipcarg_t row, ipcarg_t col);
     65
     66extern void console_set_style(int phone, int style);
     67extern void console_set_color(int phone, int fg_color, int bg_color, int flags);
     68extern void console_set_rgb_color(int phone, int fg_color, int bg_color);
     69
     70extern void console_cursor_visibility(int phone, bool show);
     71extern void console_kcon_enable(int phone);
     72
     73extern bool console_get_event(int phone, console_event_t *event);
    6174
    6275#endif
    63  
     76
    6477/** @}
    6578 */
  • uspace/lib/libc/include/io/keycode.h

    rca3ba3a r2595dab  
    2828
    2929/** @addtogroup libc
    30  * @{ 
     30 * @{
    3131 */
    3232/** @file
    3333 */
    3434
    35 #ifndef LIBC_KBD_KEYCODE_H_
    36 #define LIBC_KBD_KEYCODE_H_
     35#ifndef LIBC_IO_KEYCODE_H_
     36#define LIBC_IO_KEYCODE_H_
    3737
    3838/** Keycode definitions.
     
    200200
    201201enum keymod {
    202         KM_LSHIFT       = 0x001,
    203         KM_RSHIFT       = 0x002,
    204         KM_LCTRL        = 0x004,
    205         KM_RCTRL        = 0x008,
    206         KM_LALT         = 0x010,
    207         KM_RALT         = 0x020,
    208         KM_CAPS_LOCK    = 0x040,
    209         KM_NUM_LOCK     = 0x080,
    210         KM_SCROLL_LOCK  = 0x100,
    211 
    212         KM_SHIFT        = KM_LSHIFT | KM_RSHIFT,
    213         KM_CTRL         = KM_LCTRL | KM_RCTRL,
    214         KM_ALT          = KM_LALT | KM_RALT
     202        KM_LSHIFT      = 0x001,
     203        KM_RSHIFT      = 0x002,
     204        KM_LCTRL       = 0x004,
     205        KM_RCTRL       = 0x008,
     206        KM_LALT        = 0x010,
     207        KM_RALT        = 0x020,
     208        KM_CAPS_LOCK   = 0x040,
     209        KM_NUM_LOCK    = 0x080,
     210        KM_SCROLL_LOCK = 0x100,
     211       
     212        KM_SHIFT       = KM_LSHIFT | KM_RSHIFT,
     213        KM_CTRL        = KM_LCTRL | KM_RCTRL,
     214        KM_ALT         = KM_LALT | KM_RALT
    215215} keymod_t;
    216216
    217217#endif
    218  
     218
    219219/** @}
    220220 */
  • uspace/lib/libc/include/io/klog.h

    rca3ba3a r2595dab  
    3636#define LIBC_STREAM_H_
    3737
    38 #include <libarch/types.h>
     38#include <sys/types.h>
    3939
    40 #define EMFILE  -17
    41 
    42 extern ssize_t read_stdin(void *, size_t);
    43 extern int klog_puts(const char *);
     40extern size_t klog_write(const void *buf, size_t size);
    4441extern void klog_update(void);
    4542
  • uspace/lib/libc/include/io/printf_core.h

    rca3ba3a r2595dab  
    5757/** @}
    5858 */
    59  
    60  
  • uspace/lib/libc/include/io/style.h

    rca3ba3a r2595dab  
    2828
    2929/** @addtogroup libc
    30  * @{ 
     30 * @{
    3131 */
    3232/** @file
    3333 */
    3434
    35 #ifndef LIBC_CONSOLE_STYLE_H_
    36 #define LIBC_CONSOLE_STYLE_H_
     35#ifndef LIBC_IO_STYLE_H_
     36#define LIBC_IO_STYLE_H_
    3737
    3838enum console_style {
    39         STYLE_NORMAL    = 0,
    40         STYLE_EMPHASIS  = 1
     39        STYLE_NORMAL   = 0,
     40        STYLE_EMPHASIS = 1
    4141};
    4242
    4343#endif
    44  
     44
    4545/** @}
    4646 */
  • uspace/lib/libc/include/stdio.h

    rca3ba3a r2595dab  
    3939#include <stdarg.h>
    4040
    41 #define EOF (-1)
    42 
    43 #include <string.h>
    44 #include <io/stream.h>
     41#define EOF  (-1)
    4542
    4643#define DEBUG(fmt, ...) \
    4744{ \
    4845        char buf[256]; \
    49         int n; \
    50         n = snprintf(buf, sizeof(buf), fmt, ##__VA_ARGS__); \
     46        int n = snprintf(buf, sizeof(buf), fmt, ##__VA_ARGS__); \
    5147        if (n > 0) \
    5248                (void) __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, str_size(buf)); \
    5349}
    5450
     51#ifndef SEEK_SET
     52        #define SEEK_SET  0
     53        #define SEEK_CUR  1
     54        #define SEEK_END  2
     55#endif
     56
    5557typedef struct {
    5658        /** Underlying file descriptor. */
    5759        int fd;
    58 
     60       
    5961        /** Error indicator. */
    6062        int error;
    61 
     63       
    6264        /** End-of-file indicator. */
    6365        int eof;
     66       
     67        /** Klog indicator */
     68        int klog;
     69       
     70        /** Phone to the file provider */
     71        int phone;
    6472} FILE;
    6573
    66 extern FILE *stdin, *stdout, *stderr;
     74extern FILE stdin_null;
     75extern FILE stdout_klog;
     76
     77extern FILE *stdin;
     78extern FILE *stdout;
     79extern FILE *stderr;
     80
     81/* Character and string input functions */
     82extern int fgetc(FILE *);
     83extern char *fgets(char *, size_t, FILE *);
    6784
    6885extern int getchar(void);
     86extern char *gets(char *, size_t);
    6987
     88/* Character and string output functions */
     89extern int fputc(wchar_t, FILE *);
     90extern int fputs(const char *, FILE *);
     91
     92extern int putchar(wchar_t);
    7093extern int puts(const char *);
    71 extern int putchar(int);
    72 extern int fflush(FILE *);
     94
     95/* Formatted string output functions */
     96extern int fprintf(FILE *, const char*, ...);
     97extern int vfprintf(FILE *, const char *, va_list);
    7398
    7499extern int printf(const char *, ...);
     100extern int vprintf(const char *, va_list);
     101
     102extern int snprintf(char *, size_t , const char *, ...);
    75103extern int asprintf(char **, const char *, ...);
    76 extern int sprintf(char *, const char *, ...);
    77 extern int snprintf(char *, size_t , const char *, ...);
    78 
    79 extern int vprintf(const char *, va_list);
    80 extern int vsprintf(char *, const char *, va_list);
    81104extern int vsnprintf(char *, size_t, const char *, va_list);
    82105
    83 extern int rename(const char *, const char *);
    84 
     106/* File stream functions */
    85107extern FILE *fopen(const char *, const char *);
    86108extern int fclose(FILE *);
     109
    87110extern size_t fread(void *, size_t, size_t, FILE *);
    88111extern size_t fwrite(const void *, size_t, size_t, FILE *);
     112
     113extern int fseek(FILE *, long, int);
     114extern int ftell(FILE *);
    89115extern int feof(FILE *);
     116
     117extern int fflush(FILE *);
    90118extern int ferror(FILE *);
    91119extern void clearerr(FILE *);
    92120
    93 extern int fgetc(FILE *);
    94 extern int fputc(int, FILE *);
    95 extern int fputs(const char *, FILE *);
    96 
    97 extern int fprintf(FILE *, const char *, ...);
    98 extern int vfprintf(FILE *, const char *, va_list);
    99 
    100 #define getc fgetc
    101 #define putc fputc
    102 
    103 extern int fseek(FILE *, long, int);
    104 
    105 #ifndef SEEK_SET
    106         #define SEEK_SET        0
    107         #define SEEK_CUR        1
    108         #define SEEK_END        2
    109 #endif
     121/* Misc file functions */
     122extern int rename(const char *, const char *);
    110123
    111124#endif
  • uspace/lib/libc/include/unistd.h

    rca3ba3a r2595dab  
    4040
    4141#ifndef NULL
    42 #define NULL 0
     42        #define NULL 0
    4343#endif
    4444
    45 #define getpagesize()     (PAGE_SIZE)
     45#define getpagesize()  (PAGE_SIZE)
    4646
    4747#ifndef SEEK_SET
    48         #define SEEK_SET        0
    49         #define SEEK_CUR        1
    50         #define SEEK_END        2
     48        #define SEEK_SET  0
     49        #define SEEK_CUR  1
     50        #define SEEK_END  2
    5151#endif
    5252
    5353extern ssize_t write(int, const void *, size_t);
    5454extern ssize_t read(int, void *, size_t);
     55
    5556extern off_t lseek(int, off_t, int);
    5657extern int ftruncate(int, off_t);
     58
    5759extern int close(int);
     60extern int fsync(int);
    5861extern int unlink(const char *);
     62
     63extern char *getcwd(char *buf, size_t);
    5964extern int rmdir(const char *);
    6065extern int chdir(const char *);
    61 extern char *getcwd(char *buf, size_t);
    6266
    6367extern void _exit(int status) __attribute__ ((noreturn));
  • uspace/lib/libc/include/vfs/vfs.h

    rca3ba3a r2595dab  
    3737
    3838#include <sys/types.h>
     39#include <ipc/vfs.h>
     40#include <ipc/devmap.h>
     41#include <stdio.h>
     42
     43typedef struct {
     44        fs_handle_t fs_handle;
     45        dev_handle_t dev_handle;
     46        fs_index_t index;
     47} fs_node_t;
    3948
    4049extern char *absolutize(const char *, size_t *);
     
    4352    unsigned int flags);
    4453
     54extern int open_node(fs_node_t *node, int oflag);
     55extern int fd_phone(int);
     56extern void fd_node(int, fs_node_t *);
     57
     58extern FILE *fopen_node(fs_node_t *node, const char *);
     59extern int fphone(FILE *);
     60extern void fnode(FILE *stream, fs_node_t *node);
     61
    4562#endif
    4663
Note: See TracChangeset for help on using the changeset viewer.