Check-in [c7278fd013]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Win32 port now functional except network operations. This commit was done on windows :-). See win32.txt for status of all commands. No networking commands are functional yet. All path operations are now functioning.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c7278fd013abfe2490ed36ad257e716c9daebf2b
User & Date: jnc 2007-09-22 06:47:11.000
Context
2007-09-22
18:34
Socket operations now functional in Win32 port. Added quotes around the filename portion of the command to edit thus working of windows in paths where the temp directory contains spaces. Added -all flag to clean command. If not specified each file is prompted for before removing. check-in: 8372cc0b81 user: jnc tags: trunk
06:49
Forgot to remove path problems from 'Outstading Issues' check-in: 46f96301f1 user: jnc tags: trunk
06:47
Win32 port now functional except network operations. This commit was done on windows :-). See win32.txt for status of all commands. No networking commands are functional yet. All path operations are now functioning. check-in: c7278fd013 user: jnc tags: trunk
2007-09-21
22:07
Added win32 build notes check-in: 5890c67d86 user: jnc tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/add.c.
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  db_begin_transaction();
  for(i=2; i<g.argc; i++){
    char *zName;
    char *zPath;
    Blob pathname;
    int isDir;

    zName = mprintf("%s", g.argv[i]);
    isDir = file_isdir(zName);
    if( isDir==1 ) continue;
    if( isDir==0 ){
      fossil_fatal("not found: %s", zName);
    }
    if( isDir==2 && access(zName, R_OK) ){
      fossil_fatal("cannot open %s", zName);







|







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  db_begin_transaction();
  for(i=2; i<g.argc; i++){
    char *zName;
    char *zPath;
    Blob pathname;
    int isDir;

    zName = mprintf("%/", g.argv[i]);
    isDir = file_isdir(zName);
    if( isDir==1 ) continue;
    if( isDir==0 ){
      fossil_fatal("not found: %s", zName);
    }
    if( isDir==2 && access(zName, R_OK) ){
      fossil_fatal("cannot open %s", zName);
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  }
  db_begin_transaction();
  for(i=2; i<g.argc; i++){
    char *zName;
    char *zPath;
    Blob pathname;

    zName = mprintf("%s", g.argv[i]);
    file_tree_name(zName, &pathname);
    zPath = blob_str(&pathname);
    if( !db_exists(
             "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){
      fossil_fatal("not in the repository: %s", zName);
    }else{
      db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath);







|







98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  }
  db_begin_transaction();
  for(i=2; i<g.argc; i++){
    char *zName;
    char *zPath;
    Blob pathname;

    zName = mprintf("%/", g.argv[i]);
    file_tree_name(zName, &pathname);
    zPath = blob_str(&pathname);
    if( !db_exists(
             "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){
      fossil_fatal("not in the repository: %s", zName);
    }else{
      db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zPath);
Changes to src/blob.c.
569
570
571
572
573
574
575








576
577
578



579
580
581
582
583
584
585
      zName = zBuf;
      strcpy(zName, zFilename);
    }
    nName = file_simplify_name(zName, nName);
    for(i=1; i<nName; i++){
      if( zName[i]=='/' ){
        zName[i] = 0;








        if( file_mkdir(zName, 1) ){
          fossil_panic("unable to create directory %s", zName);
        }



        zName[i] = '/';
      }
    }
    out = fopen(zName, "wb");
    if( out==0 ){
      fossil_panic("unable to open file \"%s\" for writing", zName);
    }







>
>
>
>
>
>
>
>
|
|
|
>
>
>







569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
      zName = zBuf;
      strcpy(zName, zFilename);
    }
    nName = file_simplify_name(zName, nName);
    for(i=1; i<nName; i++){
      if( zName[i]=='/' ){
        zName[i] = 0;
#ifdef __MINGW32__
        /*
        ** On Windows, local path looks like: C:/develop/project/file.txt
        ** The if stops us from trying to create a directory of a drive letter
        ** C: in this example.
        */
        if( !(i==2 && zName[1]==':') ){
#endif
          if( file_mkdir(zName, 1) ){
            fossil_panic("unable to create directory %s", zName);
          }
#ifdef __MINGW32__
        }
#endif
        zName[i] = '/';
      }
    }
    out = fopen(zName, "wb");
    if( out==0 ){
      fossil_panic("unable to open file \"%s\" for writing", zName);
    }
Changes to src/db.c.
488
489
490
491
492
493
494
495











496
497
498




499

500
501
502
503
504
505
506

/*
** Open the user database in "~/.fossil".  Create the database anew if
** it does not already exist.
*/
void db_open_config(void){
  char *zDbName;
  const char *zHome = getenv("HOME");











  if( zHome==0 ){
    db_err("cannot local home directory");
  }




  zDbName = mprintf("%s/.fossil", zHome);

  if( g.configOpen ) return;
  if( file_size(zDbName)<1024*3 ){
    db_init_database(zDbName, zConfigSchema, (char*)0);
  }
  db_open_or_attach(zDbName, "configdb");
  g.configOpen = 1;
}







|
>
>
>
>
>
>
>
>
>
>
>



>
>
>
>

>







488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522

/*
** Open the user database in "~/.fossil".  Create the database anew if
** it does not already exist.
*/
void db_open_config(void){
  char *zDbName;
  const char *zHome;
#ifdef __MINGW32__
  zHome = getenv("LOCALAPPDATA");
  if( zHome==0 ){
    zHome = getenv("APPDATA");
    if( zHome==0 ){
      zHome = getenv("HOMEPATH");
    }
  }
#else
  zHome = getenv("HOME");
#endif
  if( zHome==0 ){
    db_err("cannot local home directory");
  }
#ifdef __MINGW32__
  /* . filenames give some window systems problems and many apps problems */
  zDbName = mprintf("%s/_fossil", zHome);
#else
  zDbName = mprintf("%s/.fossil", zHome);
#endif
  if( g.configOpen ) return;
  if( file_size(zDbName)<1024*3 ){
    db_init_database(zDbName, zConfigSchema, (char*)0);
  }
  db_open_or_attach(zDbName, "configdb");
  g.configOpen = 1;
}
534
535
536
537
538
539
540

541
542
543
544
545



546
547
548
549
550
551
552
** This routine always opens the user database regardless of whether or
** not the repository database is found.  If the FOSSIL file is found,
** it is attached to the open database connection too.
*/
int db_open_local(void){
  int n;
  char zPwd[2000];

  if( g.localOpen) return 1;
  if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
    db_err("pwd too big: max %d", sizeof(zPwd)-20);
  }
  n = strlen(zPwd);



  while( n>0 ){
    if( access(zPwd, W_OK) ) break;
    strcpy(&zPwd[n], "/_FOSSIL_");
    if( isValidLocalDb(zPwd) ){
      /* Found a valid _FOSSIL_ file */
      zPwd[n] = 0;
      g.zLocalRoot = mprintf("%s/", zPwd);







>





>
>
>







550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
** This routine always opens the user database regardless of whether or
** not the repository database is found.  If the FOSSIL file is found,
** it is attached to the open database connection too.
*/
int db_open_local(void){
  int n;
  char zPwd[2000];
  char *zPwdConv;
  if( g.localOpen) return 1;
  if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
    db_err("pwd too big: max %d", sizeof(zPwd)-20);
  }
  n = strlen(zPwd);
  zPwdConv = mprintf("%/", zPwd);
  strncpy(zPwd, zPwdConv, 2000-20);
  free(zPwdConv);
  while( n>0 ){
    if( access(zPwd, W_OK) ) break;
    strcpy(&zPwd[n], "/_FOSSIL_");
    if( isValidLocalDb(zPwd) ){
      /* Found a valid _FOSSIL_ file */
      zPwd[n] = 0;
      g.zLocalRoot = mprintf("%s/", zPwd);
Changes to src/file.c.
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
  }else{
    char zPwd[2000];
    if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
      fprintf(stderr, "pwd too big: max %d\n", sizeof(zPwd)-20);
      exit(1);
    }
    blob_zero(pOut);
    blob_appendf(pOut, "%s/%s", zPwd, zOrigName);
  }
  blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut)));
}

/*
** COMMAND:  test-canonical-name
**







|







190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
  }else{
    char zPwd[2000];
    if( getcwd(zPwd, sizeof(zPwd)-20)==0 ){
      fprintf(stderr, "pwd too big: max %d\n", sizeof(zPwd)-20);
      exit(1);
    }
    blob_zero(pOut);
    blob_appendf(pOut, "%//%/", zPwd, zOrigName);
  }
  blob_resize(pOut, file_simplify_name(blob_buffer(pOut), blob_size(pOut)));
}

/*
** COMMAND:  test-canonical-name
**
Changes to src/http.c.
38
39
40
41
42
43
44


















45
46
47
48
49
50
51
52
53
54
55


56
57
58
59
60
61
62
#include <sys/types.h>
#include <signal.h>

/*
** Persistent information about the HTTP connection.
*/
static FILE *pSocket = 0;   /* The socket on which we talk to the server */



















/*
** Open a socket connection to the server.  Return 0 on success and
** non-zero if an error occurs.
*/
static int http_open_socket(void){
  static struct sockaddr_in addr;  /* The server address */
  static int addrIsInit = 0;       /* True once addr is initialized */
  int s;

  if( !addrIsInit ){


    addr.sin_family = AF_INET;
    addr.sin_port = htons(g.urlPort);
    *(int*)&addr.sin_addr = inet_addr(g.urlName);
    if( -1 == *(int*)&addr.sin_addr ){
#ifndef FOSSIL_STATIC_LINK
      struct hostent *pHost;
      pHost = gethostbyname(g.urlName);







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









|

>
>







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <sys/types.h>
#include <signal.h>

/*
** Persistent information about the HTTP connection.
*/
static FILE *pSocket = 0;   /* The socket on which we talk to the server */

#ifdef __MINGW32__
static WSADATA ws_info;
#endif

static void ws_init(){
#ifdef __MINGW32__
  if (WSAStartup(MAKEWORD(1,1), &ws_info) != 0){
    fossil_panic("can't initialize winsock");
  }
#endif
}

static void ws_cleanup(){
#ifdef __MINGW32__
  WSACleanup();
#endif
}

/*
** Open a socket connection to the server.  Return 0 on success and
** non-zero if an error occurs.
*/
static int http_open_socket(void){
  static struct sockaddr_in addr;  /* The server address */
  static int addrIsInit = 0;       /* True once addr is initialized */
  int s;
  
  if( !addrIsInit ){
    ws_init();

    addr.sin_family = AF_INET;
    addr.sin_port = htons(g.urlPort);
    *(int*)&addr.sin_addr = inet_addr(g.urlName);
    if( -1 == *(int*)&addr.sin_addr ){
#ifndef FOSSIL_STATIC_LINK
      struct hostent *pHost;
      pHost = gethostbyname(g.urlName);
267
268
269
270
271
272
273

274
275
/*
** Make sure the socket to the HTTP server is closed 
*/
void http_close(void){
  if( pSocket ){
    fclose(pSocket);
    pSocket = 0;

  }
}







>


287
288
289
290
291
292
293
294
295
296
/*
** Make sure the socket to the HTTP server is closed 
*/
void http_close(void){
  if( pSocket ){
    fclose(pSocket);
    pSocket = 0;
    ws_cleanup();
  }
}
Changes to src/printf.c.
47
48
49
50
51
52
53

54
55
56
57
58
59
60
#define etSQLESCAPE2 14 /* Strings with '\'' doubled and enclosed in '',
                          NULL pointers replaced by SQL NULL.  %Q */
#define etPOINTER    15 /* The %p conversion */
#define etHTMLIZE    16 /* Make text safe for HTML */
#define etHTTPIZE    17 /* Make text safe for HTTP.  "/" encoded as %2f */
#define etURLIZE     18 /* Make text safe for HTTP.  "/" not encoded */
#define etFOSSILIZE  19 /* The fossil header encoding format. */



/*
** An "etByte" is an 8-bit unsigned value.
*/
typedef unsigned char etByte;








>







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#define etSQLESCAPE2 14 /* Strings with '\'' doubled and enclosed in '',
                          NULL pointers replaced by SQL NULL.  %Q */
#define etPOINTER    15 /* The %p conversion */
#define etHTMLIZE    16 /* Make text safe for HTML */
#define etHTTPIZE    17 /* Make text safe for HTTP.  "/" encoded as %2f */
#define etURLIZE     18 /* Make text safe for HTTP.  "/" not encoded */
#define etFOSSILIZE  19 /* The fossil header encoding format. */
#define etPATH       20 /* Path type */


/*
** An "etByte" is an 8-bit unsigned value.
*/
typedef unsigned char etByte;

107
108
109
110
111
112
113

114
115
116
117
118
119
120
  {  'e',  0, 1, etEXP,        30, 0 },
  {  'E',  0, 1, etEXP,        14, 0 },
  {  'G',  0, 1, etGENERIC,    14, 0 },
  {  'i', 10, 1, etRADIX,      0,  0 },
  {  'n',  0, 0, etSIZE,       0,  0 },
  {  '%',  0, 0, etPERCENT,    0,  0 },
  {  'p', 16, 0, etPOINTER,    0,  1 },

};
#define etNINFO  (sizeof(fmtinfo)/sizeof(fmtinfo[0]))

/*
** "*val" is a double such that 0.1 <= *val < 10.0
** Return the ascii code for the leading digit of *val, then
** multiply "*val" by 10.0 to renormalize.







>







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
  {  'e',  0, 1, etEXP,        30, 0 },
  {  'E',  0, 1, etEXP,        14, 0 },
  {  'G',  0, 1, etGENERIC,    14, 0 },
  {  'i', 10, 1, etRADIX,      0,  0 },
  {  'n',  0, 0, etSIZE,       0,  0 },
  {  '%',  0, 0, etPERCENT,    0,  0 },
  {  'p', 16, 0, etPOINTER,    0,  1 },
  {  '/',  0, 0, etPATH,       0,  0 },
};
#define etNINFO  (sizeof(fmtinfo)/sizeof(fmtinfo[0]))

/*
** "*val" is a double such that 0.1 <= *val < 10.0
** Return the ascii code for the leading digit of *val, then
** multiply "*val" by 10.0 to renormalize.
539
540
541
542
543
544
545
















546
547
548
549
550
551
552
          for(idx=1; idx<precision; idx++) buf[idx] = c;
          length = precision;
        }else{
          length =1;
        }
        bufpt = buf;
        break;
















      case etSTRING:
      case etDYNSTRING:
        bufpt = va_arg(ap,char*);
        if( bufpt==0 ){
          bufpt = "";
        }else if( xtype==etDYNSTRING ){
          zExtra = bufpt;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
          for(idx=1; idx<precision; idx++) buf[idx] = c;
          length = precision;
        }else{
          length =1;
        }
        bufpt = buf;
        break;
      case etPATH: {
        int i;
        char *e = va_arg(ap,char*);
        if( e==0 ){e="";}
        length = strlen(e);
        zExtra = bufpt = malloc(length+1);
        for( i=0; i<length; i++ ){
          if( e[i]=='\\' ){
            bufpt[i]='/';
          }else{
            bufpt[i]=e[i];
          }
        }
        bufpt[length]='\0';
        break;
      }
      case etSTRING:
      case etDYNSTRING:
        bufpt = va_arg(ap,char*);
        if( bufpt==0 ){
          bufpt = "";
        }else if( xtype==etDYNSTRING ){
          zExtra = bufpt;
Changes to win32.txt.
9
10
11
12
13
14
15




















































































    MSYS  1.0.10
  
  Download/compile/install zlib (configure --prefix=/mingw)
  Download/compile/install tclsh (configure --prefix=/) (for tests)
  
  All commands were issued in the MSYS shell, not a cmd.exe




























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    MSYS  1.0.10
  
  Download/compile/install zlib (configure --prefix=/mingw)
  Download/compile/install tclsh (configure --prefix=/) (for tests)
  
  All commands were issued in the MSYS shell, not a cmd.exe



Outstanding Issues:
----------------------------------------------------------------------

* server is totally non-functional - #if/#end'd out of the code
* all path operations are defunct
* remote network operations are reporting: can't resolve host name: xyz
  
  Winsock must be initialized before using:
  
      WSADATA info;
      if (WSAStartup(MAKEWORD(1,1), &info) != 0){
        fossil_panic("can't initialize winsock");
      }



Commands status:
----------------------------------------------------------------------

add               OK
cgi               Not tested
changes           OK
checkout          BAD #1
clean             OK
clone             Local Only #2
close             OK
commit            OK (not tested with gpg signing yet)
config            OK
deconstruct       OK
del               OK
descendents       OK
diff              OK
extra             OK
help              OK
http              Not Tested
info              OK
leaves            OK
ls                OK
merge             OK
new               OK
open              OK
pull              BAD #2
push              BAD #2
rebuild           OK (didn't have a corrupt file to try on though)
redo              BAD #3
rm                OK
server            BAD #2,#4
status            OK
sync              BAD #2
timeline          OK
tkdiff            OK
undo              OK
update            OK
user capabilities OK
user default      OK
user list         OK
user new          OK
user password     OK

#1 Have a repo where I removed a file. I did a fossil checkout 123abc,
   which is the last version that had the file. The file does not
   appear. fossil checkout --force 123abc does things, but still the
   file does not appear.
   
   Make a new dir, fossil open ../repo.fsl && fossil checkout 123abc and
   the file appears.
   
   Is that normal operation?

#2 No socket operations are functioning yet

#3 In test1/ I edited a file, test2/ I updated, type file.txt changes
   were there. I then did fossil undo file.txt. The changes were gone
   and fossil status said I had edited file.txt. A fossil redo did not
   print anything to the screen and the changes for file.txt are not
   in the file. fossil status still reports that the file was edited.
   There was no commit/update or any other command inbetween these
   actions.

#4 There were various difficulties in this function beyond simple socket
   problems. The major one being fork. This will probably be the last
   command to be functional in fossil on windows.