Module: YP
- Defined in:
- ext/nis/yp.c
Defined Under Namespace
Classes: YPError
Class Method Summary collapse
- .err_string(err) ⇒ Object
- .get_default_domain ⇒ Object
- .yp_all(argv[], self) ⇒ Object
- .yp_first(domain, map) ⇒ Object
- .yp_master(domain, map) ⇒ Object
- .yp_match(domain, map, inkey) ⇒ Object
- .yp_next(domain, map, inkey) ⇒ Object
- .yp_order(domain, map) ⇒ Object
- .yp_update(domain, map, ypop, inkey, inval) ⇒ Object
Class Method Details
.err_string(err) ⇒ Object
39 40 41 42 43 |
# File 'ext/nis/yp.c', line 39
VALUE
rb_yperr_string(VALUE self, VALUE err)
{
return rb_tainted_str_new2(yperr_string(FIX2INT(err)));
};
|
.get_default_domain ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'ext/nis/yp.c', line 27
VALUE
rb_yp_get_default_domain(VALUE self)
{
char *domainname;
int err;
if((err = yp_get_default_domain(&domainname)) != 0){
rb_raise(rb_eYPError, yperr_string(err));
};
return rb_tainted_str_new2(domainname);
};
|
.yp_all(argv[], self) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'ext/nis/yp.c', line 95
VALUE
rb_yp_all(int argc, VALUE argv[], VALUE self)
{
int res;
struct ypall_callback ypcb;
VALUE domainname, map, cb;
rb_scan_args(argc, argv, "21", &domainname, &map, &cb);
if( domainname == Qnil ){
domainname = rb_yp_get_default_domain(self);
};
switch( argc ){
case 3:
ypcb.foreach = rb_ypall_callback;
ypcb.data = (char*)cb;
break;
case 2:
ypcb.foreach = rb_ypall_callback;
ypcb.data = (char*)Qnil;
break;
};
res = yp_all(STR2CSTR(domainname), STR2CSTR(map), &ypcb);
rb_yp_check_yperr(res);
return Qnil;
};
|
.yp_first(domain, map) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'ext/nis/yp.c', line 123
VALUE
rb_yp_first(VALUE self, VALUE domain, VALUE map)
{
char *key, *val;
int keylen, vallen;
int res;
VALUE vkey, vval;
if( domain == Qnil ){
domain = rb_yp_get_default_domain(self);
};
res = yp_first(STR2CSTR(domain), STR2CSTR(map), &key, &keylen, &val, &vallen);
rb_yp_check_yperr(res);
if( keylen > 0 ){
vkey = rb_tainted_str_new(key, keylen);
}
else{
vkey = Qnil;
};
if( vallen > 0 ){
vval = rb_tainted_str_new(val, vallen);
}
else{
vval = Qnil;
};
return rb_assoc_new(vkey, vval);
};
|
.yp_master(domain, map) ⇒ Object
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'ext/nis/yp.c', line 245
VALUE
rb_yp_master(VALUE self, VALUE domain, VALUE map)
{
int res;
char *master;
VALUE obj;
if( domain == Qnil ){
domain = rb_yp_get_default_domain(self);
};
res = yp_master(STR2CSTR(domain), STR2CSTR(map), &master);
rb_yp_check_yperr(res);
obj = rb_tainted_str_new2(master);
free(master);
return obj;
};
|
.yp_match(domain, map, inkey) ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'ext/nis/yp.c', line 206
VALUE
rb_yp_match(VALUE self, VALUE domain, VALUE map, VALUE inkey)
{
int res;
char *val;
int vallen;
if( domain == Qnil ){
domain = rb_yp_get_default_domain(self);
};
res = yp_match(STR2CSTR(domain), STR2CSTR(map),
STR2CSTR(inkey), RSTRING(inkey)->len,
&val, &vallen);
rb_yp_check_yperr(res);
if( vallen > 0 ){
return rb_tainted_str_new(val, vallen);
}
else{
return Qnil;
};
};
|
.yp_next(domain, map, inkey) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'ext/nis/yp.c', line 155
VALUE
rb_yp_next(VALUE self, VALUE domain, VALUE map, VALUE inkey)
{
char *key, *val;
int keylen, vallen;
int res;
VALUE vkey, vval;
if( domain == Qnil ){
domain = rb_yp_get_default_domain(self);
};
res = yp_next(STR2CSTR(domain), STR2CSTR(map),
STR2CSTR(inkey), RSTRING(inkey)->len,
&key, &keylen, &val, &vallen);
rb_yp_check_yperr(res);
if( keylen > 0 ){
vkey = rb_tainted_str_new(key, keylen);
}
else{
vkey = Qnil;
};
if( vallen > 0 ){
vval = rb_tainted_str_new(val, vallen);
}
else{
vval = Qnil;
};
return rb_assoc_new(vkey, vval);
};
|
.yp_order(domain, map) ⇒ Object
230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'ext/nis/yp.c', line 230
VALUE
rb_yp_order(VALUE self, VALUE domain, VALUE map)
{
int res, order;
if( domain == Qnil ){
domain = rb_yp_get_default_domain(self);
};
res = yp_order(STR2CSTR(domain), STR2CSTR(map), &order);
rb_yp_check_yperr(res);
return INT2NUM(order);
};
|
.yp_update(domain, map, ypop, inkey, inval) ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'ext/nis/yp.c', line 189
VALUE
rb_yp_update(VALUE self, VALUE domain, VALUE map, VALUE ypop, VALUE inkey, VALUE inval)
{
int res;
if( domain == Qnil ){
domain = rb_yp_get_default_domain(self);
};
res = yp_update(STR2CSTR(domain), STR2CSTR(map), FIX2INT(ypop),
STR2CSTR(inkey), RSTRING(inkey)->len,
STR2CSTR(inval), RSTRING(inval)->len);
rb_yp_check_yperr(res);
return INT2NUM(res);
};
|