
Go to the source code of this file.
Defines | |
| #define | PINCODE_MIN_LENGTH 4 |
| #define | PINCODE_MAX_LENGTH 9 |
Functions | |
| int | shell_exec (const char *cmd) |
| const char * | get_sysset_macAddress (int offset) |
| const char * | get_wired_macAddress (void) |
| const char * | get_wireless_macAddress (void) |
| const char * | get_sysset_product_id (void) |
| gint | sysset_read_pincode_onoff (gboolean *enbale) |
| gint | sysset_write_pincode_onoff (gboolean enable) |
| gint | sysset_read_pincode_string (gchar *pincode) |
| gint | sysset_write_pincode_string (const gchar *pincode) |
| gboolean | sysset_is_pincode_empty () |
| const char * | get_sysset_fa_model (void) |
| int | get_sysset_fa_region (void) |
| const char * | get_sysset_fa_oem_code (void) |
| const char * | get_sysset_fa_country_code (void) |
| int | get_sysset_pa_board_revision (void) |
| const char * | get_sysset_epd_id (void) |
| const char* get_sysset_epd_id | ( | void | ) |
Definition at line 1015 of file system.c.
01016 { 01017 static char dm_epd_id[9]; 01018 01019 snprintf(dm_epd_id, 9, "%s%s", get_waveform_type(), get_waveform_version()); 01020 return dm_epd_id; 01021 }

| const char* get_sysset_fa_country_code | ( | void | ) |
Definition at line 747 of file system.c.
00748 { 00749 FILE *POUT = 0; 00750 int nProcessRet = 0; 00751 00752 int n; 00753 static char fa_country_code[4] = ""; 00754 00755 POUT = popen("sysset -r -a 55 -l 3", "r"); 00756 if (POUT == NULL) 00757 { 00758 ST_ERRORPRINTF("Could not read FA country-code"); 00759 } 00760 else 00761 { 00762 int nChar; 00763 int index = 0; 00764 char szBuffer[PROCESS_BUFFER_MAX + 1]; 00765 00766 while (((nChar = getc(POUT)) != EOF) && (index < PROCESS_BUFFER_MAX)) 00767 { 00768 szBuffer[index] = (char)nChar; 00769 index++; 00770 } 00771 szBuffer[index] = '\0'; 00772 ST_LOGPRINTF("echoed %s", szBuffer); 00773 00774 nProcessRet = pclose(POUT); 00775 if (WIFEXITED(nProcessRet)) 00776 { 00777 if (WEXITSTATUS(nProcessRet) == 0) 00778 { 00779 ST_LOGPRINTF("pclose returned %d", WEXITSTATUS(nProcessRet)); 00780 00781 // strip trailing spaces and new-line 00782 n = strlen(szBuffer); 00783 while ( n > 0 && isspace( szBuffer[n-1] ) ) 00784 { 00785 n--; 00786 szBuffer[n] = '\0'; 00787 } 00788 00789 // store FA country-code 00790 if (n == 0) 00791 { 00792 snprintf(fa_country_code, sizeof(fa_country_code), "000"); 00793 } 00794 else if (n == 3) 00795 { 00796 snprintf(fa_country_code, sizeof(fa_country_code), "%s", szBuffer); 00797 } 00798 else 00799 { 00800 ST_ERRORPRINTF("invalid fa_country_code from sysset [%s]", szBuffer); 00801 } 00802 } 00803 else 00804 { 00805 ST_ERRORPRINTF("pclose returned %d. Error retrieving FA country-code", WEXITSTATUS(nProcessRet)); 00806 } 00807 } 00808 else 00809 { 00810 ST_ERRORPRINTF("pclose did not exit normally"); 00811 } 00812 } 00813 00814 ST_LOGPRINTF("return [%s]", fa_country_code); 00815 return fa_country_code; 00816 }
| const char* get_sysset_fa_model | ( | void | ) |
Definition at line 561 of file system.c.
00562 { 00563 FILE *POUT = 0; 00564 int nProcessRet = 0; 00565 00566 int i; 00567 static char fa_model[33] = ""; 00568 00569 POUT = popen("sysset -r -a 16 -l 32", "r"); 00570 if (POUT == NULL) 00571 { 00572 ST_ERRORPRINTF("Could not read FA model-id"); 00573 } 00574 else 00575 { 00576 int nChar; 00577 int index = 0; 00578 char szBuffer[PROCESS_BUFFER_MAX + 1]; 00579 00580 while (((nChar = getc(POUT)) != EOF) && (index < PROCESS_BUFFER_MAX)) 00581 { 00582 szBuffer[index] = (char)nChar; 00583 index++; 00584 } 00585 szBuffer[index] = '\0'; 00586 ST_LOGPRINTF("echoed %s", szBuffer); 00587 00588 nProcessRet = pclose(POUT); 00589 if (WIFEXITED(nProcessRet)) 00590 { 00591 if (WEXITSTATUS(nProcessRet) == 0) 00592 { 00593 ST_LOGPRINTF("pclose returned %d", WEXITSTATUS(nProcessRet)); 00594 00595 // store FA model-id 00596 snprintf(fa_model, sizeof(fa_model), "%s", szBuffer); 00597 00598 // strip trailing spaces 00599 for ( i = strlen(fa_model) - 1 ; 00600 i > 0 && fa_model[i] == ' ' ; 00601 i-- ) 00602 { 00603 fa_model[i] = '\0'; 00604 } 00605 } 00606 else 00607 { 00608 ST_ERRORPRINTF("pclose returned %d. Error retrieving FA model-id", WEXITSTATUS(nProcessRet)); 00609 } 00610 } 00611 else 00612 { 00613 ST_ERRORPRINTF("pclose did not exit normally"); 00614 } 00615 } 00616 00617 ST_LOGPRINTF("return [%s]", fa_model); 00618 return fa_model; 00619 }
| const char* get_sysset_fa_oem_code | ( | void | ) |
Definition at line 675 of file system.c.
00676 { 00677 FILE *POUT = 0; 00678 int nProcessRet = 0; 00679 00680 int n; 00681 static char fa_oem_code[4] = ""; 00682 00683 POUT = popen("sysset -r -a 52 -l 3", "r"); 00684 if (POUT == NULL) 00685 { 00686 ST_ERRORPRINTF("Could not read FA oem-code"); 00687 } 00688 else 00689 { 00690 int nChar; 00691 int index = 0; 00692 char szBuffer[PROCESS_BUFFER_MAX + 1]; 00693 00694 while (((nChar = getc(POUT)) != EOF) && (index < PROCESS_BUFFER_MAX)) 00695 { 00696 szBuffer[index] = (char)nChar; 00697 index++; 00698 } 00699 szBuffer[index] = '\0'; 00700 ST_LOGPRINTF("echoed %s", szBuffer); 00701 00702 nProcessRet = pclose(POUT); 00703 if (WIFEXITED(nProcessRet)) 00704 { 00705 if (WEXITSTATUS(nProcessRet) == 0) 00706 { 00707 ST_LOGPRINTF("pclose returned %d", WEXITSTATUS(nProcessRet)); 00708 00709 // strip trailing spaces and new-line 00710 n = strlen(szBuffer); 00711 while ( n > 0 && isspace( szBuffer[n-1] ) ) 00712 { 00713 n--; 00714 szBuffer[n] = '\0'; 00715 } 00716 00717 // store FA oem-code 00718 if (n == 0) 00719 { 00720 snprintf(fa_oem_code, sizeof(fa_oem_code), "000"); 00721 } 00722 else if (n == 3) 00723 { 00724 snprintf(fa_oem_code, sizeof(fa_oem_code), "%s", szBuffer); 00725 } 00726 else 00727 { 00728 ST_ERRORPRINTF("invalid fa_oem_code from sysset [%s]", szBuffer); 00729 } 00730 } 00731 else 00732 { 00733 ST_ERRORPRINTF("pclose returned %d. Error retrieving FA oem-code", WEXITSTATUS(nProcessRet)); 00734 } 00735 } 00736 else 00737 { 00738 ST_ERRORPRINTF("pclose did not exit normally"); 00739 } 00740 } 00741 00742 ST_LOGPRINTF("return [%s]", fa_oem_code); 00743 return fa_oem_code; 00744 }
| int get_sysset_fa_region | ( | void | ) |
Definition at line 622 of file system.c.
00623 { 00624 FILE *POUT = 0; 00625 int nProcessRet = 0; 00626 00627 static int fa_region = 0; 00628 00629 POUT = popen("sysset -r -b -a 50 -l 2", "r"); 00630 if (POUT == NULL) 00631 { 00632 ST_ERRORPRINTF("Could not read FA region-code"); 00633 } 00634 else 00635 { 00636 int nChar; 00637 int index = 0; 00638 char szBuffer[PROCESS_BUFFER_MAX + 1]; 00639 00640 while (((nChar = getc(POUT)) != EOF) && (index < PROCESS_BUFFER_MAX)) 00641 { 00642 szBuffer[index] = (char)nChar; 00643 index++; 00644 } 00645 szBuffer[index] = '\0'; 00646 ST_LOGPRINTF("echoed %s", szBuffer); 00647 00648 nProcessRet = pclose(POUT); 00649 if (WIFEXITED(nProcessRet)) 00650 { 00651 if (WEXITSTATUS(nProcessRet) == 0) 00652 { 00653 ST_LOGPRINTF("pclose returned %d", WEXITSTATUS(nProcessRet)); 00654 00655 // store FA region-code 00656 if (szBuffer[0] == '0' && szBuffer[1] == 'x') 00657 { 00658 fa_region = atoi(szBuffer + 2); 00659 } 00660 } 00661 else 00662 { 00663 ST_ERRORPRINTF("pclose returned %d. Error retrieving FA region-code", WEXITSTATUS(nProcessRet)); 00664 } 00665 } 00666 else 00667 { 00668 ST_ERRORPRINTF("pclose did not exit normally"); 00669 } 00670 } 00671 return fa_region; 00672 }
| const char* get_sysset_macAddress | ( | int | offset | ) |
Definition at line 128 of file system.c.
00129 { 00130 FILE *POUT = 0; 00131 int nProcessRet = 0; 00132 char cmd[32]; 00133 00134 static char mac_address[MAC_LENGTH + 6] = " - - - - - "; 00135 00136 sprintf(cmd, "sysset -r -b -a %d -l 6", offset); 00137 POUT = popen(cmd, "r"); 00138 if (POUT == NULL) 00139 { 00140 ST_ERRORPRINTF("Could not read EUI64"); 00141 } 00142 else 00143 { 00144 int nChar; 00145 int index = 0; 00146 char szBuffer[PROCESS_BUFFER_MAX + 1]; 00147 00148 while (((nChar = getc(POUT)) != EOF) && (index < PROCESS_BUFFER_MAX)) 00149 { 00150 szBuffer[index] = (char)nChar; 00151 index++; 00152 } 00153 szBuffer[index] = '\0'; 00154 ST_LOGPRINTF("echoed %s", szBuffer); 00155 00156 nProcessRet = pclose(POUT); 00157 if (WIFEXITED(nProcessRet)) 00158 { 00159 if (WEXITSTATUS(nProcessRet) == 0) 00160 { 00161 int nLen; 00162 00163 // Normal case 00164 // 00165 // The string as retrieved from sysset is 15 (MAX_HEX_DECORATION+MAC_LENGTH+1) characters long. 00166 // e.g 0x00167c000000\n 00167 // The first two (MAX_HEX_DECORATION) characters need to be removed 00168 // and dashes inserted to separate byte values 00169 // resulting in: 00-16-7c-00-00-00 00170 // 00171 ST_LOGPRINTF("pclose returned %d", WEXITSTATUS(nProcessRet)); 00172 nLen = strlen(szBuffer); 00173 if (nLen != MAC_LENGTH + 2 + 1) 00174 { 00175 ST_ERRORPRINTF("Wrong length [%d] of MAC address [%s]", nLen, szBuffer); 00176 } 00177 else 00178 { 00179 char *cp1 = mac_address; 00180 char *cp2 = szBuffer + MAC_HEX_DECORATION; 00181 for (index = 0; index < MAC_LENGTH; index += 2) 00182 { 00183 // m.s. nibble 00184 *cp1 = tolower(*cp2); 00185 cp1++; 00186 cp2++; 00187 00188 // l.s. nibble 00189 *cp1 = tolower(*cp2); 00190 cp1++; 00191 cp2++; 00192 00193 // skip byte separator 00194 cp1++; 00195 } 00196 } 00197 } 00198 else 00199 { 00200 ST_ERRORPRINTF("pclose returned %d. Error retrieving MAC", WEXITSTATUS(nProcessRet)); 00201 } 00202 } 00203 else 00204 { 00205 ST_ERRORPRINTF("pclose did not exit normally"); 00206 } 00207 } 00208 00209 ST_LOGPRINTF("return [%s]", mac_address); 00210 return mac_address; 00211 }
| int get_sysset_pa_board_revision | ( | void | ) |
Definition at line 819 of file system.c.
00820 { 00821 FILE *POUT = 0; 00822 int nProcessRet = 0; 00823 00824 static int pa_board_revision = 0; 00825 00826 POUT = popen("sysset -r -b -a 260 -l 1", "r"); 00827 if (POUT == NULL) 00828 { 00829 ST_ERRORPRINTF("Could not read PA Board-revision"); 00830 } 00831 else 00832 { 00833 int nChar; 00834 int index = 0; 00835 char szBuffer[PROCESS_BUFFER_MAX + 1]; 00836 00837 while (((nChar = getc(POUT)) != EOF) && (index < PROCESS_BUFFER_MAX)) 00838 { 00839 szBuffer[index] = (char)nChar; 00840 index++; 00841 } 00842 szBuffer[index] = '\0'; 00843 ST_LOGPRINTF("echoed %s", szBuffer); 00844 00845 nProcessRet = pclose(POUT); 00846 if (WIFEXITED(nProcessRet)) 00847 { 00848 if (WEXITSTATUS(nProcessRet) == 0) 00849 { 00850 ST_LOGPRINTF("pclose returned %d", WEXITSTATUS(nProcessRet)); 00851 00852 // store PA Board-revision 00853 if (szBuffer[0] == '0' && szBuffer[1] == 'x') 00854 { 00855 pa_board_revision = atoi(szBuffer + 2); 00856 } 00857 } 00858 else 00859 { 00860 ST_ERRORPRINTF("pclose returned %d. Error retrieving PA board-revision", WEXITSTATUS(nProcessRet)); 00861 } 00862 } 00863 else 00864 { 00865 ST_ERRORPRINTF("pclose did not exit normally"); 00866 } 00867 } 00868 return pa_board_revision; 00869 }
| const char* get_sysset_product_id | ( | void | ) |
Definition at line 213 of file system.c.
00214 { 00215 return get_sysset_macAddress(262); 00216 }

| const char* get_wired_macAddress | ( | void | ) |
Definition at line 223 of file system.c.
00224 { 00225 char *cp; 00226 FILE *POUT = 0; 00227 int nProcessRet = 0; 00228 00229 static char mac_address[MAC_LENGTH + 6] = " - - - - - "; 00230 00231 00232 POUT = popen("/usr/bin/wired.sh mac | tail -1", "r"); 00233 if (POUT == NULL) 00234 { 00235 ST_ERRORPRINTF("Could not read wired MAC address"); 00236 } 00237 else 00238 { 00239 int nChar; 00240 int index = 0; 00241 char szBuffer[PROCESS_BUFFER_MAX + 1]; 00242 00243 while (((nChar = getc(POUT)) != EOF) && (index < PROCESS_BUFFER_MAX)) 00244 { 00245 szBuffer[index] = (char)nChar; 00246 index++; 00247 } 00248 szBuffer[index] = '\0'; 00249 ST_LOGPRINTF("echoed %s", szBuffer); 00250 00251 nProcessRet = pclose(POUT); 00252 if (WIFEXITED(nProcessRet)) 00253 { 00254 if (WEXITSTATUS(nProcessRet) == 0) 00255 { 00256 int nLen; 00257 00258 // Normal case 00259 // 00260 // The string as retrieved from wired.sh 17 (MAC_LENGTH+5+1) characters long. 00261 // e.g 00-16-7c-00-00-00\n 00262 ST_LOGPRINTF("pclose returned %d", WEXITSTATUS(nProcessRet)); 00263 nLen = strlen(szBuffer); 00264 if (nLen != MAC_LENGTH + 5 + 1) 00265 { 00266 ST_ERRORPRINTF("Wrong length [%d] of MAC address [%s]", nLen, szBuffer); 00267 } 00268 else 00269 { 00270 strncpy(mac_address, szBuffer, MAC_LENGTH + 5); 00271 for (cp = mac_address ; *cp ; cp++) 00272 { 00273 *cp = tolower(*cp); 00274 } 00275 } 00276 } 00277 else 00278 { 00279 ST_ERRORPRINTF("pclose returned %d. Error retrieving MAC", WEXITSTATUS(nProcessRet)); 00280 } 00281 } 00282 else 00283 { 00284 ST_ERRORPRINTF("pclose did not exit normally"); 00285 } 00286 } 00287 00288 ST_LOGPRINTF("return [%s]", mac_address); 00289 return mac_address; 00290 }
| const char* get_wireless_macAddress | ( | void | ) |
Definition at line 218 of file system.c.
00219 { 00220 return get_sysset_macAddress(270); 00221 }

| int shell_exec | ( | const char * | cmd | ) |
Definition at line 45 of file system.c.
00046 { 00047 const char *p = cmd; 00048 char *buf = alloca(strlen(cmd) + 1), *bufp = buf; 00049 char *argv[MAX_ARGS + 1]; 00050 int nargs = 0; 00051 int escape = 0, squote = 0, dquote = 0; 00052 int rc; 00053 int i; 00054 00055 if (cmd[0] == 0) 00056 { 00057 errno = ENOENT; 00058 return -1; 00059 } 00060 00061 while (*p) 00062 { 00063 if (escape) 00064 { 00065 *bufp++ = *p; 00066 escape = 0; 00067 } 00068 else 00069 { 00070 switch (*p) 00071 { 00072 case '\\': 00073 escape = 1; 00074 break; 00075 case '"': 00076 if (squote) 00077 *bufp++ = *p; 00078 else 00079 dquote = !dquote; 00080 break; 00081 case '\'': 00082 if (dquote) 00083 *bufp++ = *p; 00084 else 00085 squote = !squote; 00086 break; 00087 case ' ': 00088 if (!squote && !dquote) 00089 { 00090 *bufp = 0; 00091 if (nargs < MAX_ARGS) 00092 argv[nargs++] = strdup(buf); 00093 bufp = buf; 00094 break; 00095 } 00096 default: 00097 *bufp++ = *p; 00098 break; 00099 } 00100 } 00101 p++; 00102 } 00103 00104 if (bufp != buf) 00105 { 00106 *bufp = 0; 00107 if (nargs < MAX_ARGS) 00108 argv[nargs++] = strdup(buf); 00109 } 00110 00111 argv[nargs] = NULL; 00112 rc = execvp(argv[0], argv); 00113 00114 for (i = 0; i < nargs; i++) 00115 free(argv[i]); 00116 00117 return rc; 00118 }
| gboolean sysset_is_pincode_empty | ( | ) |
Definition at line 544 of file system.c.
00545 { 00546 gchar pincode[PINCODE_MAX_LENGTH + 1]; 00547 int nLen; 00548 gboolean empty = FALSE; 00549 00550 sysset_read_pincode_string(pincode); 00551 nLen = strlen(pincode); 00552 if (0 == nLen) 00553 empty = TRUE; 00554 return empty; 00555 }

| gint sysset_read_pincode_onoff | ( | gboolean * | enbale | ) |
Definition at line 298 of file system.c.
00299 { 00300 FILE *POUT = 0; 00301 int nProcessRet = 0; 00302 int nRet = -1; // 0 = ok, -1 = error 00303 00304 if (NULL == enable) 00305 return nRet; 00306 *enable = FALSE; 00307 00308 POUT = popen("sysset -r -a 58 -l 1", "r"); 00309 if (POUT == NULL) 00310 { 00311 ST_ERRORPRINTF("Could not read PINCODE on/off"); 00312 } 00313 else 00314 { 00315 int nChar; 00316 int index = 0; 00317 char szBuffer[100]; 00318 00319 while (((nChar = getc(POUT)) != EOF) && (index < sizeof(szBuffer) - 1)) 00320 { 00321 szBuffer[index] = (char)nChar; 00322 index++; 00323 } 00324 szBuffer[index] = '\0'; 00325 ST_LOGPRINTF("Read PINCODE onoff- echoed %s", szBuffer); 00326 nProcessRet = pclose(POUT); 00327 if (WIFEXITED(nProcessRet)) 00328 { 00329 if (WEXITSTATUS(nProcessRet) == 0) 00330 { 00331 int nLen; 00332 00333 // The string as retrieved by sysset is 1 + 1 (newline) character long. 00334 ST_LOGPRINTF("pclose returned %d", WEXITSTATUS(nProcessRet)); 00335 nLen = strlen(szBuffer); 00336 // it's old sysset version, treat binary 0 as "0" 00337 if (0 == nLen) 00338 { 00339 szBuffer[0] = '0'; 00340 szBuffer[1] = '\n'; 00341 szBuffer[2] = '\0'; 00342 nLen = 2; 00343 } 00344 if (nLen != 2) 00345 { 00346 ST_ERRORPRINTF("Retrieved pincode on/off [%s] wrong length [%d]", szBuffer, nLen); 00347 } 00348 else 00349 { 00350 // remove '\n' 00351 if (szBuffer[nLen - 1] == '\n') 00352 { 00353 nLen = nLen - 1; 00354 szBuffer[nLen] = '\0'; 00355 } 00356 00357 if (strcmp(szBuffer, "0") == 0) 00358 { 00359 *enable = FALSE; 00360 nRet = 0; // ok 00361 ST_LOGPRINTF("Read PINCODE onoff: %d", *enable); 00362 } 00363 else if (strcmp(szBuffer, "1") == 0) 00364 { 00365 *enable = TRUE; 00366 nRet = 0; // ok 00367 ST_LOGPRINTF("Read PINCODE onoff: %d", *enable); 00368 } 00369 else 00370 { 00371 ST_ERRORPRINTF("Retrieved pincode on/off has illegal value: [%s]", szBuffer); 00372 } 00373 } 00374 } 00375 else 00376 { 00377 ST_ERRORPRINTF("pclose returned %d. Error retrieving pincode on/off", WEXITSTATUS(nProcessRet)); 00378 } 00379 } 00380 else 00381 { 00382 ST_ERRORPRINTF("Read PINCODE onoff- pclose did not exit normally"); 00383 } 00384 } 00385 00386 ST_LOGPRINTF("Read PINCODE onoff returned %d", nRet); 00387 return nRet; 00388 }
| gint sysset_read_pincode_string | ( | gchar * | pincode | ) |
Definition at line 412 of file system.c.
00413 { 00414 FILE *POUT = 0; 00415 int nProcessRet = 0; 00416 char string[PINCODE_MAX_LENGTH + 1] = ""; 00417 int nRet = -1; // 0 = ok, -1 = error 00418 00419 if (NULL == pincode) 00420 return nRet; 00421 00422 POUT = popen("sysset -r -b -a 59 -l 4", "r"); 00423 if (POUT == NULL) 00424 { 00425 ST_ERRORPRINTF("Sysset could not read PINCODE"); 00426 } 00427 else 00428 { 00429 int nChar; 00430 int index = 0; 00431 char szBuffer[PROCESS_BUFFER_MAX + 1]; 00432 00433 while (((nChar = getc(POUT)) != EOF) && (index < PROCESS_BUFFER_MAX)) 00434 { 00435 szBuffer[index] = (char)nChar; 00436 index++; 00437 } 00438 szBuffer[index] = '\0'; 00439 ST_LOGPRINTF("Read PINCODE echoed %s", szBuffer); 00440 nProcessRet = pclose(POUT); 00441 if (WIFEXITED(nProcessRet)) 00442 { 00443 if (WEXITSTATUS(nProcessRet) == 0) 00444 { 00445 int nLen; 00446 // 00447 // The string as retrieved from sysset is 11(PINCODE_HEX_DECORATION+PINCODE_LENGTH+1) characters long. 00448 // e.g 0x85F5E0FF\n 00449 // "99999999"<--99999999<--"0x05F5E0FF"<--"0x85F5E0FF\n" 00450 // firstly remove the length of pincode in '0x85F5E0FF\n' 00451 // then, convert hex string to integer, convert the integer to string 00452 // 00453 ST_LOGPRINTF("Read PINCODE-pclose returned %d", WEXITSTATUS(nProcessRet)); 00454 nLen = strlen(szBuffer); 00455 if (nLen != (PINCODE_HEX_DECORATION + PINCODE_LENGTH + 1)) 00456 { 00457 ST_ERRORPRINTF("Wrong length [%d] of PINCODE address [%s]", nLen, szBuffer); 00458 } 00459 else 00460 { 00461 char ch[2]; 00462 int len; 00463 int integer = 0; 00464 // remove '\n' 00465 if (szBuffer[nLen - 1] == '\n') 00466 { 00467 nLen = nLen - 1; 00468 szBuffer[nLen] = '\0'; 00469 } 00470 // get the length of pincode 00471 ch[0] = szBuffer[strlen("0x8") - 1]; // ch='8' 00472 ch[1] = '\0'; 00473 len = strtoul(ch, NULL, 16); 00474 if (len > PINCODE_MAX_LENGTH) 00475 len = PINCODE_MAX_LENGTH; 00476 // remove the lenght of pincode 00477 szBuffer[strlen("0x8") - 1] = '0'; 00478 // convert hex string to integer 00479 integer = strtoul(szBuffer, NULL, 16); 00480 // convert integer to string 00481 sprintf(string, "%0*d", len, integer); 00482 // deal with some special cases, treat 0x00000000 as 0x40000000 00483 if (0 == len && 0 == integer) 00484 { 00485 strcpy(string, "0000"); 00486 } 00487 strcpy(pincode, string); 00488 ST_LOGPRINTF("PINCODE read returned [%s]", pincode); 00489 nRet = 0; 00490 } 00491 } 00492 else 00493 { 00494 ST_ERRORPRINTF("pclose returned %d. Error retrieving PINCODE", WEXITSTATUS(nProcessRet)); 00495 } 00496 } 00497 else 00498 { 00499 ST_ERRORPRINTF("Read PINCODE pclose did not exit normally"); 00500 } 00501 } 00502 return nRet; 00503 }
| gint sysset_write_pincode_onoff | ( | gboolean | enable | ) |
Definition at line 390 of file system.c.
00391 { 00392 char szCommand[32] = ""; 00393 int nProcessRet = 0; 00394 int nRet; 00395 00396 if (TRUE == enable) 00397 strcpy(szCommand, "sysset -w -a 58 -l 1 -v 1"); 00398 else 00399 strcpy(szCommand, "sysset -w -a 58 -l 1 -v 0"); 00400 ST_LOGPRINTF("Calling: %s", szCommand); 00401 nProcessRet = system(szCommand); 00402 nRet = WEXITSTATUS(nProcessRet); 00403 ST_LOGPRINTF("Write PINCODE onoff returned: %d", nRet); 00404 return nRet; 00405 }
| gint sysset_write_pincode_string | ( | const gchar * | pincode | ) |
Definition at line 505 of file system.c.
00506 { 00507 int nLen; 00508 unsigned int n, integer = 0; 00509 char string[32]; 00510 00511 char szCommand[32] = ""; 00512 int nProcessRet = 0; 00513 int nRet = -1; // -1 = error 00514 00515 if (NULL == pincode) 00516 return nRet; 00517 nLen = strlen(pincode); 00518 if (0 == nLen || (nLen >= PINCODE_MIN_LENGTH && nLen <= PINCODE_MAX_LENGTH)) 00519 { 00520 if (0 == nLen) // empty pincode 00521 { 00522 integer = 0; 00523 } 00524 else // (nLen >= PINCODE_MIN_LENGTH && nLen <= PINCODE_MAX_LENGTH) 00525 { 00526 // pincode ="99999999"--> integer=99999999=0x05F5E0FF-->0x85F5E0FF=2247483647 00527 integer = atoi(pincode); // integer = 99999999 00528 sprintf(string, "0x%d0000000", nLen); // string = "0x80000000" 00529 n = strtoul(string, NULL, 16); // n = 2147483648 00530 integer += n; // 2247483647 (0x85F5E0FF) 00531 } 00532 sprintf(szCommand, "sysset -w -b -a 59 -l 4 -v 0x%08X", integer); 00533 ST_LOGPRINTF("Calling: %s", szCommand); 00534 nProcessRet = system(szCommand); 00535 nRet = WEXITSTATUS(nProcessRet); 00536 } 00537 else 00538 { 00539 ST_ERRORPRINTF("Write PINCODE wrong length %d", nLen); 00540 } 00541 return nRet; 00542 }
1.5.6