Skip to content

Commit

Permalink
Move Windows related function to windows.c
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Feb 3, 2017
1 parent 10a3836 commit 643dc64
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 41 deletions.
5 changes: 3 additions & 2 deletions lib/error.c
@@ -1,5 +1,6 @@
/* -*- c-basic-offset: 2 -*- */
/* Copyright(C) 2013 Brazil
/*
Copyright(C) 2013-2017 Brazil
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -16,7 +17,7 @@
*/

#include "grn_error.h"
#include "grn_util.h"
#include "grn_windows.h"

#ifdef HAVE_ERRNO_H
#include <errno.h>
Expand Down
4 changes: 0 additions & 4 deletions lib/grn_util.h
Expand Up @@ -40,10 +40,6 @@ void grn_p_record(grn_ctx *ctx, grn_obj *table, grn_id id);
int grn_mkstemp(char *path_template);
grn_bool grn_path_exist(const char *path);

#ifdef WIN32
GRN_API UINT grn_windows_encoding_to_code_page(grn_encoding encoding);
#endif /* WIN32 */

#ifdef __cplusplus
}
#endif
33 changes: 33 additions & 0 deletions lib/grn_windows.h
@@ -0,0 +1,33 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2010-2017 Brazil
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License version 2.1 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#pragma once

#include "grn.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef WIN32
GRN_API UINT grn_windows_encoding_to_code_page(grn_encoding encoding);
#endif /* WIN32 */

#ifdef __cplusplus
}
#endif
1 change: 1 addition & 0 deletions lib/sources.am
Expand Up @@ -94,6 +94,7 @@ libgroonga_la_SOURCES = \
util.c \
grn_util.h \
windows.c \
grn_windows.h \
windows_event_logger.c \
file_reader.c \
window_function.c \
Expand Down
31 changes: 0 additions & 31 deletions lib/util.c
Expand Up @@ -1572,34 +1572,3 @@ grn_path_exist(const char *path)
struct stat status;
return stat(path, &status) == 0;
}

#ifdef WIN32
UINT
grn_windows_encoding_to_code_page(grn_encoding encoding)
{
UINT code_page;

switch (encoding) {
case GRN_ENC_EUC_JP :
code_page = 20932;
break;
case GRN_ENC_UTF8 :
code_page = CP_UTF8;
break;
case GRN_ENC_SJIS :
code_page = 932;
break;
case GRN_ENC_LATIN1 :
code_page = 1252;
break;
case GRN_ENC_KOI8R :
code_page = 20866;
break;
default :
code_page = CP_ACP;
break;
}

return code_page;
}
#endif /* WIN32 */
34 changes: 32 additions & 2 deletions lib/windows.c
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2010-2015 Brazil
Copyright(C) 2010-2017 Brazil
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -17,6 +17,7 @@
*/

#include "grn.h"
#include "grn_windows.h"

#ifdef WIN32
static char *windows_base_dir = NULL;
Expand Down Expand Up @@ -71,4 +72,33 @@ grn_windows_base_dir(void)
}
return windows_base_dir;
}
#endif

UINT
grn_windows_encoding_to_code_page(grn_encoding encoding)
{
UINT code_page;

switch (encoding) {
case GRN_ENC_EUC_JP :
code_page = 20932;
break;
case GRN_ENC_UTF8 :
code_page = CP_UTF8;
break;
case GRN_ENC_SJIS :
code_page = 932;
break;
case GRN_ENC_LATIN1 :
code_page = 1252;
break;
case GRN_ENC_KOI8R :
code_page = 20866;
break;
default :
code_page = CP_ACP;
break;
}

return code_page;
}
#endif /* WIN32 */
4 changes: 2 additions & 2 deletions lib/windows_event_logger.c
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2015 Brazil
Copyright(C) 2015-2017 Brazil
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand All @@ -18,7 +18,7 @@

#include "grn_logger.h"
#include "grn_ctx.h"
#include "grn_util.h"
#include "grn_windows.h"

#include <string.h>

Expand Down

0 comments on commit 643dc64

Please sign in to comment.