Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/teraterm/ttpcmn/ttcmn_cominfo.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10491 - (show annotations) (download) (as text)
Sat Jan 14 16:15:08 2023 UTC (16 months, 2 weeks ago) by zmatsuo
File MIME type: text/x-csrc
File size: 3204 byte(s)
ComPortInfoGet()の引数を誤ってたので修正

- r10487の修正抜け
1 /*
2 * Copyright (C) 2021- TeraTerm Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include <windows.h>
30
31 #include "codeconv.h"
32 #include "comportinfo.h"
33
34 #define DllExport __declspec(dllexport)
35 #include "ttcmn_cominfo.h"
36
37 /**
38 * COM�|�[�g������
39 *
40 * @param[out] ComPortTable[MAXCOMPORT]
41 * @param[in] ComPortMax �e�[�u���������g�p��(����MAXCOMPORT)
42 * @param[out] ComPortDesc[MAXCOMPORT] (4096 in tttypes.h)
43 * @retval �g�p���\��COM�|�[�g�� (0=�g�p���\�|�[�g������)
44 *
45 * MAXCOMPORT = 4096 in tttypes.h
46 * �����l���e�[�u��(COM�|�[�g������)�����������\��
47 *
48 * ����
49 * ComPortDesc���P�A�����������������[�N����
50 */
51 int WINAPI DetectComPorts(LPWORD ComPortTable, int ComPortMax, char **ComPortDesc)
52 {
53 int count;
54 int i;
55 ComPortInfo_t *port_info;
56 const ComPortInfo_t *p;
57
58 // ���O�m�����������J������
59 for (i = 0; i < ComPortMax; i++) {
60 free(ComPortDesc[i]);
61 ComPortDesc[i] = NULL;
62 }
63
64 port_info = ComPortInfoGet(&count);
65 p = port_info;
66 for (i = 0; i < count; i++) {
67 ComPortTable[i] = p->port_no;
68 ComPortDesc[i] = ToCharW(p->friendly_name);
69 p++;
70 if (i == ComPortMax - 1) {
71 // �e�[�u������������
72 break;
73 }
74 }
75
76 ComPortInfoFree(port_info, count);
77
78 return count;
79 }
80
81 /**
82 * COM�|�[�g���������������������`�F�b�N����
83 *
84 * @param[in] ComPort �`�F�b�N�����|�[�g����
85 * @retval -1 error(�������g�p������������)
86 * @retval 0 NOT FOUND;
87 * @retval 1 FOUND
88 */
89 int WINAPI CheckComPort(WORD ComPort)
90 {
91 int count;
92 int i;
93 ComPortInfo_t *port_info = ComPortInfoGet(&count);
94 const ComPortInfo_t *p = port_info;
95 int found = 0;
96 for (i = 0; i < count; i++) {
97 if (ComPort == p->port_no) {
98 found = 1;
99 break;
100 }
101 p++;
102 }
103
104 ComPortInfoFree(port_info, count);
105
106 return found;
107 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26