| 1 |
// ---------------------------------------------------------------------------- |
| 2 |
// Copyright (C) 2014 |
| 3 |
// David Freese, W1HKJ |
| 4 |
// |
| 5 |
// This file is part of flmsg |
| 6 |
// |
| 7 |
// flrig is free software; you can redistribute it and/or modify |
| 8 |
// it under the terms of the GNU General Public License as published by |
| 9 |
// the Free Software Foundation; either version 3 of the License, or |
| 10 |
// (at your option) any later version. |
| 11 |
// |
| 12 |
// flrig is distributed in the hope that it will be useful, |
| 13 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
// GNU General Public License for more details. |
| 16 |
// |
| 17 |
// You should have received a copy of the GNU General Public License |
| 18 |
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
// ---------------------------------------------------------------------------- |
| 20 |
|
| 21 |
#include <stdlib.h> |
| 22 |
#include <iostream> |
| 23 |
#include <fstream> |
| 24 |
#include <string> |
| 25 |
#include <cstring> |
| 26 |
#include <ctime> |
| 27 |
#include <sys/types.h> |
| 28 |
#include <sys/stat.h> |
| 29 |
#include <stdio.h> |
| 30 |
#include <errno.h> |
| 31 |
|
| 32 |
#include <FL/Fl.H> |
| 33 |
#include <FL/Enumerations.H> |
| 34 |
#include <FL/Fl_Window.H> |
| 35 |
#include <FL/Fl_Button.H> |
| 36 |
#include <FL/Fl_Group.H> |
| 37 |
#include <FL/Fl_Sys_Menu_Bar.H> |
| 38 |
#include <FL/x.H> |
| 39 |
#include <FL/Fl_Help_Dialog.H> |
| 40 |
#include <FL/Fl_Menu_Item.H> |
| 41 |
#include <FL/Fl_File_Icon.H> |
| 42 |
|
| 43 |
#include "config.h" |
| 44 |
#include "flmsg_config.h" |
| 45 |
|
| 46 |
#include "flmsg.h" |
| 47 |
#include "templates.h" |
| 48 |
#include "debug.h" |
| 49 |
#include "util.h" |
| 50 |
#include "gettext.h" |
| 51 |
#include "flmsg_dialog.h" |
| 52 |
#include "flinput2.h" |
| 53 |
#include "date.h" |
| 54 |
#include "calendar.h" |
| 55 |
#include "icons.h" |
| 56 |
#include "fileselect.h" |
| 57 |
#include "wrap.h" |
| 58 |
#include "status.h" |
| 59 |
#include "parse_xml.h" |
| 60 |
|
| 61 |
#ifdef WIN32 |
| 62 |
# include "flmsgrc.h" |
| 63 |
# include "compat.h" |
| 64 |
# define dirent fl_dirent_no_thanks |
| 65 |
#endif |
| 66 |
|
| 67 |
#include <FL/filename.H> |
| 68 |
#include "dirent-check.h" |
| 69 |
|
| 70 |
#include <FL/x.H> |
| 71 |
#include <FL/Fl_Pixmap.H> |
| 72 |
#include <FL/Fl_Image.H> |
| 73 |
|
| 74 |
// --------------------------------------------------------------------- |
| 75 |
// ics 203 field variables and template variables |
| 76 |
// --------------------------------------------------------------------- |
| 77 |
|
| 78 |
std::string ics203_incident = ":inc:"; |
| 79 |
std::string ics203_date = ":dat:"; |
| 80 |
std::string ics203_time = ":tim:"; |
| 81 |
std::string ics203_op_period = ":opp:"; |
| 82 |
std::string ics203_incident_commander = ":icc:"; |
| 83 |
std::string ics203_incident_deputy = ":icd:"; |
| 84 |
std::string ics203_incident_safety_officer = ":ics:"; |
| 85 |
std::string ics203_incident_info_officer = ":ici:"; |
| 86 |
std::string ics203_liaison_officer = ":icl:"; |
| 87 |
std::string ics203_prepared_by = ":pre:"; |
| 88 |
std::string ics203_agency = ":agency[n]:"; // 7 |
| 89 |
std::string ics203_agency_name = ":agency_name[n]:"; // 7 |
| 90 |
std::string ics203_planning_chief = ":planning_chief:"; |
| 91 |
std::string ics203_planning_deputy = ":planning_deputy:"; |
| 92 |
std::string ics203_resources_unit = ":resources_unit:"; |
| 93 |
std::string ics203_situation_unit = ":situation_unit:"; |
| 94 |
std::string ics203_documentation_unit = ":documentation_unit:"; |
| 95 |
std::string ics203_demobilization_unit = ":demobilization_unit:"; |
| 96 |
std::string ics203_tech_spc = ":tech_spc[n]:"; // 3 |
| 97 |
std::string ics203_logistics_chief = ":logistics_chief:"; |
| 98 |
std::string ics203_logistics_deputy = ":logistics_deputy:"; |
| 99 |
std::string ics203_support_director = ":support_director:"; |
| 100 |
std::string ics203_supply_unit = ":supply_unit:"; |
| 101 |
std::string ics203_facilities_unit = ":facilities_unit:"; |
| 102 |
std::string ics203_ground_support = ":ground_support:"; |
| 103 |
std::string ics203_service_director = ":service_director:"; |
| 104 |
std::string ics203_communications_unit = ":communications_unit:"; |
| 105 |
std::string ics203_medical_unit = ":medical_unit:"; |
| 106 |
std::string ics203_food_unit = ":food_unit:"; |
| 107 |
std::string ics203_ops_chief = ":ops_chief:"; |
| 108 |
std::string ics203_ops_deputy = ":ops_deputy:"; |
| 109 |
std::string ics203_b1_director = ":b1_director:"; |
| 110 |
std::string ics203_b1_deputy = ":b1_deputy:"; |
| 111 |
std::string ics203_b1_div = ":b1_div[n]:"; // 4 |
| 112 |
std::string ics203_b1_grp = ":b1_grp[n]:"; // 4 |
| 113 |
std::string ics203_b2_director = ":b2_director:"; |
| 114 |
std::string ics203_b2_deputy = ":b2_deputy:"; |
| 115 |
std::string ics203_b2_div = ":b2_div[n]:"; // 4 |
| 116 |
std::string ics203_b2_grp = ":b2_grp[n]:"; // 4 |
| 117 |
std::string ics203_b3_director = ":b3_director:"; |
| 118 |
std::string ics203_b3_deputy = ":b3_deputy:"; |
| 119 |
std::string ics203_b3_div = ":b3_div[n]:"; // 4 |
| 120 |
std::string ics203_b3_grp = ":b3_grp[n]:"; // 4 |
| 121 |
std::string ics203_air_ops_br_dir = ":air_ops_br_dir:"; |
| 122 |
std::string ics203_air_tactical_group_sup = ":air_tactical_group_sup:"; |
| 123 |
std::string ics203_air_support_group_sup = ":air_support_group_sup:"; |
| 124 |
std::string ics203_helicopter_coordinator = ":helicopter_coordinator:"; |
| 125 |
std::string ics203_air_tanker_fixed_wing = ":air_tanker_fixed_wing:"; |
| 126 |
std::string ics203_finance_chief = ":finance_chief:"; |
| 127 |
std::string ics203_finance_deputy = ":finance_deputy:"; |
| 128 |
std::string ics203_time_unit = ":time_unit:"; |
| 129 |
std::string ics203_procurement_unit = ":procurement_unit:"; |
| 130 |
std::string ics203_claims_unit = ":claims_unit:"; |
| 131 |
std::string ics203_cost_unit = ":cost_unit:"; |
| 132 |
|
| 133 |
std::string s203_incident; |
| 134 |
std::string s203_date; |
| 135 |
std::string s203_time; |
| 136 |
std::string s203_op_period; |
| 137 |
std::string s203_incident_commander; |
| 138 |
std::string s203_incident_deputy; |
| 139 |
std::string s203_incident_safety_officer; |
| 140 |
std::string s203_incident_info_officer; |
| 141 |
std::string s203_liaison_officer; |
| 142 |
std::string s203_prepared_by; |
| 143 |
std::string s203_agency[7]; |
| 144 |
std::string s203_agency_name[7]; |
| 145 |
std::string s203_planning_chief; |
| 146 |
std::string s203_planning_deputy; |
| 147 |
std::string s203_resources_unit; |
| 148 |
std::string s203_situation_unit; |
| 149 |
std::string s203_documentation_unit; |
| 150 |
std::string s203_demobilization_unit; |
| 151 |
std::string s203_tech_spc[3]; |
| 152 |
std::string s203_logistics_chief; |
| 153 |
std::string s203_logistics_deputy; |
| 154 |
std::string s203_support_director; |
| 155 |
std::string s203_supply_unit; |
| 156 |
std::string s203_facilities_unit; |
| 157 |
std::string s203_ground_support; |
| 158 |
std::string s203_service_director; |
| 159 |
std::string s203_communications_unit; |
| 160 |
std::string s203_medical_unit; |
| 161 |
std::string s203_food_unit; |
| 162 |
std::string s203_ops_chief; |
| 163 |
std::string s203_ops_deputy; |
| 164 |
std::string s203_b1_director; |
| 165 |
std::string s203_b1_deputy; |
| 166 |
std::string s203_b1_div[5]; |
| 167 |
std::string s203_b1_grp[5]; |
| 168 |
std::string s203_b2_director; |
| 169 |
std::string s203_b2_deputy; |
| 170 |
std::string s203_b2_div[5]; |
| 171 |
std::string s203_b2_grp[5]; |
| 172 |
std::string s203_b3_director; |
| 173 |
std::string s203_b3_deputy; |
| 174 |
std::string s203_b3_div[5]; |
| 175 |
std::string s203_b3_grp[5]; |
| 176 |
std::string s203_air_ops_br_dir; |
| 177 |
std::string s203_air_tactical_group_sup; |
| 178 |
std::string s203_air_support_group_sup; |
| 179 |
std::string s203_helicopter_coordinator; |
| 180 |
std::string s203_air_tanker_fixed_wing; |
| 181 |
std::string s203_finance_chief; |
| 182 |
std::string s203_finance_deputy; |
| 183 |
std::string s203_time_unit; |
| 184 |
std::string s203_procurement_unit; |
| 185 |
std::string s203_claims_unit; |
| 186 |
std::string s203_cost_unit; |
| 187 |
|
| 188 |
// ===================================================================== |
| 189 |
|
| 190 |
std::string buff203; |
| 191 |
std::string def_203_filename = ""; |
| 192 |
std::string base_203_filename = ""; |
| 193 |
std::string def_203_TemplateName = ""; |
| 194 |
bool using_ics203_template = false; |
| 195 |
|
| 196 |
void cb_203_set_date() |
| 197 |
{ |
| 198 |
txt_203_date->value(szDate(progStatus.dtformat)); |
| 199 |
} |
| 200 |
|
| 201 |
void cb_203_set_time() |
| 202 |
{ |
| 203 |
txt_203_time->value(szTime(progStatus.UTC)); |
| 204 |
} |
| 205 |
|
| 206 |
void clear_203fields() |
| 207 |
{ |
| 208 |
s203_incident.clear(); |
| 209 |
s203_date.clear(); |
| 210 |
s203_time.clear(); |
| 211 |
s203_op_period.clear(); |
| 212 |
s203_incident_commander.clear(); |
| 213 |
s203_incident_deputy.clear(); |
| 214 |
s203_incident_safety_officer.clear(); |
| 215 |
s203_incident_info_officer.clear(); |
| 216 |
s203_liaison_officer.clear(); |
| 217 |
s203_prepared_by.clear(); |
| 218 |
s203_planning_chief.clear(); |
| 219 |
s203_planning_deputy.clear(); |
| 220 |
s203_resources_unit.clear(); |
| 221 |
s203_situation_unit.clear(); |
| 222 |
s203_documentation_unit.clear(); |
| 223 |
s203_demobilization_unit.clear(); |
| 224 |
s203_logistics_chief.clear(); |
| 225 |
s203_logistics_deputy.clear(); |
| 226 |
s203_support_director.clear(); |
| 227 |
s203_supply_unit.clear(); |
| 228 |
s203_facilities_unit.clear(); |
| 229 |
s203_ground_support.clear(); |
| 230 |
s203_service_director.clear(); |
| 231 |
s203_communications_unit.clear(); |
| 232 |
s203_medical_unit.clear(); |
| 233 |
s203_food_unit.clear(); |
| 234 |
s203_ops_chief.clear(); |
| 235 |
s203_ops_deputy.clear(); |
| 236 |
s203_b1_director.clear(); |
| 237 |
s203_b1_deputy.clear(); |
| 238 |
s203_b2_director.clear(); |
| 239 |
s203_b2_deputy.clear(); |
| 240 |
s203_b3_director.clear(); |
| 241 |
s203_b3_deputy.clear(); |
| 242 |
s203_air_ops_br_dir.clear(); |
| 243 |
s203_air_tactical_group_sup.clear(); |
| 244 |
s203_air_support_group_sup.clear(); |
| 245 |
s203_helicopter_coordinator.clear(); |
| 246 |
s203_air_tanker_fixed_wing.clear(); |
| 247 |
s203_finance_chief.clear(); |
| 248 |
s203_finance_deputy.clear(); |
| 249 |
s203_time_unit.clear(); |
| 250 |
s203_procurement_unit.clear(); |
| 251 |
s203_claims_unit.clear(); |
| 252 |
s203_cost_unit.clear(); |
| 253 |
|
| 254 |
for (int i = 0; i < 7; i++) { |
| 255 |
s203_agency[i].clear(); |
| 256 |
s203_agency_name[i].clear(); |
| 257 |
} |
| 258 |
for (int i = 0; i < 3; i++) { |
| 259 |
s203_tech_spc[i].clear(); |
| 260 |
} |
| 261 |
for (int i = 0; i < 5; i++) { |
| 262 |
s203_b1_div[i].clear(); |
| 263 |
s203_b1_grp[i].clear(); |
| 264 |
s203_b2_div[i].clear(); |
| 265 |
s203_b2_grp[i].clear(); |
| 266 |
s203_b3_div[i].clear(); |
| 267 |
s203_b3_grp[i].clear(); |
| 268 |
} |
| 269 |
} |
| 270 |
|
| 271 |
bool check_203fields() { |
| 272 |
if (s203_incident != txt_203_incident->value()) |
| 273 |
return true; |
| 274 |
if (s203_date != txt_203_date->value()) |
| 275 |
return true; |
| 276 |
if (s203_time != txt_203_time->value()) |
| 277 |
return true; |
| 278 |
if (s203_op_period != txt_203_op_period->value()) |
| 279 |
return true; |
| 280 |
if (s203_incident_commander != txt_203_incident_commander->value()) |
| 281 |
return true; |
| 282 |
if (s203_incident_deputy != txt_203_incident_deputy->value()) |
| 283 |
return true; |
| 284 |
if (s203_incident_safety_officer != txt_203_incident_safety_officer->value()) |
| 285 |
return true; |
| 286 |
if (s203_incident_info_officer != txt_203_incident_info_officer->value()) |
| 287 |
return true; |
| 288 |
if (s203_liaison_officer != txt_203_liaison_officer->value()) |
| 289 |
return true; |
| 290 |
if (s203_prepared_by != txt_203_prepared_by->value()) |
| 291 |
return true; |
| 292 |
if (s203_planning_chief != txt_203_planning_chief->value()) |
| 293 |
return true; |
| 294 |
if (s203_planning_deputy != txt_203_planning_deputy->value()) |
| 295 |
return true; |
| 296 |
if (s203_resources_unit != txt_203_resources_unit->value()) |
| 297 |
return true; |
| 298 |
if (s203_situation_unit != txt_203_situation_unit->value()) |
| 299 |
return true; |
| 300 |
if (s203_documentation_unit != txt_203_documentation_unit->value()) |
| 301 |
return true; |
| 302 |
if (s203_demobilization_unit != txt_203_demobilization_unit->value()) |
| 303 |
return true; |
| 304 |
if (s203_logistics_chief != txt_203_logistics_chief->value()) |
| 305 |
return true; |
| 306 |
if (s203_logistics_deputy != txt_203_logistics_deputy->value()) |
| 307 |
return true; |
| 308 |
if (s203_support_director != txt_203_support_director->value()) |
| 309 |
return true; |
| 310 |
if (s203_supply_unit != txt_203_supply_unit->value()) |
| 311 |
return true; |
| 312 |
if (s203_facilities_unit != txt_203_facilities_unit->value()) |
| 313 |
return true; |
| 314 |
if (s203_ground_support != txt_203_ground_support->value()) |
| 315 |
return true; |
| 316 |
if (s203_service_director != txt_203_service_director->value()) |
| 317 |
return true; |
| 318 |
if (s203_communications_unit != txt_203_communications_unit->value()) |
| 319 |
return true; |
| 320 |
if (s203_medical_unit != txt_203_medical_unit->value()) |
| 321 |
return true; |
| 322 |
if (s203_food_unit != txt_203_food_unit->value()) |
| 323 |
return true; |
| 324 |
if (s203_ops_chief != txt_203_ops_chief->value()) |
| 325 |
return true; |
| 326 |
if (s203_ops_deputy != txt_203_ops_deputy->value()) |
| 327 |
return true; |
| 328 |
if (s203_b1_director != txt_203_b1_director->value()) |
| 329 |
return true; |
| 330 |
if (s203_b1_deputy != txt_203_b1_deputy->value()) |
| 331 |
return true; |
| 332 |
if (s203_b2_director != txt_203_b2_director->value()) |
| 333 |
return true; |
| 334 |
if (s203_b2_deputy != txt_203_b2_deputy->value()) |
| 335 |
return true; |
| 336 |
if (s203_b3_director != txt_203_b3_director->value()) |
| 337 |
return true; |
| 338 |
if (s203_b3_deputy != txt_203_b3_deputy->value()) |
| 339 |
return true; |
| 340 |
if (s203_air_ops_br_dir != txt_203_air_ops_br_dir->value()) |
| 341 |
return true; |
| 342 |
if (s203_air_tactical_group_sup != txt_203_air_tactical_group_sup->value()) |
| 343 |
return true; |
| 344 |
if (s203_air_support_group_sup != txt_203_air_support_group_sup->value()) |
| 345 |
return true; |
| 346 |
if (s203_helicopter_coordinator != txt_203_helicopter_coordinator->value()) |
| 347 |
return true; |
| 348 |
if (s203_air_tanker_fixed_wing != txt_203_air_tanker_fixed_wing->value()) |
| 349 |
return true; |
| 350 |
if (s203_finance_chief != txt_203_finance_chief->value()) |
| 351 |
return true; |
| 352 |
if (s203_finance_deputy != txt_203_finance_deputy->value()) |
| 353 |
return true; |
| 354 |
if (s203_time_unit != txt_203_time_unit->value()) |
| 355 |
return true; |
| 356 |
if (s203_procurement_unit != txt_203_procurement_unit->value()) |
| 357 |
return true; |
| 358 |
if (s203_claims_unit != txt_203_claims_unit->value()) |
| 359 |
return true; |
| 360 |
if (s203_cost_unit != txt_203_cost_unit->value()) |
| 361 |
return true; |
| 362 |
|
| 363 |
for (int i = 0; i < 7; i++) { |
| 364 |
if (s203_agency[i] != txt_203_agency[i]->value()) |
| 365 |
return true; |
| 366 |
if (s203_agency_name[i] != txt_203_agency_name[i]->value()) |
| 367 |
return true; |
| 368 |
} |
| 369 |
|
| 370 |
for (int i = 0; i < 3; i++) { |
| 371 |
if (s203_tech_spc[i] != txt_203_tech_spc[i]->value()) |
| 372 |
return true; |
| 373 |
} |
| 374 |
|
| 375 |
for (int i = 0; i < 5; i++) { |
| 376 |
if (s203_b1_div[i] != txt_203_b1_div[i]->value()) |
| 377 |
return true; |
| 378 |
if (s203_b1_grp[i] != txt_203_b1_grp[i]->value()) |
| 379 |
return true; |
| 380 |
if (s203_b2_div[i] != txt_203_b2_div[i]->value()) |
| 381 |
return true; |
| 382 |
if (s203_b2_grp[i] != txt_203_b2_grp[i]->value()) |
| 383 |
return true; |
| 384 |
if (s203_b3_div[i] != txt_203_b3_div[i]->value()) |
| 385 |
return true; |
| 386 |
if (s203_b3_grp[i] != txt_203_b3_grp[i]->value()) |
| 387 |
return true; |
| 388 |
} |
| 389 |
return false; |
| 390 |
} |
| 391 |
|
| 392 |
void update_203fields() |
| 393 |
{ |
| 394 |
s203_incident = txt_203_incident->value(); |
| 395 |
s203_date = txt_203_date->value(); |
| 396 |
s203_time = txt_203_time->value(); |
| 397 |
s203_op_period = txt_203_op_period->value(); |
| 398 |
s203_incident_commander = txt_203_incident_commander->value(); |
| 399 |
s203_incident_deputy = txt_203_incident_deputy->value(); |
| 400 |
s203_incident_safety_officer = txt_203_incident_safety_officer->value(); |
| 401 |
s203_incident_info_officer = txt_203_incident_info_officer->value(); |
| 402 |
s203_liaison_officer = txt_203_liaison_officer->value(); |
| 403 |
s203_prepared_by = txt_203_prepared_by->value(); |
| 404 |
s203_planning_chief = txt_203_planning_chief->value(); |
| 405 |
s203_planning_deputy = txt_203_planning_deputy->value(); |
| 406 |
s203_resources_unit = txt_203_resources_unit->value(); |
| 407 |
s203_situation_unit = txt_203_situation_unit->value(); |
| 408 |
s203_documentation_unit = txt_203_documentation_unit->value(); |
| 409 |
s203_demobilization_unit = txt_203_demobilization_unit->value(); |
| 410 |
s203_logistics_chief = txt_203_logistics_chief->value(); |
| 411 |
s203_logistics_deputy = txt_203_logistics_deputy->value(); |
| 412 |
s203_support_director = txt_203_support_director->value(); |
| 413 |
s203_supply_unit = txt_203_supply_unit->value(); |
| 414 |
s203_facilities_unit = txt_203_facilities_unit->value(); |
| 415 |
s203_ground_support = txt_203_ground_support->value(); |
| 416 |
s203_service_director = txt_203_service_director->value(); |
| 417 |
s203_communications_unit = txt_203_communications_unit->value(); |
| 418 |
s203_medical_unit = txt_203_medical_unit->value(); |
| 419 |
s203_food_unit = txt_203_food_unit->value(); |
| 420 |
s203_ops_chief = txt_203_ops_chief->value(); |
| 421 |
s203_ops_deputy = txt_203_ops_deputy->value(); |
| 422 |
s203_b1_director = txt_203_b1_director->value(); |
| 423 |
s203_b1_deputy = txt_203_b1_deputy->value(); |
| 424 |
s203_b2_director = txt_203_b2_director->value(); |
| 425 |
s203_b2_deputy = txt_203_b2_deputy->value(); |
| 426 |
s203_b3_director = txt_203_b3_director->value(); |
| 427 |
s203_b3_deputy = txt_203_b3_deputy->value(); |
| 428 |
s203_air_ops_br_dir = txt_203_air_ops_br_dir->value(); |
| 429 |
s203_air_tactical_group_sup = txt_203_air_tactical_group_sup->value(); |
| 430 |
s203_air_support_group_sup = txt_203_air_support_group_sup->value(); |
| 431 |
s203_helicopter_coordinator = txt_203_helicopter_coordinator->value(); |
| 432 |
s203_air_tanker_fixed_wing = txt_203_air_tanker_fixed_wing->value(); |
| 433 |
s203_finance_chief = txt_203_finance_chief->value(); |
| 434 |
s203_finance_deputy = txt_203_finance_deputy->value(); |
| 435 |
s203_time_unit = txt_203_time_unit->value(); |
| 436 |
s203_procurement_unit = txt_203_procurement_unit->value(); |
| 437 |
s203_claims_unit = txt_203_claims_unit->value(); |
| 438 |
s203_cost_unit = txt_203_cost_unit->value(); |
| 439 |
|
| 440 |
for (int i = 0; i < 7; i++) { |
| 441 |
s203_agency[i] = txt_203_agency[i]->value(); |
| 442 |
s203_agency_name[i] = txt_203_agency_name[i]->value(); |
| 443 |
} |
| 444 |
|
| 445 |
for (int i = 0; i < 3; i++) { |
| 446 |
s203_tech_spc[i] = txt_203_tech_spc[i]->value(); |
| 447 |
} |
| 448 |
|
| 449 |
for (int i = 0; i < 5; i++) { |
| 450 |
s203_b1_div[i] = txt_203_b1_div[i]->value(); |
| 451 |
s203_b1_grp[i] = txt_203_b1_grp[i]->value(); |
| 452 |
s203_b2_div[i] = txt_203_b2_div[i]->value(); |
| 453 |
s203_b2_grp[i] = txt_203_b2_grp[i]->value(); |
| 454 |
s203_b3_div[i] = txt_203_b3_div[i]->value(); |
| 455 |
s203_b3_grp[i] = txt_203_b3_grp[i]->value(); |
| 456 |
} |
| 457 |
} |
| 458 |
|
| 459 |
void update_203form() |
| 460 |
{ |
| 461 |
txt_203_incident->value(s203_incident.c_str()); |
| 462 |
txt_203_date->value(s203_date.c_str()); |
| 463 |
txt_203_time->value(s203_time.c_str()); |
| 464 |
txt_203_op_period->value(s203_op_period.c_str()); |
| 465 |
txt_203_incident_commander->value(s203_incident_commander.c_str()); |
| 466 |
txt_203_incident_deputy->value(s203_incident_deputy.c_str()); |
| 467 |
txt_203_incident_safety_officer->value(s203_incident_safety_officer.c_str()); |
| 468 |
txt_203_incident_info_officer->value(s203_incident_info_officer.c_str()); |
| 469 |
txt_203_liaison_officer->value(s203_liaison_officer.c_str()); |
| 470 |
txt_203_prepared_by->value(s203_prepared_by.c_str()); |
| 471 |
txt_203_planning_chief->value(s203_planning_chief.c_str()); |
| 472 |
txt_203_planning_deputy->value(s203_planning_deputy.c_str()); |
| 473 |
txt_203_resources_unit->value(s203_resources_unit.c_str()); |
| 474 |
txt_203_situation_unit->value(s203_situation_unit.c_str()); |
| 475 |
txt_203_documentation_unit->value(s203_documentation_unit.c_str()); |
| 476 |
txt_203_demobilization_unit->value(s203_demobilization_unit.c_str()); |
| 477 |
txt_203_logistics_chief->value(s203_logistics_chief.c_str()); |
| 478 |
txt_203_logistics_deputy->value(s203_logistics_deputy.c_str()); |
| 479 |
txt_203_support_director->value(s203_support_director.c_str()); |
| 480 |
txt_203_supply_unit->value(s203_supply_unit.c_str()); |
| 481 |
txt_203_facilities_unit->value(s203_facilities_unit.c_str()); |
| 482 |
txt_203_ground_support->value(s203_ground_support.c_str()); |
| 483 |
txt_203_service_director->value(s203_service_director.c_str()); |
| 484 |
txt_203_communications_unit->value(s203_communications_unit.c_str()); |
| 485 |
txt_203_medical_unit->value(s203_medical_unit.c_str()); |
| 486 |
txt_203_food_unit->value(s203_food_unit.c_str()); |
| 487 |
txt_203_ops_chief->value(s203_ops_chief.c_str()); |
| 488 |
txt_203_ops_deputy->value(s203_ops_deputy.c_str()); |
| 489 |
txt_203_b1_director->value(s203_b1_director.c_str()); |
| 490 |
txt_203_b1_deputy->value(s203_b1_deputy.c_str()); |
| 491 |
txt_203_b2_director->value(s203_b2_director.c_str()); |
| 492 |
txt_203_b2_deputy->value(s203_b2_deputy.c_str()); |
| 493 |
txt_203_b3_director->value(s203_b3_director.c_str()); |
| 494 |
txt_203_b3_deputy->value(s203_b3_deputy.c_str()); |
| 495 |
txt_203_air_ops_br_dir->value(s203_air_ops_br_dir.c_str()); |
| 496 |
txt_203_air_tactical_group_sup->value(s203_air_tactical_group_sup.c_str()); |
| 497 |
txt_203_air_support_group_sup->value(s203_air_support_group_sup.c_str()); |
| 498 |
txt_203_helicopter_coordinator->value(s203_helicopter_coordinator.c_str()); |
| 499 |
txt_203_air_tanker_fixed_wing->value(s203_air_tanker_fixed_wing.c_str()); |
| 500 |
txt_203_finance_chief->value(s203_finance_chief.c_str()); |
| 501 |
txt_203_finance_deputy->value(s203_finance_deputy.c_str()); |
| 502 |
txt_203_time_unit->value(s203_time_unit.c_str()); |
| 503 |
txt_203_procurement_unit->value(s203_procurement_unit.c_str()); |
| 504 |
txt_203_claims_unit->value(s203_claims_unit.c_str()); |
| 505 |
txt_203_cost_unit->value(s203_cost_unit.c_str()); |
| 506 |
|
| 507 |
for (int i = 0; i < 7; i++) { |
| 508 |
txt_203_agency[i]->value(s203_agency[i].c_str()); |
| 509 |
txt_203_agency_name[i]->value(s203_agency_name[i].c_str()); |
| 510 |
} |
| 511 |
for (int i = 0; i < 3; i++) { |
| 512 |
txt_203_tech_spc[i]->value(s203_tech_spc[i].c_str()); |
| 513 |
} |
| 514 |
for (int i = 0; i < 5; i++) { |
| 515 |
txt_203_b1_div[i]->value(s203_b1_div[i].c_str()); |
| 516 |
txt_203_b1_grp[i]->value(s203_b1_grp[i].c_str()); |
| 517 |
txt_203_b2_div[i]->value(s203_b2_div[i].c_str()); |
| 518 |
txt_203_b2_grp[i]->value(s203_b2_grp[i].c_str()); |
| 519 |
txt_203_b3_div[i]->value(s203_b3_div[i].c_str()); |
| 520 |
txt_203_b3_grp[i]->value(s203_b3_grp[i].c_str()); |
| 521 |
} |
| 522 |
} |
| 523 |
|
| 524 |
void clear_203_form() |
| 525 |
{ |
| 526 |
clear_203fields(); |
| 527 |
|
| 528 |
txt_203_incident->value(""); |
| 529 |
txt_203_date->value(""); |
| 530 |
txt_203_time->value(""); |
| 531 |
txt_203_op_period->value(""); |
| 532 |
txt_203_incident_commander->value(""); |
| 533 |
txt_203_incident_deputy->value(""); |
| 534 |
txt_203_incident_safety_officer->value(""); |
| 535 |
txt_203_incident_info_officer->value(""); |
| 536 |
txt_203_liaison_officer->value(""); |
| 537 |
txt_203_prepared_by->value(""); |
| 538 |
txt_203_planning_chief->value(""); |
| 539 |
txt_203_planning_deputy->value(""); |
| 540 |
txt_203_resources_unit->value(""); |
| 541 |
txt_203_situation_unit->value(""); |
| 542 |
txt_203_documentation_unit->value(""); |
| 543 |
txt_203_demobilization_unit->value(""); |
| 544 |
txt_203_logistics_chief->value(""); |
| 545 |
txt_203_logistics_deputy->value(""); |
| 546 |
txt_203_support_director->value(""); |
| 547 |
txt_203_supply_unit->value(""); |
| 548 |
txt_203_facilities_unit->value(""); |
| 549 |
txt_203_ground_support->value(""); |
| 550 |
txt_203_service_director->value(""); |
| 551 |
txt_203_communications_unit->value(""); |
| 552 |
txt_203_medical_unit->value(""); |
| 553 |
txt_203_food_unit->value(""); |
| 554 |
txt_203_ops_chief->value(""); |
| 555 |
txt_203_ops_deputy->value(""); |
| 556 |
txt_203_b1_director->value(""); |
| 557 |
txt_203_b1_deputy->value(""); |
| 558 |
txt_203_b2_director->value(""); |
| 559 |
txt_203_b2_deputy->value(""); |
| 560 |
txt_203_b3_director->value(""); |
| 561 |
txt_203_b3_deputy->value(""); |
| 562 |
txt_203_air_ops_br_dir->value(""); |
| 563 |
txt_203_air_tactical_group_sup->value(""); |
| 564 |
txt_203_air_support_group_sup->value(""); |
| 565 |
txt_203_helicopter_coordinator->value(""); |
| 566 |
txt_203_air_tanker_fixed_wing->value(""); |
| 567 |
txt_203_finance_chief->value(""); |
| 568 |
txt_203_finance_deputy->value(""); |
| 569 |
txt_203_time_unit->value(""); |
| 570 |
txt_203_procurement_unit->value(""); |
| 571 |
txt_203_claims_unit->value(""); |
| 572 |
txt_203_cost_unit->value(""); |
| 573 |
|
| 574 |
for (int i = 0; i < 7; i++) { |
| 575 |
txt_203_agency[i]->value(""); |
| 576 |
txt_203_agency_name[i]->value(""); |
| 577 |
} |
| 578 |
for (int i = 0; i < 3; i++) { |
| 579 |
txt_203_tech_spc[i]->value(""); |
| 580 |
} |
| 581 |
for (int i = 0; i < 5; i++) { |
| 582 |
txt_203_b1_div[i]->value(""); |
| 583 |
txt_203_b1_grp[i]->value(""); |
| 584 |
txt_203_b2_div[i]->value(""); |
| 585 |
txt_203_b2_grp[i]->value(""); |
| 586 |
txt_203_b3_div[i]->value(""); |
| 587 |
txt_203_b3_grp[i]->value(""); |
| 588 |
} |
| 589 |
} |
| 590 |
|
| 591 |
std::string &ics_n(std::string & subst, int n) |
| 592 |
{ |
| 593 |
static std::string garbage = "#$^*!"; |
| 594 |
size_t pos = subst.find("["); |
| 595 |
if (pos == std::string::npos) return garbage; |
| 596 |
pos++; |
| 597 |
subst[pos] = '0' + n; |
| 598 |
return subst; |
| 599 |
} |
| 600 |
|
| 601 |
void make_buff203(bool compress = false) |
| 602 |
{ |
| 603 |
std::string mbuff; |
| 604 |
mbuff.clear(); |
| 605 |
mbuff.append( lineout( ics203_incident, s203_incident ) ); |
| 606 |
mbuff.append( lineout( ics203_date, s203_date ) ); |
| 607 |
mbuff.append( lineout( ics203_time, s203_time ) ); |
| 608 |
mbuff.append( lineout( ics203_op_period, s203_op_period ) ); |
| 609 |
mbuff.append( lineout( ics203_incident_commander, s203_incident_commander ) ); |
| 610 |
mbuff.append( lineout( ics203_incident_deputy, s203_incident_deputy ) ); |
| 611 |
mbuff.append( lineout( ics203_incident_safety_officer, s203_incident_safety_officer ) ); |
| 612 |
mbuff.append( lineout( ics203_incident_info_officer, s203_incident_info_officer ) ); |
| 613 |
mbuff.append( lineout( ics203_liaison_officer, s203_liaison_officer ) ); |
| 614 |
mbuff.append( lineout( ics203_prepared_by, s203_prepared_by ) ); |
| 615 |
mbuff.append( lineout( ics203_planning_chief, s203_planning_chief ) ); |
| 616 |
mbuff.append( lineout( ics203_planning_deputy, s203_planning_deputy ) ); |
| 617 |
mbuff.append( lineout( ics203_resources_unit, s203_resources_unit ) ); |
| 618 |
mbuff.append( lineout( ics203_situation_unit, s203_situation_unit ) ); |
| 619 |
mbuff.append( lineout( ics203_documentation_unit, s203_documentation_unit ) ); |
| 620 |
mbuff.append( lineout( ics203_demobilization_unit, s203_demobilization_unit ) ); |
| 621 |
mbuff.append( lineout( ics203_logistics_chief, s203_logistics_chief ) ); |
| 622 |
mbuff.append( lineout( ics203_logistics_deputy, s203_logistics_deputy ) ); |
| 623 |
mbuff.append( lineout( ics203_support_director, s203_support_director ) ); |
| 624 |
mbuff.append( lineout( ics203_supply_unit, s203_supply_unit ) ); |
| 625 |
mbuff.append( lineout( ics203_facilities_unit, s203_facilities_unit ) ); |
| 626 |
mbuff.append( lineout( ics203_ground_support, s203_ground_support ) ); |
| 627 |
mbuff.append( lineout( ics203_service_director, s203_service_director ) ); |
| 628 |
mbuff.append( lineout( ics203_communications_unit, s203_communications_unit ) ); |
| 629 |
mbuff.append( lineout( ics203_medical_unit, s203_medical_unit ) ); |
| 630 |
mbuff.append( lineout( ics203_food_unit, s203_food_unit ) ); |
| 631 |
mbuff.append( lineout( ics203_ops_chief, s203_ops_chief ) ); |
| 632 |
mbuff.append( lineout( ics203_ops_deputy, s203_ops_deputy ) ); |
| 633 |
mbuff.append( lineout( ics203_b1_director, s203_b1_director ) ); |
| 634 |
mbuff.append( lineout( ics203_b1_deputy, s203_b1_deputy ) ); |
| 635 |
mbuff.append( lineout( ics203_b2_director, s203_b2_director ) ); |
| 636 |
mbuff.append( lineout( ics203_b2_deputy, s203_b2_deputy ) ); |
| 637 |
mbuff.append( lineout( ics203_b3_director, s203_b3_director ) ); |
| 638 |
mbuff.append( lineout( ics203_b3_deputy, s203_b3_deputy ) ); |
| 639 |
mbuff.append( lineout( ics203_air_ops_br_dir, s203_air_ops_br_dir ) ); |
| 640 |
mbuff.append( lineout( ics203_air_tactical_group_sup, s203_air_tactical_group_sup ) ); |
| 641 |
mbuff.append( lineout( ics203_air_support_group_sup, s203_air_support_group_sup ) ); |
| 642 |
mbuff.append( lineout( ics203_helicopter_coordinator, s203_helicopter_coordinator ) ); |
| 643 |
mbuff.append( lineout( ics203_air_tanker_fixed_wing, s203_air_tanker_fixed_wing ) ); |
| 644 |
mbuff.append( lineout( ics203_finance_chief, s203_finance_chief ) ); |
| 645 |
mbuff.append( lineout( ics203_finance_deputy, s203_finance_deputy ) ); |
| 646 |
mbuff.append( lineout( ics203_time_unit, s203_time_unit ) ); |
| 647 |
mbuff.append( lineout( ics203_procurement_unit, s203_procurement_unit ) ); |
| 648 |
mbuff.append( lineout( ics203_claims_unit, s203_claims_unit ) ); |
| 649 |
mbuff.append( lineout( ics203_cost_unit, s203_cost_unit ) ); |
| 650 |
|
| 651 |
for (int i = 0; i < 7; i++) { |
| 652 |
mbuff.append( lineout( ics_n( ics203_agency, i ), s203_agency[i] ) ); |
| 653 |
mbuff.append( lineout( ics_n( ics203_agency_name, i ), s203_agency_name[i] ) ); |
| 654 |
} |
| 655 |
for (int i = 0; i < 3; i++) { |
| 656 |
mbuff.append( lineout( ics_n( ics203_tech_spc, i ), s203_tech_spc[i] ) ); |
| 657 |
} |
| 658 |
for (int i = 0; i < 5; i++) { |
| 659 |
mbuff.append( lineout( ics_n( ics203_b1_div, i ), s203_b1_div[i] ) ); |
| 660 |
mbuff.append( lineout( ics_n( ics203_b1_grp, i ), s203_b1_grp[i] ) ); |
| 661 |
mbuff.append( lineout( ics_n( ics203_b2_div, i ), s203_b2_div[i] ) ); |
| 662 |
mbuff.append( lineout( ics_n( ics203_b2_grp, i ), s203_b2_grp[i] ) ); |
| 663 |
mbuff.append( lineout( ics_n( ics203_b3_div, i ), s203_b3_div[i] ) ); |
| 664 |
mbuff.append( lineout( ics_n( ics203_b3_grp, i ), s203_b3_grp[i] ) ); |
| 665 |
} |
| 666 |
if (compress) compress_maybe(mbuff); |
| 667 |
buff203.append(mbuff); |
| 668 |
} |
| 669 |
|
| 670 |
void read_203_buffer(std::string data) |
| 671 |
{ |
| 672 |
clear_203fields(); |
| 673 |
read_header(data); |
| 674 |
|
| 675 |
s203_incident = findstr(data, ics203_incident); |
| 676 |
s203_date = findstr(data, ics203_date); |
| 677 |
s203_time = findstr(data, ics203_time); |
| 678 |
s203_op_period = findstr(data, ics203_op_period); |
| 679 |
s203_incident_commander = findstr(data, ics203_incident_commander); |
| 680 |
s203_incident_deputy = findstr(data, ics203_incident_deputy); |
| 681 |
s203_incident_safety_officer = findstr(data, ics203_incident_safety_officer); |
| 682 |
s203_incident_info_officer = findstr(data, ics203_incident_info_officer); |
| 683 |
s203_liaison_officer = findstr(data, ics203_liaison_officer); |
| 684 |
s203_prepared_by = findstr(data, ics203_prepared_by); |
| 685 |
s203_planning_chief = findstr(data, ics203_planning_chief); |
| 686 |
s203_planning_deputy = findstr(data, ics203_planning_deputy); |
| 687 |
s203_resources_unit = findstr(data, ics203_resources_unit); |
| 688 |
s203_situation_unit = findstr(data, ics203_situation_unit); |
| 689 |
s203_documentation_unit = findstr(data, ics203_documentation_unit); |
| 690 |
s203_demobilization_unit = findstr(data, ics203_demobilization_unit); |
| 691 |
s203_logistics_chief = findstr(data, ics203_logistics_chief); |
| 692 |
s203_logistics_deputy = findstr(data, ics203_logistics_deputy); |
| 693 |
s203_support_director = findstr(data, ics203_support_director); |
| 694 |
s203_supply_unit = findstr(data, ics203_supply_unit); |
| 695 |
s203_facilities_unit = findstr(data, ics203_facilities_unit); |
| 696 |
s203_ground_support = findstr(data, ics203_ground_support); |
| 697 |
s203_service_director = findstr(data, ics203_service_director); |
| 698 |
s203_communications_unit = findstr(data, ics203_communications_unit); |
| 699 |
s203_medical_unit = findstr(data, ics203_medical_unit); |
| 700 |
s203_food_unit = findstr(data, ics203_food_unit); |
| 701 |
s203_ops_chief = findstr(data, ics203_ops_chief); |
| 702 |
s203_ops_deputy = findstr(data, ics203_ops_deputy); |
| 703 |
s203_b1_director = findstr(data, ics203_b1_director); |
| 704 |
s203_b1_deputy = findstr(data, ics203_b1_deputy); |
| 705 |
s203_b2_director = findstr(data, ics203_b2_director); |
| 706 |
s203_b2_deputy = findstr(data, ics203_b2_deputy); |
| 707 |
s203_b3_director = findstr(data, ics203_b3_director); |
| 708 |
s203_b3_deputy = findstr(data, ics203_b3_deputy); |
| 709 |
s203_air_ops_br_dir = findstr(data, ics203_air_ops_br_dir); |
| 710 |
s203_air_tactical_group_sup = findstr(data, ics203_air_tactical_group_sup); |
| 711 |
s203_air_support_group_sup = findstr(data, ics203_air_support_group_sup); |
| 712 |
s203_helicopter_coordinator = findstr(data, ics203_helicopter_coordinator); |
| 713 |
s203_air_tanker_fixed_wing = findstr(data, ics203_air_tanker_fixed_wing); |
| 714 |
s203_finance_chief = findstr(data, ics203_finance_chief); |
| 715 |
s203_finance_deputy = findstr(data, ics203_finance_deputy); |
| 716 |
s203_time_unit = findstr(data, ics203_time_unit); |
| 717 |
s203_procurement_unit = findstr(data, ics203_procurement_unit); |
| 718 |
s203_claims_unit = findstr(data, ics203_claims_unit); |
| 719 |
s203_cost_unit = findstr(data, ics203_cost_unit); |
| 720 |
|
| 721 |
for (int i = 0; i < 7; i++) { |
| 722 |
s203_agency[i] = findstr(data, ics_n( ics203_agency, i) ); |
| 723 |
s203_agency_name[i] = findstr(data, ics_n( ics203_agency_name, i) ); |
| 724 |
} |
| 725 |
for (int i = 0; i < 3; i++) { |
| 726 |
s203_tech_spc[i] = findstr(data, ics_n( ics203_tech_spc, i) ); |
| 727 |
} |
| 728 |
for (int i = 0; i < 5; i++) { |
| 729 |
s203_b1_div[i] = findstr(data, ics_n( ics203_b1_div, i) ); |
| 730 |
s203_b1_grp[i] = findstr(data, ics_n( ics203_b1_grp, i) ); |
| 731 |
s203_b2_div[i] = findstr(data, ics_n( ics203_b2_div, i) ); |
| 732 |
s203_b2_grp[i] = findstr(data, ics_n( ics203_b2_grp, i) ); |
| 733 |
s203_b3_div[i] = findstr(data, ics_n( ics203_b3_div, i) ); |
| 734 |
s203_b3_grp[i] = findstr(data, ics_n( ics203_b3_grp, i) ); |
| 735 |
} |
| 736 |
update_203form(); |
| 737 |
} |
| 738 |
|
| 739 |
void cb_203_new() |
| 740 |
{ |
| 741 |
if (check_203fields()) { |
| 742 |
if (fl_choice2("Form modified, save?", "No", "Yes", NULL) == 1) { |
| 743 |
update_header(CHANGED); |
| 744 |
cb_203_save(); |
| 745 |
} |
| 746 |
} |
| 747 |
clear_203_form(); |
| 748 |
clear_header(); |
| 749 |
def_203_filename = ICS_msg_dir; |
| 750 |
def_203_filename.append("new").append(F203_EXT); |
| 751 |
show_filename(def_203_filename); |
| 752 |
using_ics203_template = false; |
| 753 |
} |
| 754 |
|
| 755 |
void cb_203_import() |
| 756 |
{ |
| 757 |
fl_alert2("Not implemented"); |
| 758 |
} |
| 759 |
|
| 760 |
void cb_203_export() |
| 761 |
{ |
| 762 |
fl_alert2("Not implemented"); |
| 763 |
} |
| 764 |
|
| 765 |
void cb_203_wrap_import(std::string wrapfilename, std::string inpbuffer) |
| 766 |
{ |
| 767 |
clear_203_form(); |
| 768 |
read_203_buffer(inpbuffer); |
| 769 |
def_203_filename = ICS_msg_dir; |
| 770 |
def_203_filename.append(wrapfilename); |
| 771 |
show_filename(def_203_filename); |
| 772 |
using_ics203_template = false; |
| 773 |
} |
| 774 |
|
| 775 |
int eval_203_fsize() |
| 776 |
{ |
| 777 |
Ccrc16 chksum; |
| 778 |
evalstr.append("[WRAP:beg][WRAP:lf][WRAP:fn "); |
| 779 |
evalstr.append(base_203_filename).append("]"); |
| 780 |
update_203fields(); |
| 781 |
update_header(FROM); |
| 782 |
evalstr.append(header("<ics203>")); |
| 783 |
buff203.clear(); |
| 784 |
make_buff203(true); |
| 785 |
if (buff203.empty()) return 0; |
| 786 |
compress_maybe( buff203 ); |
| 787 |
evalstr.append( buff203 ); |
| 788 |
evalstr.append("[WRAP:chksum ").append(chksum.scrc16(evalstr)).append("][WRAP:end]"); |
| 789 |
return evalstr.length(); |
| 790 |
} |
| 791 |
|
| 792 |
void cb_203_wrap_export() |
| 793 |
{ |
| 794 |
if (check_203fields()) { |
| 795 |
if (fl_choice2("Form modified, save?", "No", "Yes", NULL) == 0) |
| 796 |
return; |
| 797 |
update_header(CHANGED); |
| 798 |
} |
| 799 |
update_203fields(); |
| 800 |
|
| 801 |
if (base_203_filename == std::string("new").append(F203_EXT) || |
| 802 |
base_203_filename == std::string("default").append(F203_EXT) ) |
| 803 |
if (!cb_203_save_as()) return; |
| 804 |
|
| 805 |
std::string wrapfilename = WRAP_send_dir; |
| 806 |
wrapfilename.append(base_203_filename); |
| 807 |
wrapfilename.append(".wrap"); |
| 808 |
const char *p = FSEL::saveas( |
| 809 |
"Save as wrap file", |
| 810 |
"Wrap file\t*.{wrap,WRAP}", |
| 811 |
wrapfilename.c_str()); |
| 812 |
if (p) { |
| 813 |
std::string pext = fl_filename_ext(p); |
| 814 |
wrapfilename = p; |
| 815 |
update_header(FROM); |
| 816 |
buff203.assign(header("<ics203>")); |
| 817 |
make_buff203(true); |
| 818 |
export_wrapfile(base_203_filename, wrapfilename, buff203, pext != ".wrap"); |
| 819 |
|
| 820 |
buff203.assign(header("<ics203>")); |
| 821 |
make_buff203(true); |
| 822 |
write_203(def_203_filename); |
| 823 |
} |
| 824 |
} |
| 825 |
|
| 826 |
void cb_203_wrap_autosend() |
| 827 |
{ |
| 828 |
if (check_203fields()) { |
| 829 |
if (fl_choice2("Form modified, save?", "No", "Yes", NULL) == 0) |
| 830 |
return; |
| 831 |
update_header(CHANGED); |
| 832 |
} |
| 833 |
update_203fields(); |
| 834 |
|
| 835 |
if (base_203_filename == std::string("new").append(F203_EXT) || |
| 836 |
base_203_filename == std::string("default").append(F203_EXT) ) |
| 837 |
if (!cb_203_save_as()) return; |
| 838 |
|
| 839 |
update_header(FROM); |
| 840 |
buff203.assign(header("<ics203>")); |
| 841 |
make_buff203(true); |
| 842 |
xfr_via_socket(base_203_filename, buff203); |
| 843 |
|
| 844 |
buff203.assign(header("<ics203>")); |
| 845 |
make_buff203(true); |
| 846 |
write_203(def_203_filename); |
| 847 |
} |
| 848 |
|
| 849 |
void cb_203_load_template() |
| 850 |
{ |
| 851 |
std::string def_203_filename = def_203_TemplateName; |
| 852 |
const char *p = FSEL::select( |
| 853 |
"Open template file", |
| 854 |
std::string("Template file\t*").append(T203_EXT).c_str(), |
| 855 |
def_203_filename.c_str()); |
| 856 |
if (p) { |
| 857 |
clear_203_form(); |
| 858 |
read_data_file(p); |
| 859 |
def_203_TemplateName = p; |
| 860 |
show_filename(def_203_TemplateName); |
| 861 |
using_ics203_template = true; |
| 862 |
} |
| 863 |
} |
| 864 |
|
| 865 |
void cb_203_save_template() |
| 866 |
{ |
| 867 |
if (!using_ics203_template) { |
| 868 |
cb_203_save_as_template(); |
| 869 |
return; |
| 870 |
} |
| 871 |
std::string def_203_filename = def_203_TemplateName; |
| 872 |
const char *p = FSEL::saveas( |
| 873 |
"Save template file", |
| 874 |
std::string("Template file\t*").append(T203_EXT).c_str(), |
| 875 |
def_203_filename.c_str()); |
| 876 |
if (p) { |
| 877 |
update_header(CHANGED); |
| 878 |
buff203.assign(header("<ics203>")); |
| 879 |
make_buff203(); |
| 880 |
write_203(p); |
| 881 |
} |
| 882 |
} |
| 883 |
|
| 884 |
void cb_203_save_as_template() |
| 885 |
{ |
| 886 |
std::string def_203_filename = def_203_TemplateName; |
| 887 |
const char *p = FSEL::saveas( |
| 888 |
"Save as template file", |
| 889 |
std::string("Template file\t*").append(T203_EXT).c_str(), |
| 890 |
def_203_filename.c_str()); |
| 891 |
if (p) { |
| 892 |
const char *pext = fl_filename_ext(p); |
| 893 |
def_203_TemplateName = p; |
| 894 |
if (strlen(pext) == 0) def_203_TemplateName.append(T203_EXT); |
| 895 |
remove_spaces_from_filename(def_203_TemplateName); |
| 896 |
clear_header(); |
| 897 |
update_header(CHANGED); |
| 898 |
buff203.assign(header("<ics203>")); |
| 899 |
make_buff203(); |
| 900 |
write_203(def_203_TemplateName); |
| 901 |
show_filename(def_203_TemplateName); |
| 902 |
using_ics203_template = true; |
| 903 |
} |
| 904 |
} |
| 905 |
|
| 906 |
void cb_203_open() |
| 907 |
{ |
| 908 |
const char *p = FSEL::select( |
| 909 |
_("Open data file"), |
| 910 |
std::string("ICS-203\t*").append(F203_EXT).c_str(), |
| 911 |
def_203_filename.c_str()); |
| 912 |
if (!p) return; |
| 913 |
if (strlen(p) == 0) return; |
| 914 |
clear_203_form(); |
| 915 |
read_data_file(p); |
| 916 |
using_ics203_template = false; |
| 917 |
def_203_filename = p; |
| 918 |
show_filename(def_203_filename); |
| 919 |
} |
| 920 |
|
| 921 |
void write_203(std::string s) |
| 922 |
{ |
| 923 |
FILE *file203 = fopen(s.c_str(), "w"); |
| 924 |
if (!file203) return; |
| 925 |
|
| 926 |
fwrite(buff203.c_str(), buff203.length(), 1, file203); |
| 927 |
fclose(file203); |
| 928 |
} |
| 929 |
|
| 930 |
bool cb_203_save_as() |
| 931 |
{ |
| 932 |
const char *p; |
| 933 |
std::string newfilename; |
| 934 |
|
| 935 |
std::string name = named_file(); |
| 936 |
if (!name.empty()) { |
| 937 |
name.append(F203_EXT); |
| 938 |
newfilename = ICS_msg_dir; |
| 939 |
newfilename.append(name); |
| 940 |
} else |
| 941 |
newfilename = def_203_filename; |
| 942 |
|
| 943 |
p = FSEL::saveas( |
| 944 |
_("Save data file"), |
| 945 |
std::string("ICS-203\t*").append(F203_EXT).c_str(), |
| 946 |
newfilename.c_str()); |
| 947 |
|
| 948 |
if (!p) return false; |
| 949 |
if (strlen(p) == 0) return false; |
| 950 |
|
| 951 |
if (progStatus.sernbr_fname) update_sernbr(); |
| 952 |
|
| 953 |
const char *pext = fl_filename_ext(p); |
| 954 |
def_203_filename = p; |
| 955 |
if (strlen(pext) == 0) def_203_filename.append(F203_EXT); |
| 956 |
|
| 957 |
remove_spaces_from_filename(def_203_filename); |
| 958 |
update_203fields(); |
| 959 |
update_header(NEW); |
| 960 |
buff203.assign(header("<ics203>")); |
| 961 |
make_buff203(); |
| 962 |
write_203(def_203_filename); |
| 963 |
|
| 964 |
using_ics203_template = false; |
| 965 |
show_filename(def_203_filename); |
| 966 |
return true; |
| 967 |
} |
| 968 |
|
| 969 |
void cb_203_save() |
| 970 |
{ |
| 971 |
if (base_203_filename == std::string("new").append(F203_EXT) || |
| 972 |
base_203_filename == std::string("default").append(F203_EXT) || |
| 973 |
using_ics203_template == true) { |
| 974 |
cb_203_save_as(); |
| 975 |
return; |
| 976 |
} |
| 977 |
if (check_203fields()) update_header(CHANGED); |
| 978 |
update_203fields(); |
| 979 |
buff203.assign(header("<ics203>")); |
| 980 |
make_buff203(); |
| 981 |
write_203(def_203_filename); |
| 982 |
using_ics203_template = false; |
| 983 |
} |
| 984 |
|
| 985 |
void cb_203_html() |
| 986 |
{ |
| 987 |
std::string fname_name = fl_filename_name(def_203_filename.c_str()); |
| 988 |
size_t p = fname_name.rfind('.'); |
| 989 |
if (p != std::string::npos) fname_name.erase(p); |
| 990 |
|
| 991 |
std::string ics203_fname = ICS_dir; |
| 992 |
ics203_fname.append(fname_name); |
| 993 |
ics203_fname.append(".html"); |
| 994 |
|
| 995 |
std::string html_text = ""; |
| 996 |
|
| 997 |
update_203fields(); |
| 998 |
std::string form203 = ics203_html_template; |
| 999 |
replacestr(form203, TITLE, fname_name); |
| 1000 |
|
| 1001 |
replacestr(form203, ics203_incident, s203_incident ); |
| 1002 |
replacestr(form203, ics203_date, s203_date ); |
| 1003 |
replacestr(form203, ics203_time, s203_time ); |
| 1004 |
replacestr(form203, ics203_op_period, s203_op_period ); |
| 1005 |
replacestr(form203, ics203_incident_commander, s203_incident_commander ); |
| 1006 |
replacestr(form203, ics203_incident_deputy, s203_incident_deputy ); |
| 1007 |
replacestr(form203, ics203_incident_safety_officer, s203_incident_safety_officer ); |
| 1008 |
replacestr(form203, ics203_incident_info_officer, s203_incident_info_officer ); |
| 1009 |
replacestr(form203, ics203_liaison_officer, s203_liaison_officer ); |
| 1010 |
replacestr(form203, ics203_prepared_by, s203_prepared_by ); |
| 1011 |
replacestr(form203, ics203_planning_chief, s203_planning_chief ); |
| 1012 |
replacestr(form203, ics203_planning_deputy, s203_planning_deputy ); |
| 1013 |
replacestr(form203, ics203_resources_unit, s203_resources_unit ); |
| 1014 |
replacestr(form203, ics203_situation_unit, s203_situation_unit ); |
| 1015 |
replacestr(form203, ics203_documentation_unit, s203_documentation_unit ); |
| 1016 |
replacestr(form203, ics203_demobilization_unit, s203_demobilization_unit ); |
| 1017 |
replacestr(form203, ics203_logistics_chief, s203_logistics_chief ); |
| 1018 |
replacestr(form203, ics203_logistics_deputy, s203_logistics_deputy ); |
| 1019 |
replacestr(form203, ics203_support_director, s203_support_director ); |
| 1020 |
replacestr(form203, ics203_supply_unit, s203_supply_unit ); |
| 1021 |
replacestr(form203, ics203_facilities_unit, s203_facilities_unit ); |
| 1022 |
replacestr(form203, ics203_ground_support, s203_ground_support ); |
| 1023 |
replacestr(form203, ics203_service_director, s203_service_director ); |
| 1024 |
replacestr(form203, ics203_communications_unit, s203_communications_unit ); |
| 1025 |
replacestr(form203, ics203_medical_unit, s203_medical_unit ); |
| 1026 |
replacestr(form203, ics203_food_unit, s203_food_unit ); |
| 1027 |
replacestr(form203, ics203_ops_chief, s203_ops_chief ); |
| 1028 |
replacestr(form203, ics203_ops_deputy, s203_ops_deputy ); |
| 1029 |
replacestr(form203, ics203_b1_director, s203_b1_director ); |
| 1030 |
replacestr(form203, ics203_b1_deputy, s203_b1_deputy ); |
| 1031 |
replacestr(form203, ics203_b2_director, s203_b2_director ); |
| 1032 |
replacestr(form203, ics203_b2_deputy, s203_b2_deputy ); |
| 1033 |
replacestr(form203, ics203_b3_director, s203_b3_director ); |
| 1034 |
replacestr(form203, ics203_b3_deputy, s203_b3_deputy ); |
| 1035 |
replacestr(form203, ics203_air_ops_br_dir, s203_air_ops_br_dir ); |
| 1036 |
replacestr(form203, ics203_air_tactical_group_sup, s203_air_tactical_group_sup ); |
| 1037 |
replacestr(form203, ics203_air_support_group_sup, s203_air_support_group_sup ); |
| 1038 |
replacestr(form203, ics203_helicopter_coordinator, s203_helicopter_coordinator ); |
| 1039 |
replacestr(form203, ics203_air_tanker_fixed_wing, s203_air_tanker_fixed_wing ); |
| 1040 |
replacestr(form203, ics203_finance_chief, s203_finance_chief ); |
| 1041 |
replacestr(form203, ics203_finance_deputy, s203_finance_deputy ); |
| 1042 |
replacestr(form203, ics203_time_unit, s203_time_unit ); |
| 1043 |
replacestr(form203, ics203_procurement_unit, s203_procurement_unit ); |
| 1044 |
replacestr(form203, ics203_claims_unit, s203_claims_unit ); |
| 1045 |
replacestr(form203, ics203_cost_unit, s203_cost_unit ); |
| 1046 |
|
| 1047 |
for (int i = 0; i < 7; i++) { |
| 1048 |
replacestr(form203, ics_n( ics203_agency, i ), s203_agency[i] ); |
| 1049 |
replacestr(form203, ics_n( ics203_agency_name, i ), s203_agency_name[i] ); |
| 1050 |
} |
| 1051 |
for (int i = 0; i < 3; i++) { |
| 1052 |
replacestr(form203, ics_n( ics203_tech_spc, i ), s203_tech_spc[i] ); |
| 1053 |
} |
| 1054 |
for (int i = 0; i < 5; i++) { |
| 1055 |
replacestr(form203, ics_n( ics203_b1_div, i ), s203_b1_div[i] ); |
| 1056 |
replacestr(form203, ics_n( ics203_b1_grp, i ), s203_b1_grp[i] ); |
| 1057 |
replacestr(form203, ics_n( ics203_b2_div, i ), s203_b2_div[i] ); |
| 1058 |
replacestr(form203, ics_n( ics203_b2_grp, i ), s203_b2_grp[i] ); |
| 1059 |
replacestr(form203, ics_n( ics203_b3_div, i ), s203_b3_div[i] ); |
| 1060 |
replacestr(form203, ics_n( ics203_b3_grp, i ), s203_b3_grp[i] ); |
| 1061 |
} |
| 1062 |
|
| 1063 |
FILE *file203 = fopen(ics203_fname.c_str(), "w"); |
| 1064 |
fprintf(file203,"%s", form203.c_str()); |
| 1065 |
fclose(file203); |
| 1066 |
|
| 1067 |
open_url(ics203_fname.c_str()); |
| 1068 |
} |
| 1069 |
|
| 1070 |
void cb_203_msg_type() |
| 1071 |
{ |
| 1072 |
if (tabs_msg_type->value() == tab_ics203 ) { |
| 1073 |
tab_ics203_type->value(tab_203_1); |
| 1074 |
show_filename(def_203_filename); |
| 1075 |
} |
| 1076 |
} |
| 1077 |
|
| 1078 |
void cb_203_textout() |
| 1079 |
{ |
| 1080 |
std::string ics203_fname = ICS_dir; |
| 1081 |
ics203_fname.append("ics203.txt"); |
| 1082 |
|
| 1083 |
update_203fields(); |
| 1084 |
std::string form203 = ics203_text_template; |
| 1085 |
|
| 1086 |
replacestr(form203, ics203_incident, s203_incident ); |
| 1087 |
replacestr(form203, ics203_date, s203_date ); |
| 1088 |
replacestr(form203, ics203_time, s203_time ); |
| 1089 |
replacestr(form203, ics203_op_period, s203_op_period ); |
| 1090 |
replacestr(form203, ics203_incident_commander, s203_incident_commander ); |
| 1091 |
replacestr(form203, ics203_incident_deputy, s203_incident_deputy ); |
| 1092 |
replacestr(form203, ics203_incident_safety_officer, s203_incident_safety_officer ); |
| 1093 |
replacestr(form203, ics203_incident_info_officer, s203_incident_info_officer ); |
| 1094 |
replacestr(form203, ics203_liaison_officer, s203_liaison_officer ); |
| 1095 |
replacestr(form203, ics203_prepared_by, s203_prepared_by ); |
| 1096 |
replacestr(form203, ics203_planning_chief, s203_planning_chief ); |
| 1097 |
replacestr(form203, ics203_planning_deputy, s203_planning_deputy ); |
| 1098 |
replacestr(form203, ics203_resources_unit, s203_resources_unit ); |
| 1099 |
replacestr(form203, ics203_situation_unit, s203_situation_unit ); |
| 1100 |
replacestr(form203, ics203_documentation_unit, s203_documentation_unit ); |
| 1101 |
replacestr(form203, ics203_demobilization_unit, s203_demobilization_unit ); |
| 1102 |
replacestr(form203, ics203_logistics_chief, s203_logistics_chief ); |
| 1103 |
replacestr(form203, ics203_logistics_deputy, s203_logistics_deputy ); |
| 1104 |
replacestr(form203, ics203_support_director, s203_support_director ); |
| 1105 |
replacestr(form203, ics203_supply_unit, s203_supply_unit ); |
| 1106 |
replacestr(form203, ics203_facilities_unit, s203_facilities_unit ); |
| 1107 |
replacestr(form203, ics203_ground_support, s203_ground_support ); |
| 1108 |
replacestr(form203, ics203_service_director, s203_service_director ); |
| 1109 |
replacestr(form203, ics203_communications_unit, s203_communications_unit ); |
| 1110 |
replacestr(form203, ics203_medical_unit, s203_medical_unit ); |
| 1111 |
replacestr(form203, ics203_food_unit, s203_food_unit ); |
| 1112 |
replacestr(form203, ics203_ops_chief, s203_ops_chief ); |
| 1113 |
replacestr(form203, ics203_ops_deputy, s203_ops_deputy ); |
| 1114 |
replacestr(form203, ics203_b1_director, s203_b1_director ); |
| 1115 |
replacestr(form203, ics203_b1_deputy, s203_b1_deputy ); |
| 1116 |
replacestr(form203, ics203_b2_director, s203_b2_director ); |
| 1117 |
replacestr(form203, ics203_b2_deputy, s203_b2_deputy ); |
| 1118 |
replacestr(form203, ics203_b3_director, s203_b3_director ); |
| 1119 |
replacestr(form203, ics203_b3_deputy, s203_b3_deputy ); |
| 1120 |
replacestr(form203, ics203_air_ops_br_dir, s203_air_ops_br_dir ); |
| 1121 |
replacestr(form203, ics203_air_tactical_group_sup, s203_air_tactical_group_sup ); |
| 1122 |
replacestr(form203, ics203_air_support_group_sup, s203_air_support_group_sup ); |
| 1123 |
replacestr(form203, ics203_helicopter_coordinator, s203_helicopter_coordinator ); |
| 1124 |
replacestr(form203, ics203_air_tanker_fixed_wing, s203_air_tanker_fixed_wing ); |
| 1125 |
replacestr(form203, ics203_finance_chief, s203_finance_chief ); |
| 1126 |
replacestr(form203, ics203_finance_deputy, s203_finance_deputy ); |
| 1127 |
replacestr(form203, ics203_time_unit, s203_time_unit ); |
| 1128 |
replacestr(form203, ics203_procurement_unit, s203_procurement_unit ); |
| 1129 |
replacestr(form203, ics203_claims_unit, s203_claims_unit ); |
| 1130 |
replacestr(form203, ics203_cost_unit, s203_cost_unit ); |
| 1131 |
|
| 1132 |
for (int i = 0; i < 7; i++) { |
| 1133 |
replacestr(form203, ics_n( ics203_agency, i ), s203_agency[i] ); |
| 1134 |
replacestr(form203, ics_n( ics203_agency_name, i ), s203_agency_name[i] ); |
| 1135 |
} |
| 1136 |
for (int i = 0; i < 3; i++) { |
| 1137 |
replacestr(form203, ics_n( ics203_tech_spc, i ), s203_tech_spc[i] ); |
| 1138 |
} |
| 1139 |
for (int i = 0; i < 5; i++) { |
| 1140 |
replacestr(form203, ics_n( ics203_b1_div, i ), s203_b1_div[i] ); |
| 1141 |
replacestr(form203, ics_n( ics203_b1_grp, i ), s203_b1_grp[i] ); |
| 1142 |
replacestr(form203, ics_n( ics203_b2_div, i ), s203_b2_div[i] ); |
| 1143 |
replacestr(form203, ics_n( ics203_b2_grp, i ), s203_b2_grp[i] ); |
| 1144 |
replacestr(form203, ics_n( ics203_b3_div, i ), s203_b3_div[i] ); |
| 1145 |
replacestr(form203, ics_n( ics203_b3_grp, i ), s203_b3_grp[i] ); |
| 1146 |
} |
| 1147 |
|
| 1148 |
FILE *file203 = fopen(ics203_fname.c_str(), "w"); |
| 1149 |
fprintf(file203,"%s", form203.c_str()); |
| 1150 |
fclose(file203); |
| 1151 |
|
| 1152 |
open_url(ics203_fname.c_str()); |
| 1153 |
} |