source: ThirdParty/mpqc_open/src/lib/util/keyval/ipv2_error.cc@ 482400e

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_levmar Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 482400e was 860145, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit '0b990dfaa8c6007a996d030163a25f7f5fc8a7e7' as 'ThirdParty/mpqc_open'

  • Property mode set to 100644
File size: 4.0 KB
Line 
1//
2// ipv2_error.cc
3//
4// Copyright (C) 1996 Limit Point Systems, Inc.
5//
6// Author: Curtis Janssen <cljanss@limitpt.com>
7// Maintainer: LPS
8//
9// This file is part of the SC Toolkit.
10//
11// The SC Toolkit is free software; you can redistribute it and/or modify
12// it under the terms of the GNU Library General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// The SC Toolkit is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Library General Public License for more details.
20//
21// You should have received a copy of the GNU Library General Public License
22// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28#include <stdlib.h>
29#include <stdarg.h>
30#include <string.h>
31
32#include <util/misc/formio.h>
33#include <util/keyval/ipv2.h>
34
35using namespace std;
36using namespace sc;
37
38/* Returns some text for an errcod. */
39const char*
40IPV2::error_message(IPV2::Status errcod)
41{
42 const char *ipe_ok = "No problem has been detected.";
43 const char *ipe_key_not_found = "No match was found for the given keyword.";
44 const char *ipe_out_of_bounds = "An array index is out of bounds.";
45 const char *ipe_malloc = "Memory allocation failed.";
46 const char *ipe_not_an_array = "An index was given for a scalar quantity.";
47 const char *ipe_not_a_scalar = "Expected a scalar, but found an array.";
48 const char *ipe_type = "The datum is not of the appropiate type.";
49 const char *ipe_has_no_value = "The keyword has no value.";
50 const char *ipe_val_not_expd = "A value was not expected for the keyword.";
51 const char *huh = "The nature of the problem is unknown.";
52
53 if (errcod == OK) return ipe_ok;
54 if (errcod == KeyNotFound) return ipe_key_not_found;
55 if (errcod == OutOfBounds) return ipe_out_of_bounds;
56 if (errcod == Malloc) return ipe_malloc;
57 if (errcod == NotAnArray) return ipe_not_an_array;
58 if (errcod == NotAScalar) return ipe_not_a_scalar;
59 if (errcod == Type) return ipe_type;
60 if (errcod == HasNoValue) return ipe_has_no_value;
61 if (errcod == ValNotExpd) return ipe_val_not_expd;
62 return huh;
63}
64
65void
66IPV2::error(const char *msg)
67{
68 ExEnv::errn() << "IPV2::error: ";
69 ExEnv::errn() << msg;
70 ExEnv::errn() << endl;
71 showpos();
72 exit(1);
73}
74
75void
76IPV2::warn(const char *msg)
77{
78 char *newmsg;
79 const char *poskey;
80
81 /* If msg has a %k in it, then substitute in the last keyword. */
82#if defined(NCUBE)||defined(DEC)||defined(I860)
83 /* The NCUBE and DEC are missing the strstr function. */
84 for (poskey=msg; *poskey!='\0'; poskey++) {
85 if (poskey[0] == '%' && poskey[1] == 'k') break;
86 }
87 if (poskey[0] != '%') poskey = NULL;
88#else
89 poskey = ::strstr(msg,"%k");
90#endif
91 if (poskey) {
92 newmsg = (char *) malloc(strlen(msg)-1 + strlen(lastkeyword));
93 strcpy(newmsg,msg);
94 newmsg[poskey-msg] = '\0';
95 strcat(newmsg,lastkeyword);
96 strcat(newmsg,&poskey[2]);
97 ExEnv::errn() << "IPV2::warn: ";
98 ExEnv::errn() << newmsg;
99 ExEnv::errn() << endl;
100 if (poskey) free(newmsg);
101 }
102 else {
103 ExEnv::errn() << "IPV2::warn: ";
104 ExEnv::errn() << msg;
105 ExEnv::errn() << endl;
106 }
107}
108
109void
110IPV2::ip_lastkeyword(const char*keyword)
111{
112 strncpy(lastkeyword,keyword, KEYWORD_LENGTH-1);
113}
114
115void
116IPV2::ip_lastkeywordtree(ip_keyword_tree_t*kt)
117{
118 lastkeyword[0] = '\0';
119 ip_lastkeyword_(kt);
120}
121
122void
123IPV2::ip_lastkeyword_(ip_keyword_tree_t*kt)
124{
125 if (kt->up) ip_lastkeyword_(kt->up);
126 if (strlen(lastkeyword) + strlen(kt->keyword) + 2 > KEYWORD_LENGTH) {
127 ExEnv::errn() << "IPV2: keyword too big" << endl;
128 abort();
129 }
130 strcat(lastkeyword,":");
131 strcat(lastkeyword,kt->keyword);
132}
133
134/////////////////////////////////////////////////////////////////////////////
135
136// Local Variables:
137// mode: c++
138// c-file-style: "CLJ"
139// End:
Note: See TracBrowser for help on using the repository browser.