/[rdesktop]/sourceforge.net/branches/seamlessrdp-branch/rdesktop/rdesktop.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/branches/seamlessrdp-branch/rdesktop/rdesktop.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1047 by astrand, Mon Feb 27 19:36:35 2006 UTC revision 1053 by astrand, Thu Mar 2 15:22:25 2006 UTC
# Line 86  BOOL g_hide_decorations = False; Line 86  BOOL g_hide_decorations = False;
86  BOOL g_use_rdp5 = True;  BOOL g_use_rdp5 = True;
87  BOOL g_console_session = False;  BOOL g_console_session = False;
88  BOOL g_numlock_sync = False;  BOOL g_numlock_sync = False;
89    BOOL lspci_enabled = False;
90  BOOL g_owncolmap = False;  BOOL g_owncolmap = False;
91  BOOL g_ownbackstore = True;     /* We can't rely on external BackingStore */  BOOL g_ownbackstore = True;     /* We can't rely on external BackingStore */
92  uint32 g_embed_wnd;  uint32 g_embed_wnd;
# Line 679  main(int argc, char *argv[]) Line 680  main(int argc, char *argv[])
680                                  {                                  {
681                                          serial_enum_devices(&g_num_devices, optarg + 7);                                          serial_enum_devices(&g_num_devices, optarg + 7);
682                                  }                                  }
683                                    else if (str_startswith(optarg, "lspci"))
684                                    {
685                                            lspci_enabled = True;
686                                    }
687                                  else if (str_startswith(optarg, "lptport"))                                  else if (str_startswith(optarg, "lptport"))
688                                  {                                  {
689                                          parallel_enum_devices(&g_num_devices, optarg + 7);                                          parallel_enum_devices(&g_num_devices, optarg + 7);
# Line 804  main(int argc, char *argv[]) Line 809  main(int argc, char *argv[])
809          if (g_rdpsnd)          if (g_rdpsnd)
810                  rdpsnd_init();                  rdpsnd_init();
811  #endif  #endif
812    
813            if (lspci_enabled)
814                    lspci_init();
815    
816          rdpdr_init();          rdpdr_init();
817    
818          while (run_count < 2 && continue_connect)       /* add support for Session Directory; only reconnect once */          while (run_count < 2 && continue_connect)       /* add support for Session Directory; only reconnect once */
# Line 1178  str_startswith(const char *s, const char Line 1187  str_startswith(const char *s, const char
1187  }  }
1188    
1189    
1190    /* Split input into lines, and call linehandler for each
1191       line. Incomplete lines are saved in the rest variable, which should
1192       initially point to NULL. When linehandler returns False, stop and
1193       return False. Otherwise, return True.  */
1194    BOOL
1195    str_handle_lines(const char *input, char **rest, str_handle_lines_t linehandler, void *data)
1196    {
1197            char *buf, *p;
1198            char *oldrest;
1199            size_t inputlen;
1200            size_t buflen;
1201            size_t restlen = 0;
1202            BOOL ret = True;
1203    
1204            /* Copy data to buffer */
1205            inputlen = strlen(input);
1206            if (*rest)
1207                    restlen = strlen(*rest);
1208            buflen = restlen + inputlen + 1;
1209            buf = (char *) xmalloc(buflen);
1210            buf[0] = '\0';
1211            if (*rest)
1212                    STRNCPY(buf, *rest, buflen);
1213            strncat(buf, input, inputlen);
1214            p = buf;
1215    
1216            while (1)
1217            {
1218                    char *newline = strchr(p, '\n');
1219                    if (newline)
1220                    {
1221                            *newline = '\0';
1222                            if (!linehandler(p, data))
1223                            {
1224                                    p = newline + 1;
1225                                    ret = False;
1226                                    break;
1227                            }
1228                            p = newline + 1;
1229                    }
1230                    else
1231                    {
1232                            break;
1233    
1234                    }
1235            }
1236    
1237            /* Save in rest */
1238            oldrest = *rest;
1239            restlen = buf + buflen - p;
1240            *rest = (char *) xmalloc(restlen);
1241            STRNCPY((*rest), p, restlen);
1242            xfree(oldrest);
1243    
1244            xfree(buf);
1245            return ret;
1246    }
1247    
1248    /* Execute the program specified by argv. For each line in
1249       stdout/stderr output, call linehandler. Returns false on failure. */
1250    BOOL
1251    subprocess(char *const argv[], str_handle_lines_t linehandler, void *data)
1252    {
1253            pid_t child;
1254            int fd[2];
1255            int n = 1;
1256            char output[256];
1257            char *rest = NULL;
1258    
1259            if (pipe(fd) < 0)
1260            {
1261                    perror("pipe");
1262                    return False;
1263            }
1264    
1265            if ((child = fork()) < 0)
1266            {
1267                    perror("fork");
1268                    return False;
1269            }
1270    
1271            /* Child */
1272            if (child == 0)
1273            {
1274                    /* Close read end */
1275                    close(fd[0]);
1276    
1277                    /* Redirect stdout and stderr to pipe */
1278                    dup2(fd[1], 1);
1279                    dup2(fd[1], 2);
1280    
1281                    /* Execute */
1282                    execvp(argv[0], argv);
1283                    perror("Error executing child");
1284                    _exit(128);
1285            }
1286    
1287            /* Parent. Close write end. */
1288            close(fd[1]);
1289            while (n > 0)
1290            {
1291                    n = read(fd[0], output, 255);
1292                    output[n] = '\0';
1293                    str_handle_lines(output, &rest, linehandler, data);
1294            }
1295            xfree(rest);
1296    
1297            return True;
1298    }
1299    
1300    
1301  /* not all clibs got ltoa */  /* not all clibs got ltoa */
1302  #define LTOA_BUFSIZE (sizeof(long) * 8 + 1)  #define LTOA_BUFSIZE (sizeof(long) * 8 + 1)
1303    

Legend:
Removed from v.1047  
changed lines
  Added in v.1053

  ViewVC Help
Powered by ViewVC 1.1.26