~ubuntu-branches/ubuntu/wily/sblim-sfcb/wily

« back to all changes in this revision

Viewing changes to brokerUpc.c

  • Committer: Bazaar Package Importer
  • Author(s): Thierry Carrez
  • Date: 2009-07-16 15:47:22 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090716154722-7b5n4g1r1gybd321
Tags: 1.3.4-0ubuntu1
* New upstream release (LP: #394235)
* debian/control: Add a version to the debhelper build dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $Id: brokerUpc.c,v 1.28 2008/11/04 01:10:45 buccella Exp $
 
2
 * $Id: brokerUpc.c,v 1.30 2009/03/10 19:18:19 buccella Exp $
3
3
 *
4
4
 * © Copyright IBM Corp. 2005, 2007
5
5
 *
56
56
                                      const char *className, CMPIStatus * rc);
57
57
extern void setStatus(CMPIStatus *st, CMPIrc rc, char *msg);
58
58
 
59
 
extern int initProvider(ProviderInfo *info, unsigned int sessionId);
 
59
extern int initProvider(ProviderInfo *info, unsigned int sessionId,
 
60
                        char** errorStr);
60
61
 
61
62
 
62
63
void closeProviderContext(BinRequestContext * ctx);
221
222
   memset(binCtx,0,sizeof(BinRequestContext));
222
223
   oHdr->nameSpace = setCharsMsgSegment((char *)
223
224
                          ClObjectPathGetNameSpace((ClObjectPath *) cop->hdl));
224
 
   oHdr->className = setCharsMsgSegment((char *)
 
225
   if (oHdr->type < OPS_Associators || oHdr->type > OPS_ReferenceNames) {
 
226
      oHdr->className = setCharsMsgSegment((char *)
225
227
                          ClObjectPathGetClassName((ClObjectPath *) cop->hdl));
 
228
   } else {
 
229
      oHdr->className = setCharsMsgSegment(NULL);
 
230
   }
226
231
   ctxData=CMGetContextEntry(ctx,CMPIPrincipal,NULL);
227
232
   if (ctxData.value.string) {
228
233
     bHdr->object[0] = setCharsMsgSegment(CMGetCharPtr(ctxData.value.string));
319
324
   CMPIArray *ar = NULL;
320
325
   BinRequestHdr *bhdrTmp=NULL;
321
326
   CMPIObjectPath *copLocalCall;
 
327
   char* errstr = NULL; 
 
328
   int initrc = 0; 
322
329
   int irc, c, i=-1;
323
330
 
324
331
   _SFCB_ENTER(TRACE_UPCALLS, "genericEnumRequest");
378
385
                  local=1;
379
386
                  
380
387
                  if (pInfo->initialized == 0) {
381
 
                    initProvider(pInfo,binCtx.bHdr->sessionId);
382
 
                  }
383
 
                  switch(optype) {
384
 
                    case OPS_Associators:
385
 
                      rci = pInfo->associationMI->ft->associators(pInfo->associationMI,
386
 
                                      context, result, copLocalCall, assocclass,
387
 
                                      resultclass, role, resultrole, props);
388
 
                      break;
389
 
                    case OPS_AssociatorNames:
390
 
                      rci = pInfo->associationMI->ft->associatorNames(pInfo->associationMI,
391
 
                                      context, result, copLocalCall, assocclass,
392
 
                                      resultclass, role, resultrole);
393
 
                      break;
394
 
            case OPS_References:
395
 
              rci = pInfo->associationMI->ft->references(pInfo->associationMI,
396
 
                              context, result, copLocalCall, resultclass,
397
 
                              role, props);
398
 
              break;
399
 
            case OPS_ReferenceNames:
400
 
              rci = pInfo->associationMI->ft->referenceNames(pInfo->associationMI,
401
 
                              context, result, copLocalCall, resultclass, role);
402
 
              break;
403
 
                    case OPS_EnumerateInstances:
404
 
                      rci = pInfo->instanceMI->ft->enumerateInstances(pInfo->instanceMI,
405
 
                                      context, result, copLocalCall, props);
406
 
                      break;
407
 
                    case OPS_EnumerateInstanceNames:
408
 
                      rci = pInfo->instanceMI->ft->enumerateInstanceNames(pInfo->instanceMI,
409
 
                                      context, result, copLocalCall);                                 
410
 
                      break;
 
388
                    initrc = initProvider(pInfo,binCtx.bHdr->sessionId, &errstr); 
 
389
                  }
 
390
                  if (initrc != 0) {
 
391
                     rci.msg = sfcb_native_new_CMPIString(errstr, NULL, 0);
 
392
                         free (errstr); 
 
393
                         errstr = NULL; 
 
394
                         rci.rc = CMPI_RC_ERR_FAILED; 
 
395
                  }
 
396
                  else {
 
397
                  switch(optype) {
 
398
                        case OPS_Associators:
 
399
                          rci = pInfo->associationMI->ft->associators(pInfo->associationMI,
 
400
                                                          context, result, copLocalCall, assocclass,
 
401
                                                          resultclass, role, resultrole, props);
 
402
                          break;
 
403
                        case OPS_AssociatorNames:
 
404
                          rci = pInfo->associationMI->ft->associatorNames(pInfo->associationMI,
 
405
                                                          context, result, copLocalCall, assocclass,
 
406
                                                          resultclass, role, resultrole);
 
407
                          break;
 
408
                        case OPS_References:
 
409
                          rci = pInfo->associationMI->ft->references(pInfo->associationMI,
 
410
                                                          context, result, copLocalCall, resultclass,
 
411
                                                          role, props);
 
412
                          break;
 
413
                        case OPS_ReferenceNames:
 
414
                          rci = pInfo->associationMI->ft->referenceNames(pInfo->associationMI,
 
415
                                                          context, result, copLocalCall, resultclass, role);
 
416
                          break;
 
417
                        case OPS_EnumerateInstances:
 
418
                          rci = pInfo->instanceMI->ft->enumerateInstances(pInfo->instanceMI,
 
419
                                                          context, result, copLocalCall, props);
 
420
                          break;
 
421
                        case OPS_EnumerateInstanceNames:
 
422
                          rci = pInfo->instanceMI->ft->enumerateInstanceNames(pInfo->instanceMI,
 
423
                                                          context, result, copLocalCall);                                     
 
424
                          break;
 
425
                  }
411
426
                  }
412
427
                  lockUpCall(broker);
413
428
                  if (rci.rc == CMPI_RC_OK) cpyResult(result, ar, &c);  
460
475
   CMPIInstance *inst = NULL,*tInst=NULL;
461
476
   int irc, ps, sreqSize=sizeof(GetInstanceReq);
462
477
   ProviderInfo *pInfo;
 
478
   char* errstr = NULL; 
 
479
   int initrc = 0; 
463
480
   const char **p=props;
464
481
 
465
482
   _SFCB_ENTER(TRACE_UPCALLS, "getInstance");
493
510
            CMPIArray *r;
494
511
            unlockUpCall(broker);
495
512
            if (pInfo->initialized == 0) {
496
 
              initProvider(pInfo,binCtx.bHdr->sessionId);
 
513
              initrc = initProvider(pInfo,binCtx.bHdr->sessionId, &errstr);
497
514
            }
 
515
            if (initrc != 0) {
 
516
                if (rc) {
 
517
                    rc->rc = CMPI_RC_ERR_FAILED; 
 
518
                    rc->msg = sfcb_native_new_CMPIString(errstr, NULL, 0);
 
519
                        }
 
520
                free(errstr);
 
521
                return NULL; 
 
522
                }
 
523
                else {
498
524
            st = pInfo->instanceMI->ft->getInstance(pInfo->instanceMI,context,result,cop,props);
499
525
            if (rc) *rc=st;
500
526
            r = native_result2array(result);
503
529
            if (sreq) free(sreq);
504
530
            return inst;   
505
531
         }
 
532
         }
506
533
      }
507
534
 
508
535
         resp = invokeProvider(&binCtx);
544
571
   OperationHdr oHdr = { OPS_CreateInstance, 2 };
545
572
   CMPIStatus st = { CMPI_RC_OK, NULL };
546
573
   CMPIObjectPath *op = NULL,*tOp=NULL;
 
574
   char* errstr = NULL; 
 
575
   int initrc = 0; 
547
576
   int irc;
548
577
   ProviderInfo *pInfo;
549
578
 
569
598
            CMPIArray *r;
570
599
            unlockUpCall(broker);
571
600
            if (pInfo->initialized == 0) {
572
 
              initProvider(pInfo,binCtx.bHdr->sessionId);
 
601
              initrc = initProvider(pInfo,binCtx.bHdr->sessionId, &errstr);
573
602
            }
574
 
            st = pInfo->instanceMI->ft->createInstance(pInfo->instanceMI,context,result,cop,inst);
575
 
            if (rc) *rc=st;
576
 
            r = native_result2array(result);
577
 
            if (st.rc==0) 
578
 
               op=CMGetArrayElementAt(r, 0, NULL).value.ref;
579
 
            return op;   
 
603
            if (initrc != 0) {
 
604
                    if (rc) {
 
605
                        rc->rc = CMPI_RC_ERR_FAILED; 
 
606
                        rc->msg = sfcb_native_new_CMPIString(errstr, NULL, 0);
 
607
                            }
 
608
                    free(errstr);
 
609
                    return NULL; 
 
610
                        }
 
611
                        else {
 
612
                st = pInfo->instanceMI->ft->createInstance(pInfo->instanceMI,context,result,cop,inst);
 
613
                if (rc) *rc=st;
 
614
                r = native_result2array(result);
 
615
                if (st.rc==0) 
 
616
                   op=CMGetArrayElementAt(r, 0, NULL).value.ref;
 
617
                return op;   
 
618
            }
580
619
         }
581
620
      }
582
621
      
615
654
   ModifyInstanceReq *sreq=NULL;
616
655
   OperationHdr oHdr = { OPS_ModifyInstance, 2 };
617
656
   CMPIStatus st = { CMPI_RC_OK, NULL };
 
657
   int initrc = 0; 
 
658
   char* errstr = NULL; 
618
659
   int ps,irc,sreqSize=sizeof(ModifyInstanceReq); //-sizeof(MsgSegment);
619
660
   ProviderInfo *pInfo;
620
661
 
647
688
            CMPIResult *result = native_new_CMPIResult(0,1,NULL);
648
689
            unlockUpCall(broker);
649
690
            if (pInfo->initialized == 0) {
650
 
              initProvider(pInfo,binCtx.bHdr->sessionId);
 
691
              initrc = initProvider(pInfo,binCtx.bHdr->sessionId, &errstr);
651
692
            }
 
693
            if (initrc != 0) {
 
694
                st.rc = CMPI_RC_ERR_FAILED; 
 
695
                st.msg = sfcb_native_new_CMPIString(errstr, NULL, 0);
 
696
                free(errstr);
 
697
            if (sreq) free(sreq);
 
698
                return st; 
 
699
                }
 
700
                else {
652
701
            st = pInfo->instanceMI->ft->modifyInstance(pInfo->instanceMI,context,result,cop,inst,props);
653
702
            if (sreq) free(sreq);
654
703
            return st;   
655
704
         }
 
705
                 }
656
706
      }
657
707
      
658
708
         resp = invokeProvider(&binCtx);
680
730
   DeleteInstanceReq sreq = BINREQ(OPS_DeleteInstance, 2);
681
731
   OperationHdr oHdr = { OPS_DeleteInstance, 2 };
682
732
   CMPIStatus st = { CMPI_RC_OK, NULL };
 
733
   int initrc = 0; 
 
734
   char* errstr = NULL; 
683
735
   int irc;
684
736
   ProviderInfo *pInfo;
685
737
 
702
754
            CMPIResult *result = native_new_CMPIResult(0,1,NULL);
703
755
            unlockUpCall(broker);
704
756
            if (pInfo->initialized == 0) {
705
 
              initProvider(pInfo,binCtx.bHdr->sessionId);
 
757
              initrc = initProvider(pInfo,binCtx.bHdr->sessionId, &errstr);
706
758
            }
 
759
            if (initrc != 0) {
 
760
                    st.rc = CMPI_RC_ERR_FAILED; 
 
761
                st.msg = sfcb_native_new_CMPIString(errstr, NULL, 0);
 
762
                free(errstr);
 
763
                return st; 
 
764
                }
 
765
                else {
707
766
            st = pInfo->instanceMI->ft->deleteInstance(pInfo->instanceMI,context,result,cop);
708
767
            return st;   
 
768
                }
709
769
         }
710
770
      }
711
771
      
737
797
   CMPIStatus st = { CMPI_RC_OK, NULL },rci = { CMPI_RC_OK, NULL};
738
798
   CMPIEnumeration *enm = NULL;
739
799
   CMPIArray *ar = NULL;
 
800
   int initrc = 0; 
 
801
   char* errstr = NULL; 
740
802
   int irc, i, c;
741
803
 
742
804
   _SFCB_ENTER(TRACE_UPCALLS, "execQuery");
767
829
                  local=1;
768
830
                  unlockUpCall(broker);
769
831
                  if (pInfo->initialized == 0) {
770
 
                    initProvider(pInfo,binCtx.bHdr->sessionId);
771
 
                  }
 
832
                    initrc = initProvider(pInfo,binCtx.bHdr->sessionId, &errstr);
 
833
                  }
 
834
                  if (initrc != 0) {
 
835
                      st.rc = CMPI_RC_ERR_FAILED; 
 
836
                  st.msg = sfcb_native_new_CMPIString(errstr, NULL, 0);
 
837
                  free(errstr);
 
838
              lockUpCall(broker);
 
839
                  break; 
 
840
                  }
 
841
                  else {
772
842
                  rci = pInfo->instanceMI->ft->execQuery(
773
843
                     pInfo->instanceMI, context, result, cop, query, lang);
774
844
                  lockUpCall(broker);
776
846
                  else st=rci; 
777
847
                  break;
778
848
               }
 
849
               }
779
850
            } 
780
851
            if (local) continue;  
781
852