src/events/SDL_events.c
author Sam Lantinga <slouken@libsdl.org>
Thu, 27 Jan 2011 22:44:08 -0800
changeset 5123 dc0dfdd58f27
parent 5111 481dabb098ef
child 5146 3052772b59db
permissions -rw-r--r--
Removed completely non-portable event thread hack.
Next I'll be working on generalizing the event sources and making the event queue lock-free. :)
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@3697
     3
    Copyright (C) 1997-2010 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@0
    23
slouken@0
    24
/* General event handling code for SDL */
slouken@0
    25
slouken@0
    26
#include "SDL.h"
slouken@2984
    27
#include "SDL_events.h"
slouken@0
    28
#include "SDL_syswm.h"
slouken@2984
    29
#include "SDL_thread.h"
slouken@1361
    30
#include "SDL_events_c.h"
slouken@1361
    31
#include "../timer/SDL_timer_c.h"
slouken@1361
    32
#if !SDL_JOYSTICK_DISABLED
slouken@1361
    33
#include "../joystick/SDL_joystick_c.h"
slouken@1361
    34
#endif
slouken@5123
    35
#include "../video/SDL_sysvideo.h"
slouken@0
    36
slouken@0
    37
/* Public data -- the event filter */
slouken@0
    38
SDL_EventFilter SDL_EventOK = NULL;
slouken@1895
    39
void *SDL_EventOKParam;
slouken@4429
    40
slouken@4429
    41
typedef struct {
slouken@4429
    42
    Uint32 bits[8];
slouken@4429
    43
} SDL_DisabledEventBlock;
slouken@4429
    44
slouken@4429
    45
static SDL_DisabledEventBlock *SDL_disabled_events[256];
slouken@4429
    46
static Uint32 SDL_userevents = SDL_USEREVENT;
slouken@0
    47
slouken@0
    48
/* Private data -- event queue */
slouken@0
    49
#define MAXEVENTS	128
slouken@1895
    50
static struct
slouken@1895
    51
{
slouken@1895
    52
    SDL_mutex *lock;
slouken@1895
    53
    int active;
slouken@1895
    54
    int head;
slouken@1895
    55
    int tail;
slouken@1895
    56
    SDL_Event event[MAXEVENTS];
slouken@1895
    57
    int wmmsg_next;
slouken@1895
    58
    struct SDL_SysWMmsg wmmsg[MAXEVENTS];
slouken@0
    59
} SDL_EventQ;
slouken@0
    60
slouken@0
    61
slouken@4429
    62
static __inline__ SDL_bool
slouken@4429
    63
SDL_ShouldPollJoystick()
slouken@4429
    64
{
paul@4698
    65
#if !SDL_JOYSTICK_DISABLED
slouken@4429
    66
    if (SDL_numjoysticks &&
slouken@4429
    67
        (!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] ||
slouken@4429
    68
         SDL_JoystickEventState(SDL_QUERY))) {
slouken@4429
    69
        return SDL_TRUE;
slouken@4429
    70
    }
paul@4698
    71
#endif
slouken@4429
    72
    return SDL_FALSE;
slouken@4429
    73
}
slouken@4429
    74
slouken@0
    75
/* Public functions */
slouken@0
    76
slouken@1895
    77
void
slouken@1895
    78
SDL_StopEventLoop(void)
slouken@0
    79
{
slouken@4429
    80
    int i;
slouken@4429
    81
slouken@5123
    82
    if (SDL_EventQ.lock) {
slouken@5123
    83
        SDL_DestroyMutex(SDL_EventQ.lock);
slouken@5123
    84
        SDL_EventQ.lock = NULL;
slouken@5123
    85
    }
slouken@1123
    86
slouken@1895
    87
    /* Clean out EventQ */
slouken@1895
    88
    SDL_EventQ.head = 0;
slouken@1895
    89
    SDL_EventQ.tail = 0;
slouken@1895
    90
    SDL_EventQ.wmmsg_next = 0;
slouken@4429
    91
slouken@4429
    92
    /* Clear disabled event state */
slouken@4429
    93
    for (i = 0; i < SDL_arraysize(SDL_disabled_events); ++i) {
slouken@4429
    94
        if (SDL_disabled_events[i]) {
slouken@4429
    95
            SDL_free(SDL_disabled_events[i]);
slouken@4429
    96
            SDL_disabled_events[i] = NULL;
slouken@4429
    97
        }
slouken@4429
    98
    }
slouken@0
    99
}
slouken@0
   100
slouken@0
   101
/* This function (and associated calls) may be called more than once */
slouken@1895
   102
int
slouken@5123
   103
SDL_StartEventLoop(void)
slouken@0
   104
{
slouken@1895
   105
    int retcode;
slouken@0
   106
slouken@1895
   107
    /* Clean out the event queue */
slouken@1895
   108
    SDL_EventQ.lock = NULL;
slouken@1895
   109
    SDL_StopEventLoop();
slouken@0
   110
slouken@1895
   111
    /* No filter to start with, process most event types */
slouken@1895
   112
    SDL_EventOK = NULL;
slouken@4429
   113
    SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
slouken@0
   114
slouken@5123
   115
    /* Create the lock and set ourselves active */
slouken@5123
   116
#if !SDL_THREADS_DISABLED
slouken@5123
   117
    SDL_EventQ.lock = SDL_CreateMutex();
slouken@5123
   118
    if (SDL_EventQ.lock == NULL) {
slouken@1895
   119
        return (-1);
slouken@1895
   120
    }
slouken@5123
   121
#endif /* !SDL_THREADS_DISABLED */
slouken@5123
   122
    SDL_EventQ.active = 1;
slouken@0
   123
slouken@1895
   124
    return (0);
slouken@0
   125
}
slouken@0
   126
slouken@0
   127
slouken@0
   128
/* Add an event to the event queue -- called with the queue locked */
slouken@1895
   129
static int
slouken@1895
   130
SDL_AddEvent(SDL_Event * event)
slouken@0
   131
{
slouken@1895
   132
    int tail, added;
slouken@0
   133
slouken@1895
   134
    tail = (SDL_EventQ.tail + 1) % MAXEVENTS;
slouken@1895
   135
    if (tail == SDL_EventQ.head) {
slouken@1895
   136
        /* Overflow, drop event */
slouken@1895
   137
        added = 0;
slouken@1895
   138
    } else {
slouken@1895
   139
        SDL_EventQ.event[SDL_EventQ.tail] = *event;
slouken@1895
   140
        if (event->type == SDL_SYSWMEVENT) {
slouken@1895
   141
            /* Note that it's possible to lose an event */
slouken@1895
   142
            int next = SDL_EventQ.wmmsg_next;
slouken@1895
   143
            SDL_EventQ.wmmsg[next] = *event->syswm.msg;
slouken@1895
   144
            SDL_EventQ.event[SDL_EventQ.tail].syswm.msg =
slouken@1895
   145
                &SDL_EventQ.wmmsg[next];
slouken@1895
   146
            SDL_EventQ.wmmsg_next = (next + 1) % MAXEVENTS;
slouken@1895
   147
        }
slouken@1895
   148
        SDL_EventQ.tail = tail;
slouken@1895
   149
        added = 1;
slouken@1895
   150
    }
slouken@1895
   151
    return (added);
slouken@0
   152
}
slouken@0
   153
slouken@0
   154
/* Cut an event, and return the next valid spot, or the tail */
slouken@0
   155
/*                           -- called with the queue locked */
slouken@1895
   156
static int
slouken@1895
   157
SDL_CutEvent(int spot)
slouken@0
   158
{
slouken@1895
   159
    if (spot == SDL_EventQ.head) {
slouken@1895
   160
        SDL_EventQ.head = (SDL_EventQ.head + 1) % MAXEVENTS;
slouken@1895
   161
        return (SDL_EventQ.head);
slouken@1895
   162
    } else if ((spot + 1) % MAXEVENTS == SDL_EventQ.tail) {
slouken@1895
   163
        SDL_EventQ.tail = spot;
slouken@1895
   164
        return (SDL_EventQ.tail);
slouken@1895
   165
    } else
slouken@1895
   166
        /* We cut the middle -- shift everything over */
slouken@1895
   167
    {
slouken@1895
   168
        int here, next;
slouken@0
   169
slouken@1895
   170
        /* This can probably be optimized with SDL_memcpy() -- careful! */
slouken@1895
   171
        if (--SDL_EventQ.tail < 0) {
slouken@1895
   172
            SDL_EventQ.tail = MAXEVENTS - 1;
slouken@1895
   173
        }
slouken@1895
   174
        for (here = spot; here != SDL_EventQ.tail; here = next) {
slouken@1895
   175
            next = (here + 1) % MAXEVENTS;
slouken@1895
   176
            SDL_EventQ.event[here] = SDL_EventQ.event[next];
slouken@1895
   177
        }
slouken@1895
   178
        return (spot);
slouken@1895
   179
    }
slouken@1895
   180
    /* NOTREACHED */
slouken@0
   181
}
slouken@0
   182
slouken@0
   183
/* Lock the event queue, take a peep at it, and unlock it */
slouken@1895
   184
int
slouken@1895
   185
SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
slouken@4429
   186
               Uint32 minType, Uint32 maxType)
slouken@0
   187
{
slouken@1895
   188
    int i, used;
slouken@0
   189
slouken@1895
   190
    /* Don't look after we've quit */
slouken@1895
   191
    if (!SDL_EventQ.active) {
slouken@1895
   192
        return (-1);
slouken@1895
   193
    }
slouken@1895
   194
    /* Lock the event queue */
slouken@1895
   195
    used = 0;
slouken@1895
   196
    if (SDL_mutexP(SDL_EventQ.lock) == 0) {
slouken@1895
   197
        if (action == SDL_ADDEVENT) {
slouken@1895
   198
            for (i = 0; i < numevents; ++i) {
slouken@1895
   199
                used += SDL_AddEvent(&events[i]);
slouken@1895
   200
            }
slouken@1895
   201
        } else {
slouken@1895
   202
            SDL_Event tmpevent;
slouken@1895
   203
            int spot;
slouken@0
   204
slouken@1895
   205
            /* If 'events' is NULL, just see if they exist */
slouken@1895
   206
            if (events == NULL) {
slouken@1895
   207
                action = SDL_PEEKEVENT;
slouken@1895
   208
                numevents = 1;
slouken@1895
   209
                events = &tmpevent;
slouken@1895
   210
            }
slouken@1895
   211
            spot = SDL_EventQ.head;
slouken@1895
   212
            while ((used < numevents) && (spot != SDL_EventQ.tail)) {
slouken@4429
   213
                Uint32 type = SDL_EventQ.event[spot].type;
slouken@4429
   214
                if (minType <= type && type <= maxType) {
slouken@1895
   215
                    events[used++] = SDL_EventQ.event[spot];
slouken@1895
   216
                    if (action == SDL_GETEVENT) {
slouken@1895
   217
                        spot = SDL_CutEvent(spot);
slouken@1895
   218
                    } else {
slouken@1895
   219
                        spot = (spot + 1) % MAXEVENTS;
slouken@1895
   220
                    }
slouken@1895
   221
                } else {
slouken@1895
   222
                    spot = (spot + 1) % MAXEVENTS;
slouken@1895
   223
                }
slouken@1895
   224
            }
slouken@1895
   225
        }
slouken@1895
   226
        SDL_mutexV(SDL_EventQ.lock);
slouken@1895
   227
    } else {
slouken@1895
   228
        SDL_SetError("Couldn't lock event queue");
slouken@1895
   229
        used = -1;
slouken@1895
   230
    }
slouken@1895
   231
    return (used);
slouken@1895
   232
}
slouken@1895
   233
slouken@1895
   234
SDL_bool
slouken@4429
   235
SDL_HasEvent(Uint32 type)
slouken@1895
   236
{
slouken@4429
   237
    return (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, type, type) > 0);
slouken@4429
   238
}
slouken@4429
   239
slouken@4429
   240
SDL_bool
slouken@4429
   241
SDL_HasEvents(Uint32 minType, Uint32 maxType)
slouken@4429
   242
{
slouken@4429
   243
    return (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, minType, maxType) > 0);
slouken@4429
   244
}
slouken@4429
   245
slouken@4429
   246
void
slouken@4429
   247
SDL_FlushEvent(Uint32 type)
slouken@4429
   248
{
slouken@4429
   249
    SDL_FlushEvents(type, type);
slouken@4429
   250
}
slouken@4429
   251
slouken@4429
   252
void
slouken@4429
   253
SDL_FlushEvents(Uint32 minType, Uint32 maxType)
slouken@4429
   254
{
slouken@4429
   255
    /* Don't look after we've quit */
slouken@4429
   256
    if (!SDL_EventQ.active) {
slouken@4429
   257
        return;
slouken@4429
   258
    }
slouken@4429
   259
slouken@4460
   260
    /* Make sure the events are current */
slouken@4460
   261
    SDL_PumpEvents();
slouken@4460
   262
slouken@4429
   263
    /* Lock the event queue */
slouken@4429
   264
    if (SDL_mutexP(SDL_EventQ.lock) == 0) {
slouken@4429
   265
        int spot = SDL_EventQ.head;
slouken@4429
   266
        while (spot != SDL_EventQ.tail) {
slouken@4429
   267
            Uint32 type = SDL_EventQ.event[spot].type;
slouken@4429
   268
            if (minType <= type && type <= maxType) {
slouken@4429
   269
                spot = SDL_CutEvent(spot);
slouken@4429
   270
            } else {
slouken@4429
   271
                spot = (spot + 1) % MAXEVENTS;
slouken@4429
   272
            }
slouken@4429
   273
        }
slouken@4429
   274
        SDL_mutexV(SDL_EventQ.lock);
slouken@4429
   275
    }
slouken@0
   276
}
slouken@0
   277
slouken@0
   278
/* Run the system dependent event loops */
slouken@1895
   279
void
slouken@1895
   280
SDL_PumpEvents(void)
slouken@0
   281
{
slouken@5123
   282
    SDL_VideoDevice *_this = SDL_GetVideoDevice();
slouken@0
   283
slouken@5123
   284
    /* Get events from the video subsystem */
slouken@5123
   285
    if (_this) {
slouken@5123
   286
        _this->PumpEvents(_this);
slouken@5123
   287
    }
slouken@1361
   288
#if !SDL_JOYSTICK_DISABLED
slouken@5123
   289
    /* Check for joystick state change */
slouken@5123
   290
    if (SDL_ShouldPollJoystick()) {
slouken@5123
   291
        SDL_JoystickUpdate();
slouken@5123
   292
    }
slouken@0
   293
#endif
slouken@0
   294
}
slouken@0
   295
slouken@0
   296
/* Public functions */
slouken@0
   297
slouken@1895
   298
int
slouken@1895
   299
SDL_PollEvent(SDL_Event * event)
slouken@0
   300
{
slouken@3072
   301
    return SDL_WaitEventTimeout(event, 0);
slouken@0
   302
}
slouken@0
   303
slouken@1895
   304
int
slouken@1895
   305
SDL_WaitEvent(SDL_Event * event)
slouken@0
   306
{
slouken@3072
   307
    return SDL_WaitEventTimeout(event, -1);
slouken@3072
   308
}
slouken@3072
   309
slouken@3072
   310
int
slouken@3072
   311
SDL_WaitEventTimeout(SDL_Event * event, int timeout)
slouken@3072
   312
{
slouken@3072
   313
    Uint32 expiration = 0;
slouken@3072
   314
slouken@3072
   315
    if (timeout > 0)
slouken@3072
   316
        expiration = SDL_GetTicks() + timeout;
slouken@3072
   317
slouken@3072
   318
    for (;;) {
slouken@1895
   319
        SDL_PumpEvents();
slouken@4429
   320
        switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) {
slouken@1895
   321
        case -1:
slouken@1895
   322
            return 0;
slouken@1895
   323
        case 1:
slouken@1895
   324
            return 1;
slouken@1895
   325
        case 0:
slouken@3072
   326
            if (timeout == 0) {
slouken@3072
   327
                /* Polling and no events, just return */
slouken@3072
   328
                return 0;
slouken@3072
   329
            }
slouken@3072
   330
            if (timeout > 0 && ((int) (SDL_GetTicks() - expiration) >= 0)) {
slouken@3072
   331
                /* Timeout expired and no events */
slouken@3072
   332
                return 0;
slouken@3072
   333
            }
slouken@1895
   334
            SDL_Delay(10);
slouken@3072
   335
            break;
slouken@1895
   336
        }
slouken@1895
   337
    }
slouken@0
   338
}
slouken@0
   339
slouken@1895
   340
int
slouken@1895
   341
SDL_PushEvent(SDL_Event * event)
slouken@0
   342
{
slouken@1895
   343
    if (SDL_EventOK && !SDL_EventOK(SDL_EventOKParam, event)) {
slouken@1895
   344
        return 0;
slouken@1895
   345
    }
slouken@4429
   346
    if (SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0, 0) <= 0) {
slouken@1895
   347
        return -1;
slouken@1895
   348
    }
jim@4657
   349
jim@4657
   350
    SDL_GestureProcessEvent(event);
jim@4657
   351
    
jim@4657
   352
slouken@1895
   353
    return 1;
slouken@0
   354
}
slouken@0
   355
slouken@1895
   356
void
slouken@1895
   357
SDL_SetEventFilter(SDL_EventFilter filter, void *userdata)
slouken@0
   358
{
slouken@1895
   359
    SDL_Event bitbucket;
slouken@0
   360
slouken@1895
   361
    /* Set filter and discard pending events */
slouken@1895
   362
    SDL_EventOK = filter;
slouken@1895
   363
    SDL_EventOKParam = userdata;
slouken@1895
   364
    while (SDL_PollEvent(&bitbucket) > 0);
slouken@0
   365
}
slouken@0
   366
slouken@1895
   367
SDL_bool
slouken@1895
   368
SDL_GetEventFilter(SDL_EventFilter * filter, void **userdata)
slouken@0
   369
{
slouken@1895
   370
    if (filter) {
slouken@1895
   371
        *filter = SDL_EventOK;
slouken@1895
   372
    }
slouken@1895
   373
    if (userdata) {
slouken@1895
   374
        *userdata = SDL_EventOKParam;
slouken@1895
   375
    }
slouken@1895
   376
    return SDL_EventOK ? SDL_TRUE : SDL_FALSE;
slouken@0
   377
}
slouken@0
   378
slouken@1895
   379
void
slouken@1895
   380
SDL_FilterEvents(SDL_EventFilter filter, void *userdata)
slouken@0
   381
{
slouken@1895
   382
    if (SDL_mutexP(SDL_EventQ.lock) == 0) {
slouken@1895
   383
        int spot;
slouken@0
   384
slouken@1895
   385
        spot = SDL_EventQ.head;
slouken@1895
   386
        while (spot != SDL_EventQ.tail) {
slouken@1895
   387
            if (filter(userdata, &SDL_EventQ.event[spot])) {
slouken@1895
   388
                spot = (spot + 1) % MAXEVENTS;
slouken@1895
   389
            } else {
slouken@1895
   390
                spot = SDL_CutEvent(spot);
slouken@1895
   391
            }
slouken@1895
   392
        }
slouken@1895
   393
    }
slouken@1895
   394
    SDL_mutexV(SDL_EventQ.lock);
slouken@1895
   395
}
slouken@0
   396
slouken@1895
   397
Uint8
slouken@4429
   398
SDL_EventState(Uint32 type, int state)
slouken@1895
   399
{
slouken@1895
   400
    Uint8 current_state;
slouken@4429
   401
    Uint8 hi = ((type >> 8) & 0xff);
slouken@4429
   402
    Uint8 lo = (type & 0xff);
slouken@1895
   403
slouken@4429
   404
    if (SDL_disabled_events[hi] &&
slouken@4429
   405
        (SDL_disabled_events[hi]->bits[lo/32] & (1 << (lo&31)))) {
slouken@4429
   406
        current_state = SDL_DISABLE;
slouken@4429
   407
    } else {
slouken@4429
   408
        current_state = SDL_ENABLE;
slouken@1895
   409
    }
slouken@1895
   410
slouken@4429
   411
    if (state != current_state)
slouken@4429
   412
    {
slouken@4429
   413
        switch (state) {
slouken@4429
   414
        case SDL_DISABLE:
slouken@4429
   415
            /* Disable this event type and discard pending events */
slouken@4429
   416
            if (!SDL_disabled_events[hi]) {
slouken@4429
   417
                SDL_disabled_events[hi] = (SDL_DisabledEventBlock*) SDL_calloc(1, sizeof(SDL_DisabledEventBlock));
slouken@4429
   418
                if (!SDL_disabled_events[hi]) {
slouken@4429
   419
                    /* Out of memory, nothing we can do... */
slouken@4429
   420
                    break;
slouken@4429
   421
                }
slouken@4429
   422
            }
slouken@4429
   423
            SDL_disabled_events[hi]->bits[lo/32] |= (1 << (lo&31));
slouken@4429
   424
            SDL_FlushEvent(type);
slouken@4429
   425
            break;
slouken@4429
   426
        case SDL_ENABLE:
slouken@4429
   427
            SDL_disabled_events[hi]->bits[lo/32] &= ~(1 << (lo&31));
slouken@4429
   428
            break;
slouken@4429
   429
        default:
slouken@4429
   430
            /* Querying state... */
slouken@4429
   431
            break;
slouken@1895
   432
        }
slouken@1895
   433
    }
slouken@4429
   434
slouken@4429
   435
    return current_state;
slouken@4429
   436
}
slouken@4429
   437
slouken@4429
   438
Uint32
slouken@4429
   439
SDL_RegisterEvents(int numevents)
slouken@4429
   440
{
slouken@4429
   441
    Uint32 event_base;
slouken@4429
   442
slouken@4429
   443
    if (SDL_userevents+numevents <= SDL_LASTEVENT) {
slouken@4429
   444
        event_base = SDL_userevents;
slouken@4429
   445
        SDL_userevents += numevents;
slouken@4429
   446
    } else {
slouken@4429
   447
        event_base = (Uint32)-1;
slouken@4429
   448
    }
slouken@4429
   449
    return event_base;
slouken@0
   450
}
slouken@0
   451
slouken@0
   452
/* This is a generic event handler.
slouken@0
   453
 */
slouken@1895
   454
int
slouken@1895
   455
SDL_SendSysWMEvent(SDL_SysWMmsg * message)
slouken@0
   456
{
slouken@1895
   457
    int posted;
slouken@0
   458
slouken@1895
   459
    posted = 0;
slouken@4429
   460
    if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
slouken@1895
   461
        SDL_Event event;
slouken@1895
   462
        SDL_memset(&event, 0, sizeof(event));
slouken@1895
   463
        event.type = SDL_SYSWMEVENT;
slouken@1895
   464
        event.syswm.msg = message;
slouken@1895
   465
        posted = (SDL_PushEvent(&event) > 0);
slouken@1895
   466
    }
slouken@1895
   467
    /* Update internal event state */
slouken@1895
   468
    return (posted);
slouken@0
   469
}
slouken@1895
   470
slouken@1895
   471
/* vi: set ts=4 sw=4 expandtab: */