~ubuntu-branches/ubuntu/trusty/libopensync-plugin-file/trusty

« back to all changes in this revision

Viewing changes to src/filename_scape.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2010-02-06 22:18:21 UTC
  • mfrom: (1.1.3 upstream) (4.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100206221821-kvbuxtp4n8r8ko6z
Tags: 0.39-1
* New upstream development release.
* debian/control (Build-Depends): Updated libopensync-dev build
  dependency to libopensync1exp7-dev.
* Upload to unstable.
* debian/rules (configure-stamp): Pass $(CFLAGS) to cmake instead of a
  hardcoded list.
* debian/control (Build-Depends): Bump required debhelper version to 7.0.0.
* debian/compat: Set to 7.
* debian/control (Standards-Version): Bumped to 3.8.3.
* debian/rules (install): Replace call to dh_clean -k with dh_prep.
* debian/rules (binary-arch): Removed call to dh_makeshlibs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __FILENAME_SCAPER__
 
2
#define __FILENAME_SCAPER__
 
3
 
 
4
/**
 
5
 * @file   filename_scape.h
 
6
 * @author Adenilson Cavalcanti <savagobr@yahoo.com>
 
7
 * @date   Tue Oct 21 15:31:10 2008
 
8
 *
 
9
 * @brief  An auxiliary module to scape invalid characters from filename.
 
10
 *
 
11
 * This code is free software; you can redistribute it and/or
 
12
 * modify it under the terms of the GNU Lesser General Public
 
13
 * License as published by the Free Software Foundation; either
 
14
 * version 2.1 of the License, or (at your option) any later version.
 
15
 *
 
16
 * This library is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
19
 * Lesser General Public License for more details.
 
20
 *
 
21
 * You should have received a copy of the GNU Lesser General Public
 
22
 * License along with this library; if not, write to the Free Software
 
23
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 
24
 
 
25
 */
 
26
 
 
27
static const char reserved_chars[] = { '/', '!', '?', ':', '*', '\\', '>', '<', '@' };
 
28
static const int reserved_count = 9;
 
29
static const char scaper = '_';
 
30
 
 
31
static void filename_scape_characters(char *input)
 
32
{
 
33
 
 
34
        int i;
 
35
 
 
36
        while (*input) {
 
37
                for (i = 0; i < reserved_count; ++i)
 
38
                        if (*input ==  reserved_chars[i]) {
 
39
                                *input++ = scaper;
 
40
                                goto done;
 
41
                        }
 
42
                ++input;
 
43
        done:
 
44
                ;
 
45
        }
 
46
 
 
47
}
 
48
 
 
49
#endif