Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Replace sprintf by snprintf.
[simgrid.git] / src / msg / msg_deployment.cpp
1 /* Copyright (c) 2004-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "msg_private.h"
8 #include "xbt/sysdep.h"
9 #include "xbt/log.h"
10
11 /** \ingroup msg_simulation
12  * \brief An application deployer.
13  *
14  * Creates the process described in \a file.
15  * \param file a filename of a xml description of the application. This file follows this DTD :
16  *
17  *     \include simgrid.dtd
18  *
19  * Here is a small example of such a platform 
20  *
21  *     \include msg/masterslave/deployment_masterslave.xml
22  *
23  * Have a look in the directory examples/msg/ to have a bigger example.
24  */
25 void MSG_launch_application(const char *file)
26 {
27   xbt_assert(msg_global, "MSG_init has to be called before MSG_launch_application.");
28   SIMIX_launch_application(file);
29 }
30
31 /** \ingroup msg_simulation
32  * \brief Registers the main function of a process in a global table.
33  *
34  * Registers a code function in a global table. 
35  * This table is then used by #MSG_launch_application. 
36  * \param name the reference name of the function.
37  * \param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char *argv[]))
38  */
39 void MSG_function_register(const char *name, xbt_main_func_t code)
40 {
41   SIMIX_function_register(name, code);
42 }
43
44 /** \ingroup msg_simulation
45  * \brief Registers a function as the default main function of processes.
46  *
47  * Registers a code function as being the default value. This function will get used by MSG_launch_application() when there is no registered function of the requested name in.
48  * \param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char *argv[]))
49  */
50 void MSG_function_register_default(xbt_main_func_t code)
51 {
52   SIMIX_function_register_default(code);
53 }
54
55 /** \ingroup msg_simulation
56  * \brief Retrieves a registered main function
57  *
58  * Registers a code function in a global table. 
59  * This table is then used by #MSG_launch_application. 
60  * \param name the reference name of the function.
61  */
62 xbt_main_func_t MSG_get_registered_function(const char *name)
63 {
64   return SIMIX_get_registered_function(name);
65 }
66
67 /**
68  * \brief register functions bypassing the parser
69  */
70
71 void MSG_set_function(const char *host_id, const char *function_name, xbt_dynar_t arguments)
72 {
73   SIMIX_process_set_function(host_id, function_name, arguments, -1, -1);
74 }