~nme/nme/1.1

« back to all changes in this revision

Viewing changes to Src/NMEPluginUppercase.c

  • Committer: michael.owens at linterra
  • Date: 2008-11-19 17:49:21 UTC
  • Revision ID: michael.owens@linterra.org-20081119174921-5rh22x5qdh6ltf4o
Initial submission.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 *      @file NMEPluginUppercase.c
 
3
 *      @brief NME optional plugin for cnverting text to uppercase.
 
4
 *      @author Yves Piguet. Copyright 2007-2008, Yves Piguet.
 
5
 */
 
6
 
 
7
/* License: new BSD license (see header file) */
 
8
 
 
9
#include "NMEPluginUppercase.h"
 
10
 
 
11
NMEErr NMEPluginUppercase(NMEConstText name, NMEInt nameLen,
 
12
                NMEConstText data, NMEInt dataLen,
 
13
                NMEContext *context,
 
14
                void *userData)
 
15
{
 
16
        NMEInt i;
 
17
        NMEChar c;
 
18
        (void)name;
 
19
        (void)nameLen;
 
20
        (void)userData;
 
21
        
 
22
        for (i = 0; i < dataLen; i++)
 
23
        {
 
24
                c = data[i] >= 'a' && data[i] <= 'z'
 
25
                                ? data[i] + 'A' - 'a' : data[i];
 
26
                if (!NMEAddString(&c, 1, '\0', context))
 
27
                        return kNMEErrNotEnoughMemory;
 
28
        }
 
29
        
 
30
        return kNMEErrOk;
 
31
}