I've been trying to get the ldap_plugin to compile on Solaris with the Sun Forte Compilers and needed to do the following.

Please note there is a bug in gui.c that prevents the server port from
being set through the gui.

Patches attached

Regards

Marty

LDAP Plugin
-----------

1. src/gui.c:111 (ldapoptions_ok) reads from the binddnentry and
   then writes the information to the serverport variable, thus
   making it impossible to set serverport to anything through the gui.

111: str = (char*)gtk_entry_get_text(GTK_ENTRY(lookup_widget(ldapoptions, "po
rtentry")));


2. Compilation errors from unportable C style; defining variables in the
   middle of code segments.

src/ldap_plugin.c:315 changed_object is defined after the first statement
src/ldap_plugin.c:321 int n is defined in the middle of statements
src/ldap_plugin.c:521 int n is defined in the middle of statements
src/ldap_plugin.c:989 *changes is defined in the middle of statements
src/ldap_plugin.c:998 *chinfo is defined in the middle of statements
src/ldap_plugin.c:1070 int x is defined in the middle of statements
src/ldap_plugin.c:1071 int maxlen is defined in the middle of statements
src/ldap_plugin.c:1092 *tmp is defined in the middle of statements
src/ldap_plugin.c:1477 *msg is defined in the middle of statements
src/ldap_plugin.c:1509 int i is defined in the middle of statements
src/ldap_plugin.c:1529 int n is defined in the middle of statements
src/ldap_plugin.c:1575 int n is defined in the middle of statements
src/ldap_plugin.c:1709 int n is defined in the middle of statements
*** plugins/ldap_plugin/src/gui.c.orig  Mon Aug 11 18:54:25 2003
--- plugins/ldap_plugin/src/gui.c       Mon Aug 11 18:54:29 2003
***************
*** 108,114 ****
  
    ldapconn->servername = 
(char*)gtk_editable_get_chars(GTK_EDITABLE(lookup_widget(ldapoptions, "serverentry")), 
0, -1);
  
!   str = (char*)gtk_entry_get_text(GTK_ENTRY(lookup_widget(ldapoptions, 
"binddnentry")));
    sscanf(str, "%d", ldapconn->serverport);
  
    if(ldapconn->binddn)
--- 108,114 ----
  
    ldapconn->servername = 
(char*)gtk_editable_get_chars(GTK_EDITABLE(lookup_widget(ldapoptions, "serverentry")), 
0, -1);
  
!   str = (char*)gtk_entry_get_text(GTK_ENTRY(lookup_widget(ldapoptions, 
"portentry")));
    sscanf(str, "%d", ldapconn->serverport);
  
    if(ldapconn->binddn)
*** plugins/ldap_plugin/src/ldap_plugin.c.orig  Mon Aug 11 18:50:22 2003
--- plugins/ldap_plugin/src/ldap_plugin.c       Mon Aug 11 19:06:40 2003
***************
*** 310,324 ****
              
              if(count < 1)
                {
                  dd(printf("Couldn't find the entry: %s in the LDAP server 
(deleted)\n", filter->str));
  
-                 changed_object *change = g_malloc0(sizeof(changed_object));
                  g_assert(change);
                  
  
                  sscanf(moddn, "cn=%256[^,]%*s", tmp);
  
-                 int n=0;
                  for(n=0; n<strlen(tmp); n++)
                    if(tmp[n] == ' ')
                      tmp[n] = '_';
--- 310,324 ----
              
              if(count < 1)
                {
+                 int n=0;
+                 changed_object *change = g_malloc0(sizeof(changed_object));
                  dd(printf("Couldn't find the entry: %s in the LDAP server 
(deleted)\n", filter->str));
  
                  g_assert(change);
                  
  
                  sscanf(moddn, "cn=%256[^,]%*s", tmp);
  
                  for(n=0; n<strlen(tmp); n++)
                    if(tmp[n] == ' ')
                      tmp[n] = '_';
***************
*** 509,514 ****
--- 509,515 ----
  
              if((vals = ldap_get_values(conn->ld, entry, "cn")) != NULL)
                {
+                 int n=0;
                  cn = (char *)strdup(vals[0]);
  
                  dn = g_string_new("");
***************
*** 518,524 ****
                  g_string_append(dn, conn->searchbase);
  
  
-                 int n=0;
                  uid = (char *)strdup(cn);
  
                  for(n=0; n<strlen(uid); n++)
--- 519,524 ----
***************
*** 981,992 ****
  void get_changes(ldap_connection *conn, sync_object_type newdbs)
  {
    ldap_get_changes_arg *arg;
  
    arg = g_malloc0(sizeof(ldap_get_changes_arg));
    arg->conn = conn;
    arg->newdbs = newdbs;
  
-   GList *changes = NULL;
  
    
  
--- 981,993 ----
  void get_changes(ldap_connection *conn, sync_object_type newdbs)
  {
    ldap_get_changes_arg *arg;
+   GList *changes = NULL;
+   change_info *chinfo;
  
    arg = g_malloc0(sizeof(ldap_get_changes_arg));
    arg->conn = conn;
    arg->newdbs = newdbs;
  
  
    
  
***************
*** 995,1001 ****
  
    g_free(arg);
  
-   change_info *chinfo;
  
    chinfo = g_malloc(sizeof(change_info));
    chinfo->changes = changes;
--- 996,1001 ----
***************
*** 1017,1022 ****
--- 1017,1025 ----
    char **values;
    int currattr = 0;
    int retval;
+   char msg[256];
+   int i = 0;
+   int n=0;
  
    if (!uid && !comp) 
      {
***************
*** 1066,1074 ****
    data = sync_get_key_data(comp, "N");
    if(data != NULL)
      {
-       dd(printf("Got N=%s\n", data));
        int x=0, firstname=0, lastname=0;
        int maxlen = strlen(data);
        for(x=0; x<maxlen; x++)
        {
          if(data[x] == ';')
--- 1069,1079 ----
    data = sync_get_key_data(comp, "N");
    if(data != NULL)
      {
        int x=0, firstname=0, lastname=0;
        int maxlen = strlen(data);
+       GString *tmp = g_string_new("");
+ 
+       dd(printf("Got N=%s\n", data));
        for(x=0; x<maxlen; x++)
        {
          if(data[x] == ';')
***************
*** 1088,1094 ****
            }
        }
  
-       GString *tmp = g_string_new("");
  
        g_string_append(tmp, (char*)&data[firstname]);
        g_string_append(tmp, " ");
--- 1093,1098 ----
***************
*** 1473,1479 ****
    dd(printf("About to add\n"));
    retval = ldap_add_s(conn->ld, dn->str, attrs);
  
-   char msg[256];
    msg[0] = '\0';
  
    switch(retval)
--- 1477,1482 ----
***************
*** 1505,1511 ****
      sync_log(conn->sync_pair, msg, SYNC_LOG_ERROR);
      
  
-   int i = 0;
    while(attrs[i] != NULL)
      {
        int j = 0;
--- 1508,1513 ----
***************
*** 1525,1531 ****
    uidret[strlen(cn)] = '\0';
    *uidretlen = strlen(uidret);
  
-   int n=0;
    for(n=0; n<strlen(uidret); n++)
      {
        if(uidret[n] == ' ')
--- 1527,1532 ----
***************
*** 1568,1577 ****
  {
    char *cn = NULL;
    GString *entrydn = NULL;
    
    cn = (char*)strdup(uid);
    
-   int n=0;
    for(n = 0; n<strlen(cn); n++)
      {
        if(cn[n] == '_')
--- 1569,1578 ----
  {
    char *cn = NULL;
    GString *entrydn = NULL;
+   int n=0;
    
    cn = (char*)strdup(uid);
    
    for(n = 0; n<strlen(cn); n++)
      {
        if(cn[n] == '_')
***************
*** 1688,1693 ****
--- 1689,1695 ----
        start = strstr(pos+l, ":");
        if (start) {
        char *tmp, *line, *newstart;
+       int n=0;
        do {
          start++;
          end = strstr(start, "\n");
***************
*** 1705,1711 ****
        } while(start < card+strlen(card) && start[0] == ' ');
  
        tmpretval = (char**)malloc((size+2)*sizeof(char*));
-       int n=0;
        for(n=0; n<size;n++)
          tmpretval[n] = retval[n];
        tmpretval[size] = res;
--- 1707,1712 ----

Reply via email to