]> The Tcpdump Group git mirrors - tcpdump/blob - win32/Src/w32_fzs.c
Added the files missing/dlnames.c, missing/datalinks.c, missing/strsep.c, missing...
[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
75 if(IsTextUnicode(device,
76 wcslen((short*)device), // Device always ends with a double \0, so this way to determine its
77 // length should be always valid
78 NULL))
79 {
80 fprintf(stderr, "%s: listening on %ws\n",program_name, device);
81 }
82 else
83 {
84 fprintf(stderr, "%s: listening on %s\n",program_name, device);
85 }
86
87 fflush(stderr);
88 }