Print this page
make: unifdef for other OSes (undefined)


 907  *      Global variables used:
 908  *                              host_arch   Property for magic macro HOST_ARCH
 909  *                              target_arch Property for magic macro TARGET_ARCH
 910  *
 911  *      Return value:
 912  *                              The function does not return a value, but can
 913  *                              call fatal() in case of error.
 914  */
 915 static void
 916 init_arch_macros(void)
 917 {
 918         String_rec      result_string;
 919         wchar_t         wc_buf[STRING_BUFFER_LENGTH];
 920         char            mb_buf[STRING_BUFFER_LENGTH];
 921         FILE            *pipe;
 922         Name            value;
 923         int             set_host, set_target;
 924 #ifdef NSE
 925         Property        macro;
 926 #endif
 927 #if defined(linux)
 928         const char      *mach_command = NOCATGETS("/bin/uname -p");
 929 #else
 930         const char      *mach_command = NOCATGETS("/bin/mach");
 931 #endif
 932 
 933         set_host = (get_prop(host_arch->prop, macro_prop) == NULL);
 934         set_target = (get_prop(target_arch->prop, macro_prop) == NULL);
 935 
 936         if (set_host || set_target) {
 937                 INIT_STRING_FROM_STACK(result_string, wc_buf);
 938                 append_char((int) hyphen_char, &result_string);
 939 
 940                 if ((pipe = popen(mach_command, "r")) == NULL) {
 941                         fatal_mksh(catgets(libmksdmsi18n_catd, 1, 185, "Execute of %s failed"), mach_command);
 942                 }
 943                 while (fgets(mb_buf, sizeof(mb_buf), pipe) != NULL) {
 944                         MBSTOWCS(wcs_buffer, mb_buf);
 945                         append_string(wcs_buffer, &result_string, wslen(wcs_buffer));
 946                 }
 947                 if (pclose(pipe) != 0) {
 948                         fatal_mksh(catgets(libmksdmsi18n_catd, 1, 186, "Execute of %s failed"), mach_command);
 949                 }
 950 
 951                 value = GETNAME(result_string.buffer.start, wslen(result_string.buffer.start));


1362                 wchar_t * wcb_ta = ta_str.get_string();
1363                 wchar_t * wcb_vr = vr_str.get_string();
1364 
1365                 length = 32 +
1366                   wslen(wcb_ha) +
1367                     wslen(wcb_ta) +
1368                       wslen(wcb_vr);
1369                 old_vr = wcb_vr;
1370                 MBSTOWCS(wcs_buffer, NOCATGETS("/usr/arch/"));
1371                 if (IS_WEQUALN(old_vr,
1372                                wcs_buffer,
1373                                wslen(wcs_buffer))) {
1374                         old_vr = (wchar_t *) wschr(old_vr, (int) colon_char) + 1;
1375                 }
1376                 if ( (ha == ta) || (wslen(wcb_ta) == 0) ) {
1377                         new_value = old_vr;
1378                 } else {
1379                         new_value = ALLOC_WC(length);
1380                         new_value_allocated = true;
1381                         WCSTOMBS(mbs_buffer, old_vr);
1382 #if !defined(linux)
1383                         (void) wsprintf(new_value,
1384                                         NOCATGETS("/usr/arch/%s/%s:%s"),
1385                                         ha->string_mb + 1,
1386                                         ta->string_mb + 1,
1387                                         mbs_buffer);
1388 #else
1389                         char * mbs_new_value = (char *)getmem(length);
1390                         (void) sprintf(mbs_new_value,
1391                                         NOCATGETS("/usr/arch/%s/%s:%s"),
1392                                         ha->string_mb + 1,
1393                                         ta->string_mb + 1,
1394                                         mbs_buffer);
1395                         MBSTOWCS(new_value, mbs_new_value);
1396                         retmem_mb(mbs_new_value);
1397 #endif
1398                 }
1399                 if (new_value[0] != 0) {
1400                         (void) setvar_daemon(virtual_root,
1401                                              GETNAME(new_value, FIND_LENGTH),
1402                                              false,
1403                                              no_daemon,
1404                                              true,
1405                                              debug_level);
1406                 }
1407                 if (new_value_allocated) {
1408                         retmem(new_value);
1409                 }
1410         }
1411         return macro;
1412 }


 907  *      Global variables used:
 908  *                              host_arch   Property for magic macro HOST_ARCH
 909  *                              target_arch Property for magic macro TARGET_ARCH
 910  *
 911  *      Return value:
 912  *                              The function does not return a value, but can
 913  *                              call fatal() in case of error.
 914  */
 915 static void
 916 init_arch_macros(void)
 917 {
 918         String_rec      result_string;
 919         wchar_t         wc_buf[STRING_BUFFER_LENGTH];
 920         char            mb_buf[STRING_BUFFER_LENGTH];
 921         FILE            *pipe;
 922         Name            value;
 923         int             set_host, set_target;
 924 #ifdef NSE
 925         Property        macro;
 926 #endif



 927         const char      *mach_command = NOCATGETS("/bin/mach");

 928 
 929         set_host = (get_prop(host_arch->prop, macro_prop) == NULL);
 930         set_target = (get_prop(target_arch->prop, macro_prop) == NULL);
 931 
 932         if (set_host || set_target) {
 933                 INIT_STRING_FROM_STACK(result_string, wc_buf);
 934                 append_char((int) hyphen_char, &result_string);
 935 
 936                 if ((pipe = popen(mach_command, "r")) == NULL) {
 937                         fatal_mksh(catgets(libmksdmsi18n_catd, 1, 185, "Execute of %s failed"), mach_command);
 938                 }
 939                 while (fgets(mb_buf, sizeof(mb_buf), pipe) != NULL) {
 940                         MBSTOWCS(wcs_buffer, mb_buf);
 941                         append_string(wcs_buffer, &result_string, wslen(wcs_buffer));
 942                 }
 943                 if (pclose(pipe) != 0) {
 944                         fatal_mksh(catgets(libmksdmsi18n_catd, 1, 186, "Execute of %s failed"), mach_command);
 945                 }
 946 
 947                 value = GETNAME(result_string.buffer.start, wslen(result_string.buffer.start));


1358                 wchar_t * wcb_ta = ta_str.get_string();
1359                 wchar_t * wcb_vr = vr_str.get_string();
1360 
1361                 length = 32 +
1362                   wslen(wcb_ha) +
1363                     wslen(wcb_ta) +
1364                       wslen(wcb_vr);
1365                 old_vr = wcb_vr;
1366                 MBSTOWCS(wcs_buffer, NOCATGETS("/usr/arch/"));
1367                 if (IS_WEQUALN(old_vr,
1368                                wcs_buffer,
1369                                wslen(wcs_buffer))) {
1370                         old_vr = (wchar_t *) wschr(old_vr, (int) colon_char) + 1;
1371                 }
1372                 if ( (ha == ta) || (wslen(wcb_ta) == 0) ) {
1373                         new_value = old_vr;
1374                 } else {
1375                         new_value = ALLOC_WC(length);
1376                         new_value_allocated = true;
1377                         WCSTOMBS(mbs_buffer, old_vr);

1378                         (void) wsprintf(new_value,
1379                                         NOCATGETS("/usr/arch/%s/%s:%s"),
1380                                         ha->string_mb + 1,
1381                                         ta->string_mb + 1,
1382                                         mbs_buffer);










1383                 }
1384                 if (new_value[0] != 0) {
1385                         (void) setvar_daemon(virtual_root,
1386                                              GETNAME(new_value, FIND_LENGTH),
1387                                              false,
1388                                              no_daemon,
1389                                              true,
1390                                              debug_level);
1391                 }
1392                 if (new_value_allocated) {
1393                         retmem(new_value);
1394                 }
1395         }
1396         return macro;
1397 }