881 | | * If the generated output is an overall output, it is sent on to the shell |
882 | | * "if" and "while" statements are handled by setting up a faux service that has a true input, a false input, and a boolean flag |
883 | | * If the true input is non-NULL and the flag is true, the statements execute |
884 | | * Likewise, if the false input is non-NULL and the flag is false, the statements execute |
885 | | * These flags are set during execution any time one of these faux services' inputs appear in an output statement |
943 | | |
944 | | /*printf("\n\n\n"); |
945 | | // generate commandi |
946 | | strcpy(_data_DB->command, "select "); |
947 | | strcat(_data_DB->command, _data_DB->tablename); |
948 | | strcat(_data_DB->command, ".* from "); |
949 | | strcat(_data_DB->command, _data_DB->tablename); |
950 | | strcat(_data_DB->command, ";"); |
951 | | |
952 | | // execute print (select all) command |
953 | | rc = sqlite3_exec(_data_DB->db, _data_DB->command, callback, 0, &errorMsg); |
954 | | if( rc!=SQLITE_OK && rc!=101 ) |
955 | | fprintf(stderr, "SQL error: %s\n", errorMsg); |
956 | | printf("database %s, table %s:\n", _data_DB->filename, _data_DB->tablename); |
957 | | printf("\n\n\n");*/ |
958 | | |
976 | | sprintf(_data_DB->command, "%s values('%s', '1@%s@%s", _data_DB->command, buffer1, buffer1, buffer); |
977 | | strcat(_data_DB->command, "');"); |
| 950 | sprintf(_data_DB->command, "%s values('%s', '1@%s@%s');", _data_DB->command, buffer1, buffer1, buffer); |
| 957 | |
| 958 | |
| 959 | |
| 960 | while(i < 5 && !miss[activeMission].input[i].empty()){ |
| 961 | //New data being added to DB |
| 962 | //printf("inserting data from shell\n"); |
| 963 | memset(buffer1, 0, 256); |
| 964 | ReadMessage(shellSocketFD, buffer1); |
| 965 | t=atoi(buffer1); |
| 966 | //printf("t=%d\n", t); |
| 967 | for(int m = 0; m < t; m++) { |
| 968 | data.append("@"); |
| 969 | memset(buffer, 0, 256); |
| 970 | ReadMessage(shellSocketFD, buffer); |
| 971 | data.append(buffer); |
| 972 | data.append("@"); |
| 973 | memset(buffer, 0, 256); |
| 974 | ReadMessage(shellSocketFD, buffer); |
| 975 | data.append(buffer); |
| 976 | } |
| 977 | //printf("here %s\n", data.c_str()); |
| 978 | strcpy(_data_DB->command, "insert into "); |
| 979 | strcat(_data_DB->command, _data_DB->tablename); |
| 980 | strcat(_data_DB->command, " ("); |
| 981 | strcat(_data_DB->command, cols[0]); |
| 982 | strcat(_data_DB->command, ", "); |
| 983 | strcat(_data_DB->command, cols[1]); |
| 984 | strcat(_data_DB->command, ") "); |
| 985 | strcat(_data_DB->command, " values('"); |
| 986 | strcat(_data_DB->command, miss[activeMission].input[i].c_str()); |
| 987 | sprintf(_data_DB->command, "%s', '%s%s');", _data_DB->command, buffer1, data.c_str()); |
| 988 | char *errorMsg; |
| 989 | rc = sqlite3_exec(_data_DB->db, _data_DB->command, callback, 0, &errorMsg); |
| 990 | if( rc!=SQLITE_OK && rc!=101 ) |
| 991 | fprintf(stderr, "SQL error: %s\n", errorMsg); |
| 992 | //printf("SML: finished adding data from shell on input %d\n", i); |
| 993 | i++; |
| 994 | data.clear(); |
| 995 | } |
| 996 | |
| 997 | |
| 998 | //Useful for spotchecking what's in the database |
1380 | | * Can currently handle 3 inputs and 3 outputs per service, but easily expandable |
1381 | | * Also, can handle one layer of nested conditional statements, but could |
1382 | | * be expanded to meet additional needs. Only support now is for straight bool flags, |
1383 | | * but support could be added for more complex conditionals later. |
| 1394 | * Can currently handle 5 inputs and 5 outputs per service, but easily expandable |
| 1395 | * Also, can handle two layer of nested conditional statements, but could |
| 1396 | * be expanded to meet additional needs. |