Ignore:
Timestamp:
Apr 19, 2008, 9:25:41 PM (12 years ago)
Author:
Sam Hocevar
Message:
  • Changed most of the long ints in the API into C99 types. WARNING: this completely breaks compatibility with previous versions of libcaca on 64-bit systems.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/attr.c

    r2300 r2303  
    6666 *  \return The requested attribute.
    6767 */
    68 unsigned long int cucul_get_attr(cucul_canvas_t const *cv, int x, int y)
     68uint32_t cucul_get_attr(cucul_canvas_t const *cv, int x, int y)
    6969{
    7070    if(x < 0 || x >= (int)cv->width || y < 0 || y >= (int)cv->height)
    71         return (unsigned long int)cv->curattr;
    72 
    73     return (unsigned long int)cv->attrs[x + y * cv->width];
     71        return cv->curattr;
     72
     73    return cv->attrs[x + y * cv->width];
    7474}
    7575
     
    9191 *  To retrieve the current attribute value, use cucul_get_attr(-1,-1).
    9292 *
    93  *  If an error occurs, -1 is returned and \b errno is set accordingly:
    94  *  - \c EINVAL The attribute value is out of the 32-bit range.
     93 *  This function never fails.
    9594 *
    9695 *  \param cv A handle to the libcucul canvas.
    9796 *  \param attr The requested attribute value.
    98  *  \return 0 in case of success, -1 if an error occurred.
    99  */
    100 int cucul_set_attr(cucul_canvas_t *cv, unsigned long int attr)
    101 {
    102     if(sizeof(unsigned long int) > sizeof(uint32_t) && attr > 0xffffffff)
    103     {
    104         seterrno(EINVAL);
    105         return -1;
    106     }
    107 
     97 *  \return This function always returns 0.
     98 */
     99int cucul_set_attr(cucul_canvas_t *cv, uint32_t attr)
     100{
    108101    if(attr < 0x00000010)
    109102        attr = (cv->curattr & 0xfffffff0) | attr;
     
    127120 *    setting the attribute does not modify the current colour information.
    128121 *
    129  *  If an error occurs, -1 is returned and \b errno is set accordingly:
    130  *  - \c EINVAL The attribute value is out of the 32-bit range.
     122 *  This function never fails.
    131123 *
    132124 *  \param cv A handle to the libcucul canvas.
     
    134126 *  \param y Y coordinate.
    135127 *  \param attr The requested attribute value.
    136  *  \return 0 in case of success, -1 if an error occurred.
    137  */
    138 int cucul_put_attr(cucul_canvas_t *cv, int x, int y, unsigned long int attr)
     128 *  \return This function always returns 0.
     129 */
     130int cucul_put_attr(cucul_canvas_t *cv, int x, int y, uint32_t attr)
    139131{
    140132    uint32_t *curattr, *curchar;
    141 
    142     if(sizeof(unsigned long int) > sizeof(uint32_t) && attr > 0xffffffff)
    143     {
    144         seterrno(EINVAL);
    145         return -1;
    146     }
    147133
    148134    if(x < 0 || x >= (int)cv->width || y < 0 || y >= (int)cv->height)
     
    208194 *  white with 50% alpha (A=8 R=15 G=15 B=15).
    209195 *
    210  *  If an error occurs, 0 is returned and \b errno is set accordingly:
    211  *  - \c EINVAL At least one of the colour values is invalid.
     196 *  This function never fails.
    212197 *
    213198 *  \param cv A handle to the libcucul canvas.
    214199 *  \param fg The requested ARGB foreground colour.
    215200 *  \param bg The requested ARGB background colour.
    216  *  \return 0 in case of success, -1 if an error occurred.
    217  */
    218 int cucul_set_color_argb(cucul_canvas_t *cv, unsigned int fg, unsigned int bg)
     201 *  \return This function always returns 0.
     202 */
     203int cucul_set_color_argb(cucul_canvas_t *cv, uint16_t fg, uint16_t bg)
    219204{
    220205    uint32_t attr;
    221 
    222     if(fg > 0xffff || bg > 0xffff)
    223     {
    224         seterrno(EINVAL);
    225         return -1;
    226     }
    227206
    228207    if(fg < 0x100)
     
    258237 *  \return The corresponding DOS ANSI value.
    259238 */
    260 uint8_t cucul_attr_to_ansi(unsigned long int attr)
     239uint8_t cucul_attr_to_ansi(uint32_t attr)
    261240{
    262241    uint8_t fg = nearest_ansi((attr >> 4) & 0x3fff);
     
    282261 *  \return The corresponding ANSI foreground value.
    283262 */
    284 uint8_t cucul_attr_to_ansi_fg(unsigned long int attr)
     263uint8_t cucul_attr_to_ansi_fg(uint32_t attr)
    285264{
    286265    return nearest_ansi(((uint16_t)attr >> 4) & 0x3fff);
     
    302281 *  \return The corresponding ANSI background value.
    303282 */
    304 uint8_t cucul_attr_to_ansi_bg(unsigned long int attr)
     283uint8_t cucul_attr_to_ansi_bg(uint32_t attr)
    305284{
    306285    return nearest_ansi(attr >> 18);
     
    322301 *  \return The corresponding 12-bit RGB foreground value.
    323302 */
    324 unsigned int cucul_attr_to_rgb12_fg(unsigned long int attr)
     303uint16_t cucul_attr_to_rgb12_fg(uint32_t attr)
    325304{
    326305    uint16_t fg = (attr >> 4) & 0x3fff;
     
    353332 *  \return The corresponding 12-bit RGB background value.
    354333 */
    355 unsigned int cucul_attr_to_rgb12_bg(unsigned long int attr)
     334uint16_t cucul_attr_to_rgb12_bg(uint32_t attr)
    356335{
    357336    uint16_t bg = attr >> 18;
     
    388367 *  \param argb An array of 8-bit integers.
    389368 */
    390 void cucul_attr_to_argb64(unsigned long int attr, uint8_t argb[8])
     369void cucul_attr_to_argb64(uint32_t attr, uint8_t argb[8])
    391370{
    392371    uint16_t fg = (attr >> 4) & 0x3fff;
Note: See TracChangeset for help on using the changeset viewer.