免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: tjf258
打印 上一主题 下一主题

[其它] ARM9 开发板上 不能locale ,还有怎么查支持的字符集 [复制链接]

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
11 [报告]
发表于 2013-09-24 21:28 |只看该作者
方便贴出你的代码不?

论坛徽章:
0
12 [报告]
发表于 2013-09-25 16:09 |只看该作者
char* mes_pdu()
{
char inbuf[BUFLEN]="你好!";
char outbuf[BUFLEN];
char buf[BUFLEN];
char* pin = inbuf;
char* pout = outbuf;
  printf("%s\n", inbuf);
//打开文件,读入GB2312数据到inbuf,数据长度为 len
int inleft = strlen(inbuf);
int outleft = BUFLEN;
int i;
int retsize;
iconv_t cd;
cd = iconv_open("UNICODE", "gb2312";


if (errno == EINVAL) {
                     /*EINVAL
                         实现不支持从 fromcode 到 tocode 的转换。
                    * Incomplete character or shift sequence
                      */
          printf("unsuport\n";
                     /*
                      * Outputs converted characters
                      */}
                      else
                               printf("nothing\n";
        if((iconv_t)-1 == cd) {
     perror("iconv_open error";
}

bzero(outbuf,BUFLEN);
retsize = iconv(cd, &pin, (size_t *)&inleft, &pout, (size_t *)&outleft);
if((size_t)-1 == retsize) {
     perror("iconv error";   
}
        if (retsize==-1)
        printf("retsize=-1\n";


  // for(i=0;i<=40;i++)
// printf("%x\n", outbuf);
// getchar();
   
char *tmp,*tmp2;
char tmp0[BUFLEN];

bzero(tmp0,BUFLEN);

if (NULL == (tmp2=(char *) malloc (140)) )
                                                   {
                                                    perror("error...";
                                                    exit(1);
                                                   }
if (NULL == (tmp=(char *) malloc (140)) )
                                                   {
                                                    perror("error...";
                                                    exit(1);
                                                   }
                                                  
        memcpy(tmp0,outbuf+2,BUFLEN-outleft);
       
       
         printf("%d\n", strlen(tmp0));
         
                 printf("=+++++++++++++++++++++=\n";
         for(i=0;i<=40;i++)
         
   printf("%x\n", tmp0);
  
getchar();
        int        count=0;                //表示输入了多少字符  
         
for(i = 0;i <=30
{      
          if(tmp0==0&&tmp0[i+1]==0)
                          
          count+=0;
                 else
                {
                    count++;
           tmp[i+1] =tmp0;      
           tmp = tmp0[i + 1];
          }
      
        i=i+2;
}   //两两换


  printf("=+++++++++++++++++++++=\n");
printf("%d\n", count);
  
printf("=+++++++++++++++++++++=\n");

for(i=0;i<=count*2;i++)
   printf("%x\n", tmp);

memcpy(tmp2,tmp,count*2);printf("=+++++++++++++++++++++=\n");

  for(i=0;i<=count*2;i++)
   printf("%x\n", tmp2);

free(tmp);
tmp = NULL;
iconv_close(cd);
return tmp2;
}回复 11# T-Bagwell


   

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
13 [报告]
发表于 2013-09-25 18:13 |只看该作者

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <unistd.h>
  5. #include <sys/stat.h>
  6. #include <sys/types.h>
  7. #include <sys/mount.h>
  8. #include <dirent.h>
  9. #include <fcntl.h>
  10. #include <sys/wait.h>
  11. #include <sys/vfs.h>
  12. #include <pthread.h>
  13. #include <netdb.h>
  14. #include <netinet/in.h>
  15. #include <sys/socket.h>
  16. #include <errno.h>
  17. #include <dirent.h>

  18. #include <iconv.h>

  19. //#define TEMP_OUT_SMBCLIENT "./pvrNeighborhood"
  20. #define TEMP_OUT_SMBCLIENT_UTF8 "./pvrNeighborhoodutf8"
  21. #define MAX_FILE_READ_BUFFER_SIZE        512
  22. #define SMB_MAX        20
  23. #define DEFAULT_NETWORK_NEIGHBORHOOD_MOUNTPOINT "/mnt"
  24. #define TEMP_NEIGHBORHOOD_SEARCH_FILE "/mnt/network"
  25. #define TEMP_NMBLOOKUP_FILE         "/mnt/nmblookupfile"

  26. #define MAX_NAME_LEN (256*2)
  27. #define MAX_PER_PAGE        6
  28. static char computerName[256][MAX_NAME_LEN];
  29. static int number;
  30. static         char *host_name[256];
  31. static char pcIpAddress[MAX_NAME_LEN];

  32. static int path_count;
  33. static char path[SMB_MAX][MAX_FILE_READ_BUFFER_SIZE];
  34. //static char utf8path[SMB_MAX][MAX_FILE_READ_BUFFER_SIZE];


  35. int code_convert(char *from_charset,char *to_charset,char *inbuf,int inlen,char *outbuf,int outlen)
  36. {
  37.     iconv_t cd;
  38.     int rc;
  39.     char **pin = &inbuf;
  40.     char **pout = &outbuf;

  41.     cd = iconv_open(to_charset,from_charset);
  42.     if (cd==0)
  43.     {
  44.         return -1;
  45.     }
  46.    
  47.     memset(outbuf,0,outlen);
  48.     if (iconv(cd,pin,&inlen,pout,&outlen)==-1)
  49.     {
  50.         return -1;
  51.     }
  52.    
  53.     iconv_close(cd);
  54.    
  55.     return 0;
  56. }

  57. int u2g(char *inbuf,int inlen,char *outbuf,int outlen)
  58. {
  59.    return code_convert("utf-8","gb2312",inbuf,inlen,outbuf,outlen);
  60. }

  61. int g2u(char *inbuf,size_t inlen,char *outbuf,size_t outlen)
  62. {
  63.     return code_convert("gb2312","utf-8",inbuf,inlen,outbuf,outlen);
  64. }

  65. int smb_attache_mounted(const char *ipaddr, const char *sharename)
  66. {
  67.         char service_path[256];
  68.         char mountpoint[256];
  69.         char stream[MAX_FILE_READ_BUFFER_SIZE];
  70.         FILE *pfile;
  71.         int result = 0;

  72.         if (ipaddr == NULL || sharename == NULL)
  73.             return 0;

  74.         pfile = fopen("/proc/mounts", "r");
  75.         if(!pfile)
  76.                 return 0;

  77.         while (fgets(stream, MAX_FILE_READ_BUFFER_SIZE, pfile))
  78.         {
  79.                 sscanf(stream, "%s %s ", service_path, mountpoint);
  80.                 if (strstr(service_path, ipaddr) != 0 && strstr(service_path, sharename) != 0)
  81.                 {
  82.                         result = 1;
  83.                         fprintf(stderr, "have smb mount\n");
  84.                         break;
  85.                 }
  86.         }

  87.         fclose(pfile);
  88.         return result;
  89. }

  90. /** smb_mount
  91.     * return : 0, mount failed, need password
  92.     *             -1: no shared file or dir
  93.                   >0: shared file or dir's count
  94. */
  95. int smb_mount(const char *ipaddr, const char *username, const char *password, char *ret_path[])
  96. {
  97.         pid_t pid;
  98.         char username_and_passwd[64];
  99.         char stream[MAX_FILE_READ_BUFFER_SIZE];
  100.         char connection_error_message[MAX_FILE_READ_BUFFER_SIZE];
  101.         char srcPath[MAX_FILE_READ_BUFFER_SIZE];
  102.         char data[MAX_FILE_READ_BUFFER_SIZE];
  103.         char diskShareTypeChr[64];
  104.         char shareName[64];
  105.         char *pType;
  106.         DIR *tmp_dir;
  107.         int writefile = 0;
  108.         int status = 0;
  109.         int count = 0;
  110.         FILE *pfile;

  111.         memset(username_and_passwd, 0, 64);
  112.         memset(stream, 0, MAX_FILE_READ_BUFFER_SIZE);
  113.         memset(connection_error_message, 0, MAX_FILE_READ_BUFFER_SIZE);
  114.         memset(path, 0, MAX_FILE_READ_BUFFER_SIZE*SMB_MAX);

  115.         //remove(TEMP_OUT_SMBCLIENT);
  116.         remove(TEMP_OUT_SMBCLIENT_UTF8);

  117.         char smbclientCmd[1024] = { 0 };
  118.         if(username == NULL)
  119.             sprintf(smbclientCmd, "smbclient -L %s -N > %s", ipaddr, TEMP_OUT_SMBCLIENT_UTF8);
  120.         else
  121.             sprintf(smbclientCmd, "smbclient -L %s -U %s%%%s > %s", ipaddr, username, password, TEMP_OUT_SMBCLIENT_UTF8);

  122.        printf("smbclientCmd : %s\n", smbclientCmd);
  123.        system(smbclientCmd);
  124.             

  125.       FILE *utf8file = fopen(TEMP_OUT_SMBCLIENT_UTF8, "r");
  126.       if (utf8file)
  127.       {
  128.          fseek(utf8file, 0, SEEK_END);
  129.          int length = ftell(utf8file);
  130.          if (length > 0)
  131.           {
  132.              fseek(utf8file, 0, SEEK_SET);
  133.              char *bufferUtf8 = (char *)malloc(length + 1);
  134.              memset(bufferUtf8, 0, length + 1);
  135.              fread(bufferUtf8, length, 1, utf8file);
  136.              char *bufferGbk = (char *)malloc(length * 2 + 1);
  137.              u2g(bufferUtf8, length + 1, bufferGbk, length * 2 + 1);
  138.              printf("%s\n\n%s\n\n", bufferUtf8, bufferGbk);
  139.              //FILE *gbkfile = fopen(TEMP_OUT_SMBCLIENT, "w");
  140.              FILE *gbkfile = fopen(TEMP_OUT_SMBCLIENT_UTF8, "w");
  141.              if (gbkfile)
  142.              {
  143.                  fwrite(bufferGbk, strlen(bufferGbk), 1, gbkfile);
  144.                  fclose(gbkfile);
  145.              }
  146.              free(bufferGbk);
  147.              free(bufferUtf8);
  148.           }
  149.           else
  150.           {
  151.              printf("can not open pvrNeighborhood to write\n");
  152.              return -1;
  153.           }
  154.         fclose(utf8file);
  155.       }
  156.       else
  157.       {
  158.          printf("can not open pvrNeighborhoodutf8 to read\n");
  159.          return -1;
  160.       }
  161.        

  162.         //pfile = fopen(TEMP_OUT_SMBCLIENT, "r");
  163.         pfile = fopen(TEMP_OUT_SMBCLIENT_UTF8, "r");
  164.         if(!pfile){
  165.                 printf("open tmpfile error\n");
  166.                 return -1;
  167.         }
  168.         sprintf(connection_error_message, "Connection to %s failed", ipaddr);
  169.         while(count < SMB_MAX && fgets(stream, MAX_FILE_READ_BUFFER_SIZE, pfile)){
  170.                 fprintf(stderr,"smbclient: %s\n",stream);
  171.                 if (NULL != strstr(stream, connection_error_message)){
  172.                         fprintf(stderr, "liuqi????%s\n", connection_error_message);
  173.                         fclose(pfile);                                                                                         
  174.                         return -1;                                                                                          
  175.                 }
  176.                 if (NULL != strstr(stream, "NT_STATUS_ACCESS_DENIED")  
  177.                                 || NULL != strstr(stream, "NT_STATUS_LOGON_FAILURE") ){
  178.                         fclose(pfile);                                                                                         
  179.         fprintf(stderr," NT_STATUS_LOGON_FAILURE smbclient: %s\n",stream);

  180.                         return -1;                                                                                          
  181.                 }
  182.                 if (NULL != strstr(stream, "NT_STATUS_LOGON_FAILURE")){
  183.                         fclose(pfile);
  184.                         return -1;                                                                                          
  185.                 }                                                                                                      

  186.         }
  187.         fclose(pfile);

  188.         //pfile = fopen(TEMP_OUT_SMBCLIENT, "r");
  189.         pfile = fopen(TEMP_OUT_SMBCLIENT_UTF8, "r");
  190.         if(NULL == pfile)
  191.         {
  192.                 //fprintf(stderr, "open %s error\n", TEMP_OUT_SMBCLIENT);
  193.                 fprintf(stderr, "open %s error\n", TEMP_OUT_SMBCLIENT_UTF8);
  194.                 return -1;
  195.         }

  196.         while (fgets(stream, MAX_FILE_READ_BUFFER_SIZE, pfile)){
  197.                 if (0 == strncmp(stream, "\t", strlen("\t"))){
  198.                         memset(path[count], 0 , MAX_FILE_READ_BUFFER_SIZE);
  199.                         memset(diskShareTypeChr, 0, sizeof(diskShareTypeChr));
  200.                         strcpy(diskShareTypeChr, "Disk");
  201.                         strcat(diskShareTypeChr, " ");
  202.                         pType = strstr(stream, diskShareTypeChr);
  203.                         if (NULL == pType){
  204.                                 continue;
  205.                         }
  206.                         strncpy(shareName, stream +1, pType - stream -2);
  207.                         shareName[pType- stream - 2] = '\0';
  208.                         char *pEndOfShareName = shareName + strlen(shareName) -1;
  209.                         while('\40' == *pEndOfShareName)
  210.                                 pEndOfShareName --;
  211.                         *(pEndOfShareName + 1) = '\0';
  212.                         fprintf(stderr, " share name = |%s|\n", shareName);
  213.                         if( '我几年前写的代码,参考一下吧,肯定好用,而且产品化过,现在还在跑着呢 == shareName[strlen(shareName)-1])
  214.                         {
  215.                                 continue;
  216.                         }


  217.                         strcpy(path[count], DEFAULT_NETWORK_NEIGHBORHOOD_MOUNTPOINT);
  218.                         strcat(path[count], "/");
  219.                         strcat(path[count], ipaddr);

  220.                         tmp_dir = opendir(path[count]);
  221.                         if(!tmp_dir)
  222.                                 if (0 != mkdir(path[count], 0777)){
  223.                                         fprintf(stderr, "liuqi<<<<Make %s error\n", path[count]);
  224.                                 }

  225.                         strcat(path[count], "/");
  226.                         strcat(path[count], shareName);
  227.                         fprintf(stderr, "liuqi>>>>%s\n", path[count]);

  228.                         if(smb_attache_mounted(ipaddr, shareName)){
  229.                                char umount_cmd[64] = { 0 };
  230.                                 sprintf(umount_cmd, "umount %s", path[count]);
  231.                                 printf("umount_cmd:%s\n",umount_cmd);
  232.                             system(umount_cmd);
  233.                         }

  234.                        
  235.                        
  236.                         tmp_dir = opendir(path[count]);
  237.                         if(!tmp_dir){
  238.                                 if (0 != mkdir(path[count], 0777)){
  239.                                         fprintf(stderr, "liuqi####Make %s error\n", path[count]);
  240.                                 }
  241.                         }
  242.                         closedir(tmp_dir);
  243.                         sprintf(srcPath, "\\\\%s\\%s", ipaddr, shareName);
  244.                         fprintf(stderr, "liuqi<%s>\n", path[count]);
  245.                         if(username == NULL){
  246.                                 sprintf(data, "user=root,iocharset=cp936");
  247.                                 fprintf(stderr,"liuqi#$%s#%s\n", srcPath, data);
  248.                                 tmp_dir = opendir(path[count]);
  249.                                 fprintf(stderr, "open dir %d\n", tmp_dir);

  250.                                 if (mount(srcPath, path[count], "cifs", 0, data) != 0 )
  251.                                 {
  252.                                         fprintf(stderr, "Mount %s on %s error\n", srcPath, path[count]);

  253.                                         if (errno == EACCES)
  254.                                         {
  255.                                         fprintf(stderr, "Mount Failed %s on %s \n", srcPath, path[count]);

  256.                                 //                rmdir(path[count]);
  257.                                                 fclose(pfile);
  258.                                                 return 0;   //return need password
  259.                                         }
  260.                                         else
  261.                                         {
  262.                                                 fprintf(stderr, "mount error\n");
  263.                                                 ;
  264.                                 //        rmdir(path[count]);
  265.                                         }
  266.                                 }
  267.                                 else{
  268.                                         ret_path[count]=path[count];
  269.                                         fprintf(stderr, "(%s) |(%s)\n", ret_path[count] , path[count]);
  270.                                         count++;
  271.                                 }

  272.                         }
  273.                         else{
  274.                                 sprintf(data, "user=%s,pass=%s,iocharset=cp936",
  275.                                                 username, password);
  276.                                 fprintf(stderr, "|iiiii|%s|\n", data);
  277.                                 if(mount(srcPath, path[count], "cifs", 0, data) != 0 )
  278.                                 {
  279.                                         fprintf(stderr, "Mount Failed %s on %s \n", srcPath, path[count]);
  280.                                         if (errno == EACCES)
  281.                                         {
  282.                                                 fprintf(stderr, stderr, "Mount %s on %s error\n", srcPath, path[count]);
  283.                                 //                rmdir(path[count]);
  284.                                                 fclose(pfile);
  285.                                                 return 0;   //return need password
  286.                                         }
  287.                                         else{
  288.                                                 ;
  289.                                 //        rmdir(path[count]);
  290.                                         }
  291.                                 }
  292.                                 else{
  293.                                         ret_path[count] = path[count];
  294.                                         fprintf(stderr, "(%s) |(%s)\n", ret_path[count] , path[count]);
  295.                                         count++;
  296.                                 }

  297.                         }
  298.                 }
  299.         }
  300.         fclose(pfile);
  301.         path_count = count;
  302.         fprintf(stderr, "#%s#\n", path[count]);
  303.         return count == 0 ? 0 : -1;  //if count == 0, return no shared file
  304. }
  305. extern int covert(char *desc, char *src, char *input, size_t ilen, char *output, size_t olen);

  306. int smb_get_path_count(int* a_count)
  307. {
  308.         * a_count =  path_count;
  309.         return 0;
  310. }
  311. int smb_mount_path_get(int i,char *string_path)
  312. {
  313.         char tmpStr[128];

  314.         memset(tmpStr, 0, sizeof(char)*128);
  315.         memcpy(tmpStr, path[i], strlen(path[i]));
  316.         covert("utf-8", "gb18030", tmpStr, strlen(tmpStr), string_path, sizeof(char)*MAX_FILE_READ_BUFFER_SIZE-1);
  317.         //string_path = utf8path[i];
  318.         fprintf(stderr, "#%s#\n", path[i]);
  319.         fprintf(stderr, "========%s=======\n", string_path);
  320.         return 0;
  321. }

  322. int get_smb_tree_host(int num, char *host_name_init[])
  323. {
  324.         int i = num * MAX_PER_PAGE;
  325.         int count = 0;
  326. fprintf(stderr, "number = %d, host_name_init[count] = %s\n", number, host_name[i]);

  327.         for( count =0 ; i < number && count < 6; i++)
  328.         {
  329.                 fprintf(stderr, "host_name_init[count] = %s\n", host_name[i]);
  330.                 host_name_init[count] = host_name[i];
  331.                 count++;
  332.         }
  333. fprintf(stderr, " liuqi >>>> count = %d\n", count);
  334.         return count;
  335. }


  336. int smb_tree_init()
  337. {
  338.         char tempFilename[] = TEMP_NEIGHBORHOOD_SEARCH_FILE;
  339.         char sharedName[MAX_NAME_LEN];
  340.         char path[MAX_NAME_LEN];
  341.         int i = 0;
  342.         memset(computerName, 0 , 256*MAX_NAME_LEN);
  343.         memset(sharedName, 0, MAX_NAME_LEN);

  344.         pid_t pid= fork();

  345.         if (pid == 0)
  346.         {
  347.                 int writeFile= open(tempFilename, O_CREAT | O_RDWR | O_TRUNC,
  348.                         S_IREAD | S_IWRITE);

  349.                 close(1);
  350.                 dup2(writeFile, 1);

  351.                 execlp("smbtree", "smbtree", "-S" , "-N","-s", "/home/work/samba/lib/smb.conf", NULL);
  352.                 perror("smbtree");
  353.                 return 0;
  354.         }
  355.         else if (pid >0)
  356.         {
  357.                 int status;
  358.                 while (1){
  359.                         pid_t ptw = waitpid(pid, NULL, WNOHANG);
  360.                         if (ptw == pid)
  361.                                 break;
  362.                         usleep(500000);     
  363.                 }

  364.                 FILE *pfile;
  365.                 pfile = fopen(tempFilename, "r");
  366.                 char stream[MAX_NAME_LEN];
  367.                 if(!pfile){
  368.                         fprintf(stderr, "Can't mount network directory!\n");
  369.                         return;
  370.                 }
  371.                 while (fgets(stream, MAX_NAME_LEN, pfile)){
  372.                         char *c;
  373.                         if(strstr(stream, "smbtree: not found"))
  374.                         {
  375.                                 return 0;
  376.                         }
  377.                         if( !strncmp(stream, "\t\\\\", strlen("\t\\\\"))){
  378.                                 sscanf(stream, "\t%[^\40\t]", path);
  379.                                 c = strrchr(path, '\\');
  380.                                 if(NULL == c)
  381.                                         continue;
  382.                                 c++;
  383.                                 memset(computerName[i], 0, MAX_NAME_LEN);
  384.                                 strcpy(computerName[i], c);
  385.                                 host_name[i] = computerName[i];
  386.                                 fprintf(stderr, "liuqi>>|%s|\n", computerName[i]);
  387.                                 i++;
  388.                                 continue;
  389.                         }
  390.                 }
  391.                 fclose(pfile);
  392.         }
  393.         fprintf(stderr, "i = %d\n", i);
  394.         number = i;
  395.         return i;

  396. }

  397. char *get_host_ipaddr(char *name)
  398. {
  399.         int writeFile;
  400.         memset(pcIpAddress, 0, MAX_NAME_LEN);
  401.         pid_t pid= fork();
  402.         if (pid == 0)
  403.         {
  404.                 writeFile = open(TEMP_NMBLOOKUP_FILE, O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
  405.                 close(1);
  406.                 dup2(writeFile, 1);
  407.                 execlp("nmblookup", "nmblookup", name, NULL);
  408.                 return NULL;
  409.         }
  410.         else if (pid >0){
  411.                 while(1){
  412.                         pid_t ptw = waitpid(pid, NULL, WNOHANG);
  413.                         if (ptw == pid)
  414.                                 break;
  415.                         usleep(50000);
  416.                 }
  417.                 FILE *pfile;
  418.                 pfile = fopen(TEMP_NMBLOOKUP_FILE, "r");
  419.                 char stream[MAX_NAME_LEN];
  420.                 if(!pfile){
  421.                         fprintf(stderr, "Can't mount network directory!\n");
  422.                         return NULL;
  423.                 }

  424.                 while (fgets(stream, MAX_NAME_LEN, pfile)){
  425.                         char *c;
  426.                         char temp[MAX_NAME_LEN];

  427.                         sscanf(stream, "%s %s", pcIpAddress, temp);

  428.                         c = strchr(pcIpAddress, '.');
  429.                         if(NULL == c)
  430.                                 continue;
  431.                         c++;

  432.                         c = strchr(pcIpAddress, '.');
  433.                         if(NULL == c)
  434.                                 continue;
  435.                         c++;

  436.                         c = strchr(pcIpAddress, '.');
  437.                         if(NULL == c)
  438.                                 continue;       
  439.                         if(pcIpAddress[0]>'0'&&pcIpAddress[0]<'9')
  440.                         return pcIpAddress;
  441.                 }
  442.                 fclose(pfile);

  443.         }
  444.         return pcIpAddress;

  445. }

  446. smb_umount()
  447. {
  448.     int i = 0;
  449.     for(i =0; i < path_count; i++){
  450.             char umount_cmd[1024] = { 0 };
  451.             fprintf(umount_cmd, "umount %s", path[i]);
  452.             system(umount_cmd);
  453.         }
  454.         path_count = 0;
  455. }


  456. #if 0
  457. int main(int argc, char *argv[])
  458. {
  459.         int ret=0;
  460.         char *str[10];
  461.         if(argc == 4)
  462.                 ret = smb_mount(argv[1], argv[2], argv[3], str);
  463.         else
  464.                 ret = smb_mount(argv[1], NULL, NULL, str);

  465.         int i=0;
  466.         for(i=0; i < ret; i++)
  467.         fprintf(stderr, "!%s!\n", str[i]);

  468.         return 0;
  469. }
  470. #endif

复制代码
我几年前写的代码,参考一下吧,肯定好用,而且产品化过,现在还在跑着呢

论坛徽章:
0
14 [报告]
发表于 2013-09-25 22:14 |只看该作者
谢谢!!

宿主机上能正常iconv了

可是放在板子上还是不行

你看我这样
./configure --prefix=/home/xyongkun/libiconv/output --host=arm-linux cc=/opt/arm-2009q1/bin/arm-none-linux-gnueabi-gcc
make
make install
是能生成板子上运行的库吗





回复 13# T-Bagwell


   

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
15 [报告]
发表于 2013-09-26 11:10 |只看该作者
本帖最后由 T-Bagwell 于 2013-09-26 11:10 编辑
tjf258 发表于 2013-09-25 22:14
谢谢!!

宿主机上能正常iconv了


如果是编译iconv的话,我觉得你可以先试试编译成静态库,.a
奈何我没有板子了,都给人了……

论坛徽章:
0
16 [报告]
发表于 2013-09-27 16:40 |只看该作者
在宿主机上用静态库 可以运行
可是交叉编译 到板子上又不行了   


我想问下你  板子上/bin没有iconv命令嘛
我要怎么弄才有 具体怎么弄 给点思路  
谢谢
回复 15# T-Bagwell


   

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
17 [报告]
发表于 2013-09-27 17:24 |只看该作者
这就是传说中的移植了
交叉编译iconv,编译iconv的.a

论坛徽章:
0
18 [报告]
发表于 2013-12-11 15:35 |只看该作者
可以再程序中调用 setLocal 试试

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
19 [报告]
发表于 2013-12-12 07:11 |只看该作者
回复 18# zhangpipi123


    没用的,他没有locale的支持,一般嵌入式里面就是C和english我记得
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP