File: scan_ip6if.c

package info (click to toggle)
libowfat 0.22-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,148 kB
  • ctags: 976
  • sloc: ansic: 10,424; makefile: 42
file content (27 lines) | stat: -rw-r--r-- 533 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "ip6.h"
#include "byte.h"
#include <ctype.h>
#include "socket.h"
#include "havealloca.h"

unsigned int scan_ip6if(const char* src,char* ip,uint32* scope_id) {
  int i=scan_ip6(src,ip);
  *scope_id=0;
  if (src[i]=='%') {
    int j;
    char* tmp;
    for (j=i+1; isalnum(src[j]); ++j) ;
    if (!src[j])
      tmp=(char*)src+i+1;
    else {
      tmp=alloca(j-i);
      byte_copy(tmp,j-(i+1),src+i+1);
      tmp[j-(i+1)]=0;
    }
    if (*tmp) {
      *scope_id=socket_getifidx(tmp);
      return j;
    }
  }
  return i;
}