2003-07-01 20:37:09 +00:00
|
|
|
// The contents of this file are subject to the BOINC Public License
|
|
|
|
// Version 1.0 (the "License"); you may not use this file except in
|
|
|
|
// compliance with the License. You may obtain a copy of the License at
|
|
|
|
// http://boinc.berkeley.edu/license_1.0.txt
|
2003-10-29 11:05:39 +00:00
|
|
|
//
|
2003-07-01 20:37:09 +00:00
|
|
|
// Software distributed under the License is distributed on an "AS IS"
|
|
|
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
|
|
|
// License for the specific language governing rights and limitations
|
2003-10-29 11:05:39 +00:00
|
|
|
// under the License.
|
|
|
|
//
|
|
|
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
|
|
|
//
|
2003-07-01 20:37:09 +00:00
|
|
|
// The Initial Developer of the Original Code is the SETI@home project.
|
|
|
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
2003-10-29 11:05:39 +00:00
|
|
|
// University of California at Berkeley. All Rights Reserved.
|
|
|
|
//
|
2003-07-01 20:37:09 +00:00
|
|
|
// Contributor(s):
|
|
|
|
//
|
|
|
|
|
2004-03-04 11:41:43 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include "stdafx.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
2003-05-07 23:42:17 +00:00
|
|
|
#include <string.h>
|
2004-03-04 11:41:43 +00:00
|
|
|
#endif
|
2003-05-07 23:42:17 +00:00
|
|
|
|
2004-06-08 14:37:42 +00:00
|
|
|
#include "boinc_api.h"
|
2003-05-07 23:42:17 +00:00
|
|
|
#include "parse.h"
|
2003-06-14 20:24:29 +00:00
|
|
|
#include "error_numbers.h"
|
2003-05-07 23:42:17 +00:00
|
|
|
#include "util.h"
|
2004-05-19 23:16:19 +00:00
|
|
|
#include "filesys.h"
|
2003-05-07 23:42:17 +00:00
|
|
|
|
|
|
|
#include "app_ipc.h"
|
|
|
|
|
2004-01-08 00:27:59 +00:00
|
|
|
char* xml_graphics_modes[NGRAPHICS_MODES] = {
|
2003-05-09 20:33:57 +00:00
|
|
|
"<mode_unsupported/>",
|
|
|
|
"<mode_hide_graphics/>",
|
|
|
|
"<mode_window/>",
|
|
|
|
"<mode_fullscreen/>",
|
|
|
|
"<mode_blankscreen/>"
|
2003-05-07 23:42:17 +00:00
|
|
|
};
|
|
|
|
|
2003-10-31 22:37:46 +00:00
|
|
|
#define REREAD_PREFS_MSG "<reread_prefs/>"
|
|
|
|
|
2003-05-07 23:42:17 +00:00
|
|
|
int write_init_data_file(FILE* f, APP_INIT_DATA& ai) {
|
2004-02-02 22:17:48 +00:00
|
|
|
string str1, str2;
|
2003-09-27 17:53:43 +00:00
|
|
|
if (strlen(ai.app_name)) {
|
|
|
|
fprintf(f, "<app_name>%s</app_name>\n", ai.app_name);
|
|
|
|
}
|
2004-04-23 23:01:04 +00:00
|
|
|
if (strlen(ai.project_preferences)) {
|
|
|
|
fprintf(f, "<project_preferences>\n%s</project_preferences>\n", ai.project_preferences);
|
2003-05-07 23:42:17 +00:00
|
|
|
}
|
|
|
|
if (strlen(ai.team_name)) {
|
2004-02-02 22:17:48 +00:00
|
|
|
str1 = ai.team_name;
|
|
|
|
xml_escape(str1, str2);
|
|
|
|
fprintf(f, "<team_name>%s</team_name>\n", str2.c_str());
|
2003-05-07 23:42:17 +00:00
|
|
|
}
|
|
|
|
if (strlen(ai.user_name)) {
|
2004-02-02 22:17:48 +00:00
|
|
|
str1 = ai.user_name;
|
|
|
|
xml_escape(str1, str2);
|
|
|
|
fprintf(f, "<user_name>%s</user_name>\n", str2.c_str());
|
2003-05-07 23:42:17 +00:00
|
|
|
}
|
2004-04-23 00:05:16 +00:00
|
|
|
if (strlen(ai.project_dir)) {
|
|
|
|
fprintf(f, "<project_dir>%s</project_dir>\n", ai.project_dir);
|
|
|
|
}
|
2004-04-23 22:51:28 +00:00
|
|
|
if (strlen(ai.boinc_dir)) {
|
|
|
|
fprintf(f, "<boinc_dir>%s</boinc_dir>\n", ai.boinc_dir);
|
|
|
|
}
|
|
|
|
if (strlen(ai.authenticator)) {
|
|
|
|
fprintf(f, "<authenticator>%s</authenticator>\n", ai.authenticator);
|
|
|
|
}
|
2004-04-23 00:05:16 +00:00
|
|
|
if (strlen(ai.wu_name)) {
|
|
|
|
fprintf(f, "<wu_name>%s</wu_name>\n", ai.wu_name);
|
|
|
|
}
|
2004-03-27 00:23:19 +00:00
|
|
|
#ifdef _WIN32
|
2003-05-07 23:42:17 +00:00
|
|
|
if (strlen(ai.comm_obj_name)) {
|
|
|
|
fprintf(f, "<comm_obj_name>%s</comm_obj_name>\n", ai.comm_obj_name);
|
|
|
|
}
|
2004-04-23 00:05:16 +00:00
|
|
|
#else
|
|
|
|
fprintf(f, "<shm_key>%d</shm_key>\n", ai.shm_key);
|
2004-03-27 00:23:19 +00:00
|
|
|
#endif
|
2003-05-07 23:42:17 +00:00
|
|
|
fprintf(f,
|
2004-04-23 22:51:28 +00:00
|
|
|
"<slot>%d</slot>\n"
|
2003-05-07 23:42:17 +00:00
|
|
|
"<wu_cpu_time>%f</wu_cpu_time>\n"
|
|
|
|
"<user_total_credit>%f</user_total_credit>\n"
|
|
|
|
"<user_expavg_credit>%f</user_expavg_credit>\n"
|
|
|
|
"<host_total_credit>%f</host_total_credit>\n"
|
|
|
|
"<host_expavg_credit>%f</host_expavg_credit>\n"
|
|
|
|
"<checkpoint_period>%f</checkpoint_period>\n"
|
2004-05-24 04:03:34 +00:00
|
|
|
"<fraction_done_update_period>%f</fraction_done_update_period>\n"
|
|
|
|
"<fraction_done_start>%f</fraction_done_start>"
|
|
|
|
"<fraction_done_end>%f</fraction_done_end>",
|
2004-04-23 22:51:28 +00:00
|
|
|
ai.slot,
|
2003-05-07 23:42:17 +00:00
|
|
|
ai.wu_cpu_time,
|
|
|
|
ai.user_total_credit,
|
|
|
|
ai.user_expavg_credit,
|
|
|
|
ai.host_total_credit,
|
|
|
|
ai.host_expavg_credit,
|
|
|
|
ai.checkpoint_period,
|
2004-05-24 04:03:34 +00:00
|
|
|
ai.fraction_done_update_period,
|
|
|
|
ai.fraction_done_start,
|
|
|
|
ai.fraction_done_end
|
2003-05-07 23:42:17 +00:00
|
|
|
);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int parse_init_data_file(FILE* f, APP_INIT_DATA& ai) {
|
|
|
|
char buf[256];
|
|
|
|
memset(&ai, 0, sizeof(ai));
|
2004-05-24 04:03:34 +00:00
|
|
|
ai.fraction_done_start = 0;
|
|
|
|
ai.fraction_done_end = 1;
|
2003-05-07 23:42:17 +00:00
|
|
|
while (fgets(buf, 256, f)) {
|
2004-04-23 23:01:04 +00:00
|
|
|
if (match_tag(buf, "<project_preferences>")) {
|
|
|
|
safe_strncpy(ai.project_preferences, "", sizeof(ai.project_preferences));
|
2003-05-07 23:42:17 +00:00
|
|
|
while (fgets(buf, 256, f)) {
|
2004-04-23 23:01:04 +00:00
|
|
|
if (match_tag(buf, "</project_preferences>")) break;
|
|
|
|
safe_strcat(ai.project_preferences, buf);
|
2003-05-07 23:42:17 +00:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2003-09-27 17:53:43 +00:00
|
|
|
else if (parse_str(buf, "<app_name>", ai.app_name, sizeof(ai.app_name))) continue;
|
2003-05-07 23:42:17 +00:00
|
|
|
else if (parse_str(buf, "<user_name>", ai.user_name, sizeof(ai.user_name))) continue;
|
|
|
|
else if (parse_str(buf, "<team_name>", ai.team_name, sizeof(ai.team_name))) continue;
|
2004-04-23 00:05:16 +00:00
|
|
|
else if (parse_str(buf, "<project_dir>", ai.project_dir, sizeof(ai.project_dir))) continue;
|
2004-04-23 22:51:28 +00:00
|
|
|
else if (parse_str(buf, "<boinc_dir>", ai.boinc_dir, sizeof(ai.boinc_dir))) continue;
|
|
|
|
else if (parse_str(buf, "<authenticator>", ai.authenticator, sizeof(ai.authenticator))) continue;
|
2004-04-23 00:05:16 +00:00
|
|
|
else if (parse_str(buf, "<wu_name>", ai.wu_name, sizeof(ai.wu_name))) continue;
|
2004-03-31 19:43:15 +00:00
|
|
|
#ifdef _WIN32
|
2003-05-07 23:42:17 +00:00
|
|
|
else if (parse_str(buf, "<comm_obj_name>", ai.comm_obj_name, sizeof(ai.comm_obj_name))) continue;
|
2004-04-23 00:05:16 +00:00
|
|
|
#else
|
|
|
|
else if (parse_int(buf, "<shm_key>", ai.shm_key)) continue;
|
2004-03-31 19:43:15 +00:00
|
|
|
#endif
|
2004-04-23 22:51:28 +00:00
|
|
|
else if (parse_int(buf, "<slot>", ai.slot)) continue;
|
2003-05-07 23:42:17 +00:00
|
|
|
else if (parse_double(buf, "<user_total_credit>", ai.user_total_credit)) continue;
|
|
|
|
else if (parse_double(buf, "<user_expavg_credit>", ai.user_expavg_credit)) continue;
|
|
|
|
else if (parse_double(buf, "<host_total_credit>", ai.host_total_credit)) continue;
|
|
|
|
else if (parse_double(buf, "<host_expavg_credit>", ai.host_expavg_credit)) continue;
|
|
|
|
else if (parse_double(buf, "<wu_cpu_time>", ai.wu_cpu_time)) continue;
|
|
|
|
else if (parse_double(buf, "<checkpoint_period>", ai.checkpoint_period)) continue;
|
|
|
|
else if (parse_double(buf, "<fraction_done_update_period>", ai.fraction_done_update_period)) continue;
|
2004-05-24 04:03:34 +00:00
|
|
|
else if (parse_double(buf, "<fraction_done_start>", ai.fraction_done_start)) continue;
|
|
|
|
else if (parse_double(buf, "<fraction_done_end>", ai.fraction_done_end)) continue;
|
2004-04-14 23:32:17 +00:00
|
|
|
//else fprintf(stderr, "parse_init_data_file: unrecognized %s", buf);
|
2003-05-07 23:42:17 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: this should handle arbitrarily many fd/filename pairs.
|
|
|
|
// Also, give the tags better names
|
2003-09-27 17:53:43 +00:00
|
|
|
//
|
|
|
|
int write_fd_init_file(FILE* f, char *file_name, int fdesc, bool input_file) {
|
2003-05-07 23:42:17 +00:00
|
|
|
if (input_file) {
|
|
|
|
fprintf(f, "<fdesc_dup_infile>%s</fdesc_dup_infile>\n", file_name);
|
|
|
|
fprintf(f, "<fdesc_dup_innum>%d</fdesc_dup_innum>\n", fdesc);
|
|
|
|
} else {
|
|
|
|
fprintf(f, "<fdesc_dup_outfile>%s</fdesc_dup_outfile>\n", file_name);
|
|
|
|
fprintf(f, "<fdesc_dup_outnum>%d</fdesc_dup_outnum>\n", fdesc);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: this should handle arbitrarily many fd/filename pairs.
|
|
|
|
// Also, this shouldn't be doing the actual duping!
|
|
|
|
//
|
|
|
|
int parse_fd_init_file(FILE* f) {
|
|
|
|
char buf[256],filename[256];
|
|
|
|
int filedesc;
|
|
|
|
while (fgets(buf, 256, f)) {
|
|
|
|
if (parse_str(buf, "<fdesc_dup_infile>", filename, sizeof(filename))) {
|
|
|
|
if (fgets(buf, 256, f)) {
|
|
|
|
if (parse_int(buf, "<fdesc_dup_innum>", filedesc)) {
|
|
|
|
freopen(filename, "r", stdin);
|
|
|
|
fprintf(stderr, "opened input file %s\n", filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (parse_str(buf, "<fdesc_dup_outfile>", filename, sizeof(filename))) {
|
|
|
|
if (fgets(buf, 256, f)) {
|
|
|
|
if (parse_int(buf, "<fdesc_dup_outnum>", filedesc)) {
|
|
|
|
freopen(filename, "w", stdout);
|
|
|
|
fprintf(stderr, "opened output file %s\n", filename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else fprintf(stderr, "parse_fd_init_file: unrecognized %s", buf);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-02-09 05:11:05 +00:00
|
|
|
APP_CLIENT_SHM::APP_CLIENT_SHM() {
|
|
|
|
shm = 0;
|
|
|
|
}
|
|
|
|
|
2003-05-07 23:42:17 +00:00
|
|
|
bool APP_CLIENT_SHM::pending_msg(int seg_num) {
|
2003-05-09 20:33:57 +00:00
|
|
|
if (seg_num < 0 || seg_num >= NUM_SEGS || shm == NULL) return false;
|
|
|
|
return (shm[seg_num*SHM_SEG_SIZE]?true:false);
|
2003-05-07 23:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool APP_CLIENT_SHM::get_msg(char *msg, int seg_num) {
|
2003-05-09 20:33:57 +00:00
|
|
|
if (seg_num < 0 || seg_num >= NUM_SEGS || shm == NULL) return false;
|
2003-05-08 18:11:05 +00:00
|
|
|
|
2003-05-09 20:33:57 +00:00
|
|
|
// Check if there's an available message
|
2003-05-08 18:11:05 +00:00
|
|
|
//
|
2003-05-09 20:33:57 +00:00
|
|
|
if (!shm[seg_num*SHM_SEG_SIZE]) return false;
|
2003-05-08 18:11:05 +00:00
|
|
|
|
2003-05-09 20:33:57 +00:00
|
|
|
// Copy the message from shared memory
|
2003-05-08 18:11:05 +00:00
|
|
|
//
|
2004-01-08 00:27:59 +00:00
|
|
|
safe_strncpy(msg, &shm[(seg_num*SHM_SEG_SIZE)+1], SHM_SEG_SIZE-1);
|
2003-05-08 18:11:05 +00:00
|
|
|
|
2003-05-09 20:33:57 +00:00
|
|
|
// Reset the message status flag
|
2003-05-08 18:11:05 +00:00
|
|
|
//
|
2003-05-09 20:33:57 +00:00
|
|
|
shm[seg_num*SHM_SEG_SIZE] = 0;
|
|
|
|
return true;
|
2003-05-07 23:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool APP_CLIENT_SHM::send_msg(char *msg,int seg_num) {
|
2003-05-09 20:33:57 +00:00
|
|
|
if (seg_num < 0 || seg_num >= NUM_SEGS || shm == NULL) return false;
|
2003-05-08 18:11:05 +00:00
|
|
|
|
2003-05-09 20:33:57 +00:00
|
|
|
// Check if there's already a message
|
2003-05-08 18:11:05 +00:00
|
|
|
//
|
2003-05-09 20:33:57 +00:00
|
|
|
//if (shm[seg_num*SHM_SEG_SIZE]) return false;
|
2003-05-08 18:11:05 +00:00
|
|
|
|
2003-05-09 20:33:57 +00:00
|
|
|
// Copy the message into shared memory
|
2003-05-08 18:11:05 +00:00
|
|
|
//
|
2004-01-08 00:27:59 +00:00
|
|
|
safe_strncpy(&shm[(seg_num*SHM_SEG_SIZE)+1], msg, SHM_SEG_SIZE-1);
|
2003-05-08 18:11:05 +00:00
|
|
|
|
2003-05-09 20:33:57 +00:00
|
|
|
// Set the message status flag
|
2003-05-08 18:11:05 +00:00
|
|
|
//
|
2003-05-09 20:33:57 +00:00
|
|
|
shm[seg_num*SHM_SEG_SIZE] = 1;
|
|
|
|
return true;
|
2003-05-07 23:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void APP_CLIENT_SHM::reset_msgs(void) {
|
2003-05-09 20:33:57 +00:00
|
|
|
if (shm == NULL) return;
|
|
|
|
memset(shm, 0, sizeof(char)*NUM_SEGS*SHM_SEG_SIZE);
|
2003-05-07 23:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void APP_CLIENT_SHM::reset_msg(int seg_num) {
|
2003-05-09 20:33:57 +00:00
|
|
|
if (seg_num < 0 || seg_num >= NUM_SEGS || shm == NULL) return;
|
|
|
|
memset(&shm[seg_num*SHM_SEG_SIZE], 0, sizeof(char)*SHM_SEG_SIZE);
|
2003-05-07 23:42:17 +00:00
|
|
|
}
|
|
|
|
|
2003-10-30 23:23:52 +00:00
|
|
|
bool APP_CLIENT_SHM::send_graphics_msg(int seg, int msg, int mode) {
|
|
|
|
switch (msg) {
|
|
|
|
case GRAPHICS_MSG_SET_MODE:
|
|
|
|
return send_msg(xml_graphics_modes[mode], seg);
|
|
|
|
break;
|
|
|
|
case GRAPHICS_MSG_REREAD_PREFS:
|
|
|
|
return send_msg(REREAD_PREFS_MSG, seg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
2003-05-07 23:42:17 +00:00
|
|
|
}
|
|
|
|
|
2003-10-30 23:23:52 +00:00
|
|
|
bool APP_CLIENT_SHM::get_graphics_msg(int seg, int& msg, int& mode) {
|
2003-05-09 20:33:57 +00:00
|
|
|
char buf[SHM_SEG_SIZE];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!get_msg(buf, seg)) return false;
|
2004-01-08 00:27:59 +00:00
|
|
|
for (i=0; i<NGRAPHICS_MODES; i++) {
|
2003-05-09 20:33:57 +00:00
|
|
|
if (match_tag(buf, xml_graphics_modes[i])) {
|
2003-10-30 23:23:52 +00:00
|
|
|
msg = GRAPHICS_MSG_SET_MODE;
|
2003-05-09 20:33:57 +00:00
|
|
|
mode = i;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2003-10-30 23:23:52 +00:00
|
|
|
if (match_tag(buf, REREAD_PREFS_MSG)) {
|
|
|
|
msg = GRAPHICS_MSG_REREAD_PREFS;
|
|
|
|
return true;
|
|
|
|
}
|
2003-05-09 20:33:57 +00:00
|
|
|
return false;
|
2003-05-07 23:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int write_graphics_file(FILE* f, GRAPHICS_INFO* gi) {
|
|
|
|
fprintf(f,
|
|
|
|
"<graphics_info>\n"
|
|
|
|
" <graphics_xsize>%d</graphics_xsize>\n"
|
|
|
|
" <graphics_ysize>%d</graphics_ysize>\n"
|
|
|
|
" <graphics_refresh_period>%f</graphics_refresh_period>\n"
|
|
|
|
"</graphics_info>\n",
|
|
|
|
gi->xsize,
|
|
|
|
gi->ysize,
|
|
|
|
gi->refresh_period
|
|
|
|
);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int parse_graphics_file(FILE* f, GRAPHICS_INFO* gi) {
|
|
|
|
char buf[256];
|
|
|
|
while (fgets(buf, 256, f)) {
|
|
|
|
if (match_tag(buf, "<graphics_info>")) continue;
|
|
|
|
if (match_tag(buf, "</graphics_info>")) return 0;
|
|
|
|
else if (parse_int(buf, "<graphics_xsize>", gi->xsize)) continue;
|
|
|
|
else if (parse_int(buf, "<graphics_ysize>", gi->ysize)) continue;
|
|
|
|
else if (parse_double(buf, "<graphics_refresh_period>", gi->refresh_period)) continue;
|
|
|
|
else fprintf(stderr, "parse_graphics_file: unrecognized %s", buf);
|
|
|
|
}
|
2003-10-21 04:06:55 +00:00
|
|
|
return ERR_XML_PARSE;
|
2003-05-07 23:42:17 +00:00
|
|
|
}
|
|
|
|
|
2003-06-14 20:24:29 +00:00
|
|
|
// create a file (new_link) which contains an XML
|
|
|
|
// reference to existing file.
|
|
|
|
//
|
2003-10-29 11:05:39 +00:00
|
|
|
int boinc_link(const char *existing, const char *new_link) {
|
2003-06-14 20:24:29 +00:00
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
fp = fopen(new_link, "w");
|
|
|
|
if (!fp) return ERR_FOPEN;
|
|
|
|
fprintf(fp, "<soft_link>%s</soft_link>\n", existing);
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// resolve XML soft link
|
|
|
|
//
|
2003-10-29 11:05:39 +00:00
|
|
|
int boinc_resolve_filename(const char *virtual_name, char *physical_name, int len) {
|
2003-06-14 20:24:29 +00:00
|
|
|
FILE *fp;
|
|
|
|
char buf[512];
|
|
|
|
|
|
|
|
safe_strncpy(physical_name, virtual_name, len);
|
|
|
|
|
|
|
|
// Open the file and load the first line
|
2004-05-19 23:16:19 +00:00
|
|
|
//
|
|
|
|
fp = boinc_fopen(virtual_name, "r");
|
2004-01-30 22:19:19 +00:00
|
|
|
if (!fp) return ERR_FOPEN;
|
2003-06-14 20:24:29 +00:00
|
|
|
|
|
|
|
fgets(buf, 512, fp);
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
// If it's the <soft_link> XML tag, return its value,
|
|
|
|
// otherwise, return the original file name
|
|
|
|
//
|
|
|
|
parse_str(buf, "<soft_link>", physical_name, len);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-10-29 11:05:39 +00:00
|
|
|
|
|
|
|
// resolve XML soft link
|
|
|
|
//
|
2004-06-08 14:37:42 +00:00
|
|
|
int boinc_resolve_filename_s(const char *virtual_name, string& physical_name) {
|
2003-11-01 00:45:07 +00:00
|
|
|
|
|
|
|
physical_name = virtual_name;
|
2003-10-29 11:05:39 +00:00
|
|
|
// Open the file and load the first line
|
|
|
|
FILE *fp = fopen(virtual_name, "r");
|
2004-01-30 22:19:19 +00:00
|
|
|
if (!fp) return ERR_FOPEN;
|
2003-11-03 03:18:13 +00:00
|
|
|
|
2003-10-29 11:05:39 +00:00
|
|
|
char buf[512];
|
|
|
|
fgets(buf, 512, fp);
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
// If it's the <soft_link> XML tag, return its value,
|
|
|
|
// otherwise, return the original file name
|
|
|
|
//
|
|
|
|
parse_str(buf, "<soft_link>", physical_name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|