sprinkled some more const qualifiers

This commit is contained in:
Sven Neumann
2003-07-02 15:23:47 +00:00
parent d94c3f36d9
commit 5143aa7c4b
6 changed files with 134 additions and 107 deletions

View File

@ -63,21 +63,21 @@
#include "libgimp/stdplugins-intl.h" #include "libgimp/stdplugins-intl.h"
gchar *prog_name = "bmp"; const gchar *prog_name = "bmp";
gchar *filename; const gchar *filename = NULL;
gboolean interactive_bmp; gboolean interactive_bmp;
struct Bitmap_File_Head_Struct Bitmap_File_Head; struct Bitmap_File_Head_Struct Bitmap_File_Head;
struct Bitmap_Head_Struct Bitmap_Head; struct Bitmap_Head_Struct Bitmap_Head;
/* Declare some local functions. /* Declare some local functions.
*/ */
static void query (void); static void query (void);
static void run (const gchar *name, static void run (const gchar *name,
gint nparams, gint nparams,
const GimpParam *param, const GimpParam *param,
gint *nreturn_vals, gint *nreturn_vals,
GimpParam **return_vals); GimpParam **return_vals);
GimpPlugInInfo PLUG_IN_INFO = GimpPlugInInfo PLUG_IN_INFO =
{ {

View File

@ -9,32 +9,32 @@
#define Write(file,buffer,len) fwrite(buffer, len, 1, file) #define Write(file,buffer,len) fwrite(buffer, len, 1, file)
#define WriteOK(file,buffer,len) (Write(buffer, len, file) != 0) #define WriteOK(file,buffer,len) (Write(buffer, len, file) != 0)
extern gint32 ReadBMP (gchar *); extern gint32 ReadBMP (const gchar *filename);
extern GimpPDBStatusType WriteBMP (gchar *, extern GimpPDBStatusType WriteBMP (const gchar *filename,
gint32, gint32,
gint32); gint32);
extern Image ReadImage (FILE *, extern Image ReadImage (FILE *,
gint, gint,
gint, gint,
guchar[256][3], guchar[256][3],
gint, gint,
gint, gint,
gint, gint,
gint, gint,
gint); gint);
extern void WriteImage (FILE *, extern void WriteImage (FILE *,
guchar *, guchar *,
gint, gint,
gint, gint,
gint, gint,
gint, gint,
gint, gint,
gint, gint,
gint); gint);
extern gboolean interactive_bmp; extern gboolean interactive_bmp;
extern gchar *prog_name; extern const gchar *prog_name;
extern gchar *filename; extern const gchar *filename;
extern struct Bitmap_File_Head_Struct extern struct Bitmap_File_Head_Struct
{ {

View File

@ -79,7 +79,7 @@ ReadColorMap (FILE *fd,
} }
gint32 gint32
ReadBMP (gchar *name) ReadBMP (const gchar *name)
{ {
FILE *fd; FILE *fd;
gchar *temp_buf; gchar *temp_buf;
@ -326,21 +326,24 @@ ReadImage (FILE *fd,
{ {
image = gimp_image_new (width, height, GIMP_RGB); image = gimp_image_new (width, height, GIMP_RGB);
layer = gimp_layer_new (image, _("Background"), layer = gimp_layer_new (image, _("Background"),
width, height, GIMP_RGB_IMAGE, 100, GIMP_NORMAL_MODE); width, height,
GIMP_RGB_IMAGE, 100, GIMP_NORMAL_MODE);
channels = 3; channels = 3;
} }
else if (grey) else if (grey)
{ {
image = gimp_image_new (width, height, GIMP_GRAY); image = gimp_image_new (width, height, GIMP_GRAY);
layer = gimp_layer_new (image, _("Background"), layer = gimp_layer_new (image, _("Background"),
width, height, GIMP_GRAY_IMAGE, 100, GIMP_NORMAL_MODE); width, height,
GIMP_GRAY_IMAGE, 100, GIMP_NORMAL_MODE);
channels = 1; channels = 1;
} }
else else
{ {
image = gimp_image_new (width, height, GIMP_INDEXED); image = gimp_image_new (width, height, GIMP_INDEXED);
layer = gimp_layer_new (image, _("Background"), layer = gimp_layer_new (image, _("Background"),
width, height, GIMP_INDEXED_IMAGE, 100, GIMP_NORMAL_MODE); width, height,
GIMP_INDEXED_IMAGE, 100, GIMP_NORMAL_MODE);
channels = 1; channels = 1;
} }

View File

@ -106,9 +106,9 @@ WriteColorMap (FILE *f,
} }
GimpPDBStatusType GimpPDBStatusType
WriteBMP (gchar *filename, WriteBMP (const gchar *filename,
gint32 image, gint32 image,
gint32 drawable_ID) gint32 drawable_ID)
{ {
FILE *outfile; FILE *outfile;
gint Red[MAXCOLORS]; gint Red[MAXCOLORS];

View File

@ -37,7 +37,6 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <errno.h> #include <errno.h>
#include <ctype.h>
#ifdef __EMX__ #ifdef __EMX__
#include <process.h> #include <process.h>
#endif #endif
@ -79,20 +78,20 @@ static void run (const gchar *name,
GimpParam **return_vals); GimpParam **return_vals);
static gint open_url_dialog (void); static gint open_url_dialog (void);
static void ok_callback (GtkWidget *widget, static void ok_callback (GtkWidget *widget,
gpointer data); gpointer data);
static void about_callback (GtkWidget *widget, static void about_callback (GtkWidget *widget,
gpointer data); gpointer data);
static void new_window_callback (GtkWidget *widget, static void new_window_callback (GtkWidget *widget,
gpointer data); gpointer data);
static void url_callback (GtkWidget *widget, static void url_callback (GtkWidget *widget,
gpointer data); gpointer data);
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
static gint mozilla_remote (gchar *command); static gint mozilla_remote (const gchar *command);
#endif #endif
static gint open_url (gchar *url, static gint open_url (const gchar *url,
gint new_window); gboolean new_window);
GimpPlugInInfo PLUG_IN_INFO = GimpPlugInInfo PLUG_IN_INFO =
@ -216,8 +215,8 @@ run (const gchar *name,
} }
static gint static gint
start_browser (gchar *prog, start_browser (const gchar *prog,
gchar *url) const gchar *url)
{ {
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
@ -241,12 +240,12 @@ start_browser (gchar *prog,
} }
static gint static gint
open_url (gchar *url, open_url (const gchar *url,
gint new_window) gboolean new_window)
{ {
gchar buf[512]; gchar buf[512];
while (isspace (*url)) while (g_ascii_isspace (*url))
++url; ++url;
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
@ -931,7 +930,7 @@ mozilla_remote_command (Display *dpy, Window window, const char *command)
} }
static int static int
mozilla_remote (char *command) mozilla_remote (const gchar *command)
{ {
int status = 0; int status = 0;
Display *dpy; Display *dpy;

View File

@ -433,7 +433,7 @@ p_invert(gint value)
return(FALSE); return(FALSE);
} }
int p_system(gchar *cmd) int p_system(const gchar *cmd)
{ {
int l_rc; int l_rc;
int l_rc2; int l_rc2;
@ -644,8 +644,8 @@ run (const gchar *name,
* before calling g_ascii_strtod, and puts back the comma after the call * before calling g_ascii_strtod, and puts back the comma after the call
*/ */
static gdouble static gdouble
p_my_ascii_strtod (gchar *nptr, p_my_ascii_strtod (gchar *nptr,
gchar **endptr) gchar **endptr)
{ {
gint ii; gint ii;
gint ic; gint ic;
@ -1014,12 +1014,12 @@ p_float_to_str(gdouble flt_val)
* ============================================================================ * ============================================================================
*/ */
gchar * gchar *
p_namedup(gchar *name) p_namedup(const gchar *name)
{ {
gchar *l_name; const gchar *l_str;
gchar *l_str; gchar *l_name;
gchar *l_ptr; gchar *l_ptr;
gint l_len; gint l_len;
l_str = name; l_str = name;
l_len = 0; l_len = 0;
@ -1245,8 +1245,10 @@ p_write_prop(FILE *fp, t_proptype proptype, t_param_prop *param, gint wr_all_prp
*/ */
gint gint
p_write_parasite(gchar *dirname, FILE *fp, p_write_parasite(const gchar *dirname,
GimpParasite *parasite, gint wr_all_prp) FILE *fp,
GimpParasite *parasite,
gint wr_all_prp)
{ {
gchar *l_new_parasite_prop_lines; gchar *l_new_parasite_prop_lines;
gchar *l_parasite_buff; gchar *l_parasite_buff;
@ -1380,7 +1382,10 @@ p_write_image_paths(FILE *fp, gint32 image_id, gint wr_all_prp)
} }
void void
p_write_image_parasites(gchar *dirname, FILE *fp, gint32 image_id, gint wr_all_prp) p_write_image_parasites(const gchar *dirname,
FILE *fp,
gint32 image_id,
gint wr_all_prp)
{ {
GimpParasite *l_parasite; GimpParasite *l_parasite;
gint32 l_idx; gint32 l_idx;
@ -1403,7 +1408,10 @@ p_write_image_parasites(gchar *dirname, FILE *fp, gint32 image_id, gint wr_all_p
} }
void void
p_write_drawable_parasites(gchar *dirname, FILE *fp, gint32 drawable_id, gint wr_all_prp) p_write_drawable_parasites (const gchar *dirname,
FILE *fp,
gint32 drawable_id,
gint wr_all_prp)
{ {
GimpParasite *l_parasite; GimpParasite *l_parasite;
gint32 l_idx; gint32 l_idx;
@ -1432,11 +1440,12 @@ p_write_drawable_parasites(gchar *dirname, FILE *fp, gint32 drawable_id, gint wr
*/ */
static void static void
p_write_layer_prp(gchar *dirname, p_write_layer_prp(const gchar *dirname,
FILE *fp, gchar *layer_shortname, FILE *fp,
gint32 image_id, const gchar *layer_shortname,
gint32 layer_id, gint32 image_id,
gint wr_all_prp) gint32 layer_id,
gint wr_all_prp)
{ {
t_param_prop l_param; t_param_prop l_param;
gint l_ofsx, l_ofsy; gint l_ofsx, l_ofsy;
@ -1503,11 +1512,12 @@ p_write_layer_prp(gchar *dirname,
*/ */
static void static void
p_write_channel_prp(gchar *dirname, p_write_channel_prp(const gchar *dirname,
FILE *fp, gchar *channel_shortname, FILE *fp,
gint32 image_id, const gchar *channel_shortname,
gint32 channel_id, gint32 image_id,
gint wr_all_prp) gint32 channel_id,
gint wr_all_prp)
{ {
t_param_prop l_param; t_param_prop l_param;
gint l_ofsx, l_ofsy; gint l_ofsx, l_ofsy;
@ -1568,7 +1578,10 @@ p_write_channel_prp(gchar *dirname,
*/ */
static void static void
p_write_image_prp(gchar *dirname, FILE *fp, gint32 image_id, gint wr_all_prp) p_write_image_prp (const gchar *dirname,
FILE *fp,
gint32 image_id,
gint wr_all_prp)
{ {
GimpImageBaseType l_image_type; GimpImageBaseType l_image_type;
guint l_width, l_height; guint l_width, l_height;
@ -2113,16 +2126,18 @@ p_skip_blanks(gchar* scan_ptr)
*/ */
static gchar * static gchar *
p_scann_token(gchar* scan_ptr, t_param_prop *param, t_proptype *prop_id) p_scann_token(gchar *scan_ptr,
t_param_prop *param,
t_proptype *prop_id)
{ {
int l_idx; int l_idx;
int l_ids; int l_ids;
int l_max_line_len; int l_max_line_len;
int l_num_fvals; int l_num_fvals;
gchar *l_token; gchar *l_token;
gchar *l_string_buff; gchar *l_string_buff;
gchar *l_ptr; gchar *l_ptr;
gchar *l_ptr2; gchar *l_ptr2;
/* check for end of property line */ /* check for end of property line */
@ -2536,7 +2551,9 @@ p_find_parasite(t_parasite_props *parasite_props, gint32 parasite_id)
* ============================================================================ * ============================================================================
*/ */
gint gint
p_create_and_attach_parasite(gint32 gimp_obj_id, gchar *dirname, t_parasite_props *parasite_props) p_create_and_attach_parasite (gint32 gimp_obj_id,
const gchar *dirname,
t_parasite_props *parasite_props)
{ {
gchar *l_parasite_file; gchar *l_parasite_file;
GimpParasite l_parasite; GimpParasite l_parasite;
@ -2606,8 +2623,11 @@ p_create_and_attach_parasite(gint32 gimp_obj_id, gchar *dirname, t_parasite_prop
* ============================================================================ * ============================================================================
*/ */
void void
p_check_and_add_parasite(gint32 gimp_obj_id, gchar *dirname, p_check_and_add_parasite(gint32 gimp_obj_id,
t_parasite_props *parasite_props, gint32 pos, t_parasitetype parasite_type) const gchar *dirname,
t_parasite_props *parasite_props,
gint32 pos,
t_parasitetype parasite_type)
{ {
t_parasite_props *l_prop; t_parasite_props *l_prop;
@ -2628,7 +2648,8 @@ p_check_and_add_parasite(gint32 gimp_obj_id, gchar *dirname,
* scann one inputline for layer properties (also used for layer_mask props) * scann one inputline for layer properties (also used for layer_mask props)
* ============================================================================ * ============================================================================
*/ */
gint p_scann_layer_prop(gchar* scan_ptr, t_image_props *image_prop) gint p_scann_layer_prop(gchar *scan_ptr,
t_image_props *image_prop)
{ {
t_layer_props *l_new_prop; t_layer_props *l_new_prop;
@ -2739,7 +2760,8 @@ gint p_scann_layer_prop(gchar* scan_ptr, t_image_props *image_prop)
* scann one inputline for channel properties (also used for layer_mask props) * scann one inputline for channel properties (also used for layer_mask props)
* ============================================================================ * ============================================================================
*/ */
gint p_scann_channel_prop(gchar* scan_ptr, t_image_props *image_prop) gint p_scann_channel_prop(const gchar *scan_ptr,
t_image_props *image_prop)
{ {
t_channel_props *l_new_prop; t_channel_props *l_new_prop;
@ -2848,13 +2870,14 @@ gint p_scann_channel_prop(gchar* scan_ptr, t_image_props *image_prop)
* *
* ============================================================================ * ============================================================================
*/ */
gint p_scann_image_prop(gchar* scan_ptr, t_image_props *image_prop) gint p_scann_image_prop(gchar *scan_ptr,
t_image_props *image_prop)
{ {
gchar *l_ptr; gchar *l_ptr;
t_param_prop l_param; t_param_prop l_param;
t_proptype l_prop_id; t_proptype l_prop_id;
t_guide_props *l_guide_prop; t_guide_props *l_guide_prop;
t_parasite_props *l_parasite_prop; t_parasite_props *l_parasite_prop;
if(strncmp(scan_ptr, GIMP_XJ_IMAGE, strlen(GIMP_XJ_IMAGE)) != 0) if(strncmp(scan_ptr, GIMP_XJ_IMAGE, strlen(GIMP_XJ_IMAGE)) != 0)
{ {
@ -2955,7 +2978,8 @@ gint p_scann_image_prop(gchar* scan_ptr, t_image_props *image_prop)
* scann one inputline for parasite properties * scann one inputline for parasite properties
* ============================================================================ * ============================================================================
*/ */
gint p_scann_parasite_prop(gchar* scan_ptr, t_image_props *image_prop) gint p_scann_parasite_prop(const gchar *scan_ptr,
t_image_props *image_prop)
{ {
t_parasite_props *l_new_prop; t_parasite_props *l_new_prop;
@ -3017,7 +3041,8 @@ gint p_scann_parasite_prop(gchar* scan_ptr, t_image_props *image_prop)
* scann one inputline for path properties * scann one inputline for path properties
* ============================================================================ * ============================================================================
*/ */
gint p_scann_path_prop(gchar* scan_ptr, t_image_props *image_prop) gint p_scann_path_prop (gchar *scan_ptr,
t_image_props *image_prop)
{ {
t_path_props *l_new_prop; t_path_props *l_new_prop;
@ -3118,7 +3143,7 @@ p_add_paths(gint32 image_id, t_path_props *path_props)
gchar * gchar *
p_load_linefile(gchar *filename, gint32 *len) p_load_linefile(const gchar *filename, gint32 *len)
{ {
FILE *l_fp; FILE *l_fp;
struct stat stat_buf; struct stat stat_buf;
@ -3158,7 +3183,7 @@ p_load_linefile(gchar *filename, gint32 *len)
gint32 gint32
p_next_lineindex(gchar *file_buff, gint32 max_len, gint32 pos) p_next_lineindex(const gchar *file_buff, gint32 max_len, gint32 pos)
{ {
if (pos < 0) { return (-1); } if (pos < 0) { return (-1); }
@ -3182,7 +3207,7 @@ p_next_lineindex(gchar *file_buff, gint32 max_len, gint32 pos)
* ============================================================================ * ============================================================================
*/ */
t_image_props * p_load_prop_file(gchar *prop_filename) t_image_props * p_load_prop_file(const gchar *prop_filename)
{ {
gint32 l_filesize; gint32 l_filesize;
gint32 l_line_idx; gint32 l_line_idx;