~ubuntu-branches/ubuntu/maverick/9base/maverick

« back to all changes in this revision

Viewing changes to lib9/netmkaddr.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-08-20 17:34:06 UTC
  • mfrom: (6.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090820173406-xpwqa9ruyevvc0ut
Tags: 1:3-3
* Updating maintainer field.
* Updating vcs fields.
* Updating package to standards version 3.8.3.
* Updatin variables writing in rules to consistent style.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
         */
17
17
        cp = strchr(linear, '!');
18
18
        if(cp == 0){
19
 
                if(defnet==0){
20
 
                        if(defsrv)
21
 
                                snprint(addr, sizeof(addr), "net!%s!%s",
22
 
                                        linear, defsrv);
23
 
                        else
24
 
                                snprint(addr, sizeof(addr), "net!%s", linear);
25
 
                }
26
 
                else {
27
 
                        if(defsrv)
28
 
                                snprint(addr, sizeof(addr), "%s!%s!%s", defnet,
29
 
                                        linear, defsrv);
30
 
                        else
31
 
                                snprint(addr, sizeof(addr), "%s!%s", defnet,
32
 
                                        linear);
33
 
                }
 
19
                if(defnet == 0)
 
20
                        defnet = "net";
 
21
                /* allow unix sockets to omit unix! prefix */
 
22
                if(access(linear, 0) >= 0){
 
23
                        snprint(addr, sizeof(addr), "unix!%s", linear);
 
24
                        return addr;
 
25
                }
 
26
                /* allow host:service in deference to Unix convention */
 
27
                if((cp = strchr(linear, ':')) != nil){
 
28
                        snprint(addr, sizeof(addr), "%s!%.*s!%s", 
 
29
                                defnet, utfnlen(linear, cp-linear),
 
30
                                linear, cp+1);
 
31
                        return addr;
 
32
                }
 
33
                if(defsrv)
 
34
                        snprint(addr, sizeof(addr), "%s!%s!%s",
 
35
                                defnet, linear, defsrv);
 
36
                else
 
37
                        snprint(addr, sizeof(addr), "%s!%s", defnet, linear);
34
38
                return addr;
35
39
        }
36
40
 
42
46
                return linear;
43
47
 
44
48
        /*
 
49
         * if the network is unix, no service
 
50
         */
 
51
        if(strncmp(linear, "unix!", 5) == 0)
 
52
                return linear;
 
53
 
 
54
        /*
45
55
         *  add default service
46
56
         */
47
57
        if(defsrv == 0)
48
58
                return linear;
 
59
 
49
60
        snprint(addr, sizeof(addr), "%s!%s", linear, defsrv);
50
 
 
51
61
        return addr;
52
62
}