Changes between Version 9 and Version 10 of AppDev


Ignore:
Timestamp:
Jun 19, 2014, 9:54:38 AM (10 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AppDev

    v9 v10  
    1 = Application development tips =
     1= Cross-platform functions =
    22
    3 == Cross-platform functions ==
     3If you're porting an existing Unix app to Windows,
     4you'll find that while most POSIX calls are supported on Windows,
     5some are not.
    46
    5 Most POSIX calls are supported on Unix and Windows. For areas that are different (e.g. scanning directories) BOINC supplies some generic functions with implementations for all platforms. Similar code may be available from other open-source projects.
     7BOINC supplies some generic functions with implementations for all platforms.
     8Similar code may be available from other open-source projects
     9
     10General functions (in lib/util.cpp/h):
    611
    712 double dtime():: return Unix time with fractional seconds
    813 double dday():: return Unix time at start of this day
    914 void boinc_sleep(double):: sleep for given period
    10  read_file_string(const char*, string):: read file into string
     15 double drand(), rand_normal():: uniform and normal random numbers
     16 read_file_string(const char* path, std::string&):: read file into string
    1117
    12 etc. See lib/util.h and lib/filesys.h for others.
     18Filesystem functions (in lib/filesys.cpp/h):
     19{{{
     20  extern int boinc_delete_file(const char*);
     21  extern int boinc_touch_file(const char *path);
     22  extern FILE* boinc_fopen(const char* path, const char* mode);
     23  extern int boinc_copy(const char* orig, const char* newf);
     24  extern int boinc_rename(const char* old, const char* newf);
     25  extern int boinc_mkdir(const char*);
     26#ifdef _WIN32
     27  extern int boinc_allocate_file(const char*, double size);
     28#else
     29  extern int boinc_chown(const char*, gid_t);
     30#endif
     31  extern int boinc_rmdir(const char*);
     32  extern void boinc_getcwd(char*);
     33  extern void relative_to_absolute(const char* relname, char* path);
     34  extern int is_file(const char* path);
     35  extern int is_dir(const char* path);
     36  extern int is_file_follow_symlinks(const char* path);
     37  extern int is_dir_follow_symlinks(const char* path);
     38  extern int is_symlink(const char* path);
     39  extern bool is_dir_empty(const char*);
     40  extern int boinc_truncate(const char*, double);
     41  extern int boinc_file_exists(const char* path);
     42  extern int boinc_file_or_symlink_exists(const char* path);
     43  extern int file_size(const char*, double&);
     44  extern int clean_out_dir(const char*);
     45  extern int dir_size(const char* dirpath, double&, bool recurse=true);
    1346
    14 == Windows-specific issues ==
     47  class DirScanner;   // for scanning directories
     48  struct FILE_LOCK;   // for locking a file
     49}}}
    1550
    16  * Visual Studio: set '!Create/Use Precompiled Header' to 'Automatically Generate' ({{{/YX}}}) in C/C++ Precompiled Header project properties.
    17  * Visual Studio: change 'Compile As' to 'Compile as C++ Code ({{{/TP}}})' in C/C++ 'Compile As' project properties.
     51Various RSA cryptographic functions: lib/crypt.cpp,h
    1852
    19 == Unix-specific issues ==
     53Various MD5 hash functions: lib/md5.cpp,h
    2054
    21 === Shared libraries ===
     55Semaphores: lib/synch.cpp,h
    2256
    23 Your application can use shared libraries (.so).
    24 Include these as separate files.
    25 They will reside in your project's directory on the client host.
    26 The BOINC client appends the project directory to LD_LIBRARY_PATH,
    27 so your program will find them and run correctly.
     57Shared memory: lib/shmem.cpp,h
    2858
    29 A problem may arise if you support multiple platforms
    30 (say, Linux32 and Linux64).
    31 You need different versions of the shared library for each platform.
    32 These libraries must have distinct physical names - say, libfoo_1.1_linux32.so
    33 and libfoo_1.1_linux64.so.
    34 
    35 But what if there are multiple shared libraries, and some depend on others?
    36 It may be difficult to change the Makefiles to use these distinct names.
    37 Here's what you can do to solve this problem:
    38 
    39  * Give each shared library its 'natural' name (e.g., libfoo.so) as its logical name.
    40  * Give shared libraries the "copy_file" attribute.
    41 
    42 The client will then copy these libraries into the app's execution directory,
    43 giving it the logical name.
     59Network communication: lib/network.cpp,h