19 #include "misc/coding/coding.h"
21 GSM_Error
NoneFunction(void)
26 GSM_Error
NotImplementedFunction(void)
28 return GE_NOTIMPLEMENTED
;
31 GSM_Error
NotSupportedFunction(void)
33 return GE_NOTSUPPORTED
;
36 unsigned char *GetMsg (INI_Section
*cfg
, unsigned char *default_string
)
38 unsigned char *retval
, buffer
[40], buff2
[40], buff
[2000];
39 static unsigned char def_str
[2000];
44 if (cfg
==NULL
) return default_string
;
46 EncodeUnicode (buff2
, "common", 6);
48 /* Set all 0x0a to \n */
49 memset(def_str
,0,sizeof(def_str
));
50 for (num
=0;num
<((int)strlen(default_string
));num
++) {
51 if (default_string
[num
] == 0x0a) {
52 def_str
[strlen(def_str
)] = '\\';
53 def_str
[strlen(def_str
)] = 'n';
54 } else def_str
[strlen(def_str
)] = default_string
[num
];
58 /* First find our section */
59 for (h
= cfg
; h
!= NULL
; h
= h
->Next
) {
60 if (mywstrncasecmp(buff2
, h
->SectionName
, 0)) {
68 DecodeUnicode(e
->EntryName
,buffer
);
69 if (strlen(buffer
) == 5 && (buffer
[0] == 'F' || buffer
[0] == 'f')) {
73 DecodeUnicode(e
->EntryValue
+2,buff
);
74 if (strncmp(buff
,def_str
,strlen(def_str
))==0) {
75 sprintf(buff
,"T%04i",num
);
76 EncodeUnicode (buffer
, buff
, 5);
77 retval
= INI_GetValue(cfg
, buff2
, buffer
, true);
79 sprintf(buff
,"%s",DecodeUnicodeConsole(retval
+2));
80 buff
[strlen(buff
)-1] = 0;
81 /* Set all \n to 0x0a */
82 memset(def_str
,0,sizeof(def_str
));
84 while (num
!= (int)strlen(buff
)) {
85 if (num
< (int)strlen(buff
) - 1) {
86 if (buff
[num
] == '\\' && buff
[num
+1] == 'n') {
87 def_str
[strlen(def_str
)] = 0x0a;
90 def_str
[strlen(def_str
)] = buff
[num
++];
93 def_str
[strlen(def_str
)] = buff
[num
++];
98 retval
= default_string
;
105 return default_string
;
110 unsigned char *ErrorText
;
113 static PrintErrorEntry PrintErrorEntries
[] = {
114 {GE_NONE
, "No error."},
115 {GE_DEVICEOPENERROR
, "Error opening device. Unknown/busy or no permissions."},
116 {GE_DEVICELOCKED
, "Error opening device. Device locked."},
117 {GE_DEVICENOTEXIST
, "Error opening device. Not exist."},
118 {GE_DEVICEBUSY
, "Error opening device. Already opened by other application."},
119 {GE_DEVICENOPERMISSION
, "Error opening device. No permissions."},
120 {GE_DEVICENODRIVER
, "Error opening device. No required driver in operating system."},
121 {GE_DEVICENOTWORK
, "Error opening device. Some hardware not connected/wrong configured."},
122 {GE_DEVICEDTRRTSERROR
, "Error setting device DTR or RTS."},
123 {GE_DEVICECHANGESPEEDERROR
, "Error setting device speed. Maybe speed not supported."},
124 {GE_DEVICEWRITEERROR
, "Error writing device."},
125 {GE_DEVICEREADERROR
, "Error during reading device"},
126 {GE_DEVICEPARITYERROR
, "Can't set parity on device"},
127 {GE_TIMEOUT
, "No response in specified timeout. Probably phone not connected."},
129 {GE_UNKNOWNRESPONSE
, "Unknown response from phone. See readme.txt, how to report it."},
131 {GE_UNKNOWNCONNECTIONTYPESTRING
,"Unknown connection type string. Check config file."},
132 {GE_UNKNOWNMODELSTRING
, "Unknown model type string. Check config file."},
133 {GE_SOURCENOTAVAILABLE
, "Some required functions not compiled for your OS. Please contact."},
134 {GE_NOTSUPPORTED
, "Function not supported by phone."},
135 {GE_EMPTY
, "Entry is empty"},
136 {GE_SECURITYERROR
, "Security error. Maybe no PIN ?"},
137 {GE_INVALIDLOCATION
, "Invalid location. Maybe too high ?"},
138 {GE_NOTIMPLEMENTED
, "Function not implemented. Help required."},
139 {GE_FULL
, "Memory full."},
140 {GE_UNKNOWN
, "Unknown error."},
142 {GE_CANTOPENFILE
, "Can't open specified file. Read only ?"},
143 {GE_MOREMEMORY
, "More memory required..."},
144 {GE_PERMISSION
, "Permission to file/device required..."},
145 {GE_EMPTYSMSC
, "Empty SMSC number. Set in phone or use -smscnumber"},
146 {GE_INSIDEPHONEMENU
, "You're inside phone menu (during editing ?). Leave it and try again."},
147 {GE_WORKINPROGRESS
, "Function is during writing. If want help, please contact with authors."},
148 {GE_PHONEOFF
, "Phone is disabled and connected to charger"},
149 {GE_FILENOTSUPPORTED
, "File format not supported by Gammu"},
150 {GE_BUG
, "Nobody is perfect, some bug appeared in protocol implementation. Please contact authors."},
151 {GE_CANCELED
, "Transfer was canceled by phone (you pressed cancel on phone?)."},
153 {GE_OTHERCONNECTIONREQUIRED
, "Current connection type doesn't support called function."},
155 {GE_INVALIDDATETIME
, "Invalid date or time specified."},
160 unsigned char *print_error(GSM_Error e
, FILE *df
, INI_Section
*cfg
)
162 unsigned char *def
= NULL
;
165 while (PrintErrorEntries
[i
].ErrorNum
!= 0) {
166 if (PrintErrorEntries
[i
].ErrorNum
== e
) {
167 def
= PrintErrorEntries
[i
].ErrorText
;
172 if (def
== NULL
) def
= "Unknown error.";
173 if (df
!=NULL
&& di
.dl
!=0) fprintf(df
,"[ERROR %i: %s]\n",e
,def
);
175 return GetMsg(cfg
,def
);
178 char *GetGammuVersion(void)
180 static char Buffer
[1000]="";
182 sprintf(Buffer
, "%s",VERSION
);
186 GSM_Error
GSM_SetDebugFile(char *info
, Debug_Info
*privdi
)
190 /* If we should use global file descriptor, use it */
191 if (privdi
->use_global
) {
192 /* Aren't we the changing the global di? */
194 if (privdi
->df
== stdout
) privdi
->df
= di
.df
;
198 /* If we should not use global file descriptor, don't even try use it */
199 if (privdi
->df
== di
.df
) privdi
->df
= stdout
;
202 if (info
[0]!=0 && privdi
->dl
!= 0) {
203 switch (privdi
->dl
) {
205 testfile
= fopen(info
,"wcb");
208 case DL_TEXTERRORDATE
:
209 testfile
= fopen(info
,"ac");
211 dbgprintf("Can't open debug file\n");
212 return GE_CANTOPENFILE
;
214 fseek(testfile
, 0, SEEK_END
);
215 if (ftell(testfile
) > 5000000) {
217 testfile
= fopen(info
,"wc");
221 testfile
= fopen(info
,"wc");
224 dbgprintf("Can't open debug file\n");
225 return GE_CANTOPENFILE
;
227 if (privdi
->df
&& privdi
->df
!= stdout
) {
230 privdi
->df
= testfile
;
236 /* How should editor hadle tabs in this file? Add editor commands here.
237 * vim: noexpandtab sw=8 ts=8 sts=8: