From: Rafał Długołęcki Date: Thu, 1 Aug 2013 21:19:37 +0000 (+0200) Subject: vlp-7 More documentation in cint.c X-Git-Tag: 3.1~6 X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=abed78d4382b70979c3a6eb492ca1a6a9ee16fa1;p=vlp.git vlp-7 More documentation in cint.c --- diff --git a/src/int/cint.c b/src/int/cint.c index 00e78b5..222bf22 100644 --- a/src/int/cint.c +++ b/src/int/cint.c @@ -37,16 +37,25 @@ int maxDirSet; ctx_struct my_ctx; ctx_struct parent_ctx; -/* IDs of remote instances */ +/** + * IDs of remote instances + */ int RInstance[255]; -/* Direct connection channels */ + +/** + * Direct connection channels + */ int DirConn[255]; -/* graphic vars */ +/** + * Graphic variables + */ int fcol, bcol, curx=0, cury=0; -/* Macro to decode addressing modes : */ +/** + * Macro to decode addressing modes: + */ #define getargument(a, argnr) \ switch (eop->args[ argnr ]) \ { \ @@ -62,7 +71,12 @@ int fcol, bcol, curx=0, cury=0; } /** - * Load code and prototypes from file + * Loads code and prototypes from files + * Files have following extensions: + * .ccd - compiler code + * .pcd - program code + * .trd - traced debug + * @param _filename Filename of file to read. */ static void load(char *_filename) { @@ -138,7 +152,8 @@ static void load(char *_filename) } /** - * Establish configuration parameters + * Establishes configuration parameters + * Creates two sockets for program run */ static void initiate(int argc, char **argv) { @@ -231,7 +246,9 @@ static void initiate(int argc, char **argv) usage(); } - +/** + * + */ void decode(){ extopcode *eop; @@ -246,14 +263,19 @@ void decode(){ getargument(a3, 2); } -/* -------------------------------------------------------------------- */ - - +/** + * Sends message to graph module. + * @param msg Message to send. + */ void send_to_graph(G_MESSAGE *msg) { write(graph_sock, msg, sizeof(G_MESSAGE)); } +/** + * Reads message from graph module. + * @param msg Message to read. + */ int read_from_graph(G_MESSAGE *msg) { fd_set rset,wset; @@ -268,9 +290,13 @@ int read_from_graph(G_MESSAGE *msg) if (FD_ISSET(graph_sock, &rset)) return(read(graph_sock,msg,sizeof(G_MESSAGE))); } - return(0); + return 0; } +/** + * Reads message from net module. + * @param msg Message to read. + */ int read_from_net(MESSAGE *msg) { fd_set rset,wset; @@ -285,11 +311,13 @@ int read_from_net(MESSAGE *msg) if (FD_ISSET(net_sock, &rset)) return(read(net_sock, msg, sizeof(MESSAGE))); } - return(0); + return 0; } -/* Get graphic resource number */ +/** + * Gets graphic resource number + */ int get_graph_res() { MESSAGE msg; @@ -332,7 +360,9 @@ int get_graph_res() } -/* writeln string */ +/** + * Writes string line (ended with new line character) + */ void writeln_str(char *s) { G_MESSAGE msg; @@ -346,7 +376,10 @@ void writeln_str(char *s) send_to_graph(&msg); } -/* write string */ +/** + * Writes string + * @param s String to write + */ void write_str(char *s) { G_MESSAGE msg; @@ -357,7 +390,10 @@ void write_str(char *s) send_to_graph(&msg); } -/* write char */ +/** + * Writes char + * @param a Character to write + */ void write_char(char a) { G_MESSAGE msg; @@ -370,7 +406,10 @@ void write_char(char a) } -/* read char */ +/** + * Reads char + * @return Read character + */ char read_char() { char ch; @@ -395,7 +434,9 @@ char read_char() return ch; } -/* read line */ +/** + * Reads line + */ void read_line() { G_MESSAGE msg; @@ -410,12 +451,15 @@ void read_line() st = read_from_graph(&msg); if (st > 0) if ((msg.msg_type == MSG_GRAPH) && - (msg.param.pword[0]== GRAPH_READLN_RESPONSE)) + (msg.param.pword[0] == GRAPH_READLN_RESPONSE)) break; } } -/* read string */ +/** + * Reads string + * @param s Buffer to store string. + */ void read_str(char *s) { char ss[255]; @@ -430,8 +474,8 @@ void read_str(char *s) st = read_from_graph(&msg); if (st > 0) { if ((msg.msg_type == MSG_GRAPH) && - (msg.param.pword[0]==GRAPH_READSTR_RESPONSE)) { - strcpy(ss,msg.param.pstr); + (msg.param.pword[0] == GRAPH_READSTR_RESPONSE)) { + strcpy(ss, msg.param.pstr); break; } } @@ -440,15 +484,18 @@ void read_str(char *s) } /** - * send message to kernel + * Sends message to kernel + * @param msg Message to send to kernel */ void send_to_kernel(MESSAGE *msg) { write(internal_sock, msg, sizeof(MESSAGE)); } -/* send message to net */ -/* 2010 returns 1 if ok and 0 if node desn't exists */ +/** + * Sends message to net + * @return Returns 1 if ok and 0 if node desn't exists (since 2010) + */ int send_to_net(MESSAGE *msg) { int k, len; @@ -682,7 +729,6 @@ void request_id() } - void send_ready() { int sock, len; @@ -721,6 +767,17 @@ void send_ready() fcntl(DirConn[parent_ctx.node], F_GETFL, 0)); } +/** + * strcpy(filename, argv[2]); + * strcpy(ProgName, argv[2]); + * + * argv[1] = base name of this interpreter instance. + * For network there is created argv[1].net socket + * For graphics there is created argv[1].gr socket + * argv[2] = up to 80 characters string (with terminating \0). It is used to + * load selected program + * argv[3] = if exists and is equal to 'r', this is a remote call + */ int main(int argc, char **argv) { /* initialize executor */