source: tol/vbtol/source/vbutils.cpp @ 2b19912

1941-docker-image-to-testdevel
Last change on this file since 2b19912 was 370f6fd2, checked in by Liván Ramírez Dorta <livanr68@…>, 18 years ago

changes from CVS not merged previously

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@157 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/* tclutils.cpp: This file define a set of utils functions.
2                 GNU/tolTcl Library
3
4   Copyright (C) 2001, 2002, 2003 - Bayes Decisión, SL
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19   USA.
20 */
21
22#include "VButils.h"
23
24/*
25  Convert a Character Array to a BSTR String
26*/
27
28BSTR ChartoBSTR(char* str)
29{
30  int i, Len = strlen(str);
31  unsigned short* FinalStr = new unsigned short[Len + 1];
32
33  for (i=0; i<Len; i++)
34  {
35    unsigned char Part = str[i];
36    FinalStr[i] = Part;
37    FinalStr[i+1] = '\0';
38  }
39  return((BSTR)FinalStr);
40}
41
42/*
43 
44*/
45
46BList VB_stack;
47
48void VB_concat(BList* head, BList* tail)
49{
50  if (head->Cdr()) {
51    VB_concat(head->Cdr(), tail);
52  }
53  else {
54    head->PutCdr(tail);
55  }
56}
57
58/*
59 
60*/
61
62FN_PTR VB_Writer = NULL;
63
64void VBTol_gsl_error_handler(const char * reason, const char * file, int line,
65                                                         int gsl_errno)
66{
67  char * buf = new char[strlen(reason)+25];
68
69  sprintf(buf, "GSL Error # %-5d: %s", gsl_errno, reason);
70  if (VB_Writer) {
71    BSTR temp = ChartoBSTR(buf);
72    BSTR ret = SysAllocString(temp);
73    delete[] temp;
74    VB_Writer(ret);
75  }
76  else
77    ::MessageBox(NULL, buf, "C++ DLL", 0);
78  delete[] buf;
79}
80
81void VBTol_HciWriter(const BText & str)
82{
83  if (VB_Writer) {
84    BSTR temp = ChartoBSTR(((BText&)str).Buffer());
85    BSTR ret = SysAllocString(temp);
86    delete[] temp;
87    VB_Writer(ret);
88  }
89  else
90    ::MessageBox(NULL, ((BText&)str).Buffer(), "C++ DLL", 0);
91}
Note: See TracBrowser for help on using the repository browser.