Sfoglia il codice sorgente

ncd: modules: socket: add read() eof variable

Ambroz Bizjak 11 anni fa
parent
commit
da7d47178a
3 ha cambiato i file con 9 aggiunte e 5 eliminazioni
  1. 2 1
      ncd/NCDStringIndex.c
  2. 5 3
      ncd/modules/socket.c
  3. 2 1
      ncd/static_strings.h

+ 2 - 1
ncd/NCDStringIndex.c

@@ -83,7 +83,8 @@ static const char *static_strings[] = {
     "length",
     "type",
     "exit_status",
-    "size"
+    "size",
+    "eof",
 };
 
 static NCD_string_id_t do_get (NCDStringIndex *o, const char *str, size_t str_len)

+ 5 - 3
ncd/modules/socket.c

@@ -65,7 +65,9 @@
  * 
  * Variables:
  *   string (empty) - some data received from the socket, or empty on EOF
- *   string not_eof - "true" if EOF was not encountered, "false" if it was
+ *   string eof - "true" if EOF was encountered, "false" if not
+ *   string not_eof - (deprecated) "true" if EOF was not encountered,
+ *     "false" if it was
  * 
  * Description:
  *   Receives data from the connection. If EOF was encountered (remote host
@@ -806,8 +808,8 @@ static int read_func_getvar (void *vo, NCD_string_id_t name, NCDValMem *mem, NCD
         return 1;
     }
     
-    if (name == NCD_STRING_NOT_EOF) {
-        *out = ncd_make_boolean(mem, (o->read_size != 0), o->i->params->iparams->string_index);
+    if (name == NCD_STRING_EOF || name == NCD_STRING_NOT_EOF) {
+        *out = ncd_make_boolean(mem, (o->read_size == 0) == (name == NCD_STRING_EOF), o->i->params->iparams->string_index);
         return 1;
     }
     

+ 2 - 1
ncd/static_strings.h

@@ -64,7 +64,8 @@ enum {
     NCD_STRING_LENGTH,
     NCD_STRING_TYPE,
     NCD_STRING_EXIT_STATUS,
-    NCD_STRING_SIZE
+    NCD_STRING_SIZE,
+    NCD_STRING_EOF,
 };
 
 #endif