Explorar el Código

暂时注掉二维码生成接口,待崩溃解决后放开

guohui hace 1 año
padre
commit
80ba44ddc6
Se han modificado 1 ficheros con 19 adiciones y 14 borrados
  1. 19 14
      pro/src/sys.c

+ 19 - 14
pro/src/sys.c

@@ -111,21 +111,26 @@ int sys_set_factory(void)
 
 int sys_get_path(char *path, char *name)
 {
-    char tmp[500];
+    int r,n;
+    char *p,tmp[500];
 
     pid_t pid = getpid();
     snprintf(tmp, sizeof(tmp), "/proc/%d/exe", pid); 
-    readlink(tmp, path, sizeof(tmp));
-    char *p = strrchr(path, '/');
-    if(p && strlen(path)>1) {
-        *p = 0;
-        if(p && name && strlen(name)>0) {
-            strcat(path, "/");
-            strcat(path, name);
+    n = readlink(tmp, path, sizeof(tmp));
+    if(n>0 && n<sizeof(tmp)) {
+        path[n] = 0;
+        p = strrchr(path, '/');
+        if(p && strlen(path)>1) {
+            *p = 0;
+            if(name && strlen(name)>0) {
+                strcat(path, "/");
+                strcat(path, name);
+            }
         }
+        return 0;
     }
     
-    return 0;
+    return -1;
 }
 
 ////////////////////////////////////////////////
@@ -1411,7 +1416,7 @@ int sys_get_prod(GlobalDeviceInfo *info)
     int r;
     char *p,*tok;
     buf_t fbuf;
-    char temp[100];
+    char path[100]={0};
 
     r = file_load(INFO_FILE_PATH, &fbuf);
     if(r) {
@@ -1465,11 +1470,11 @@ int sys_get_prod(GlobalDeviceInfo *info)
     p = str_get(fbuf.buf, tok, info->service.tele, sizeof(info->service.tele));
     if(p) LOGD("___%s:%s\n", tok, p);
 
-    sys_get_path(temp, "../web/img/shdh.png");
-    //qrc_to_png(info->service.tele, temp);
+    sys_get_path(path, "../web/img/shdh.png");
+    //r = qrc_to_png(info->service.tele, path);
 
-    sys_get_path(temp, "../web/img/sbh.png");
-    //qrc_to_png(info->product.number, temp);
+    sys_get_path(path, "../web/img/sbh.png");
+    //r = qrc_to_png(info->product.number, path);
 
     free(fbuf.buf);
     return 0;