[Build] Move SDL build configuration to `sdl/`

* Clean up SDL includes and include guards.
* Add the sdl target to `sdl/CMakeLists.txt`.
This commit is contained in:
Fabrice de Gans 2024-03-16 18:18:36 -07:00 committed by Fabrice de Gans
parent 000c7f854c
commit d4430ca440
21 changed files with 238 additions and 408 deletions

View File

@ -188,21 +188,21 @@ if(NOT WIN32)
find_library(PTHREAD_LIB pthread)
if(PTHREAD_LIB)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${PTHREAD_LIB})
set(VBAMCORE_LIBS ${VBAMCORE_LIBS} ${PTHREAD_LIB})
set(VBAM_PTHREAD_LIB ${PTHREAD_LIB})
endif()
elseif(MINGW)
if(NOT VBAM_STATIC)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -lpthread)
set(VBAMCORE_LIBS ${VBAMCORE_LIBS} -lpthread)
set(VBAM_PTHREAD_LIB -lpthread)
else()
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-Wl,-Bstatic -lwinpthread -Wl,-Bdynamic")
set(VBAMCORE_LIBS ${VBAMCORE_LIBS} "-Wl,-Bstatic -lwinpthread -Wl,-Bdynamic")
set(VBAM_PTHREAD_LIB "-Wl,-Bstatic -lwinpthread -Wl,-Bdynamic")
endif()
else()
find_package(PThreads4W)
if(PThreads4W_FOUND)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} PThreads4W::PThreads4W)
set(VBAMCORE_LIBS ${VBAMCORE_LIBS} PThreads4W::PThreads4W)
set(VBAM_PTHREAD_LIB PThreads4W::PThreads4W)
endif()
endif()
@ -287,14 +287,8 @@ if(NOT ENABLE_ONLINEUPDATES)
add_compile_definitions(NO_ONLINEUPDATES)
endif()
if(ENABLE_LIRC)
set(WITHLIRC 1)
else()
set(WITHLIRC 0)
endif()
# C defines
add_compile_definitions(HAVE_NETINET_IN_H HAVE_ARPA_INET_H HAVE_ZLIB_H FINAL_VERSION SDL USE_OPENGL SYSCONF_INSTALL_DIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}" WITH_LIRC=${WITHLIRC})
add_compile_definitions(HAVE_NETINET_IN_H HAVE_ARPA_INET_H HAVE_ZLIB_H FINAL_VERSION SDL USE_OPENGL SYSCONF_INSTALL_DIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
add_compile_definitions(PKGDATADIR="${CMAKE_INSTALL_FULL_DATADIR}/vbam")
add_compile_definitions(__STDC_FORMAT_MACROS)
@ -371,97 +365,12 @@ if(NOT TRANSLATIONS_ONLY)
add_subdirectory(third_party/include/stb)
add_subdirectory(src/core)
add_subdirectory(src/components)
endif()
set(
SRC_SDL
src/sdl/ConfigManager.cpp
src/sdl/dictionary.c
src/sdl/expr.cpp
src/sdl/exprNode.cpp
src/sdl/expr-lex.cpp
src/sdl/filters.cpp
src/sdl/iniparser.c
src/sdl/inputSDL.cpp
src/sdl/SDL.cpp
)
if(MSVC)
list(APPEND SRC_SDL "dependencies/msvc/getopt.c")
endif()
set(
HDR_SDL
src/sdl/ConfigManager.h
src/sdl/dictionary.h
src/sdl/expr.cpp.h
src/sdl/exprNode.h
src/sdl/filters.h
src/sdl/iniparser.h
src/sdl/inputSDL.h
)
if(MSVC)
list(APPEND HDR_SDL "dependencies/msvc/getopt.h")
endif()
if((NOT TRANSLATIONS_ONLY) AND ENABLE_SDL)
add_executable(
vbam
WIN32
${SRC_SDL}
${HDR_SDL}
)
if(WIN32)
set(WIN32_LIBRARIES wsock32 ws2_32 winmm version imm32)
endif()
if(MSVC)
# the debug lib libcmtd is linked in debug mode, so don't link the normal version
set_target_properties(vbam PROPERTIES LINK_FLAGS_DEBUG "/nodefaultlib:libcmt")
endif()
if(ENABLE_LIRC)
set(LIRC_CLIENT_LIBRARY lirc_client)
endif()
target_link_libraries(vbam
vbam-components-audio-sdl
vbam-components-draw-text
vbam-components-filters
vbam-components-filters-agb
vbam-components-filters-interframe
vbam-components-user-config
${VBAMCORE_LIBS}
${WIN32_LIBRARIES}
${LIRC_CLIENT_LIBRARY}
)
if(WIN32)
target_link_libraries(vbam ${SDL2MAIN_LIBRARY})
endif()
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/vbam${CMAKE_EXECUTABLE_SUFFIX} DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
if(WIN32)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/sdl/vbam.cfg-example
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}
RENAME vbam.cfg
)
else()
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/sdl/vbam.cfg-example
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}
RENAME vbam.cfg
)
endif()
add_subdirectory(src/sdl)
endif()
if(ENABLE_WX)
add_subdirectory(src/wx)
endif()
if(ENABLE_WX)
# Native Language Support
if(ENABLE_NLS)
add_subdirectory(po)
@ -471,9 +380,6 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/vba-over.ini DESTINATION ${CMAKE_I
# manual pages
if(UNIX)
if(ENABLE_SDL)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/debian/vbam.6 DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man6)
endif()
if(ENABLE_WX)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/debian/visualboyadvance-m.6 DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man6)
endif()

79
src/sdl/CMakeLists.txt Normal file
View File

@ -0,0 +1,79 @@
if(NOT ENABLE_SDL)
return()
endif()
# Define the vbam executable.
add_executable(vbam WIN32)
target_sources(vbam
PRIVATE
ConfigManager.cpp
ConfigManager.h
dictionary.c
dictionary.h
expr.cpp
expr.cpp.h
exprNode.cpp
exprNode.h
expr-lex.cpp
filters.cpp
filters.h
iniparser.c
iniparser.h
inputSDL.cpp
inputSDL.h
SDL.cpp
)
if(MSVC)
# We should probably use an external library for this.
target_sources(vbam
PRIVATE
${CMAKE_SOURCE_DIR}/dependencies/msvc/getopt.c
${CMAKE_SOURCE_DIR}/dependencies/msvc/getopt.h
)
endif()
if(ENABLE_LIRC)
set(LIRC_CLIENT_LIBRARY lirc_client)
endif()
target_link_libraries(vbam
vbam-core
vbam-components-audio-sdl
vbam-components-draw-text
vbam-components-filters
vbam-components-filters-agb
vbam-components-filters-interframe
vbam-components-user-config
${OPENGL_LIBRARIES}
)
if(WIN32)
target_link_libraries(vbam ${SDL2_LIBRARY} ${SDL2MAIN_LIBRARY})
endif()
if(ENABLE_LIRC)
target_link_libraries(vbam lirc_client)
target_compile_definitions(vbam VBAM_ENABLE_LIRC)
endif()
if(WIN32)
target_link_libraries(vbam wsock32 ws2_32 winmm version imm32 ${SDL2MAIN_LIBRARY})
endif()
# Installation scripts.
install(
PROGRAMS ${PROJECT_BINARY_DIR}/vbam${CMAKE_EXECUTABLE_SUFFIX}
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
)
install(
FILES ${CMAKE_CURRENT_LIST_DIR}/vbam.cfg-example
DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}
RENAME vbam.cfg
)
if(UNIX)
# man pages.
install(FILES ${CMAKE_SOURCE_DIR}/src/debian/vbam.6 DESTINATION ${CMAKE_INSTALL_FULL_MANDIR}/man6)
endif()

View File

@ -1,20 +1,46 @@
#include "ConfigManager.h"
#include "components/user_config/user_config.h"
// necessary to get portable strerror_r
#undef _GNU_SOURCE
#include <string.h>
#define _GNU_SOURCE 1
#include "sdl/ConfigManager.h"
#include <cstring>
#include <cerrno>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef _WIN32
#include <direct.h>
#include <io.h>
#define getcwd _getcwd
#define stat _stat
#define mkdir(X,Y) (_mkdir(X))
// from: https://www.linuxquestions.org/questions/programming-9/porting-to-win32-429334/
#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR)
#endif
#endif // _WIN32
#ifndef __GNUC__
#define HAVE_DECL_GETOPT 0
#define __STDC__ 1
#include "getopt.h"
#else // ! __GNUC__
#define HAVE_DECL_GETOPT 1
#include <getopt.h>
#endif // ! __GNUC__
#include "components/user_config/user_config.h"
#include "core/base/file_util.h"
#include "core/gb/gbGlobals.h"
#include "core/gb/gbSound.h"
@ -24,32 +50,8 @@
#include "core/gba/gbaRemote.h"
#include "core/gba/gbaRtc.h"
#include "core/gba/gbaSound.h"
#include "iniparser.h"
#ifndef _WIN32
#define GETCWD getcwd
#else // _WIN32
#include <direct.h>
#include <io.h>
#define GETCWD _getcwd
#define stat _stat
#define mkdir(X,Y) (_mkdir(X))
// from: https://www.linuxquestions.org/questions/programming-9/porting-to-win32-429334/
#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR)
#endif
#endif // _WIN32
#ifndef __GNUC__
#define HAVE_DECL_GETOPT 0
#define __STDC__ 1
#include "getopt.h"
#else // ! __GNUC__
#define HAVE_DECL_GETOPT 1
#include <getopt.h>
#endif // ! __GNUC__
#include <string>
#include <sstream>
#include "sdl/filters.h"
#include "sdl/iniparser.h"
namespace {
@ -437,7 +439,7 @@ const char* FindConfigFile(const char *name)
#define EXE_NAME "vbam"
#endif // ! _WIN32
if (GETCWD(buffer, 2048)) {
if (getcwd(buffer, 2048)) {
}
if (FileExists(name))

View File

@ -1,20 +1,9 @@
#ifndef _CONFIGMANAGER_H
#define _CONFIGMANAGER_H
#ifndef VBAM_SDL_CONFIGMANAGER_H_
#define VBAM_SDL_CONFIGMANAGER_H_
#pragma once
#include "core/base/system.h"
#include "../sdl/filters.h"
#include <stdio.h>
#ifndef __GNUC__
#define HAVE_DECL_GETOPT 0
#define __STDC__ 1
#include "getopt.h"
#else // ! __GNUC__
#define HAVE_DECL_GETOPT 1
#include <getopt.h>
#endif // ! __GNUC__
extern const char *biosFileNameGB;
extern const char *biosFileNameGBA;
@ -64,4 +53,5 @@ const char *ReadPrefString(const char *pref_key);
void LoadConfigFile(int argc, char **argv);
void LoadConfig();
int ReadOpts(int argc, char **argv);
#endif
#endif // VBAM_SDL_CONFIGMANAGER_H_

View File

@ -16,12 +16,6 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//OpenGL library
#if (defined _MSC_VER)
#pragma comment(lib, "OpenGL32")
#include <windows.h>
#endif
#include <cmath>
#include <cstdarg>
#include <cstdio>
@ -31,18 +25,72 @@
#include <sys/stat.h>
#include <sys/types.h>
#ifdef __APPLE__
// System includes.
#ifdef _WIN32
#include <direct.h>
#include <io.h>
#define getcwd _getcwd
#define snprintf sprintf
#define stat _stat
#define access _access
#ifndef W_OK
#define W_OK 2
#endif
#define mkdir(X,Y) (_mkdir(X))
// from: https://www.linuxquestions.org/questions/programming-9/porting-to-win32-429334/
#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR)
#endif
#endif // _WIN32
#ifndef __GNUC__
#define HAVE_DECL_GETOPT 0
#define __STDC__ 1
#include "getopt.h"
#else // ! __GNUC__
#define HAVE_DECL_GETOPT 1
#include <getopt.h>
#endif // ! __GNUC__
// OpenGL library.
#if defined(_WIN32)
#pragma comment(lib, "OpenGL32")
#include <Windows.h>
#endif // defined(_WIN32)
#if defined(__APPLE__)
#include <OpenGL/OpenGL.h>
#include <OpenGL/glext.h>
#include <OpenGL/glu.h>
#else
#else // !defined(__APPLE__)
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glu.h>
#endif
#endif // defined(__APPLE__)
#include <SDL.h>
#if defined(VBAM_ENABLE_LIRC)
#include <lirc/lirc_client.h>
#include <sys/poll.h>
#endif
#include "components/audio_sdl/audio_sdl.h"
#include "components/draw_text/draw_text.h"
#include "components/filters_agb/filters_agb.h"
@ -61,49 +109,13 @@
#include "core/gba/gbaGlobals.h"
#include "core/gba/gbaRtc.h"
#include "core/gba/gbaSound.h"
#include "ConfigManager.h"
#include "filters.h"
#include "inputSDL.h"
#include "sdl/ConfigManager.h"
#include "sdl/filters.h"
#include "sdl/inputSDL.h"
// from: https://stackoverflow.com/questions/7608714/why-is-my-pointer-not-null-after-free
#define freeSafe(ptr) free(ptr); ptr = NULL;
#ifndef _WIN32
#include <unistd.h>
#define GETCWD getcwd
#else // _WIN32
#include <direct.h>
#include <io.h>
#define GETCWD _getcwd
#define snprintf sprintf
#define stat _stat
#define access _access
#ifndef W_OK
#define W_OK 2
#endif
#define mkdir(X,Y) (_mkdir(X))
// from: https://www.linuxquestions.org/questions/programming-9/porting-to-win32-429334/
#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode) & _S_IFMT) == _S_IFDIR)
#endif
#endif // _WIN32
#ifndef __GNUC__
#define HAVE_DECL_GETOPT 0
#define __STDC__ 1
#include "getopt.h"
#else // ! __GNUC__
#define HAVE_DECL_GETOPT 1
#include <getopt.h>
#endif // ! __GNUC__
#if WITH_LIRC
#include <lirc/lirc_client.h>
#include <sys/poll.h>
#endif
extern void remoteInit();
extern void remoteCleanUp();
extern void remoteStubMain();
@ -270,7 +282,7 @@ static void sdlChangeVolume(float d)
}
}
#if WITH_LIRC
#if defined(VBAM_ENABLE_LIRC)
//LIRC code
bool LIRCEnabled = false;
int LIRCfd = 0;
@ -392,7 +404,7 @@ FILE* sdlFindFile(const char* name)
fprintf(stdout, "Searching for file %s\n", name);
if (GETCWD(buffer, sizeof(buffer))) {
if (getcwd(buffer, sizeof(buffer))) {
fprintf(stdout, "Searching current directory: %s\n", buffer);
}
@ -1327,7 +1339,7 @@ void sdlPollEvents()
}
}
#if WITH_LIRC
#if defined(VBAM_ENABLE_LIRC)
void lircCheckInput(void)
{
if (LIRCEnabled) {
@ -1799,7 +1811,7 @@ int main(int argc, char** argv)
systemMessage(0, "Failed to init joystick support: %s", SDL_GetError());
}
#if WITH_LIRC
#if defined(VBAM_ENABLE_LIRC)
StartLirc();
#endif
inputInitJoysticks();
@ -1901,7 +1913,7 @@ int main(int argc, char** argv)
SDL_Delay(500);
}
sdlPollEvents();
#if WITH_LIRC
#if defined(VBAM_ENABLE_LIRC)
lircCheckInput();
#endif
if (mouseCounter) {
@ -1939,7 +1951,7 @@ int main(int argc, char** argv)
free(patchNames[i]);
}
#if WITH_LIRC
#if defined(VBAM_ENABLE_LIRC)
StopLirc();
#endif

View File

@ -18,17 +18,17 @@
// Parts adapted from VBA-H (VBA for Hackers) by LabMaster
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "core/base/port.h"
#include "core/gba/gbaCpu.h"
#include "core/gba/gbaCpuArmDis.h"
#include "core/gba/gbaElf.h"
#include "core/gba/gbaSound.h"
#include "exprNode.h"
#include "sdl/exprNode.h"
extern bool debugger;
extern int emulating;

View File

@ -17,6 +17,13 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef VBAM_SDL_DEBUGGER_H_
#define VBAM_SDL_DEBUGGER_H_
#include <cstdint>
extern void debuggerMain();
extern void debuggerOutput(const char*, uint32_t);
extern void debuggerSignal(int, int);
#endif // VBAM_SDL_DEBUGGER_H_

View File

@ -18,7 +18,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include <unistd.h>
/** Maximum value size for integers and doubles. */
#define MAXVALSZ 1024

View File

@ -11,8 +11,8 @@
*/
/*--------------------------------------------------------------------------*/
#ifndef _DICTIONARY_H_
#define _DICTIONARY_H_
#ifndef VBAM_SDL_DICTIONARY_H_
#define VBAM_SDL_DICTIONARY_H_
/*---------------------------------------------------------------------------
Includes
@ -165,4 +165,4 @@ void dictionary_dump(dictionary *d, FILE *out);
} // extern "C"
#endif
#endif
#endif // VBAM_SDL_DICTIONARY_H_

View File

@ -90,7 +90,7 @@ enum yytokentype {
#include <string.h>
#include <cstdlib>
#include "exprNode.h"
#include "sdl/exprNode.h"
extern int yyerror(const char*);
extern int yylex();

View File

@ -6,7 +6,7 @@
#include "core/base/system.h"
#include "core/gba/gbaElf.h"
#include "exprNode.h"
#include "sdl/exprNode.h"
extern int yyerror(const char *);
extern int yylex();

View File

@ -16,15 +16,16 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sdl/exprNode.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "core/base/port.h"
#include "core/gba/gba.h"
#include "core/gba/gbaElf.h"
#include "core/gba/gbaGlobals.h"
#include "exprNode.h"
#ifndef __GNUC__
#define strdup _strdup

View File

@ -17,6 +17,9 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef VBAM_SDL_EXPRNODE_H_H
#define VBAM_SDL_EXPRNODE_H_H
#include "core/gba/gbaElf.h"
struct Node {
@ -68,3 +71,5 @@ extern void exprNodeArrayPrint(Node*);
extern bool exprNodeArrayResolve(Node*, Function*, CompileUnit*);
#define YYSTYPE struct Node*
#endif // VBAM_SDL_EXPRNODE_H_H

View File

@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "filters.h"
#include "sdl/filters.h"
#include "components/filters/filters.h"
#include "components/filters_interframe/interframe.h"

View File

@ -16,8 +16,8 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef VBA_SDL_FILTERS_H
#define VBA_SDL_FILTERS_H
#ifndef VBAM_SDL_FILTERS_H_
#define VBAM_SDL_FILTERS_H_
#include <cstdint>
@ -83,4 +83,4 @@ IFBFilterFunc initIFBFilter(const int f, const int colorDepth);
// Get the display name for an IFB filter
char* getIFBFilterName(const IFBFilter f);
#endif // VBA_SDL_FILTERS_H
#endif // VBAM_SDL_FILTERS_H_

View File

@ -1,175 +0,0 @@
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
Free Software Foundation, Inc.
NOTE: This source is derived from an old version taken from the GNU C
Library (glibc).
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "getopt.h"
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
#define const
#endif
#endif
#include <stdio.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#define GETOPT_INTERFACE_VERSION 2
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
#include <gnu-versions.h>
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
#define ELIDE_CODE
#endif
#endif
#ifndef ELIDE_CODE
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#include <stdlib.h>
#endif
#ifndef NULL
#define NULL 0
#endif
int getopt_long(argc, argv, options, long_options, opt_index) int argc;
char* const* argv;
const char* options;
const struct option* long_options;
int* opt_index;
{
return _getopt_internal(argc, argv, options, long_options, opt_index, 0);
}
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
If an option that starts with '-' (not '--') doesn't match a long option,
but does match a short option, it is parsed as a short option
instead. */
int getopt_long_only(argc, argv, options, long_options, opt_index) int argc;
char* const* argv;
const char* options;
const struct option* long_options;
int* opt_index;
{
return _getopt_internal(argc, argv, options, long_options, opt_index, 1);
}
#endif /* Not ELIDE_CODE. */
#ifdef TEST
#include <stdio.h>
int main(argc, argv) int argc;
char** argv;
{
int c;
int digit_optind = 0;
while (1) {
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] = { { "add", 1, 0, 0 },
{ "append", 0, 0, 0 },
{ "delete", 1, 0, 0 },
{ "verbose", 0, 0, 0 },
{ "create", 0, 0, 0 },
{ "file", 1, 0, 0 },
{ 0, 0, 0, 0 } };
c = getopt_long(argc, argv, "abc:d:0123456789", long_options, &option_index);
if (c == -1)
break;
switch (c) {
case 0:
printf("option %s", long_options[option_index].name);
if (optarg)
printf(" with arg %s", optarg);
printf("\n");
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf("option %c\n", c);
break;
case 'a':
printf("option a\n");
break;
case 'b':
printf("option b\n");
break;
case 'c':
printf("option c with value `%s'\n", optarg);
break;
case 'd':
printf("option d with value `%s'\n", optarg);
break;
case '?':
break;
default:
printf("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc) {
printf("non-option ARGV-elements: ");
while (optind < argc)
printf("%s ", argv[optind++]);
printf("\n");
}
exit(0);
}
#endif /* TEST */

View File

@ -7,7 +7,8 @@
*/
/*--------------------------------------------------------------------------*/
/*---------------------------- Includes ------------------------------------*/
#include "iniparser.h"
#include "sdl/iniparser.h"
#include <ctype.h>
/*---------------------------- Defines -------------------------------------*/

View File

@ -7,8 +7,8 @@
*/
/*--------------------------------------------------------------------------*/
#ifndef _INIPARSER_H_
#define _INIPARSER_H_
#ifndef VBAM_SDL_INIPARSER_H_
#define VBAM_SDL_INIPARSER_H_
/*---------------------------------------------------------------------------
Includes
@ -308,4 +308,4 @@ void iniparser_freedict(dictionary *d);
} // extern "C"
#endif
#endif
#endif // VBAM_SDL_INIPARSER_H_

View File

@ -15,8 +15,9 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "inputSDL.h"
#include "ConfigManager.h"
#include "sdl/inputSDL.h"
#include "sdl/ConfigManager.h"
#define SDLBUTTONS_NUM 14

View File

@ -15,10 +15,12 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef VBAM_SDL_INPUT_H
#define VBAM_SDL_INPUT_H
#ifndef VBAM_SDL_INPUT_H_
#define VBAM_SDL_INPUT_H_
#include "SDL.h"
#include <cstdint>
#include <SDL_events.h>
enum EKey {
KEY_LEFT,
@ -136,4 +138,4 @@ void inputSetDefaultJoypad(EPad pad);
*/
EPad inputGetDefaultJoypad();
#endif // VBAM_SDL_INPUT_H
#endif // VBAM_SDL_INPUT_H_