1 | /************************************************** |
2 | * ODBCINSTSetProperty |
3 | * |
4 | ************************************************** |
5 | * This code was created by Peter Harvey @ CodeByDesign. |
6 | * Released under LGPL 28.JAN.99 |
7 | * |
8 | * Contributions from... |
9 | * ----------------------------------------------- |
10 | * Peter Harvey - pharvey@codebydesign.com |
11 | **************************************************/ |
12 | #include <config.h> |
13 | #include <odbcinstext.h> |
14 | |
15 | int ODBCINSTSetProperty( HODBCINSTPROPERTY hFirstProperty, char *pszProperty, char *pszValue ) |
16 | { |
17 | char szError[LOG_MSG_MAX+1]; |
18 | HODBCINSTPROPERTY hCurProperty; |
19 | |
20 | /* SANITY CHECKS */ |
21 | if ( hFirstProperty == NULL ) |
22 | { |
23 | inst_logPushMsg( __FILE__, __FILE__, __LINE__, LOG_CRITICAL, ODBC_ERROR_GENERAL_ERR, "Invalid property list handle" ); |
24 | return ODBCINST_ERROR; |
25 | } |
26 | if ( pszProperty == NULL ) |
27 | { |
28 | inst_logPushMsg( __FILE__, __FILE__, __LINE__, LOG_CRITICAL, ODBC_ERROR_GENERAL_ERR, "Invalid Property Name" ); |
29 | return ODBCINST_ERROR; |
30 | } |
31 | if ( pszValue == NULL ) |
32 | { |
33 | inst_logPushMsg( __FILE__, __FILE__, __LINE__, LOG_CRITICAL, ODBC_ERROR_GENERAL_ERR, "Invalid Value buffer" ); |
34 | return ODBCINST_ERROR; |
35 | } |
36 | |
37 | /* FIND pszProperty */ |
38 | for ( hCurProperty = hFirstProperty; hCurProperty != NULL; hCurProperty = hCurProperty->pNext ) |
39 | { |
40 | if ( strcasecmp( pszProperty, hCurProperty->szName ) == 0 ) |
41 | { |
42 | /* CHANGE IT */ |
43 | strncpy( hCurProperty->szValue, pszValue, INI_MAX_PROPERTY_VALUE ); |
44 | return ODBCINST_SUCCESS; |
45 | } |
46 | } |
47 | |
48 | sprintf( szError, "Could not find property (%s)" , pszProperty ); |
49 | inst_logPushMsg( __FILE__, __FILE__, __LINE__, LOG_WARNING, ODBC_ERROR_GENERAL_ERR, szError ); |
50 | |
51 | return ODBCINST_ERROR; |
52 | } |
53 | |
54 | int ODBCINSTAddProperty( HODBCINSTPROPERTY hFirstProperty, char *pszProperty, char *pszValue ) |
55 | { |
56 | HODBCINSTPROPERTY hNew; |
57 | |
58 | hNew = (HODBCINSTPROPERTY)malloc( sizeof(ODBCINSTPROPERTY) ); |
59 | memset(hNew, 0, sizeof(ODBCINSTPROPERTY)); |
60 | hNew->nPromptType = ODBCINST_PROMPTTYPE_HIDDEN; |
61 | hNew->pNext = NULL; |
62 | hNew->bRefresh = 0; |
63 | hNew->hDLL = hFirstProperty->hDLL; |
64 | hNew->pWidget = NULL; |
65 | hNew->pszHelp = NULL; |
66 | hNew->aPromptData = NULL; |
67 | strcpy(hNew->szName, pszProperty ); |
68 | strcpy( hNew->szValue, pszValue ); |
69 | |
70 | /* |
71 | * add to end of list |
72 | */ |
73 | |
74 | while ( hFirstProperty -> pNext ) |
75 | { |
76 | hFirstProperty = hFirstProperty -> pNext; |
77 | } |
78 | |
79 | hNew -> pNext = NULL; |
80 | hFirstProperty -> pNext = hNew; |
81 | |
82 | return 0; |
83 | } |
84 | |