Print this page
patch tsoome-feedback


   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2001-2002 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #pragma ident   "%Z%%M% %I%     %E% SMI"
  28 
  29 #include <stdio.h>
  30 #include <stdlib.h>
  31 #include <sys/types.h>
  32 #include <sys/stat.h>
  33 #include <unistd.h>
  34 #include <errno.h>
  35 #include <strings.h>
  36 #include <string.h>
  37 #include <fcntl.h>
  38 #include <assert.h>
  39 #include <libipp.h>
  40 #include <libnvpair.h>
  41 #include <ipp/ippctl.h>
  42 
  43 /*
  44  * Debug macros
  45  */
  46 
  47 #if     defined(DEBUG) && !defined(lint)
  48 uint32_t        ipp_debug_flags =


 208                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_OP);
 209                 goto failed;
 210         }
 211 
 212         if ((rc = nvlist_add_string(nvlp, IPPCTL_ANAME, (char *)aname)) != 0) {
 213                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_ANAME);
 214                 goto failed;
 215         }
 216 
 217         if ((rc = nvlist_add_uint32(nvlp, IPPCTL_FLAGS, flags)) != 0) {
 218                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_FLAGS);
 219                 goto failed;
 220         }
 221 
 222         /*
 223          * Talk to the kernel.
 224          */
 225 
 226         return (dispatch(&nvlp, NULL, NULL));
 227 failed:
 228         if (nvlp != NULL)
 229                 nvlist_free(nvlp);
 230         errno = rc;
 231         return (-1);
 232 }
 233 #undef  __FN__
 234 
 235 #define __FN__  "ipp_action_modify"
 236 int
 237 ipp_action_modify(
 238         const char      *aname,
 239         nvlist_t        **nvlpp,
 240         ipp_flags_t     flags)
 241 {
 242         nvlist_t        *nvlp;
 243         int             rc;
 244 
 245         /*
 246          * Sanity check the arguments.
 247          */
 248 


 319                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_OP);
 320                 goto failed;
 321         }
 322 
 323         if ((rc = nvlist_add_string(nvlp, IPPCTL_ANAME, (char *)aname)) != 0) {
 324                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_ANAME);
 325                 goto failed;
 326         }
 327 
 328         if ((rc = nvlist_add_uint32(nvlp, IPPCTL_FLAGS, flags)) != 0) {
 329                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_FLAGS);
 330                 goto failed;
 331         }
 332 
 333         /*
 334          * Talk to the kernel.
 335          */
 336 
 337         return (dispatch(&nvlp, fn, arg));
 338 failed:
 339         if (nvlp != NULL)
 340                 nvlist_free(nvlp);
 341         errno = rc;
 342         return (-1);
 343 }
 344 #undef  __FN__
 345 
 346 #define __FN__  "ipp_action_mod"
 347 int
 348 ipp_action_mod(
 349         const char      *aname,
 350         char            **modnamep)
 351 {
 352         nvlist_t        *nvlp;
 353         int             rc;
 354 
 355         /*
 356          * Sanity check the arguments.
 357          */
 358 
 359         if (aname == NULL || modnamep == NULL) {


 372                 goto failed;
 373         }
 374 
 375         if ((rc = nvlist_add_byte(nvlp, IPPCTL_OP,
 376             IPPCTL_OP_ACTION_MOD)) != 0) {
 377                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_OP);
 378                 goto failed;
 379         }
 380 
 381         if ((rc = nvlist_add_string(nvlp, IPPCTL_ANAME, (char *)aname)) != 0) {
 382                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_ANAME);
 383                 goto failed;
 384         }
 385 
 386         /*
 387          * Talk to the kernel.
 388          */
 389 
 390         return (dispatch(&nvlp, string_callback, (void *)modnamep));
 391 failed:
 392         if (nvlp != NULL)
 393                 nvlist_free(nvlp);
 394         errno = rc;
 395         return (-1);
 396 }
 397 #undef  __FN__
 398 
 399 #define __FN__  "ipp_list_mods"
 400 int
 401 ipp_list_mods(
 402         char            ***modname_arrayp,
 403         int             *neltp)
 404 {
 405         nvlist_t        *nvlp;
 406         array_desc_t    ad;
 407         int             rc;
 408 
 409         /*
 410          * Sanity check the arguments.
 411          */
 412 


 429             IPPCTL_OP_LIST_MODS)) != 0) {
 430                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_OP);
 431                 goto failed;
 432         }
 433 
 434         /*
 435          * Talk to the kernel.
 436          */
 437 
 438         ad.name = IPPCTL_MODNAME_ARRAY;
 439         ad.array = NULL;
 440         ad.nelt = 0;
 441 
 442         if ((rc = dispatch(&nvlp, string_array_callback, (void *)&ad)) == 0) {
 443                 *modname_arrayp = ad.array;
 444                 *neltp = ad.nelt;
 445         }
 446 
 447         return (rc);
 448 failed:
 449         if (nvlp != NULL)
 450                 nvlist_free(nvlp);
 451         errno = rc;
 452         return (-1);
 453 }
 454 #undef  __FN__
 455 
 456 #define __FN__  "ipp_mod_list_actions"
 457 int
 458 ipp_mod_list_actions(
 459         const char      *modname,
 460         char            ***aname_arrayp,
 461         int             *neltp)
 462 {
 463         nvlist_t        *nvlp;
 464         array_desc_t    ad;
 465         int             rc;
 466 
 467         /*
 468          * Sanity check the arguments.
 469          */


 493             (char *)modname)) != 0) {
 494                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_MODNAME);
 495                 goto failed;
 496         }
 497 
 498         /*
 499          * Talk to the kernel.
 500          */
 501 
 502         ad.name = IPPCTL_ANAME_ARRAY;
 503         ad.array = NULL;
 504         ad.nelt = 0;
 505 
 506         if ((rc = dispatch(&nvlp, string_array_callback, (void *)&ad)) == 0) {
 507                 *aname_arrayp = ad.array;
 508                 *neltp = ad.nelt;
 509         }
 510 
 511         return (rc);
 512 failed:
 513         if (nvlp != NULL)
 514                 nvlist_free(nvlp);
 515         errno = rc;
 516         return (-1);
 517 }
 518 #undef  __FN__
 519 
 520 #define __FN__  "ipp_free"
 521 void
 522 ipp_free(
 523         char    *buf)
 524 {
 525         free(buf);
 526 }
 527 #undef  __FN__
 528 
 529 #define __FN__  "ipp_free_array"
 530 void
 531 ipp_free_array(
 532         char    **array,
 533         int     nelt)




   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2001-2002 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 


  27 #include <stdio.h>
  28 #include <stdlib.h>
  29 #include <sys/types.h>
  30 #include <sys/stat.h>
  31 #include <unistd.h>
  32 #include <errno.h>
  33 #include <strings.h>
  34 #include <string.h>
  35 #include <fcntl.h>
  36 #include <assert.h>
  37 #include <libipp.h>
  38 #include <libnvpair.h>
  39 #include <ipp/ippctl.h>
  40 
  41 /*
  42  * Debug macros
  43  */
  44 
  45 #if     defined(DEBUG) && !defined(lint)
  46 uint32_t        ipp_debug_flags =


 206                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_OP);
 207                 goto failed;
 208         }
 209 
 210         if ((rc = nvlist_add_string(nvlp, IPPCTL_ANAME, (char *)aname)) != 0) {
 211                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_ANAME);
 212                 goto failed;
 213         }
 214 
 215         if ((rc = nvlist_add_uint32(nvlp, IPPCTL_FLAGS, flags)) != 0) {
 216                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_FLAGS);
 217                 goto failed;
 218         }
 219 
 220         /*
 221          * Talk to the kernel.
 222          */
 223 
 224         return (dispatch(&nvlp, NULL, NULL));
 225 failed:

 226         nvlist_free(nvlp);
 227         errno = rc;
 228         return (-1);
 229 }
 230 #undef  __FN__
 231 
 232 #define __FN__  "ipp_action_modify"
 233 int
 234 ipp_action_modify(
 235         const char      *aname,
 236         nvlist_t        **nvlpp,
 237         ipp_flags_t     flags)
 238 {
 239         nvlist_t        *nvlp;
 240         int             rc;
 241 
 242         /*
 243          * Sanity check the arguments.
 244          */
 245 


 316                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_OP);
 317                 goto failed;
 318         }
 319 
 320         if ((rc = nvlist_add_string(nvlp, IPPCTL_ANAME, (char *)aname)) != 0) {
 321                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_ANAME);
 322                 goto failed;
 323         }
 324 
 325         if ((rc = nvlist_add_uint32(nvlp, IPPCTL_FLAGS, flags)) != 0) {
 326                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_FLAGS);
 327                 goto failed;
 328         }
 329 
 330         /*
 331          * Talk to the kernel.
 332          */
 333 
 334         return (dispatch(&nvlp, fn, arg));
 335 failed:

 336         nvlist_free(nvlp);
 337         errno = rc;
 338         return (-1);
 339 }
 340 #undef  __FN__
 341 
 342 #define __FN__  "ipp_action_mod"
 343 int
 344 ipp_action_mod(
 345         const char      *aname,
 346         char            **modnamep)
 347 {
 348         nvlist_t        *nvlp;
 349         int             rc;
 350 
 351         /*
 352          * Sanity check the arguments.
 353          */
 354 
 355         if (aname == NULL || modnamep == NULL) {


 368                 goto failed;
 369         }
 370 
 371         if ((rc = nvlist_add_byte(nvlp, IPPCTL_OP,
 372             IPPCTL_OP_ACTION_MOD)) != 0) {
 373                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_OP);
 374                 goto failed;
 375         }
 376 
 377         if ((rc = nvlist_add_string(nvlp, IPPCTL_ANAME, (char *)aname)) != 0) {
 378                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_ANAME);
 379                 goto failed;
 380         }
 381 
 382         /*
 383          * Talk to the kernel.
 384          */
 385 
 386         return (dispatch(&nvlp, string_callback, (void *)modnamep));
 387 failed:

 388         nvlist_free(nvlp);
 389         errno = rc;
 390         return (-1);
 391 }
 392 #undef  __FN__
 393 
 394 #define __FN__  "ipp_list_mods"
 395 int
 396 ipp_list_mods(
 397         char            ***modname_arrayp,
 398         int             *neltp)
 399 {
 400         nvlist_t        *nvlp;
 401         array_desc_t    ad;
 402         int             rc;
 403 
 404         /*
 405          * Sanity check the arguments.
 406          */
 407 


 424             IPPCTL_OP_LIST_MODS)) != 0) {
 425                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_OP);
 426                 goto failed;
 427         }
 428 
 429         /*
 430          * Talk to the kernel.
 431          */
 432 
 433         ad.name = IPPCTL_MODNAME_ARRAY;
 434         ad.array = NULL;
 435         ad.nelt = 0;
 436 
 437         if ((rc = dispatch(&nvlp, string_array_callback, (void *)&ad)) == 0) {
 438                 *modname_arrayp = ad.array;
 439                 *neltp = ad.nelt;
 440         }
 441 
 442         return (rc);
 443 failed:

 444         nvlist_free(nvlp);
 445         errno = rc;
 446         return (-1);
 447 }
 448 #undef  __FN__
 449 
 450 #define __FN__  "ipp_mod_list_actions"
 451 int
 452 ipp_mod_list_actions(
 453         const char      *modname,
 454         char            ***aname_arrayp,
 455         int             *neltp)
 456 {
 457         nvlist_t        *nvlp;
 458         array_desc_t    ad;
 459         int             rc;
 460 
 461         /*
 462          * Sanity check the arguments.
 463          */


 487             (char *)modname)) != 0) {
 488                 DBG1(DBG_ERR, "failed to add '%s' to nvlist\n", IPPCTL_MODNAME);
 489                 goto failed;
 490         }
 491 
 492         /*
 493          * Talk to the kernel.
 494          */
 495 
 496         ad.name = IPPCTL_ANAME_ARRAY;
 497         ad.array = NULL;
 498         ad.nelt = 0;
 499 
 500         if ((rc = dispatch(&nvlp, string_array_callback, (void *)&ad)) == 0) {
 501                 *aname_arrayp = ad.array;
 502                 *neltp = ad.nelt;
 503         }
 504 
 505         return (rc);
 506 failed:

 507         nvlist_free(nvlp);
 508         errno = rc;
 509         return (-1);
 510 }
 511 #undef  __FN__
 512 
 513 #define __FN__  "ipp_free"
 514 void
 515 ipp_free(
 516         char    *buf)
 517 {
 518         free(buf);
 519 }
 520 #undef  __FN__
 521 
 522 #define __FN__  "ipp_free_array"
 523 void
 524 ipp_free_array(
 525         char    **array,
 526         int     nelt)