More splits from "tuxpaint.c":

+ "debug.h": Defines whether debugging printf() calls should be enabled.
  + "dirwalk.c/h": Callback functions for recursive directory traversal.
  + "fonts.c/h": Font loading/grouping/discarding variables and functions.
  + "get_fname.c/h": Functions for constructing preferred file paths.
This commit is contained in:
William Kendrick 2006-02-19 08:02:39 +00:00
parent ce30f735f1
commit e964eb17a0
19 changed files with 1796 additions and 1568 deletions

View file

@ -7,7 +7,7 @@
# bill@newbreedsoftware.com
# http://www.newbreedsoftware.com/tuxpaint/
# June 14, 2002 - February 17, 2006
# June 14, 2002 - February 18, 2006
# The version number, for release:
@ -951,16 +951,14 @@ install-man:
# Build the program!
tuxpaint: obj/tuxpaint.o obj/i18n.o obj/cursor.o obj/pixels.o \
obj/floodfill.o obj/rgblinear.o obj/playsound.o \
obj/progressbar.o \
obj/floodfill.o obj/rgblinear.o obj/playsound.o obj/fonts.o \
obj/progressbar.o obj/dirwalk.o obj/get_fname.o \
$(HQXX_O) $(ARCH_LIBS)
@echo
@echo "...Linking Tux Paint..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-o tuxpaint \
obj/tuxpaint.o obj/i18n.o obj/cursor.o obj/pixels.o \
obj/floodfill.o obj/rgblinear.o obj/playsound.o \
obj/progressbar.o \
$^ \
$(HQXX_O) \
$(ARCH_LIBS) $(SDL_LIBS) \
-lm $(ARCH_LINKS)
@ -972,9 +970,9 @@ tuxpaint: obj/tuxpaint.o obj/i18n.o obj/cursor.o obj/pixels.o \
obj/tuxpaint.o: src/tuxpaint.c obj \
src/i18n.h src/cursor.h src/pixels.h \
src/floodfill.h src/rgblinear.h src/playsound.h \
src/progressbar.h \
src/compiler.h \
src/floodfill.h src/rgblinear.h src/playsound.h src/fonts.h \
src/progressbar.h src/dirwalk.h src/get_fname.h \
src/compiler.h src/debug.h \
src/tools.h src/titles.h src/colors.h src/shapes.h \
src/magic.h src/sounds.h src/tip_tux.h src/great.h \
$(HQXX_H) \
@ -997,46 +995,69 @@ obj/tuxpaint.o: src/tuxpaint.c obj \
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(MOUSE_CFLAGS) $(DEFS) \
-c src/tuxpaint.c -o obj/tuxpaint.o
obj/i18n.o: src/i18n.c src/i18n.h
obj/i18n.o: src/i18n.c src/i18n.h src/debug.h
@echo
@echo "...Compiling i18n support..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(DEFS) \
-c src/i18n.c -o obj/i18n.o
obj/cursor.o: src/cursor.c src/cursor.h
obj/get_fname.o: src/get_fname.c src/get_fname.h src/debug.h
@echo
@echo "...Compiling filename support..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(DEFS) \
-c src/get_fname.c -o obj/get_fname.o
obj/fonts.o: src/fonts.c src/fonts.h src/dirwalk.h src/progressbar.h \
src/get_fname.h src/debug.h
@echo
@echo "...Compiling font support..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/fonts.c -o obj/fonts.o
obj/dirwalk.o: src/dirwalk.c src/dirwalk.h src/progressbar.h src/fonts.h \
src/debug.h
@echo
@echo "...Compiling directory-walking support..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/dirwalk.c -o obj/dirwalk.o
obj/cursor.o: src/cursor.c src/cursor.h src/debug.h
@echo
@echo "...Compiling cursor support..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(MOUSE_CFLAGS) $(DEFS) \
-c src/cursor.c -o obj/cursor.o
obj/pixels.o: src/pixels.c src/pixels.h src/compiler.h
obj/pixels.o: src/pixels.c src/pixels.h src/compiler.h src/debug.h
@echo
@echo "...Compiling pixel functions..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/pixels.c -o obj/pixels.o
obj/floodfill.o: src/floodfill.c src/floodfill.h \
src/compiler.h src/rgblinear.h \
src/playsound.h src/progressbar.h \
src/sounds.h
src/rgblinear.h \
src/playsound.h src/progressbar.h src/sounds.h \
src/compiler.h src/debug.h
@echo
@echo "...Compiling floodfill functions..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/floodfill.c -o obj/floodfill.o
obj/playsound.o: src/playsound.c src/playsound.h src/compiler.h
obj/playsound.o: src/playsound.c src/playsound.h \
src/compiler.h src/debug.h
@echo
@echo "...Compiling sound playback functions..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/playsound.c -o obj/playsound.o
obj/progressbar.o: src/progressbar.c src/progressbar.h src/compiler.h
obj/progressbar.o: src/progressbar.c src/progressbar.h \
src/compiler.h src/debug.h
@echo
@echo "...Compiling progress bar functions..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/progressbar.c -o obj/progressbar.o
obj/rgblinear.o: src/rgblinear.c src/rgblinear.h src/compiler.h
obj/rgblinear.o: src/rgblinear.c src/rgblinear.h \
src/compiler.h src/debug.h
@echo
@echo "...Compiling RGB to Linear functions..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
@ -1049,7 +1070,7 @@ obj/BeOS_Print.o: src/BeOS_Print.cpp obj src/BeOS_print.h
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/BeOS_print.cpp -o obj/BeOS_print.o
obj/win32_print.o: src/win32_print.c obj src/win32_print.h
obj/win32_print.o: src/win32_print.c obj src/win32_print.h src/debug.h
@echo
@echo "...Compiling win32 print support..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \

View file

@ -9,7 +9,7 @@ http://www.newbreedsoftware.com/tuxpaint/
$Id$
2006.February.17 (0.9.16)
2006.February.19 (0.9.16)
* Interface improvements:
-----------------------
* Modified "Text" tool so that it correctly handles the 16-bit unicode
@ -55,14 +55,18 @@ $Id$
* Compiling, porting and packaging updates:
-----------------------------------------
* Split parts of "tuxpaint.c" into separate source files:
+ "i18n.c/h": Language-related variables, enums, arrays and functions.
+ "cursor.c/h": XBM bitmap cursor #includes and functions.
+ "compiler.h": Compiler-version-specific definitions.
+ "pixles.c/h": 'getpixel' and 'putpixel' functions & function pointers.
+ "cursor.c/h": XBM bitmap cursor #includes and functions.
+ "debug.h": Defines whether debugging printf() calls should be enabled.
+ "dirwalk.c/h": Callback functions for recursive directory traversal.
+ "fonts.c/h": Font loading/grouping/discarding variables and functions.
+ "floodfill.c/h": 'Fill' tool's flood-fill routine.
+ "rgblinear.c/h": RGB-to-linear float and binary data, and functions.
+ "progressbar.c/h": Animated progress bar function.
+ "get_fname.c/h": Functions for constructing preferred file paths.
+ "i18n.c/h": Language-related variables, enums, arrays and functions.
+ "pixles.c/h": 'getpixel' and 'putpixel' functions & function pointers.
+ "playsound.c/h": Sound-playing function.
+ "progressbar.c/h": Animated progress bar function.
+ "rgblinear.c/h": RGB-to-linear float and binary data, and functions.
* Made sure GPL notice was included in all other source files.

View file

@ -23,11 +23,12 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - February 17, 2006
June 14, 2002 - February 18, 2006
$Id$
*/
#include "cursor.h"
#include "debug.h"
#define UNUSED(arg) ((void)(arg))

2
src/debug.h Normal file
View file

@ -0,0 +1,2 @@
//#define DEBUG

304
src/dirwalk.c Normal file
View file

@ -0,0 +1,304 @@
/*
dirwalk.c
*/
#include <stdio.h>
#include <stdlib.h>
#define __USE_GNU /* for strcasestr() */
#include <string.h>
#include <locale.h>
#include <libintl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#ifndef WIN32
#include <unistd.h>
#include <dirent.h>
#endif
#include "SDL_ttf.h"
#include "dirwalk.h"
#include "progressbar.h"
#include "fonts.h"
#include "debug.h"
///////////////// directory walking callers and callbacks //////////////////
void loadfont_callback(SDL_Surface * screen, const char *restrict const dir, unsigned dirlen, tp_ftw_str *files, unsigned i)
{
dirlen = dirlen;
while(i--)
{
int loadable = 0;
const char *restrict const cp = strchr(files[i].str, '.');
show_progress_bar(screen);
if(cp)
{
// need gcc 3.4 for the restrict in this location
const char * /*restrict*/ const suffixes[] = {"ttc", "dfont", "pfa", "pfb", "otf", "ttf",};
int j = sizeof suffixes / sizeof suffixes[0];
while(j--)
{
// only check part, because of potential .gz or .bz2 suffix
if(!strncasecmp(cp+1,suffixes[j],strlen(suffixes[j])))
{
loadable = 1;
break;
}
}
}
if(!loadable)
{
if(strcasestr(files[i].str, "/rsrc"))
loadable = 1;
}
// Loadable: TrueType (.ttf), OpenType (.otf), Type1 (.pfa and .pfb),
// and various useless bitmap fonts. Compressed files (with .gz or .bz2)
// should also work. A *.dfont is pretty much a Mac resource fork in a normal
// file, and may load with some library versions.
if (loadable)
{
char fname[512];
TTF_Font *font;
snprintf(fname, sizeof fname, "%s/%s", dir, files[i].str);
//printf("Loading font: %s\n", fname);
font = TTF_OpenFont(fname, text_sizes[text_size]);
if(font)
{
const char *restrict const family = TTF_FontFaceFamilyName(font);
const char *restrict const style = TTF_FontFaceStyleName(font);
#ifdef DEBUG
int numfaces = TTF_FontFaces(font);
if (numfaces != 1)
printf("Found %d faces in %s, %s, %s\n", numfaces, files[i].str, family, style);
#endif
// First, the blacklist. We list font families that can crash Tux Paint
// via bugs in the SDL_ttf library. We also test fonts to be sure that
// they have both uppercase and lowercase letters. Note that we do not
// test for "Aa", because it is OK if uppercase and lowercase are the
// same. (but not nice -- such fonts get a low score later)
//
// We test the alphabet twice, to help with translation. If the users
// will be unable to type ASCII letters, then both lines should be
// translated. Otherwise, only Line X should be translated and the
// ASCII-only fonts should be given bad scores in the scoring code below.
// (the best scores going to fonts that support both)
if
(
strcmp("Zapfino",family) && strcmp("Elvish Ring NFI",family)
&&
(
(charset_works(font, gettext("qx")) && charset_works(font, gettext("QX"))) // Line X
||
(charset_works(font, gettext("qy")) && charset_works(font, gettext("QY"))) // Line Y
)
)
{
if (num_font_styles==num_font_styles_max)
{
num_font_styles_max = num_font_styles_max * 5 / 4 + 30;
user_font_styles = realloc(user_font_styles, num_font_styles_max * sizeof *user_font_styles);
}
user_font_styles[num_font_styles] = malloc(sizeof *user_font_styles[num_font_styles]);
user_font_styles[num_font_styles]->directory = strdup(dir);
user_font_styles[num_font_styles]->filename = files[i].str; // steal it (mark NULL below)
user_font_styles[num_font_styles]->family = strdup(family);
user_font_styles[num_font_styles]->style = strdup(style);
// Now we score fonts to ensure that the best ones will be placed at
// the top of the list. The user will see them first. This sorting is
// especially important for users who have scroll buttons disabled.
// Translators should do whatever is needed to put crummy fonts last.
user_font_styles[num_font_styles]->score = charset_works(font, gettext("oO")); // distinct uppercase and lowercase
user_font_styles[num_font_styles]->score += charset_works(font, gettext("`\%_@$~#{}<>^&*")); // uncommon punctuation
user_font_styles[num_font_styles]->score += charset_works(font, gettext(",.?!")); // common punctuation
user_font_styles[num_font_styles]->score += charset_works(font, gettext("017")); // digits
user_font_styles[num_font_styles]->score += charset_works(font, gettext("O0")); // distinct circle-like characters
user_font_styles[num_font_styles]->score += charset_works(font, gettext("1Il|")); // distinct line-like characters
num_font_styles++;
//printf("Accepted: %s, %s, %s, score(%d)\n", files[i].str, family, style, user_font_styles[num_font_styles]->score);
files[i].str = NULL; // so free() won't crash -- we stole the memory
}
else
{
#if 0
// THREADED_FONTS
printf("Font is too defective: %s, %s, %s\n", files[i].str, family, style);
#endif
}
TTF_CloseFont(font);
}
else
{
#if 0
// THREADED_FONTS
printf("could not open %s\n", files[i].str);
#endif
}
}
free(files[i].str);
}
free(files);
}
// For qsort()
int compare_ftw_str(const void *v1, const void *v2)
{
const char *restrict const s1 = ((tp_ftw_str*)v1)->str;
const char *restrict const s2 = ((tp_ftw_str*)v2)->str;
return -strcmp(s1, s2);
}
void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen, int rsrc,
void (*fn)(SDL_Surface * screen, const char *restrict const dir, unsigned dirlen, tp_ftw_str *files, unsigned count)
)
{
DIR *d;
unsigned num_file_names = 0;
unsigned max_file_names = 0;
tp_ftw_str *file_names = NULL;
unsigned num_dir_names = 0;
unsigned max_dir_names = 0;
tp_ftw_str *dir_names = NULL;
int d_namlen;
int add_rsrc;
dir[dirlen++] = '/';
dir[dirlen] = '\0';
//printf("processing directory %s %d\n", dir, dirlen);
/* Open the directory: */
d = opendir(dir);
if (!d)
return;
for(;;)
{
struct dirent * f = readdir(d);
int filetype = TP_FTW_UNKNOWN;
if(!f)
break;
if(f->d_name[0]=='.')
continue;
// Linux and BSD can often provide file type info w/o the stat() call
#ifdef DT_UNKNOWN
switch(f->d_type)
{
default:
continue;
case DT_REG:
if(!rsrc) // if maybe opening resource files, need st_size
filetype = TP_FTW_NORMAL;
break;
case DT_DIR:
filetype = TP_FTW_DIRECTORY;
break;
case DT_UNKNOWN:
case DT_LNK:
;
}
#else
#warning Failed to see DT_UNKNOWN
#endif
#if defined(_DIRENT_HAVE_D_NAMLEN) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
d_namlen = f->d_namlen;
#else
d_namlen = strlen(f->d_name);
#endif
add_rsrc = 0;
if(filetype == TP_FTW_UNKNOWN)
{
struct stat sbuf;
memcpy(dir+dirlen, f->d_name, d_namlen+1);
if(stat(dir, &sbuf))
continue; // oh well... try the next one
if(S_ISDIR(sbuf.st_mode))
filetype = TP_FTW_DIRECTORY;
else if(S_ISREG(sbuf.st_mode))
{
filetype = TP_FTW_NORMAL;
if(rsrc && !sbuf.st_size)
add_rsrc = 5; // 5 is length of "/rsrc"
}
else
continue; // was a device file or somesuch
}
if(filetype==TP_FTW_NORMAL)
{
char *cp;
if(num_file_names==max_file_names)
{
max_file_names = max_file_names * 5 / 4 + 30;
file_names = realloc(file_names, max_file_names * sizeof *file_names);
}
cp = malloc(d_namlen + add_rsrc + 1);
memcpy(cp, f->d_name, d_namlen);
if(add_rsrc)
memcpy(cp+d_namlen, "/rsrc", 6);
else
cp[d_namlen] = '\0';
file_names[num_file_names].str = cp;
file_names[num_file_names].len = d_namlen;
num_file_names++;
}
if(filetype==TP_FTW_DIRECTORY)
{
char * cp;
if(num_dir_names==max_dir_names)
{
max_dir_names = max_dir_names * 5 / 4 + 3;
dir_names = realloc(dir_names, max_dir_names * sizeof *dir_names);
}
cp = malloc(d_namlen + 1);
memcpy(cp, f->d_name, d_namlen + 1);
dir_names[num_dir_names].str = cp;
dir_names[num_dir_names].len = d_namlen;
num_dir_names++;
}
}
closedir(d);
show_progress_bar(screen);
dir[dirlen] = '\0'; // repair it (clobbered for stat() call above)
if(file_names)
{
// let callee sort and keep the string
#if 0
qsort(file_names, num_file_names, sizeof *file_names, compare_ftw_str);
while(num_file_names--)
{
free(file_names[num_file_names].str);
}
free(file_names);
#else
fn(screen, dir, dirlen, file_names, num_file_names);
#endif
}
if(dir_names)
{
qsort(dir_names, num_dir_names, sizeof *dir_names, compare_ftw_str);
while(num_dir_names--)
{
memcpy(dir+dirlen, dir_names[num_dir_names].str, dir_names[num_dir_names].len+1);
tp_ftw(screen, dir, dirlen+dir_names[num_dir_names].len, rsrc, fn);
free(dir_names[num_dir_names].str);
}
free(dir_names);
}
}

33
src/dirwalk.h Normal file
View file

@ -0,0 +1,33 @@
/*
dirwalk.h
*/
#ifndef DIRWALK_H
#define DIRWALK_H
#include "SDL.h"
#include "compiler.h"
/////////////////////////////// directory tree walking /////////////////////
#define TP_FTW_UNKNOWN 1
#define TP_FTW_DIRECTORY 2
#define TP_FTW_NORMAL 0
#define TP_FTW_PATHSIZE 400
typedef struct tp_ftw_str {
char *str;
unsigned char len;
// unsigned char is_rsrc;
} tp_ftw_str;
void loadfont_callback(SDL_Surface * screen, const char *restrict const dir, unsigned dirlen, tp_ftw_str *files, unsigned i);
int compare_ftw_str(const void *v1, const void *v2);
void tp_ftw(SDL_Surface * screen, char *restrict const dir, unsigned dirlen, int rsrc,
void (*fn)(SDL_Surface * screen, const char *restrict const dir, unsigned dirlen, tp_ftw_str *files, unsigned count));
#endif

View file

@ -23,7 +23,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - February 17, 2006
June 14, 2002 - February 18, 2006
$Id$
*/
@ -35,6 +35,8 @@
#include "playsound.h"
#include "progressbar.h"
#include "debug.h"
/* For flood fill... */

1135
src/fonts.c Normal file

File diff suppressed because it is too large Load diff

120
src/fonts.h Normal file
View file

@ -0,0 +1,120 @@
/*
fonts.h
*/
#ifndef FONTS_H
#define FONTS_H
// plan to rip this out as soon as it is considered stable
//#define THREADED_FONTS
#define FORKED_FONTS
#ifdef WIN32
#undef FORKED_FONTS
#endif
#include "SDL.h"
#include "SDL_ttf.h"
#include "compiler.h"
#ifndef FORKED_FONTS
#include "SDL_thread.h"
#include "SDL_mutex.h"
extern SDL_Thread *font_thread;
#endif
extern volatile long font_thread_done, font_thread_aborted;
extern volatile long waiting_for_fonts;
extern int font_scanner_pid;
extern int font_socket_fd;
extern int no_system_fonts;
extern int was_bad_font;
TTF_Font *BUGFIX_TTF_OpenFont206(const char * const file, int ptsize);
#define TTF_OpenFont BUGFIX_TTF_OpenFont206
TTF_Font *try_alternate_font(int size);
TTF_Font *load_locale_font(TTF_Font *fallback, int size);
int load_user_fonts(SDL_Surface * screen, void *vp);
#ifdef FORKED_FONTS
void reliable_write(int fd, const void *buf, size_t count);
void reliable_read(int fd, void *buf, size_t count);
void run_font_scanner(SDL_Surface * screen);
void receive_some_font_info(SDL_Surface * screen);
#endif
//////////////////////////////////////////////////////////////////////
// font stuff
// example from a Debian box with MS fonts:
// start with 232 files
// remove "Cursor", "Webdings", "Dingbats", "Standard Symbols L"
// split "Condensed" faces out into own family
// group by family
// end up with 34 user choices
extern int text_state;
// nice progression (alternating 33% and 25%) 9 12 18 24 36 48 72 96 144 192
// commonly hinted sizes seem to be: 9, 10, 12, 14, 18, 20 (less so), 24
// reasonable: 9,12,18... and 10,14,18...
static int text_sizes[] = {9, 12, 18, 24, 36, 48,
56, 64, 96, 112, 128, 160}; // point sizes
#define MIN_TEXT_SIZE 0u
#define MAX_TEXT_SIZE (sizeof text_sizes / sizeof text_sizes[0] - 1)
static unsigned text_size = 4; // initial text size
// for sorting through the font files at startup
typedef struct style_info {
char *filename;
char *directory;
char *family; // name like "FooCorp Thunderstruck"
char *style; // junk like "Oblique Demi-Bold"
int italic;
int boldness;
int score;
int truetype; // Is it? (TrueType gets priority)
} style_info;
// user's notion of a font
typedef struct family_info {
char *directory;
char *family;
char *filename[4];
TTF_Font *handle;
int score;
} family_info;
extern TTF_Font * medium_font, * small_font, * large_font, * locale_font;
extern family_info **user_font_families;
extern int num_font_families;
extern int num_font_families_max;
extern style_info **user_font_styles;
extern int num_font_styles;
extern int num_font_styles_max;
int compar_fontgroup(const void *v1, const void *v2);
int compar_fontkiller(const void *v1, const void *v2);
int compar_fontscore(const void *v1, const void *v2);
void parse_font_style(style_info *si);
void groupfonts_range(style_info **base, int count);
void dupe_markdown_range(family_info **base, int count);
void groupfonts(void);
TTF_Font *getfonthandle(int desire);
void loadfonts(SDL_Surface * screen, const char * const dir);
int do_surfcmp(const SDL_Surface *const *const v1, const SDL_Surface *const *const v2);
int surfcmp(const void *s1, const void *s2);
int charset_works(TTF_Font *font, const char *s);
#endif

99
src/get_fname.c Normal file
View file

@ -0,0 +1,99 @@
/*
get_fname.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "get_fname.h"
#include "debug.h"
char * savedir;
/* The filename for the current image: */
char * get_fname(const char * const name)
{
char f[512];
const char * tux_settings_dir;
/* Where is the user's data directory?
This is where their saved files are stored,
local fonts, brushes and stamps can be found,
and where the "current_id.txt" file is saved */
#ifdef WIN32
/* Windows predefines "savedir" as:
"C:\Documents and Settings\%USERNAME%\Application Data\TuxPaint"
though it may get overridden with "--savedir" option */
snprintf(f, sizeof(f), "%s/%s", savedir, name);
#elif __BEOS__
/* BeOS similarly predefines "savedir" as "./userdata"... */
if (*name == '\0')
strcpy(f, savedir);
else
snprintf(f, sizeof(f), "%s/%s", savedir, name);
#elif __APPLE__
/* Macintosh: It's under ~/Library/Application Support/TuxPaint */
tux_settings_dir = "Library/Application Support/TuxPaint";
#else
/* Linux & Unix: It's under ~/.tuxpaint */
tux_settings_dir = ".tuxpaint";
#endif
/* Put together home directory path + settings directory + filename... */
if (savedir == NULL)
{
/* Save directory not overridden: */
if (getenv("HOME") != NULL)
{
if (*name == '\0')
{
/* (Some mkdir()'s don't like trailing slashes) */
snprintf(f, sizeof(f), "%s/%s", getenv("HOME"), tux_settings_dir);
}
else
{
snprintf(f, sizeof(f), "%s/%s/%s",
getenv("HOME"), tux_settings_dir, name);
}
}
else
{
/* WOAH! Don't know where HOME directory is! Last resort, use '.'! */
strcpy(f, name);
}
}
else
{
/* User had overridden save directory with "--savedir" option: */
if (*name != '\0')
{
/* (Some mkdir()'s don't like trailing slashes) */
snprintf(f, sizeof(f), "%s/%s", savedir, name);
}
else
{
snprintf(f, sizeof(f), "%s", savedir);
}
}
return strdup(f);
}

14
src/get_fname.h Normal file
View file

@ -0,0 +1,14 @@
/*
get_fname.h
*/
#ifndef GET_FNAME_H
#define GET_FNAME_H
extern char * savedir;
char * get_fname(const char * const name);
#endif

View file

@ -32,6 +32,7 @@
#include <string.h>
#include <libintl.h>
#include "i18n.h"
#include "debug.h"
/* Globals: */

View file

@ -29,6 +29,7 @@
#include "pixels.h"
#include "compiler.h"
#include "debug.h"
/* Draw a single pixel into the surface: */
void putpixel8(SDL_Surface * surface, int x, int y, Uint32 pixel)

View file

@ -1,4 +1,5 @@
#include "playsound.h"
#include "debug.h"
#ifndef NOSOUND
Mix_Chunk * sounds[NUM_SOUNDS];

View file

@ -29,13 +29,11 @@
#include "progressbar.h"
#include "debug.h"
SDL_Surface * img_progress;
int progress_bar_disabled, prog_bar_ctr;
static void eat_sdl_events(void);
void show_progress_bar(SDL_Surface * screen)
{
SDL_Rect dest, src;

View file

@ -23,11 +23,12 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - February 17, 2006
June 14, 2002 - February 18, 2006
$Id$
*/
#include "rgblinear.h"
#include "debug.h"
unsigned char linear_to_sRGB (float linear)
{

File diff suppressed because it is too large Load diff

View file

@ -35,6 +35,7 @@
#include <assert.h>
#include "win32_dirent.h"
#include "debug.h"
DIR *opendir( const char *pSpec )
{

View file

@ -28,6 +28,7 @@
#include <direct.h>
#include "SDL_syswm.h"
#include "win32_print.h"
#include "debug.h"
#define NOREF(x) ((x)=(x))