/[gpgoe]/trunk/src/OEMisc.c
ViewVC logotype

Diff of /trunk/src/OEMisc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 16 by twoaday, Tue Apr 11 06:56:23 2006 UTC revision 24 by twoaday, Tue Dec 13 10:40:30 2011 UTC
# Line 12  Line 12 
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.   * GNU General Public License for more details.
  *  
  * You should have received a copy of the GNU Lesser General Public License  
  * along with GPGOE; if not, write to the Free Software Foundation,  
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA  
15   */   */
16    
17  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
# Line 46  native_to_utf8 (const char *string) Line 42  native_to_utf8 (const char *string)
42    
43      n = MultiByteToWideChar (GetACP (), 0, string, -1, result, n);      n = MultiByteToWideChar (GetACP (), 0, string, -1, result, n);
44      if (n < 0) {      if (n < 0) {
45          free (result);          xfree (result);
46          return NULL;          return NULL;
47      }      }
48    
# Line 58  native_to_utf8 (const char *string) Line 54  native_to_utf8 (const char *string)
54    
55      n = WideCharToMultiByte (CP_UTF8, 0, result, -1, native, n, NULL, NULL);      n = WideCharToMultiByte (CP_UTF8, 0, result, -1, native, n, NULL, NULL);
56      if (n < 0) {      if (n < 0) {
57          free (result);          xfree (result);
58          return NULL;          return NULL;
59      }      }
60    
61      free (result);      xfree (result);
62      return native;      return native;
63  }  }
64    
# Line 78  utf8_to_native (const char *string) Line 74  utf8_to_native (const char *string)
74      n = MultiByteToWideChar (CP_UTF8, 0, string, -1, NULL, 0);      n = MultiByteToWideChar (CP_UTF8, 0, string, -1, NULL, 0);
75      if (n < 0)      if (n < 0)
76          return NULL;          return NULL;
   
77      result = (wchar_t*)xcalloc (1, (n+1) * sizeof *result);      result = (wchar_t*)xcalloc (1, (n+1) * sizeof *result);
   
78      n = MultiByteToWideChar (CP_UTF8, 0, string, -1, result, n);      n = MultiByteToWideChar (CP_UTF8, 0, string, -1, result, n);
79      if (n < 0) {      if (n < 0) {
80          free (result);          xfree (result);
81          return NULL;          return NULL;
82      }      }
83    
84      n = WideCharToMultiByte (GetACP (), 0, result, -1, NULL, 0, NULL, NULL);      n = WideCharToMultiByte (GetACP (), 0, result, -1, NULL, 0, NULL, NULL);
85      if (n < 0)      if (n < 0)
86          return NULL;          return NULL;
87        native = (char*)xcalloc (1, n+1);
     native = (char*)malloc (n+1);  
     if (!native)  
         abort ();  
   
88      n = WideCharToMultiByte (GetACP (), 0, result, -1, native, n, NULL, NULL);      n = WideCharToMultiByte (GetACP (), 0, result, -1, native, n, NULL, NULL);
89      if (n < 0) {      if (n < 0) {
90          free (result);          xfree (result);
91          return NULL;          return NULL;
92      }      }
93    
94      free (result);      xfree (result);
95      return native;      return native;
96  }  }
97    
# Line 210  show_error (HWND hwnd, const char *capti Line 200  show_error (HWND hwnd, const char *capti
200      va_list ptr;      va_list ptr;
201    
202      va_start (ptr, fmt);      va_start (ptr, fmt);
203      _vsnprintf (buffer, sizeof (buffer)-1, fmt, ptr);      _vsnprintf (buffer, DIM (buffer)-1, fmt, ptr);
204      va_end (ptr);      va_end (ptr);
205      MessageBox (hwnd, buffer, caption, type);      MessageBox (hwnd, buffer, caption, type);
206  }  }
# Line 246  quote_msg_text (const char *inp, char ** Line 236  quote_msg_text (const char *inp, char **
236  /* Center the window @hwndChild over the parent window @parent. */  /* Center the window @hwndChild over the parent window @parent. */
237  void  void
238  center_window (HWND hwndChild, HWND parent)  center_window (HWND hwndChild, HWND parent)
239  {      {
240      HWND hwndParent;      HWND hwndParent;
241      RECT rChild, rParent;      RECT rChild, rParent;
242      HDC hdc;      HDC hdc;

Legend:
Removed from v.16  
changed lines
  Added in v.24

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26