Changeset 3d4d52d for lib/format_legacy.c
- Timestamp:
- 02/17/06 14:49:14 (15 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 65a5900
- Parents:
- f03fc17
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_legacy.c
rf03fc17 r3d4d52d 127 127 } 128 128 129 static int erf_init_input(struct libtrace_t *libtrace) { 130 struct stat buf; 131 struct sockaddr_un unix_sock; 129 static int erf_init_input(struct libtrace_t *libtrace) 130 { 132 131 libtrace->format_data = (struct libtrace_format_data_t *) 133 132 malloc(sizeof(struct libtrace_format_data_t)); 134 133 135 CONNINFO.path = libtrace->uridata; 136 if (!strncmp(CONNINFO.path,"-",1)) { 137 /* STDIN */ 138 INPUT.file = LIBTRACE_FDOPEN(fileno(stdin), "r"); 139 } else { 140 if (stat(CONNINFO.path,&buf) == -1 ) { 141 trace_set_err(errno,"stat(%s)",CONNINFO.path); 142 return 0; 143 } 144 if (S_ISSOCK(buf.st_mode)) { 145 if ((INPUT.fd = socket( 146 AF_UNIX, SOCK_STREAM, 0)) == -1) { 147 trace_set_err("socket(%s)",CONNINFO.path); 148 return 0; 149 } 150 unix_sock.sun_family = AF_UNIX; 151 bzero(unix_sock.sun_path,108); 152 snprintf(unix_sock.sun_path, 153 108,"%s" 154 ,CONNINFO.path); 155 156 if (connect(INPUT.fd, 157 (struct sockaddr *)&unix_sock, 158 sizeof(struct sockaddr)) == -1) { 159 trace_set_err("socket(%s)",CONNINFO.path); 160 return 0; 161 } 162 } else { 163 int fd; 164 165 /* we use an FDOPEN call to reopen an FD 166 // returned from open(), so that we can set 167 // O_LARGEFILE. This gets around gzopen not 168 // letting you do this... 169 */ 170 fd=open( CONNINFO.path, O_LARGEFILE); 171 if (fd==-1) { 172 trace_set_err(errno,"open(%s)",CONNINFO.path); 173 return 0; 174 } 175 INPUT.file = LIBTRACE_FDOPEN(fd,"r"); 176 } 177 } 178 return 1; 134 libtrace->format_data->input.file = trace_open_file(libtrace); 135 136 if (libtrace->format_data->input.file) 137 return 1; 138 139 return 0; 140 179 141 } 180 142
Note: See TracChangeset
for help on using the changeset viewer.