Commit 0457d691 authored by Tor Lillqvist's avatar Tor Lillqvist

New file.

	* plug-ins/makefile.msc: New file.

	* plug-ins/*/*.c (Well, not really all files, but many):
 	Portability fixes. Include config.h, and guard inclusion of POSIX
 	and Unix headers like <unistd.h>, <dirent.h> and
 	<sys/time.h>. Include <string.h> if functions from it are
 	used. Use g_ntohl() and g_htonl() insteead of ntohl() and htonl(),
 	thus no need to include <netinet/in.h>. Include <io.h> on Win32
 	when using open/read/write (which actually are defined as
 	_open/_read/_write by glib.h). Define S_* macros if necessary on
 	Win32. Define rint() and M_PI if necessary (these definitions
 	should be factored out somewhere, no sense repeating them in lots
 	of files). Open files in binary mode when needed.

	* plug-ins/FractalExplorer/FractalExplorer.c: Use
 	g_malloc()/g_free(). Use g_strdup_printf().

  	* plug-ins/dbbrowser/dbbrowser.c: No need to include <X11/Xlib.h>.

	* plug-ins/destripe/destripe.c: Guard use of SIGBUS.

	* plug-ins/{flame/flame,hrz/hrz,pnm/pnm}.c: No need to check for
 	NULL returns from g_malloc() and g_new() as they abort on failure.
	Use g_strdup_printf().

	* plug-ins/gz/gz.c: Win32 version of running the subprocess.

	* plug-ins/hrz/hrz.c: Win32 version. Use more generic tests for
 	non-Unix (OS/2 and Win32), for instance HAVE_MMAP.

	* plug-ins/script-fu/interp_slib.c: Win32 version of myruntime().

	* plug-ins/script-fu/interp_sliba.c: Handle \\ (escaped backslahsh).

	* plug-ins/script-fu/script-fu-console.c: Bypass on Win32.

	* plug-ins/script-fu/script-fu-scripts.c: Portability fixes. Use
 	g_strdup_printf() instead of separate malloc() and sprintf(). Use
 	g_strescape() for strings being passed to Scheme. Some Win32-only
 	stuff.
parent e2a29e47
......@@ -4,16 +4,19 @@
1999-05-28 Tor Lillqvist <tml@iki.fi>
Merge in Win32 changes to plug-ins. Small Win32-related changes
to app and libgimp.
* configure.in: Check for mmap.
* app/makefile.msc: Depend on gimpi.lib.
* app/app_procs.c (app_init): Fix gccism: Allocate filenames (an
array with non-constant size) dynamically.
array with non-constant size) dynamically.
* app/{datafiles,fileops,general,install,module_db,temp_buf}.c:
Include glib.h before standard headers, because of certain obscure
details related to compiling with gcc on Win32.
Include glib.h before standard headers, because of certain obscure
details related to compiling with gcc on Win32.
(If you really want to know: glib.h defines he names of POSIXish
(but non-ANSI) functions as prefixed with underscore, because
......@@ -40,8 +43,8 @@
* libgimp/{gimp,gimpui}.def: Add two entry points.
* libgimp/gimp.h: Can't use __declspec(dllexport) for PLUG_IN_INFO
when compiling with gcc on Win32. Also handle __argc, __argv and
_stdcall differently with gcc on Win32
when compiling with gcc on Win32. Also handle __argc, __argv and
_stdcall differently with gcc on Win32
* libgimp/gimpenv.c: Include <string.h>.
......@@ -55,6 +58,52 @@
* libgimp/makefile.msc: Miscellaneous updates. The gimpi library
is now built as a static library.
* modules/colorsel_triangle.c: No need to include gdkx.h. Define
M_PI if needed.
* modules/makefile.msc: Use GLib 1.3, update GTk+ paths.
* plug-ins/makefile.msc: New file.
* plug-ins/*/*.c (Well, not really all files, but many):
Portability fixes. Include config.h, and guard inclusion of POSIX
and Unix headers like <unistd.h>, <dirent.h> and
<sys/time.h>. Include <string.h> if functions from it are
used. Use g_ntohl() and g_htonl() insteead of ntohl() and htonl(),
thus no need to include <netinet/in.h>. Include <io.h> on Win32
when using open/read/write (which actually are defined as
_open/_read/_write by glib.h). Define S_* macros if necessary on
Win32. Define rint() and M_PI if necessary (these definitions
should be factored out somewhere, no sense repeating them in lots
of files). Open files in binary mode when needed.
* plug-ins/FractalExplorer/FractalExplorer.c: Use
g_malloc()/g_free(). Use g_strdup_printf().
* plug-ins/dbbrowser/dbbrowser.c: No need to include <X11/Xlib.h>.
* plug-ins/destripe/destripe.c: Guard use of SIGBUS.
* plug-ins/{flame/flame,hrz/hrz,pnm/pnm}.c: No need to check for
NULL returns from g_malloc() and g_new() as they abort on failure.
Use g_strdup_printf().
* plug-ins/gz/gz.c: Win32 version of running the subprocess.
* plug-ins/hrz/hrz.c: Win32 version. Use more generic tests for
non-Unix (OS/2 and Win32), for instance HAVE_MMAP.
* plug-ins/script-fu/interp_slib.c: Win32 version of myruntime().
* plug-ins/script-fu/interp_sliba.c: Handle \\ (escaped backslahsh).
* plug-ins/script-fu/script-fu-console.c: Bypass on Win32.
* plug-ins/script-fu/script-fu-scripts.c: Portability fixes. Use
g_strdup_printf() instead of separate malloc() and sprintf(). Use
g_strescape() for strings being passed to Scheme. Some Win32-only
stuff.
Thu May 27 22:04:49 1999 Jay Cox (jaycox@earthlink.net)
* app/channel.c: applied fix for the channel_bounds bug from
......
......@@ -16,6 +16,9 @@ plug-ins, and finally in modules. Check the makefile.msc files in said
directories.
The current build setup for Windows is a mess, with complex
hand-maintained makefiles. I know.
hand-maintained makefiles. I know. Adding parallel makefiles for gcc
isn't going to make it any better. On the other hand, I don't think
using the Unix style configuration mechanism (under cygwin) is quite
feasible, either.
--Tor Lillqvist <tml@iki.fi>
......@@ -23,10 +23,14 @@
* + Save (perhaps optionally?) the palette in a KCF
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
......
......@@ -43,16 +43,36 @@
Include necessary files
*********************************************************************/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <math.h>
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <ctype.h>
#ifdef NATIVE_WIN32
#include <io.h>
#ifndef W_OK
#define W_OK 2
#endif
#ifndef S_ISDIR
#define S_ISDIR(m) ((m) & _S_IFDIR)
#endif
#ifndef S_ISREG
#define S_ISREG(m) ((m) & _S_IFREG)
#endif
#endif
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
......@@ -298,6 +318,7 @@ run(char *name,
values[0].data.d_status = status;
gimp_drawable_detach(drawable);
}
/**********************************************************************
......@@ -336,8 +357,8 @@ explorer(GDrawable * drawable)
bytes = drawable->bpp;
/* allocate row buffers */
src_row = (guchar *) malloc((x2 - x1) * bytes);
dest_row = (guchar *) malloc((x2 - x1) * bytes);
src_row = (guchar *) g_malloc((x2 - x1) * bytes);
dest_row = (guchar *) g_malloc((x2 - x1) * bytes);
/* initialize the pixel regions */
gimp_pixel_rgn_init(&srcPR, drawable, 0, 0, width, height, FALSE, FALSE);
......@@ -369,8 +390,8 @@ explorer(GDrawable * drawable)
gimp_drawable_merge_shadow(drawable->id, TRUE);
gimp_drawable_update(drawable->id, x1, y1, (x2 - x1), (y2 - y1));
free(src_row);
free(dest_row);
g_free(src_row);
g_free(dest_row);
}
/**********************************************************************
......@@ -596,9 +617,7 @@ fractalexplorer_delete_fractalexplorer_callback(GtkWidget *widget,
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
gtk_widget_show(label);
str = g_malloc((strlen(sel_obj->draw_name) + 32 * sizeof(char)));
sprintf(str, msg[lng][MSG_DELSURE2], sel_obj->draw_name);
str = g_strdup_printf(msg[lng][MSG_DELSURE2], sel_obj->draw_name);
label = gtk_label_new(str);
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
......@@ -1217,9 +1236,7 @@ fractalexplorer_rename_menu_callback(GtkWidget *widget, gpointer data)
static void
fractalexplorer_copy_menu_callback(GtkWidget *widget, gpointer data)
{
gchar *new_name = g_malloc(strlen(fractalexplorer_obj_for_menu->draw_name) + 6);
sprintf(new_name,msg[lng][MSG_COPYNAME],fractalexplorer_obj_for_menu->draw_name);
gchar *new_name = g_strup_printf(msg[lng][MSG_COPYNAME],fractalexplorer_obj_for_menu->draw_name);
new_fractalexplorer_obj(new_name);
g_free(new_name);
......@@ -1416,13 +1433,11 @@ plug_in_parse_fractalexplorer_path()
if (*token == '~')
{
path = g_malloc (strlen (home) + strlen (token) + 2);
sprintf (path, "%s%s", home, token + 1);
path = g_strdup_printf ("%s%s", home, token + 1);
}
else
{
path = g_malloc (strlen (token) + 2);
strcpy (path, token);
path = g_strdup (token);
} /* else */
/* Check if directory exists */
......@@ -1722,9 +1737,7 @@ fractalexplorer_list_load_all(GList *plist)
{
while ((dir_ent = readdir (dir)))
{
filename = g_malloc (strlen(path) + strlen (dir_ent->d_name) + 1);
sprintf (filename, "%s%s", path, dir_ent->d_name);
filename = g_strdup_printf ("%s%s", path, dir_ent->d_name);
/* Check the file and see that it is not a sub-directory */
err = stat (filename, &filestat);
......@@ -1791,9 +1804,7 @@ gradient_list_load_all(GList *plist)
{
while ((dir_ent = readdir (dir)))
{
filename = g_malloc (strlen(path) + strlen (dir_ent->d_name) + 1);
sprintf (filename, "%s%s", path, dir_ent->d_name);
filename = g_strdup_printf ("%s%s", path, dir_ent->d_name);
/* Check the file and see that it is not a sub-directory */
err = stat (filename, &filestat);
......
......@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "libgimp/gimp.h"
......
......@@ -53,6 +53,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "libgimp/gimp.h"
#include "gtk/gtk.h"
......
......@@ -7,11 +7,15 @@
/* Alexander.Schulz@stud.uni-karlsruhe.de */
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include "bmp.h"
......
......@@ -84,13 +84,15 @@
* - Speed-ups
*/
#include "config.h"
#include <math.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
......
......@@ -23,10 +23,14 @@
* + Save (perhaps optionally?) the palette in a KCF
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
......
......@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "libgimp/gimp.h"
......
......@@ -53,6 +53,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "libgimp/gimp.h"
#include "gtk/gtk.h"
......
......@@ -84,13 +84,15 @@
* - Speed-ups
*/
#include "config.h"
#include <math.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
......
......@@ -56,20 +56,34 @@
* -Dan Risacher, 0430 CDT, 26 May 1997
*/
#include "config.h"
#ifdef NATIVE_WIN32
#define STRICT
#include <windows.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#include <sys/stat.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <errno.h>
#ifdef __EMX__
#include <fcntl.h>
#include <process.h>
#endif
#include "libgimp/gimp.h"
/* Author 1: Josh MacDonald (url.c) */
......@@ -275,13 +289,21 @@ save_image (char *filename,
gint32 drawable_ID,
gint32 run_mode)
{
FILE* f;
GParam* params;
gint retvals;
char* ext;
char* tmpname;
#ifndef NATIVE_WIN32
FILE* f;
int pid;
int status;
#else
SECURITY_ATTRIBUTES secattr;
HANDLE f;
STARTUPINFO startupinfo;
PROCESS_INFORMATION processinfo;
gchar *cmdline;
#endif
ext = find_extension(filename);
if (0 == *ext) {
......@@ -317,7 +339,10 @@ save_image (char *filename,
/* return -1; */
/* } */
#ifndef NATIVE_WIN32
#ifndef __EMX__
/* fork off a gzip process */
if ((pid = fork()) < 0)
{
......@@ -356,6 +381,46 @@ save_image (char *filename,
return 0;
}
}
#else /* NATIVE_WIN32 */
secattr.nLength = sizeof (SECURITY_ATTRIBUTES);
secattr.lpSecurityDescriptor = NULL;
secattr.bInheritHandle = TRUE;
if ((f = CreateFile (filename, GENERIC_WRITE, FILE_SHARE_READ,
&secattr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL))
== INVALID_HANDLE_VALUE)
{
g_message ("gz: CreateFile failed\n");
_exit (127);
}
startupinfo.cb = sizeof (STARTUPINFO);
startupinfo.lpReserved = NULL;
startupinfo.lpDesktop = NULL;
startupinfo.lpTitle = NULL;
startupinfo.dwFlags =
STARTF_FORCEOFFFEEDBACK | STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
startupinfo.wShowWindow = SW_SHOWMINNOACTIVE;
startupinfo.cbReserved2 = 0;
startupinfo.lpReserved2 = NULL;
startupinfo.hStdInput = GetStdHandle (STD_INPUT_HANDLE);
startupinfo.hStdOutput = f;
startupinfo.hStdError = GetStdHandle (STD_ERROR_HANDLE);
cmdline = g_strdup_printf ("gzip -cf %s", tmpname);
if (!CreateProcess (NULL, cmdline, NULL, NULL,
TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL,
&startupinfo, &processinfo))
{
g_message ("gz: CreateProcess failed\n");
_exit (127);
}
CloseHandle (f);
CloseHandle (processinfo.hThread);
WaitForSingleObject (processinfo.hProcess, INFINITE);
#endif /* NATIVE_WIN32 */
unlink (tmpname);
......@@ -369,8 +434,16 @@ load_image (char *filename, gint32 run_mode)
gint retvals;
char* ext;
char* tmpname;
#ifndef NATIVE_WIN32
int pid;
int status;
#else
SECURITY_ATTRIBUTES secattr;
HANDLE f;
STARTUPINFO startupinfo;
PROCESS_INFORMATION processinfo;
gchar *cmdline;
#endif
ext = find_extension(filename);
if (0 == *ext) {
......@@ -385,7 +458,10 @@ load_image (char *filename, gint32 run_mode)
tmpname = params[1].data.d_string;
#ifndef NATIVE_WIN32
#ifndef __EMX__
/* fork off a g(un)zip and wait for it */
if ((pid = fork()) < 0)
{
......@@ -424,6 +500,46 @@ load_image (char *filename, gint32 run_mode)
return -1;
}
}
#else
secattr.nLength = sizeof (SECURITY_ATTRIBUTES);
secattr.lpSecurityDescriptor = NULL;
secattr.bInheritHandle = TRUE;
if ((f = CreateFile (tmpname, GENERIC_WRITE, FILE_SHARE_READ,
&secattr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL))
== INVALID_HANDLE_VALUE)
{
g_message ("gz: CreateFile failed\n");
_exit (127);
}
startupinfo.cb = sizeof (STARTUPINFO);
startupinfo.lpReserved = NULL;
startupinfo.lpDesktop = NULL;
startupinfo.lpTitle = NULL;
startupinfo.dwFlags =
STARTF_FORCEOFFFEEDBACK | STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
startupinfo.wShowWindow = SW_SHOWMINNOACTIVE;
startupinfo.cbReserved2 = 0;
startupinfo.lpReserved2 = NULL;
startupinfo.hStdInput = GetStdHandle (STD_INPUT_HANDLE);
startupinfo.hStdOutput = f;
startupinfo.hStdError = GetStdHandle (STD_ERROR_HANDLE);
cmdline = g_strdup_printf ("gzip -cfd %s", filename);
if (!CreateProcess (NULL, cmdline, NULL, NULL,
TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL,
&startupinfo, &processinfo))
{
g_message ("gz: CreateProcess failed: %d\n", GetLastError ());
_exit (127);
}
CloseHandle (f);
CloseHandle (processinfo.hThread);
WaitForSingleObject (processinfo.hProcess, INFINITE);
#endif /* NATIVE_WIN32 */
/* now that we un-gziped it, load the temp file */
......
......@@ -48,16 +48,19 @@
*
*/
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include "libgimp/gimp.h"
#include "gtk/gtk.h"
#include <sys/types.h>
#include <signal.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "libgimp/gimp.h"
#include "gtk/gtk.h"
typedef enum {
EXTEND,
......
......@@ -565,7 +565,9 @@ destripe_dialog(void)
gtk_rc_parse(gimp_gtkrc());
gdk_set_use_xshm(gimp_use_xshm());
#ifdef SIGBUS
signal(SIGBUS, SIG_DFL);
#endif
signal(SIGSEGV, SIG_DFL);
gtk_preview_set_gamma(gimp_gamma());
gtk_preview_set_install_cmap(gimp_install_cmap());
......
......@@ -21,11 +21,15 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <math.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/types.h>
#include "gtk/gtk.h"
......
......@@ -37,10 +37,14 @@
/* Version 1.12. */
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <signal.h>
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
......
......@@ -11,20 +11,32 @@
* etc.
*/
#include "config.h"
#include <setjmp.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#ifdef NATIVE_WIN32
#include <io.h>
#endif
#ifndef _O_BINARY
#define _O_BINARY 0
#endif
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
#include "app/brush_header.h"
#include <netinet/in.h>
/* Declare local data types
......@@ -206,7 +218,8 @@ static gint32 load_image (char *filename) {
gimp_progress_init(temp);
g_free (temp);
fd = open(filename, O_RDONLY);
fd = open(filename, O_RDONLY | _O_BINARY);
if (fd == -1) {
return -1;
}
......@@ -217,13 +230,13 @@ static gint32 load_image (char *filename) {
}
/* rearrange the bytes in each unsigned int */
ph.header_size = ntohl(ph.header_size);
ph.version = ntohl(ph.version);
ph.width = ntohl(ph.width);
ph.height = ntohl(ph.height);
ph.bytes = ntohl(ph.bytes);
ph.magic_number = ntohl(ph.magic_number);
ph.spacing = ntohl(ph.spacing);
ph.header_size = g_ntohl(ph.header_size);
ph.version = g_ntohl(ph.version);
ph.width = g_ntohl(ph.width);
ph.height = g_ntohl(ph.height);
ph.bytes = g_ntohl(ph.bytes);
ph.magic_number = g_ntohl(ph.magic_number);
ph.spacing = g_ntohl(ph.spacing);
/* How much extra to add ot the header seek - 1 needs a bit more */
version_extra = 0;
......@@ -305,19 +318,20 @@ static gint save_image (char *filename, gint32 image_ID, gint32 drawable_ID) {
gimp_pixel_rgn_init(&pixel_rgn, drawable, 0, 0, drawable->width,
drawable->height, FALSE, FALSE);
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0644);
fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY | _O_BINARY, 0644);
if (fd == -1) {
printf("Unable to open %s\n", filename);
return 0;
}
ph.header_size = htonl(sizeof(ph) + strlen(info.description) + 1);
ph.version = htonl(2);
ph.width = htonl(drawable->width);
ph.height = htonl(drawable->height);
ph.bytes = htonl(drawable->bpp);
ph.magic_number = htonl(GBRUSH_MAGIC);
ph.spacing = htonl(info.spacing);
ph.header_size = g_htonl(sizeof(ph) + strlen(info.description) + 1);
ph.version = g_htonl(2);
ph.width = g_htonl(drawable->width);
ph.height = g_htonl(drawable->height);
ph.bytes = g_htonl(drawable->bpp);
ph.magic_number = g_htonl(GBRUSH_MAGIC);
ph.spacing = g_htonl(info.spacing);
if (write(fd, &ph, sizeof(ph)) != sizeof(ph)) {
close(fd);
......
......@@ -34,6 +34,9 @@
#include "config.h"
#ifndef HAVE_RINT
#define rint(x) floor ((x) + 0.5)
#endif
/* Test for GTK1.2-style gdkrgb code, else use old 'preview' code. */
#ifdef __GDK_RGB_H__
......
......@@ -19,11 +19,15 @@
/* saves and loads gimp icon files (For toolbox, etc)...
*/
#include "config.h"
#include <setjmp.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
......@@ -31,7 +35,6 @@
#include <math.h>
#include "gtk/gtk.h"
#include "libgimp/gimp.h"
#include <netinet/in.h>
typedef struct
......
......@@ -43,6 +43,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
......