home *** CD-ROM | disk | FTP | other *** search
/ Freelog 42 / Freelog042.iso / Alu / Ancestrologie / Sources / InterBase_WI-V6.0.1-server.ZIP / examples / services / start_license_add.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-05  |  1.7 KB  |  78 lines

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include "ibase.h"
  5.  
  6. #define RESPBUF    256
  7.  
  8. void main (argc, argv)
  9. int    argc;
  10. char    *argv[];
  11. {
  12. char    *user = "duquette",
  13.         *pass = "duquette";
  14.  
  15. char    *key = "eval",
  16.         *id = "eval";
  17.  
  18. long    status [20];
  19. long    *svc_handle = NULL;
  20. char    svc_name[RESPBUF], spb_buff[RESPBUF], thd_buff[RESPBUF];
  21. char    respbuf[RESPBUF], *p = respbuf, *spb = spb_buff, *thd = thd_buff,*x;
  22. short    spblen, thdlen;
  23. int    i = 0, cnt=0;
  24.  
  25.  
  26. *spb++ = isc_spb_version;
  27. *spb++ = isc_spb_current_version;
  28.  
  29. *spb++ = isc_spb_user_name;
  30. *spb++ = strlen (user);
  31. for (x = user; *x;)
  32.   *spb++ = *x++;
  33.  
  34. *spb++ = isc_spb_password;
  35. *spb++ = strlen (pass);
  36. for (x = pass; *x;)
  37.   *spb++ = *x++;
  38.  
  39. sprintf (svc_name, "service_mgr");
  40.  
  41. spblen = spb - spb_buff;
  42.  
  43. if (isc_service_attach (status, 0, svc_name, &svc_handle, spblen, spb_buff))
  44.     {
  45.     isc_print_status (status);
  46.     exit (1);
  47.     }
  48.  
  49. *thd++ = isc_action_svc_add_license;
  50. *thd++ = isc_spb_lic_key;
  51. *thd++ = strlen (key);
  52. *thd++ = strlen (key) >> 8;
  53. for (x = key; *x;)
  54.   *thd++ = *x++;
  55.  
  56. *thd++ = isc_spb_lic_id;
  57. *thd++ = strlen (id);
  58. *thd++ = strlen (id) >> 8;
  59. for (x = id; *x;)
  60.   *thd++ = *x++;
  61.  
  62. thdlen = thd - thd_buff;
  63. printf ("Attach succeed\n");
  64.  
  65. if (isc_service_start(status, &svc_handle, NULL, thdlen, thd_buff))
  66.     {
  67.     long *vector = status;
  68.     printf ("Unable to add license:\n");
  69.     while (isc_interprete (respbuf, &vector))
  70.         printf ("ERROR: %s\n", respbuf);
  71.     printf ("End of errors\n");
  72.     isc_service_detach (status, &svc_handle);
  73.     exit(1);
  74.     }
  75. printf ("License Added\n");
  76. isc_service_detach(status, &svc_handle);
  77. }
  78.