<pre style='margin:0'>
Umesh Singla (umeshksingla) pushed a commit to branch gsoc17-migrate
in repository macports-base.

</pre>
<p><a href="https://github.com/macports/macports-base/commit/d3a1a3df819ecb11aa59b216996218e9c074a94a">https://github.com/macports/macports-base/commit/d3a1a3df819ecb11aa59b216996218e9c074a94a</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit d3a1a3df819ecb11aa59b216996218e9c074a94a
</span>Author: Umesh Singla <umeshksingla@macports.org>
AuthorDate: Sat Aug 26 01:16:37 2017 +0530

<span style='display:block; white-space:pre;color:#404040;'>    Pass ports as strings to Tcl
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    This completes the fetch latest snapshot functionality for migrate
</span>---
 src/macports1.0/snapshot.tcl  |  2 +-
 src/registry2.0/snapshotobj.c | 48 ++++++++++++++++++++++++-------------------
 2 files changed, 28 insertions(+), 22 deletions(-)

<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/snapshot.tcl b/src/macports1.0/snapshot.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index f9ef291..b3077ea 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/snapshot.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/snapshot.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -16,7 +16,7 @@ namespace eval snapshot {
</span>           # The main function. Handles all the calls to the correct functions.
         #
         # Args:
<span style='display:block; white-space:pre;background:#ffe0e0;'>-        #           opts - The options passed in. Currently, there is no option available.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        #           opts - The options passed in.
</span>         # Returns:
         #           registry::snapshot
         #
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/registry2.0/snapshotobj.c b/src/registry2.0/snapshotobj.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 371704b..e3fe714 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/registry2.0/snapshotobj.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/registry2.0/snapshotobj.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -96,30 +96,36 @@ static int snapshot_obj_ports(Tcl_Interp* interp, reg_snapshot* snapshot, int ob
</span>             reg_error error;
             int port_count = reg_snapshot_ports_get(snapshot, &ports, &error);
             if (port_count >= 0) {
<span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                printf("ports fetched\n");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                printf("port_count: %d\n", port_count);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                //printf("size of ' %zu ' 0 \n", sizeof(ports[1]->name));
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                char* portstr = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                char* portstrs[port_count + 1];
</span>                 int i;
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                for(i=0; i < port_count; i++){
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                    printf("in it - ");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                    printf("! %s ! ", ports[i]->name);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                    printf(".. %d ..  ", ports[i]->requested);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                    printf("! %s ! \n", ports[i]->state);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                for(i = 0; i < port_count; i++){
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    port* current_port = ports[i];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    portstr = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    if (asprintf(&portstr, "%s %d %s %s",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                            current_port->name,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                            current_port->requested,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                            current_port->state,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                            current_port->variants) < 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                        return TCL_ERROR;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    portstrs[i] = portstr;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    free(portstr);
</span>                 }
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-                return TCL_OK;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                // TODO: correct the below for 'ports', added as a prototype for now
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                // Tcl_Obj** objs;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                // if (list_snapshot_ports_to_obj(interp, &objs, ports, port_count, &error)){
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                //     Tcl_Obj* result = Tcl_NewObj(port_count, objs);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                //     Tcl_SetObjResult(interp, result);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                //     free(objs);
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                //     return TCL_OK;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-                // } 
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                Tcl_Obj** objs;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                if (list_string_to_obj(&objs, portstrs, port_count, &error)){
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    Tcl_Obj* result = Tcl_NewListObj(port_count, objs);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    Tcl_SetObjResult(interp, result);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    free(objs);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    for (i=0; i < port_count; i++) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                        free(ports[i]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    free(ports);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    return TCL_OK;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                    return registry_failed(interp, &error);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+                }
</span>             }
             return registry_failed(interp, &error);
         }
</pre><pre style='margin:0'>

</pre>