]> The Tcpdump Group git mirrors - tcpdump/blob - win32/Src/w32_fzs.c
Clean up comments.
[tcpdump] / win32 / Src / w32_fzs.c
1 /*
2 * Copyright (c) 1999, 2000
3 * Politecnico di Torino. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the Politecnico
13 * di Torino, and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 */
21
22 #include <w32_fzs.h>
23 #include <tcpdump-stdinc.h>
24 #include <signal.h>
25
26 static WCHAR *TmpName=NULL;
27
28 extern char* AdapterName1;
29
30
31 WCHAR* SChar2WChar(char* nome)
32 {
33 int i;
34 TmpName=(WCHAR*) malloc ((strlen(nome)+2)*sizeof(WCHAR));
35 for (i=0;i<(signed)strlen(nome)+1; i++)
36 TmpName[i]=nome[i];
37 TmpName[i]=0;
38 return TmpName;
39 }
40
41 void* GetAdapterFromList(void* device,int index)
42 {
43 DWORD dwVersion;
44 DWORD dwWindowsMajorVersion;
45 char* Adapter95;
46 WCHAR* Adapter;
47 int i;
48
49 dwVersion=GetVersion();
50 dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
51 if (dwVersion >= 0x80000000 && dwWindowsMajorVersion >= 4) // Windows '95
52 {
53 Adapter95=device;
54 for(i=0;i<index-1;i++){
55 while(*Adapter95++!=0);
56 if(*Adapter95==0)return NULL;
57 }
58 return Adapter95;
59 }
60 else{
61 Adapter=(WCHAR*)device;
62 for(i=0;i<index-1;i++){
63 while(*Adapter++!=0);
64 if(*Adapter==0)return NULL;
65 }
66 return Adapter;
67 }
68
69 }
70
71
72 void PrintCapBegins (char* program_name, char* device)
73 {
74 DWORD dwVersion;
75 DWORD dwWindowsMajorVersion;
76 int ii,jj;
77 char dev[256];
78
79 dwVersion=GetVersion();
80 dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
81 if (dwVersion >= 0x80000000 && dwWindowsMajorVersion >= 4) // Windows '95
82 {
83 for(ii=0,jj=0;ii<128;ii++)
84 if (device[ii]=='\0') break;
85 else if (device[ii]!='\0') {dev[jj]=device[ii];jj++;}
86 dev[jj]='\0';
87 (void)fprintf(stderr, "%s: listening on %s\n",program_name, dev);
88 (void)fflush(stderr);
89 }
90
91 else
92 {
93 for(ii=0,jj=0;ii<128;ii++)
94 if (device[ii]=='\0'&& device[ii+1]=='\0') break;
95 else if (device[ii]!='\0') {dev[jj]=device[ii];jj++;}
96 dev[jj++]='\0';
97 dev[jj]='\0';
98 fwrite(program_name,strlen(program_name),1,stderr);
99 fwrite(": listening on ",15,1,stderr);
100 fwrite(dev,strlen(dev),1,stderr);
101 fwrite("\n",1,1,stderr);
102 (void)fflush(stderr);
103 }
104 }