API.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  1. /**************************************************************************
  2. *
  3. * Licensed Materials - Property of IBM and/or HCL and/or HCL
  4. *
  5. * IBM Informix Dynamic Server
  6. * Copyright IBM Corporation 2009-2017. All rights reserved.
  7. * (c) Copyright HCL Technologies Ltd. 2017. All Rights Reserved.
  8. *
  9. * Product : Install API
  10. * Title : API.h
  11. * Description : Main include file for the install API.
  12. *
  13. ************************************************************************
  14. */
  15. #ifndef API_API_INCLUDED
  16. #define API_API_INCLUDED
  17. #include <stdio.h>
  18. #include <sys/types.h>
  19. #define IAD_RC(rc) rc,__FILE__,__LINE__
  20. #ifndef WIN32
  21. #define EXPORT extern
  22. #define STDCALL
  23. #define MS 1
  24. #define SEP '/' /* move to global internal header */
  25. #define bycopy(s1, s2, n) memmove(s2, s1, n)
  26. #define MKDIR(a,b) mkdir(a,b)
  27. #include <pwd.h>
  28. #ifdef NOT_DEFINED
  29. #include <shadow.h>
  30. #endif
  31. #include <grp.h>
  32. #else /* WIN32 */
  33. #define SEP '\\' /* move to global internal header */
  34. #define bycopy(s1, s2, n) memcpy(s2, s1, n)
  35. #define MKDIR(a,b) _mkdir(a)
  36. #define COBJMACROS
  37. #include <windows.h>
  38. #include <lm.h>
  39. #include <ntsecapi.h>
  40. #ifdef DLL
  41. #define EXPORT __declspec(dllexport)
  42. #else
  43. #define EXPORT __declspec(dllimport)
  44. #endif /* DLL */
  45. #define STDCALL __stdcall
  46. #define fork _fork
  47. #define MS 1000
  48. #define SZMAX_REG_STR 300
  49. #endif /* WIN32 */
  50. #include "ifxtypes.h"
  51. #ifdef DISCOVERY_ENABLED
  52. #include "../rsam/ipia.h"
  53. #endif
  54. #include "htrace.h"
  55. #define MAX_NAME 255
  56. #define MAX_LINE 255
  57. #define IAD_MAX_MSGSIZE 512
  58. #define MIN_LOGCOUNT 3 /* move to global internal header */
  59. #define KB (1024)
  60. #define MB (1024*1024)
  61. #define GB (1024*1024*1024)
  62. #define TB (1024*1024*1024*1024)
  63. #define PB (1024*1024*1024*1024*1024)
  64. #ifndef MIN
  65. #define MIN(a,b) ((a) < (b) ? (a) : (b))
  66. #endif
  67. #ifndef MAX
  68. #define MAX(a,b) ((a) > (b) ? (a) : (b))
  69. #endif
  70. #define IAD_MAGIC_NUMBER 0x58494144
  71. #define IAD_BADMAGIC(is) (is && is->magic_number != IAD_MAGIC_NUMBER)
  72. #define IAD_GOODMAGIC(is) (is && is->magic_number == IAD_MAGIC_NUMBER)
  73. #define SVCST_UNINITIALIZED 0 /* needs to be zero */
  74. #define SVCST_CLEAN 1
  75. #define SVCST_DIRTY 2
  76. #define PORT_FREE 0
  77. #define PORT_USED 1
  78. #define PORT_CLAIMED 2
  79. #define ANY_PORT 0
  80. #define NAME_FREE 0
  81. #define NAME_USED 1
  82. #define RETURN_FILENAME 1
  83. #define RETURN_PATHNAME 2
  84. #define SHMKEY 0x52564801
  85. #define IAD_MAX_AUTOCFG_NUM (50)
  86. typedef long cpointer;
  87. /* typedef connection protocol */
  88. typedef unsigned int CPROTOCOL;
  89. enum IAD_BOOLEAN {
  90. IAD_FALSE,
  91. IAD_TRUE
  92. };
  93. typedef enum
  94. {
  95. IAD_PRODID_BUNDLE = 1,
  96. IAD_PRODID_IDS = 2,
  97. IAD_PRODID_CSDK = 3,
  98. IAD_PRODID_CONN = 4,
  99. IAD_PRODID_GLS = 5,
  100. IAD_PRODID_PSM = 6,
  101. IAD_PRODID_JDBC = 7,
  102. IAD_PRODID_IWA = 8,
  103. IAD_PRODID_MAX = 9
  104. } PRODUCT_ID;
  105. enum iad_method {
  106. IAD_METHOD_DFT = 0,
  107. IAD_METHOD_NUM = 1,
  108. IAD_METHOD_PCT = 2
  109. };
  110. typedef enum
  111. {
  112. IAD_REG_DEFAULT = 0,
  113. IAD_REG_32,
  114. IAD_REG_64
  115. } iad_registery_view;
  116. typedef enum {
  117. UNITS_KB = 0,
  118. UNITS_MB = 1,
  119. UNITS_GB = 2,
  120. UNITS_TB = 3,
  121. UNITS_PB = 4
  122. } diskmem_unittype;
  123. typedef enum {
  124. IAD_FILE = 0,
  125. IAD_LOCAL,
  126. IAD_REMOTE
  127. } sqlhost_locations_type;
  128. typedef struct {
  129. diskmem_unittype unit_type;
  130. char unit_charid;
  131. char unit_abbrev[3];
  132. char unit_name[10];
  133. long kb_convertfac;
  134. } unittype_tab;
  135. extern unittype_tab diskmem_units[5];
  136. enum install_mode
  137. {
  138. IAD_MODE_INSTALL = 0x0,
  139. IAD_MODE_UNINSTALL = 0x00000001,
  140. IAD_MODE_PRIVATE = 0x00000002,
  141. IAD_MODE_MAINTAIN = 0x00000004,
  142. IAD_MODE_NOSQL = 0x00000008
  143. };
  144. enum install_type
  145. {
  146. IAD_TYPE_TYPICAL = 0x00000001, /* Typical Installation */
  147. IAD_TYPE_CUSTOM = 0x00000002 /* Custom Installation */
  148. };
  149. enum space_deploy_status
  150. {
  151. space_not_deployed,
  152. space_deployed
  153. };
  154. enum install_deploy_status
  155. {
  156. IAD_SERVER_STATUS_CONFIG = 0,
  157. IAD_SERVER_STATUS_DEPLOYED = 1,
  158. IAD_SERVER_STATUS_ONLINE = 2
  159. };
  160. enum genconfig_status
  161. {
  162. IAD_GENCONFIG_INIT = 0,
  163. IAD_GENCONFIG_CALCULATING = 1,
  164. IAD_GENCONFIG_COMPLETE = 2,
  165. IAD_GENCONFIG_DEFAULT = 3
  166. };
  167. enum iad_install_string
  168. {
  169. IAD_INSTANCE_NAME_BASE = 0,
  170. IAD_CIA_NAME = 1,
  171. IAD_CIA_FULLNAME = 2,
  172. IAD_INFOCENTER_URL = 3,
  173. IAD_INFOCENTER_NAME = 4,
  174. IAD_BUILD_DATE = 5,
  175. IAD_BUILD_TIME = 6
  176. };
  177. #ifdef WIN32
  178. /* Predefined Windows registry hives */
  179. typedef enum
  180. {
  181. /* functional formating use tab not space */
  182. IAD_HKEY_CLASSES_ROOT = 0,
  183. IAD_HKEY_CURRENT_CONFIG,
  184. IAD_HKEY_CURRENT_USER,
  185. IAD_HKEY_LOCAL_MACHINE,
  186. IAD_HKEY_PERFORMANCE_DATA,
  187. IAD_HKEY_USERS
  188. } IAD_HKEY;
  189. typedef struct reg_data IAD_REGDATA;
  190. typedef struct reg_subkeys IAD_REGSUBKEYS;
  191. /* structure to hold registry key value/type/data information */
  192. struct reg_data
  193. {
  194. DWORD index;
  195. TCHAR *value;
  196. DWORD type;
  197. TCHAR *data;
  198. struct reg_data *next;
  199. };
  200. /* structure to hold registry key subkeys information */
  201. struct reg_subkeys
  202. {
  203. DWORD index;
  204. TCHAR *keyname;
  205. struct reg_subkeys *next;
  206. };
  207. #endif
  208. typedef struct install install_t;
  209. typedef struct iad_space iad_space_t;
  210. typedef struct status
  211. {
  212. int event_counter;
  213. int total_events;
  214. int (*setStatus) (install_t* status);
  215. /* jni specific */
  216. #ifndef WIN32
  217. void *env;
  218. void *a;
  219. #else
  220. install_t ** pData;
  221. DWORD dwThreadId;
  222. HANDLE hThread;
  223. #endif
  224. } status_t;
  225. typedef struct blank_line
  226. {
  227. char dummy;
  228. } blank_line_t;
  229. typedef struct comment_line
  230. {
  231. char *comment;
  232. } comment_line_t;
  233. typedef struct environment_line
  234. {
  235. char *variable;
  236. char *value;
  237. } environment_line_t;
  238. typedef struct connection_line
  239. {
  240. char *alias; /* server name */
  241. CPROTOCOL connection_type;
  242. unsigned short port;
  243. char *service_name;
  244. char *hostname;
  245. char *options;
  246. } connection_line_t;
  247. typedef struct onconfig_line
  248. {
  249. char *label;
  250. char *value;
  251. char *comment;
  252. } onconfig_line_t;
  253. typedef struct onconfig_params
  254. {
  255. muintptr shmbase;
  256. size_t rootsize;
  257. size_t bufferpool;
  258. size_t shmvirtsize;
  259. } onconfig_params_t;
  260. typedef struct environment
  261. {
  262. int type;
  263. union
  264. {
  265. blank_line_t bl;
  266. comment_line_t cl;
  267. environment_line_t dl;
  268. } lines;
  269. struct environment *next;
  270. } environment_t;
  271. typedef struct connection
  272. {
  273. int type;
  274. union
  275. {
  276. blank_line_t bl;
  277. comment_line_t cl;
  278. connection_line_t dl;
  279. } lines;
  280. struct connection *next;
  281. } connection_t;
  282. typedef struct configLines
  283. {
  284. int type;
  285. int lineno;
  286. union
  287. {
  288. blank_line_t bl;
  289. comment_line_t cl;
  290. onconfig_line_t dl;
  291. } lines;
  292. } configLines_t;
  293. typedef struct serviceName
  294. {
  295. char *name;
  296. struct serviceName *next;
  297. } serviceName_t;
  298. typedef struct service_line
  299. {
  300. char *name;
  301. unsigned short port;
  302. char *protocol;
  303. serviceName_t *aliases;
  304. char *comment;
  305. } service_line_t;
  306. typedef struct serviceLine
  307. {
  308. int type;
  309. union
  310. {
  311. blank_line_t bl;
  312. comment_line_t cl;
  313. service_line_t sl;
  314. } lines;
  315. struct serviceLine *next;
  316. } serviceLine_t;
  317. typedef struct servicesInfo
  318. {
  319. int state;
  320. int CheatingSockets;
  321. char *servicesFileName;
  322. serviceLine_t *firstLine;
  323. size_t MaxNameLength;
  324. size_t MaxProtoLength;
  325. size_t MaxAliasLength;
  326. } servicesInfo_t;
  327. /* Dbspace struct - holds dbspace specific information */
  328. typedef struct db_space
  329. {
  330. size_t pagesize;
  331. char *mirrorpath;
  332. size_t mirroroffset;
  333. int mirror_flg; /* enum type: IAD_MIRROR_ON|IAD_MIRROR_OFF */
  334. size_t f_extsize;
  335. size_t n_extsize;
  336. int tmp_dbs_flg; /*enum type: IAD_TEMPSPACE_ON|IAD_TEMPSPACE_OFF*/
  337. } db_space_t;
  338. /* Sbspace struct - holds sbspace specific information */
  339. typedef struct sb_sbspace
  340. {
  341. char *mirrorpath;
  342. size_t mirroroffset;
  343. int mirror_flg; /* enum type: IAD_MIRROR_ON|IAD_MIRROR_OFF */
  344. size_t metadataoffset;
  345. size_t metadatasize;
  346. int tmp_sbs_flg; /*enum type: IAD_TEMPSPACE_ON|IAD_TEMPSPACE_OFF*/
  347. char *def_specs;
  348. } sb_space_t;
  349. /* Blob space struct - holds blob space specific information */
  350. typedef struct blob_space
  351. {
  352. int pageunit;
  353. char *mirrorpath;
  354. size_t mirroroffset;
  355. int mirror_flg; /* enum type: IAD_MIRROR_ON|IAD_MIRROR_OFF */
  356. } blob_space_t;
  357. /* Data space struct - holds information for all data spaces */
  358. struct iad_space
  359. {
  360. int type; /* enum type: IAD_DBSPACE|IAD_SBSPACE|IAD_BLOBSPACE */
  361. enum space_deploy_status dep_stat;
  362. union
  363. {
  364. db_space_t dbs;
  365. sb_space_t sbs;
  366. /* ext_space_t exts; TODO - not supported by admin API */
  367. blob_space_t blobsp;
  368. } data_spaces;
  369. char *name;
  370. char *path;
  371. size_t size;
  372. size_t offset;
  373. struct iad_space *mirror;
  374. struct iad_space *next;
  375. };
  376. /* Struct for transaction logging information */
  377. typedef struct iad_trans_log
  378. {
  379. int type; /* enum type: IAD_PHYSLOG | IAD_LOGICALLOG */
  380. int logcount;
  381. size_t logsize;
  382. char *spc_name;
  383. } iad_translog_t;
  384. /* Disk information */
  385. typedef struct iad_disk
  386. {
  387. unsigned long filesys_id;
  388. unsigned long total_space;
  389. size_t free_space;
  390. size_t req_space;
  391. enum IAD_BOOLEAN is_raw;
  392. char *long_path;
  393. char *path; /* First valid subpath of long_path */
  394. int offset;
  395. double io_speed;
  396. int read_speed;
  397. int write_speed;
  398. enum IAD_BOOLEAN speed_tested;
  399. struct iad_disk *next;
  400. } iad_disk_t;
  401. typedef struct _iad_machine
  402. {
  403. int num_cpus;
  404. size_t pagesize;
  405. int blk_size;
  406. double proc_speed;
  407. off_t physmemory;
  408. } iad_machine_t;
  409. typedef struct _iad_autocfg_params
  410. {
  411. int magic_number;
  412. int params_state;
  413. int concurrent_users;
  414. int ds_users;
  415. int rto_restart_policy;
  416. int txn_support;
  417. int mirror_critical;
  418. int mirror_allspaces;
  419. int sbspace_enabled;
  420. int sbspace_logopt;
  421. size_t max_disk_requested;
  422. off_t max_memory_requested;
  423. char *instance_path;
  424. char *mirror_path;
  425. int max_cpu_requested;
  426. int server_type;
  427. int server_num;
  428. double lru_min;
  429. double lru_max;
  430. enum iad_method cpu_alloc_method;
  431. enum iad_method mem_alloc_method;
  432. enum iad_method disk_alloc_method;
  433. int max_cpu_pct;
  434. int max_mem_pct;
  435. int max_disk_pct;
  436. int error_states[IAD_MAX_AUTOCFG_NUM];
  437. } iad_autocfg_params_t;
  438. typedef struct _iad_autocfg_disk
  439. {
  440. int space_type;
  441. size_t recommended_size;
  442. int recommended_number;
  443. int num_elements;
  444. size_t element_size;
  445. char *path;
  446. } iad_autocfg_disk_t;
  447. typedef struct _iad_autocfg_results
  448. {
  449. int magic_number;
  450. int results_state;
  451. off_t user_memory;
  452. off_t ds_memory; /* dss memory to be configured */
  453. int ds_max_scans;
  454. off_t ds_nonpdq_mem;
  455. off_t shmvirtsize;
  456. off_t shmadd; /* size of additional shared mem segment */
  457. off_t vp_memory_cache; /* per processor memory cache */
  458. off_t onlidx_maxmem;
  459. int buffers; /* size of buffer cache */
  460. int cleaners;
  461. int lrus;
  462. int locks;
  463. int num_listen_threads;
  464. int disk_speed;
  465. int plog_speed;
  466. int llog_speed;
  467. int num_disks;
  468. iad_autocfg_disk_t disk_alloc[6];
  469. } iad_autocfg_results_t;
  470. typedef struct instance
  471. {
  472. int instance_state;
  473. char *name;
  474. environment_t *environment_list;
  475. connection_t *connection_list;
  476. configLines_t *onconfig;
  477. size_t onconfig_size;
  478. size_t onconfig_cnt;
  479. int onconfig_key;
  480. char jsonListPasswd[12];
  481. iad_space_t *data_space;
  482. iad_translog_t t_log[2]; /* only 2 log types: physical/logical */
  483. iad_autocfg_params_t *auto_params;
  484. iad_autocfg_results_t *auto_results;
  485. sqlhost_locations_type sqlhost;
  486. #ifdef WIN32
  487. WCHAR sqlhost_location[DNLEN+1];
  488. char *SoftwareKey;
  489. #endif
  490. struct instance *next;
  491. } instance_t;
  492. typedef struct group_info
  493. {
  494. int properties;
  495. int type;
  496. char * grpname;
  497. char * username;
  498. char * passwd;
  499. struct group_info * next;
  500. } group_info_t;
  501. struct user_info
  502. {
  503. unsigned int userproperties;
  504. group_info_t * additional_groups;
  505. #ifdef WIN32
  506. WCHAR DeploymentUser[UNLEN + 1];
  507. WCHAR DeploymentUserDomain[DNLEN + 1];
  508. char *DeploymentUserDomainC;
  509. SID DeploymentUserSID;
  510. WCHAR LocalHostName[MAX_COMPUTERNAME_LENGTH + 1];
  511. LSA_HANDLE LocalPolicyHandle;
  512. /*
  513. * DomainControler is also used in NetGetDCName() that uses the format
  514. * \\<MACHINE_NAME>, therefore we need additional 2 chars for "\\"
  515. */
  516. WCHAR DomainControler[MAX_COMPUTERNAME_LENGTH + 2 + 1];
  517. char *DomainControlerC;
  518. WCHAR AdminGroup[UNLEN + 1];
  519. WCHAR * passwd;
  520. char username[UNLEN + DNLEN + 2];
  521. #endif /* WIN32 */
  522. };
  523. /*Used to extract version info from version string*/
  524. typedef struct verInfo{
  525. enum IAD_BOOLEAN isVerBeta;
  526. enum IAD_BOOLEAN isVerSpBld;
  527. enum IAD_BOOLEAN isVerPID;
  528. enum IAD_BOOLEAN isOutOfMem;
  529. int maj;
  530. int min;
  531. int fp;
  532. int interim;
  533. char * verDelimited;
  534. } verInfo;
  535. /* structure to store product information */
  536. typedef struct ifxproduct
  537. {
  538. char *fullprodname;
  539. char *version;
  540. verInfo prodverInfo;
  541. PRODUCT_ID product_type;
  542. }ifxproduct_t;
  543. #ifdef DISCOVERY_ENABLED
  544. typedef struct serverdiscovery
  545. {
  546. size_t instances_cnt; /* count of instances found */
  547. size_t alias_list_size; /* size of alias list */
  548. size_t alias_list_cnt; /* number of aliases found */
  549. serverAttr *instances_arr; /* from server discovery */
  550. char *alias_list_arr;
  551. char **servername_list; /* list of servernames corresponding to instances_arr offset */
  552. }serverdiscovery_t;
  553. #endif
  554. /*
  555. * This should go to iad_install.h
  556. */
  557. typedef struct sub_installer
  558. {
  559. int si_prodid;
  560. char si_nname[6]; /* Short name of sub-installer */
  561. int si_rc; /* Return Code of Sub-Installer */
  562. struct sub_installer
  563. *si_next; /* Next sub-installer in the list or NULL */
  564. } subi_t;
  565. /* End of iad_install.h */
  566. struct install
  567. {
  568. long magic_number;
  569. int mode; /* Change with iadChangeInstallMode() */
  570. int iad_type; /* Change with iadSetInstallType() */
  571. int api_pid;
  572. subi_t *subi_list; /* List of sub-installers running */
  573. long error;
  574. long prev_error;
  575. char dirname[255];
  576. int install_tag;
  577. int diskmem_iounits;
  578. ifxproduct_t *prod;
  579. status_t * status;
  580. int build_sqlhost;
  581. struct user_info user_req;
  582. iad_machine_t machineconfig;
  583. iad_disk_t *fs_disk;
  584. instance_t *head_instance;
  585. instance_t *curr_instance;
  586. servicesInfo_t services;
  587. #ifndef WIN32
  588. mode_t config_perm;
  589. mode_t chunk_perm;
  590. mode_t directory_perm;
  591. #endif /* WIN32 */
  592. #ifdef DISCOVERY_ENABLED
  593. serverdiscovery_t *instances_discovered;
  594. #endif
  595. };
  596. enum server_type
  597. {
  598. IAD_SERVER_OLTP = 0,
  599. IAD_SERVER_DSS,
  600. IAD_SERVER_MIXED
  601. };
  602. enum autocfg_type
  603. {
  604. IAD_SET_MAXCPU = 0,
  605. IAD_SET_MAXMEM,
  606. IAD_SET_MAXDISK,
  607. IAD_SET_MAXCPU_PCT,
  608. IAD_SET_MAXMEM_PCT,
  609. IAD_SET_MAXDISK_PCT,
  610. IAD_SET_MIRROR_ALL,
  611. IAD_SET_MIRROR_CRITICAL,
  612. IAD_SET_SBSPACE_ENABLED,
  613. IAD_SET_SBSPACE_LOGOPT,
  614. IAD_SET_RTOPOLICY,
  615. IAD_SET_INSTANCEPATH,
  616. IAD_SET_MIRRORPATH,
  617. IAD_SET_MAXUSERS,
  618. IAD_SET_MAXDSUSERS,
  619. IAD_SET_SERVERTYPE,
  620. IAD_SET_SERVERNUM,
  621. IAD_SET_TXNSUPPORT,
  622. IAD_SET_ROOTPATH,
  623. IAD_SET_LLOGPATH,
  624. IAD_SET_PLOGPATH,
  625. IAD_SET_DATAPATH,
  626. IAD_SET_SLOBPATH,
  627. IAD_SET_TEMPPATH,
  628. IAD_SET_FINALELEMENT = 49
  629. };
  630. enum disk_alloc_types
  631. {
  632. IAD_ROOTDBS = 0,
  633. IAD_PLOGDBS,
  634. IAD_LLOGDBS,
  635. IAD_DATADBS,
  636. IAD_SLOBDBS,
  637. IAD_TEMPDBS
  638. };
  639. enum _iad_rec_types
  640. {
  641. IAD_AUTO_BUFFERSIZE = 0,
  642. IAD_AUTO_SHMVIRTSIZE = 1,
  643. IAD_AUTO_SHMADD = 2,
  644. IAD_AUTO_VPMEMCACHE = 3,
  645. IAD_AUTO_TOTALMEMORY = 4,
  646. IAD_AUTO_CLEANERS = 5,
  647. IAD_AUTO_LOCKS = 6,
  648. IAD_AUTO_LISTENTHREADS = 7,
  649. IAD_AUTO_LRUS = 8,
  650. IAD_AUTO_TOTAL_DISK_SIZE = 19,
  651. IAD_AUTO_ROOTDBS_SIZE = 20,
  652. IAD_AUTO_PLOGDBS_SIZE = 21,
  653. IAD_AUTO_PLOG_SIZE = 22,
  654. IAD_AUTO_LLOGDBS_SIZE = 23,
  655. IAD_AUTO_LLOGS_NUM = 24,
  656. IAD_AUTO_LLOGS_SIZE = 25,
  657. IAD_AUTO_DATADBS_SIZE = 26,
  658. IAD_AUTO_DATADBS_NUM = 27,
  659. IAD_AUTO_SBSPACE_SIZE = 28,
  660. IAD_AUTO_SBSPACE_NUM = 29,
  661. IAD_AUTO_TEMPDBS_SIZE = 30,
  662. IAD_AUTO_TEMPDBS_NUM = 31,
  663. IAD_AUTO_NUMCPUS = 32,
  664. IAD_AUTO_ROOTDBS_PATH = 50,
  665. IAD_AUTO_LLOGDBS_PATH = 51,
  666. IAD_AUTO_PLOGDBS_PATH = 52,
  667. IAD_AUTO_DATADBS_PATH = 53,
  668. IAD_AUTO_SLOBDBS_PATH = 54,
  669. IAD_AUTO_TEMPDBS_PATH = 55
  670. };
  671. EXPORT int STDCALL finish(install_t *is);
  672. /* Given the absolute path, populate disk struct with file
  673. system information */
  674. EXPORT int STDCALL iadSetFileSysInfo(install_t *install_struct, const char *path, size_t size);
  675. EXPORT int STDCALL iadGetFileSysInfo(install_t *install_struct, const char *path);
  676. EXPORT size_t STDCALL iadGetFileSysFreespace(install_t *install_struct, const char *path);
  677. EXPORT size_t STDCALL iadGetFileSysRequiredspace(install_t *install_struct, const char *path);
  678. EXPORT int STDCALL iadSetDiskMemUnits(install_t *install_struct, const char *units_str);
  679. /* Convert size in string format to size_t */
  680. extern size_t STDCALL iadSizeStrToSize_t(install_t* install_struct, const char *size);
  681. extern void initMachInfo(install_t *install_struct);
  682. /* server discovery code */
  683. extern void initDiscovery(install_t *install_struct);
  684. extern char ** parseCfgAliases(install_t *install_struct, const char *servername, char *aliases, int *alias_cnt);
  685. /* Copy source string to destination string */
  686. extern int STDCALL iadStrDup(char **dest, const char *source);
  687. /* Check that the provided path is valid */
  688. extern int STDCALL validatePath(const char *path);
  689. /* Given a path of a proposed instance to be created, check it for
  690. possible informix chunk files
  691. Input: the path to be checked
  692. Returns:
  693. - IAD_E_PATH_NOT_EXISTS if not path found (expected for new install)
  694. - IAD_E_PATHERROR if some other problem is detected, like the path is found
  695. but its a file or other entity instead of a directory
  696. - The number of possible chunk files found (0 meaning ok)
  697. - Positive non-zero number indicates that the path may contain chunk
  698. files and shouldn't be used
  699. */
  700. extern int STDCALL iadCheckInstancePath(install_t *is, const char *instance_path);
  701. /* Given an absolute path get the directory string */
  702. extern int STDCALL iadDirFromPath(install_t *is, const char *path, char **dirPath);
  703. /* Given a path, stripping the path from the end,
  704. get the first valid parent.
  705. Returns:
  706. - the first occurrence of valid subpath found.
  707. - path if path represents an existing directory
  708. - NULL if path does not contain valid subpath,
  709. */
  710. extern char * STDCALL iadGetValidSubPath(install_t *is, const char *path);
  711. /* Given an absolute file path, create the file.
  712. directories in path if not present
  713. Returns:
  714. - IAD_E_NOERROR: file was successfully created
  715. - IAD_E_INVALID_PARAMETER: filename is NULL
  716. - IAD_E_FILE_OPEN_ERROR: file could not be created
  717. - IAD_E_PATH_ERROR: file path could not be created
  718. */
  719. extern void STDCALL iadXlateFilePathInplace(install_t *install_struct, char *filepath, size_t maxpath);
  720. extern int STDCALL iadCreateFile(install_t *install_struct, const char *filename);
  721. extern int STDCALL iadGetEnvironmentVariable(const char *lpName, char *lpBuffer, int size);
  722. #ifndef WIN32
  723. /* Set the properties of a given path. Path can be passed as a file,
  724. a directory or absolute path to the file or directory
  725. mode - set to disable the ownership of files.
  726. owner - owner property for the path. This can be NULL. If this is
  727. NULL, owner property will not be changed for path
  728. group - group property for the path. This can be NULL. If this is
  729. NULL, group property will not be changed for path
  730. Returns:
  731. - IAD_E_NOERROR: ownership and/or permission was successfully set
  732. - IAD_E_INVALID_PARAMETER: path is NULL
  733. - IAD_E_INVALID_PATH: path does not exist or is invalid
  734. - IAD_E_GROUPINFO_NOT_FOUND: group passed does not exist
  735. - IAD_E_USERINFO_NOT_FOUND: user passed does not exist
  736. - IAD_E_FAIL: unable to set ownership and/or permissions
  737. */
  738. extern int STDCALL iadSetFileProperties(int mode, const char *path, const char *owner, const char *group, mode_t perms);
  739. #endif
  740. /* Given a pathname, this function returns the filename or the parent
  741. path depending on RETURN_FILENAME mode or RETURN_PATHNAME mode
  742. Returns:
  743. - filename string or path string depending on mode passed
  744. - throws an assertion if invalid mode or null filename is passed
  745. */
  746. extern char * STDCALL iadGetNameFromPath(install_t *is, const char *filename, int mode);
  747. /* Get the version of an informix installation
  748. Inputs:
  749. Install_t (struct), Path (informixdir), crfile (name of cr file IIF-cr, IDS2000-cr, etc)
  750. Returns:
  751. - version string
  752. - NULL if version can not be extracted
  753. */
  754. extern char * STDCALL iadGetVersionFromCRFile(install_t *install_struct, const char *path, const char *crfile);
  755. /* Check to see if product can be upgraded
  756. *
  757. * Inputs:
  758. * Install_t (struct), currVer (Current version of product being installed), informixdir
  759. * Returns (int):
  760. * IAD_I_NO_INSTALLATION : indicates there is not installation present
  761. * IAD_I_UPGRADEABLE : indicates that product can be upgraded
  762. * IAD_E_INVALID_UPGRADE : indicates that product can not be upgraded
  763. *
  764. */
  765. extern int STDCALL iadIsSqlhostFileReq(install_t *install_struct);
  766. extern int STDCALL iadIsServerUpgradeable(install_t *install_struct, const char* currVer, const char *informixdir);
  767. extern int STDCALL iadIsCSDKUpgradeable(install_t *install_struct, const char* currVer, const char *informixdir);
  768. extern int STDCALL iadIsConnUpgradeable(install_t *install_struct, const char* currVer, const char *informixdir);
  769. /* Get all instances related to an installation
  770. Returns:
  771. - list of instances
  772. - server count
  773. - NULL in the event of an error
  774. */
  775. extern char ** STDCALL iadGetInstallationInstances(install_t *is, const char *path, int *server_count);
  776. #ifdef WIN32
  777. /* Acquire all subkeys for a given registry key. When the function
  778. returns, list rs will be populated with subkeys information
  779. Inputs:
  780. - rootKey: Parent key to registry specified by keyPath. It can also
  781. be one of HKEY_CLASSES_ROOT, HKEY_CURRENT_CONFIG,
  782. HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE,
  783. HKEY_PERFORMANCE_DATA, HKEY_USERS
  784. - keyPath: Registry path specifying the location of the key for
  785. which information is to be acquired.
  786. - rs: Linked list containing subkeys for rs.
  787. - node: anything else, 32, 64: default, 32 node or 64 node
  788. Returns:
  789. - IAD_E_NOERROR: No Error. Successful completion
  790. - IAD_E_REGISTRY_ERROR: Error in registry query or registry
  791. values enumeration.
  792. - IAD_E_MEMORY_ALLOCATION_FAILURE: Memory allocation failure.
  793. */
  794. EXPORT int STDCALL iadQueryRegSubKeys(HKEY rootKey, LPCSTR keyPath, IAD_REGSUBKEYS **rs, iad_registery_view node);
  795. EXPORT void STDCALL iadFreeRegSubKeys(IAD_REGSUBKEYS **rs);
  796. /* Acquire information of Name/Type/Data associated with a registry
  797. key. When the function returns, list rd will be populated with
  798. information on keyPath
  799. Inputs:
  800. - rootKey: Parent key to registry specified by keyPath. It can also
  801. be one of HKEY_CLASSES_ROOT, HKEY_CURRENT_CONFIG,
  802. HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE,
  803. HKEY_PERFORMANCE_DATA, HKEY_USERS
  804. - keyPath: Registry path specifying the location of the key for
  805. which information is to be acquired.
  806. - rs: Linked list containing Name/Type/Data information about rd.
  807. - node: anything else, 32, 64: default, 32 node or 64 node
  808. Returns:
  809. - IAD_E_NOERROR: No Error. Successful completion
  810. - IAD_E_REGISTRY_ERROR: Error in registry query or registry
  811. values enumeration.
  812. - IAD_E_MEMORY_ALLOCATION_FAILURE: Memory allocation failure.
  813. */
  814. EXPORT int STDCALL iadQueryRegData(HKEY rootKey, LPCTSTR keyPath, IAD_REGDATA **rd, iad_registery_view node);
  815. EXPORT void STDCALL iadFreeRegData(IAD_REGDATA **rd);
  816. /* Given a registry key and an associated regsitry Value, this
  817. function retieves the Data for the Value
  818. Inputs:
  819. - rootHive: Enum type that represents the registry root hive.
  820. See definition for IAD_HKEY enum type
  821. - keyPath: Registry path specifying location of key for which info
  822. is to be acquired
  823. - regName: Registry Value for which Data is to be acquired
  824. - node: anything else, 32, 64: default, 32 node or 64 node
  825. Returns;
  826. - the data associated with the name is returned upon success
  827. - NULL is returned if data could not be retrieved
  828. */
  829. extern char * STDCALL iadGetRegDataFromName(IAD_HKEY rootHive, const char *keyPath, const char *regName, iad_registery_view node);
  830. /* Copy a source registry key to a target registry key
  831. Inputs:
  832. - source_key: key to be copied
  833. - dest_key: key to be copied to
  834. Returns:
  835. - IAD_E_NOERROR: No Error. Registry key was successfully copied
  836. */
  837. extern int STDCALL CopyRegTree(HKEY dest_key, HKEY source_key);
  838. /* Based on user and server information in the install structure,
  839. this function creates the informix service with the necessary
  840. properties on the system. The necessary functions that populate
  841. install structure with information needed to create the service
  842. must be called prior to calling this function.
  843. Call heirarchy:
  844. - iadAddUserGroupRequired(): Set up structure for user. User
  845. information will be used for service creation.
  846. - iadSetEnvironment(): Set INFORMIXDIR
  847. - iadSetEnvironment(): Set INFORMIXSERVER
  848. Inputs:
  849. - is: install structure. Structure will have been prepopulated
  850. with properties that the service will be created with.
  851. Returns:
  852. - IAD_E_STRUCTURE_NOT_INITIALIZED: install structure has not been
  853. initialized. Therefore memory has not been allocated for it.
  854. - IAD_E_NULLPOINTER : The instance structure with the service will be
  855. created has not been defined. Instance structure is null
  856. : Service name (INFORMIXSERVER) has not been defined
  857. : INFORMIXDIR has not been defined
  858. : User account/password with which to create
  859. service has not been defined in the install
  860. structure
  861. - IAD_E_INCORRECT_PASSWORD: User password is incorrect
  862. - IAD_E_INVALID_PARAMETER: Service already exists
  863. - IAD_E_FAIL: All other errors. See log
  864. */
  865. EXPORT int STDCALL iadDeployWindowsService(install_t *is);
  866. /*
  867. removes a service from windows' list of background services name:
  868. internal name of the service (on_informix)
  869. Inputs:
  870. - is: Install structure
  871. - name: Windows service name
  872. Returns:
  873. - IAD_E_NULLPOINTER if name is NULL
  874. - IAD_E_FAIL if an error occurs in the windows API;
  875. the return of GetLastError is printed to stdout
  876. - IAD_E_INVALID_PARAMETER if no service exists with the specified name
  877. */
  878. EXPORT int STDCALL iadWinServiceDelete(install_t *is, const char *name);
  879. #endif
  880. EXPORT int STDCALL iadSetInstallType(install_t*, int);
  881. EXPORT int STDCALL deployInstallation(install_t *install_struct);
  882. EXPORT int STDCALL iadSetInstallModeNoSQL(install_t *is);
  883. EXPORT int STDCALL iadUnSetInstallModeNoSQL(install_t *is);
  884. EXPORT int STDCALL iadSetInstallModePrivate(install_t *is);
  885. EXPORT install_t *STDCALL init_API(int mode, PRODUCT_ID prod, const char *fullProdName, const char *fullVersion);
  886. EXPORT install_t *STDCALL initInstallAPI(int mode, PRODUCT_ID prod, const char *fullProdName, const char *fullVersion, const char *log_file, const char *dbg_file, int dbg_sev);
  887. EXPORT int STDCALL setupIATrace(const char *log_file, const char *dbg_file, int dbg_sev);
  888. EXPORT int STDCALL iadGetErrorCode();
  889. EXPORT char* STDCALL iadGetErrorText();
  890. EXPORT int STDCALL iadSetInstallDir(install_t* install_struct, const char *pathname);
  891. extern int iadGetTrueFalseProperty(const char *value);
  892. extern int initAutoCfg(instance_t *inst);
  893. extern void
  894. iadSetError(
  895. int rc,
  896. char *file_name,
  897. int line_number,
  898. char *format,
  899. ...
  900. );
  901. extern void
  902. iadSetOSError(
  903. int rc,
  904. char *file_name,
  905. int line_number,
  906. int os_error,
  907. char *format,
  908. ...
  909. );
  910. extern int iadGetOSErrorNumber();
  911. EXPORT long STDCALL iadGetRecommendation(install_t *inst, int type);
  912. EXPORT char* STDCALL iadGetRecommendationString(install_t *inst, int type);
  913. EXPORT int STDCALL iadCalculateRecommendation(install_t *inst);
  914. EXPORT int STDCALL iadCheckforInstance(install_t *inst, const char *servername, int servernum);
  915. EXPORT int STDCALL iadCreateServerNum(install_t *inst);
  916. EXPORT int STDCALL iadCheckAliasList(install_t *inst, const char *alias);
  917. EXPORT int STDCALL iadLoadRecommendation(install_t *inst);
  918. EXPORT int STDCALL iadUpdateRecommendation(install_t *inst, int type, const char *value);
  919. EXPORT int STDCALL iadLoadDefaultConfig(install_t *inst);
  920. EXPORT int STDCALL iadSetAutoConfig(install_t *inst, int type, const char *value);
  921. /*
  922. *iadCompareVers function
  923. *input: char * ver1, char * ver2 (example: 11.70.FC1W1)
  924. *return: int
  925. *return code explanation
  926. *0:Verstion Strings are equal
  927. *1:String 1 greater than String 2
  928. *2:String 2 greater than String 1
  929. *-2:Invalid String
  930. *-3:System out of memory
  931. *-4:Special builds, which can't be compared
  932. *Note: Beta < Release build < Special build < PID < (PID + speical build)
  933. *Example: 11.70.FC1B1 < 11.70.FC1 < 11.70.FC1X1 < 11.70.FC1W1 < 11.70.FC1W1X1
  934. */
  935. EXPORT int STDCALL iadCompareVers(const char* version1, const char *version2);
  936. EXPORT int STDCALL iadDeployWindowsService(install_t *is);
  937. EXPORT int STDCALL iadWinServiceDelete(install_t *is, const char *name);
  938. /*
  939. *extractVersInfo function
  940. *input: char * ver1 (example: 11.70.FC1W1)
  941. *return: verInfo (Struct) that contains version specific information
  942. *such as major version, minor version, FixPack Version.
  943. *Also, verifies if version is Beta, PID and/or Special build.
  944. */
  945. EXPORT verInfo STDCALL iadExtractVersInfo(const char* version1);
  946. extern char* iad_strupshift(const char *value);
  947. int test_write_speed(install_t *is, iad_disk_t *dp, int fd, off_t measure_size, int measure);
  948. int test_read_speed(install_t *is, iad_disk_t *dp, int fd, off_t measure_size, int measure);
  949. #if defined(NT)
  950. extern LPCSTR WideToString(LPWSTR wideStr);
  951. #endif
  952. #endif /* API_API_INCLUDED */