|
Main Page Data Structures File List Globals
convert_from_string.c File ReferenceComverts strings into their original composite datatypes.
More...
#include "white_interface.h"
Go to the source code of this file.
Detailed Description
Comverts strings into their original composite datatypes.
This block receives strings that were created by convert_to_string.c and converts them back to their original move or button datatypes. The text string is made up from the fields of the original datatype, separated by commas. The first part of the string identifies the datatype that it is representing.
Definition in file convert_from_string.c.
Define Documentation
Function Documentation
int is_button |
( |
char * |
str |
) |
|
|
|
Tests whether a string represents a button message.
-
Parameters:
-
str |
A pointer the string. |
-
Returns:
-
true if the string represents a button messge, false otherwise.
Definition at line 53 of file convert_from_string.c.
References FALSE, and TRUE.
Referenced by poin_entry_Run.
00054 {
00055 if (*str == 'b')
00056 return TRUE;
00057 else
00058 return FALSE;
00059 }
|
int is_move |
( |
char * |
str |
) |
|
|
|
Tests whether a string represents a move message.
-
Parameters:
-
str |
A pointer the string. |
-
Returns:
-
true if the string represents a move messge, false otherwise.
Definition at line 39 of file convert_from_string.c.
References FALSE, and TRUE.
Referenced by poin_entry_Run.
00040 {
00041 if (*str == 'm')
00042 return TRUE;
00043 else
00044 return FALSE;
00045 }
|
|
VCC Init function.
This function runs when the VCC simulation is first started.
Definition at line 66 of file convert_from_string.c.
|
|
VCC Run function.
This runs whenever a message arrives at the convert_from_string block's in port.
Definition at line 75 of file convert_from_string.c.
References is_button, is_move, sscanf, and strchr.
00076 {
00077 char *comma;
00078 char *input;
00079 move m;
00080 button b;
00081 int player, x1, y1, x2, y2, button_no;
00082
00083 if (in_Enabled())
00084 {
00085 input = in_Value();
00086
00087 comma = strchr(input, ',');
00088
00089
00090
00091
00092
00093
00094 if (is_move(input))
00095 {
00096 sscanf(comma+1, "%d,%d,%d,%d,%d", &player, &x1, &y1, &x2, &y2);
00097 m.player = player;
00098 m.x1 = x1;
00099 m.y1 = y1;
00100 m.x2 = x2;
00101 m.y2 = y2;
00102 move_out_Post(&m);
00103 }
00104
00105
00106
00107
00108 if (is_button(input))
00109 {
00110 sscanf(comma+1, "%d,%d", &player, &button_no);
00111 b.player = player;
00112 b.button_no = button_no;
00113 button_out_Post(&b);
00114 }
00115 }
00116 }
|
int sscanf |
( |
const char * |
s, |
|
|
const char * |
format, |
|
|
... |
|
|
) |
|
|
|
C standard library function.
Parses a string according to the supplied control string. -
Parameters:
-
s |
A pointer to the string to be parsed. |
format |
A pointer to the control string. |
-
Returns:
-
An integer error code.
Referenced by poin_entry_Run. |
char* strchr |
( |
const char * |
s, |
|
|
int |
c |
|
) |
|
|
|
C standard library function.
Finds the location of a particular charactcter within the supplied string. -
Parameters:
-
s |
A pointer to the string to search through. |
c |
The character to search for. |
-
Returns:
-
A pointer to the first matching character that was found.
Referenced by poin_entry_Run. |
|
|